Connect Microsoft AutoGen agents to Agent Bazaar's paid tool marketplace. Every tool call is priced, metered, and receipted — your agents pay only for what they use.
pip install autogen-agentchat autogen-ext[mcp]
AutoGen's autogen-ext[mcp] package includes McpWorkbench, which bridges MCP servers into AutoGen's tool system.
export NOUI_API_KEY="bz_your_key_here" export OPENAI_API_KEY="sk-..." # or Azure OpenAI credentials
Use McpWorkbench to connect to Bazaar's SSE endpoint. All discovered tools are automatically available to your agents:
import os
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.tools.mcp import McpWorkbench, SseServerParams
from autogen_ext.models.openai import OpenAIChatCompletionClient
API_KEY = os.environ["NOUI_API_KEY"]
# Configure the Bazaar MCP connection
bazaar_params = SseServerParams(
url="https://noui.bot/api/mcp/sse",
headers={"Authorization": f"Bearer {API_KEY}"},
)
async def main():
# Connect to Bazaar and discover tools
async with McpWorkbench(bazaar_params) as workbench:
tools = workbench.tools
print(f"Loaded {len(tools)} Bazaar tools")
# Create an AutoGen agent with Bazaar tools
model_client = OpenAIChatCompletionClient(model="gpt-4o")
agent = AssistantAgent(
name="bazaar_agent",
model_client=model_client,
tools=tools,
system_message=(
"You are a helpful agent with access to "
"Bazaar MCP tools. Use them to answer questions."
),
)
# Run a task
result = await Console(
agent.run_stream(
task="Check the platform stats on noui.bot"
)
)
print(result)
asyncio.run(main())AutoGen excels at multi-agent setups. Give Bazaar tools to specific agents in a group chat:
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.conditions import TextMentionTermination
async def multi_agent_example():
async with McpWorkbench(bazaar_params) as workbench:
model = OpenAIChatCompletionClient(model="gpt-4o")
# Tool-using agent has Bazaar access
tool_agent = AssistantAgent(
name="tool_user",
model_client=model,
tools=workbench.tools,
system_message="You fetch data using Bazaar tools.",
)
# Analyst agent has no tools — just reasoning
analyst = AssistantAgent(
name="analyst",
model_client=model,
system_message=(
"You analyze data provided by tool_user. "
"Say TERMINATE when analysis is complete."
),
)
termination = TextMentionTermination("TERMINATE")
team = RoundRobinGroupChat(
[tool_agent, analyst],
termination_condition=termination,
)
result = await Console(
team.run_stream(
task="Get noui.bot stats and analyze the trends"
)
)
print(result)Every tool call through Bazaar is metered transparently:
What happens on each tool call:
# Check your balance anytime curl https://noui.bot/api/v1/bazaar/balance \ -H "Authorization: Bearer bz_your_key" # View receipts curl https://noui.bot/api/v1/bazaar/usage/summary \ -H "Authorization: Bearer bz_your_key"
Always use async with McpWorkbench(...). It handles connection lifecycle, reconnection, and cleanup automatically.
In multi-agent setups, only give Bazaar tools to agents that need them. Analyst and summarizer agents rarely need paid API access.
Always set a termination condition in group chats. Without one, agents may loop and rack up tool call costs. Use MaxMessageTermination as a safety net.