Agents and MCP
OpenAI Agents SDK
Wrap the Tracehold MCP server in an OpenAI Agents SDK agent.
Install#
pip install openai-agents
Wire it up#
import os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp
async def main():
# The connection must be open while the agent runs.
async with MCPServerStreamableHttp(
name="tracehold",
params={
"url": os.environ["TRACEHOLD_MCP_URL"],
"headers": {
"Authorization": f"Bearer {os.environ['TRACEHOLD_MCP_TOKEN']}",
},
},
) as tracehold:
agent = Agent(
name="cloud-ops",
instructions=(
"You are a cloud operations agent. If Tracehold holds a call for approval, keep calling tracehold_wait_for_approval with its Action ID until it is decided."
),
mcp_servers=[tracehold],
)
result = await Runner.run(agent, "List my S3 buckets")
print(result.final_output)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
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>
python agent.py
Verify#
The first tool call flows through the gateway and appears in Tracehold under Activity, with its risk, the decision and why.
When a call waits for a person#
A call Tracehold holds returns "requires human approval" with an Action ID.
The instruction above has the agent wait with tracehold_wait_for_approval,
which runs the call once a person approves: the SDK hands a held call's text
to the model as the tool's output and the run goes on (tested with
openai-agents 0.20.0). For approvals that can take long,
end the run and resume it on Tracehold's webhook instead, and leave
cache_tools_list off (the default) so each run sees the server's current
tools. See Agents in pipelines.
Multiple agents#
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.