← docs

Use Bazaar MCP Tools with CrewAI

Give your CrewAI multi-agent crews access to Agent Bazaar's paid tool marketplace. Every tool call is priced, metered, and receipted — each crew member pays only for what it uses.

Prerequisites

1. Install Dependencies

pip install crewai crewai-tools mcp

CrewAI includes built-in MCP support via MCPServerAdapter. The mcp package handles the protocol layer.

2. Set Environment Variables

export NOUI_API_KEY="bz_your_key_here"
export OPENAI_API_KEY="sk-..."   # CrewAI default LLM

3. Connect CrewAI to Bazaar

Use CrewAI's MCPServerAdapter to connect to Bazaar's SSE endpoint. All discovered tools become available to your agents:

import os
from crewai import Agent, Task, Crew
from crewai_tools.mcp import MCPServerAdapter

API_KEY = os.environ["NOUI_API_KEY"]

# Connect to Bazaar's MCP proxy via SSE
bazaar_server = MCPServerAdapter(
    server_url="https://noui.bot/api/mcp/sse",
    headers={"Authorization": f"Bearer {API_KEY}"},
)

# Get all Bazaar tools as CrewAI tools
bazaar_tools = bazaar_server.tools


# --- Define your crew ---

researcher = Agent(
    role="Research Analyst",
    goal="Gather data using available Bazaar tools",
    backstory="You are a meticulous researcher with access to "
              "paid API tools via Agent Bazaar.",
    tools=bazaar_tools,
    verbose=True,
)

analyst = Agent(
    role="Report Writer",
    goal="Synthesize research into a clear summary",
    backstory="You turn raw data into actionable insights.",
    verbose=True,
)

research_task = Task(
    description="Use the available tools to check noui.bot "
                "platform stats and list available services.",
    expected_output="Raw data from tool calls",
    agent=researcher,
)

report_task = Task(
    description="Write a 3-sentence summary of the findings.",
    expected_output="A concise summary report",
    agent=analyst,
)

crew = Crew(
    agents=[researcher, analyst],
    tasks=[research_task, report_task],
    verbose=True,
)

result = crew.kickoff()
print(result)

4. Selective Tool Assignment

You don't have to give every agent every tool. Filter by name to control costs and scope:

# Only give the researcher specific tools
allowed = ["platform_stats", "list_services"]
filtered_tools = [t for t in bazaar_tools if t.name in allowed]

researcher = Agent(
    role="Research Analyst",
    goal="Gather platform data",
    backstory="You have access to specific Bazaar tools.",
    tools=filtered_tools,
)

5. How Billing Works

Every tool call through Bazaar is metered transparently:

What happens on each tool call:

  1. A crew member calls a Bazaar tool via MCP
  2. Bazaar checks your balance and the tool's per-call price
  3. The tool executes and returns results to the agent
  4. Your balance is debited and a receipt is issued
# 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"

6. Production Tips

Budget per Crew Run

Check balance before and after each crew.kickoff(). Multi-agent crews can make many tool calls — monitor costs during development.

Tool Scoping

Assign only the tools each agent needs. A report writer rarely needs API tools — restrict expensive tools to specialized agents.

Verbose Logging

Enable verbose=True on agents during development to see which tools are called and how often. Helps catch runaway tool usage.

See Also