MCPcopy Create free account
hub / github.com/openai/openai-agents-python / run

Function run

examples/mcp/sse_remote_example/main.py:62–82  ·  view source on GitHub ↗
(url: str, name: str)

Source from the content-addressed store, hash-verified

60
61
62async def run(url: str, name: str) -> None:
63 async with MCPServerSse(
64 name=name,
65 params={
66 "url": url,
67 "timeout": 5,
68 "sse_read_timeout": 30,
69 },
70 ) as server:
71 agent = Agent(
72 name="SSE Assistant",
73 instructions="Use the available MCP tools to answer the user.",
74 mcp_servers=[server],
75 model_settings=ModelSettings(tool_choice="required"),
76 )
77
78 trace_id = gen_trace_id()
79 with trace(workflow_name="SSE MCP Server Example", trace_id=trace_id):
80 print(f"View trace: https://platform.openai.com/traces/trace?trace_id={trace_id}\n")
81 result = await Runner.run(agent, "Use the MCP add tool to add 7 and 22.")
82 print(result.final_output)
83
84
85async def main() -> None:

Callers 1

mainFunction · 0.70

Calls 6

MCPServerSseClass · 0.90
AgentClass · 0.90
ModelSettingsClass · 0.90
gen_trace_idFunction · 0.90
traceFunction · 0.90
runMethod · 0.45

Tested by

no test coverage detected