Loop
How it worksThe loopWhy LoopPricingDocs
guide AutoGen · MCP · multi-agent · tool

Use Loop with AutoGen.

Add real-time local restaurant data to any AutoGen agent. mcp_server_tools fetches all four Loop tools automatically — no manual tool definitions. Works with single agents and multi-agent teams via RoundRobinGroupChat. No API key required on the free tier.

install packages

Three packages required. The mcp extra adds StreamableHttpServerParams and mcp_server_tools; the openai extra adds OpenAIChatCompletionClient.

pip
pip install -U "autogen-agentchat" "autogen-ext[mcp,openai]"
step 1 Single agent with mcp_server_tools

Call mcp_server_tools(server_params) once and pass the returned list to AssistantAgent(tools=...). AutoGen discovers all four Loop tools — search, get_details, verify, and report — from the MCP server automatically.

single agent — mcp_server_tools
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_core import CancellationToken
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import StreamableHttpServerParams, mcp_server_tools


async def main() -> None:
    server_params = StreamableHttpServerParams(
        url="https://stayinloop.dev/mcp"
    )
    # Fetches all 4 Loop tools: search, get_details, verify, report
    tools = await mcp_server_tools(server_params)

    model_client = OpenAIChatCompletionClient(model="gpt-4o")
    agent = AssistantAgent(
        name="local_business_agent",
        model_client=model_client,
        tools=tools,
        system_message=(
            "You help users find and verify real local restaurants. "
            "Always call verify() before recommending a place."
        ),
    )

    await Console(
        agent.run_stream(
            task="Find a vegan restaurant with outdoor seating in Kreuzberg, Berlin.",
            cancellation_token=CancellationToken(),
        )
    )


asyncio.run(main())
step 2 Multi-agent team with RoundRobinGroupChat

Fetch tools once, share them across multiple agents, and assemble a team with RoundRobinGroupChat. A finder agent calls search() and get_details(); a verifier agent calls verify() and report(). MaxMessageTermination stops the team after N turns.

multi-agent team — RoundRobinGroupChat
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.ui import Console
from autogen_core import CancellationToken
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import StreamableHttpServerParams, mcp_server_tools


async def main() -> None:
    server_params = StreamableHttpServerParams(url="https://stayinloop.dev/mcp")
    tools = await mcp_server_tools(server_params)
    model_client = OpenAIChatCompletionClient(model="gpt-4o")

    # Agent 1: searches for candidates and fetches details
    finder = AssistantAgent(
        name="finder",
        model_client=model_client,
        tools=tools,
        system_message=(
            "Search for restaurants with search() and retrieve full details "
            "with get_details(). Pass result_id and result_token to the verifier."
        ),
    )

    # Agent 2: verifies availability and closes the loop
    verifier = AssistantAgent(
        name="verifier",
        model_client=model_client,
        tools=tools,
        system_message=(
            "Verify restaurant availability with verify() and report outcomes "
            "with report(result_token, outcome). "
            "Outcome is one of: correct, wrong, booked, closed, other."
        ),
    )

    team = RoundRobinGroupChat(
        [finder, verifier],
        termination_condition=MaxMessageTermination(6),
    )

    await Console(
        team.run_stream(
            task="Find and verify a quiet Italian restaurant in Kreuzberg, Berlin.",
            cancellation_token=CancellationToken(),
        )
    )


asyncio.run(main())
step 3 Add an API key (optional)

The free tier requires no authentication. For higher-volume projects, apply for an API key and pass it in StreamableHttpServerParams(headers={"Authorization": "Bearer ..."}).

with API key — Authorization header
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_core import CancellationToken
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.tools.mcp import StreamableHttpServerParams, mcp_server_tools


async def main() -> None:
    # Pass your Loop API key in the Authorization header
    server_params = StreamableHttpServerParams(
        url="https://stayinloop.dev/mcp",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
    )
    tools = await mcp_server_tools(server_params)
    model_client = OpenAIChatCompletionClient(model="gpt-4o")

    agent = AssistantAgent(
        name="local_business_agent",
        model_client=model_client,
        tools=tools,
    )

    await Console(
        agent.run_stream(
            task="Find an Italian restaurant in Kreuzberg, Berlin.",
            cancellation_token=CancellationToken(),
        )
    )


asyncio.run(main())
quick reference
ToolWhen to callKey output
search()User asks for a restaurantUp to 8 ranked records
get_details()User selects a resultFull record + result_token
verify()Before committing to a recommendationLive observation + confidence
report()After user acts on resultMutates record confidence

Full schema: api.stayinloop.dev/v1/openapi.json

import reference
SymbolPackageImport
AssistantAgentautogen-agentchatfrom autogen_agentchat.agents import AssistantAgent
RoundRobinGroupChatautogen-agentchatfrom autogen_agentchat.teams import RoundRobinGroupChat
MaxMessageTerminationautogen-agentchatfrom autogen_agentchat.conditions import MaxMessageTermination
Consoleautogen-agentchatfrom autogen_agentchat.ui import Console
OpenAIChatCompletionClientautogen-ext[openai]from autogen_ext.models.openai import OpenAIChatCompletionClient
StreamableHttpServerParams, mcp_server_toolsautogen-ext[mcp]from autogen_ext.tools.mcp import StreamableHttpServerParams, mcp_server_tools
CancellationTokenautogen-corefrom autogen_core import CancellationToken
common questions

How do I add Loop to an AutoGen agent?

Create StreamableHttpServerParams(url="https://stayinloop.dev/mcp") and call tools = await mcp_server_tools(server_params). Pass the list to AssistantAgent(tools=tools). All four Loop tools are discovered automatically. Requires pip install "autogen-ext[mcp]".

What does mcp_server_tools return?

A list of AutoGen-compatible tool adapters — one per tool exposed by the MCP server. For Loop it returns four adapters: search, get_details, verify, and report. Pass the list directly to tools= on any AssistantAgent.

How do I build a multi-agent Loop team?

Fetch tools once, create two AssistantAgents with different system messages (e.g. a finder and a verifier), and wrap them in RoundRobinGroupChat with a MaxMessageTermination condition. Both agents share the same Loop tools list.

Is an API key required?

No. The free tier accepts unauthenticated connections to https://stayinloop.dev/mcp. For higher-volume projects, apply for a key at stayinloop.dev/#pricing and pass it via StreamableHttpServerParams(headers={"Authorization": "Bearer <key>"}).

← All guidesCrewAI guideLangChain guide