Agents and MCP
CrewAI
Add Tracehold as an MCP tool adapter for a CrewAI crew.
Install#
pip install 'crewai-tools[mcp]' crewai
Wire it up#
import os
from crewai import Agent, Crew, Task
from crewai_tools import MCPServerAdapter
server_params = {
"url": os.environ["TRACEHOLD_MCP_URL"],
"transport": "streamable-http",
"headers": {
"Authorization": f"Bearer {os.environ['TRACEHOLD_MCP_TOKEN']}",
},
}
with MCPServerAdapter(server_params) as tracehold_tools:
ops_agent = Agent(
role="Cloud operator",
goal="Keep infrastructure healthy.",
backstory=(
"Careful, explainable, audit-first. If Tracehold holds a call for approval, keep calling tracehold_wait_for_approval with its Action ID until it is decided."
),
tools=tracehold_tools,
)
task = Task(
description="List the S3 buckets in the us-east-1 region.",
expected_output="A bulleted list of bucket names.",
agent=ops_agent,
)
crew = Crew(agents=[ops_agent], tasks=[task])
result = crew.kickoff()
print(result)
Run#
export TRACEHOLD_MCP_URL=https://api.tracehold.ai/mcp/<server-id>/ # the server's endpoint in Tracehold
export TRACEHOLD_MCP_TOKEN=<your-mcp-token>
export OPENAI_API_KEY=<your-openai-key>
python crew.py
Verify#
Every crewai-tools invocation appears in Tracehold under Activity. All calls through one MCP server share that server's identity in Tracehold, including calls from sub-agents. Give an agent its own server when you want its actions reviewed, rate-limited and audited separately.
When a call waits for a person#
A call Tracehold holds returns "requires human approval" with an Action ID;
with the backstory above, the agent waits with tracehold_wait_for_approval,
which runs the call once a person approves (tested with crewai-tools
1.15.27, whose adapter returns a result with several parts as a list). See
Agents in pipelines.
Notes#
MCPServerAdaptermust be used as a context manager; exiting closes the MCP connection cleanly.- Tracehold sees one identity per MCP server and does not track which agent in a crew delegated a call. Give agents that need separate review their own servers.