🚀 The fast, Pythonic way to build MCP servers and clients.
Add agno, Agent Framework, and OpenAI Agents SDK to downstream smoke (#6222)
nate nowack529f856b6c65
diff --git a/.github/workflows/run-downstream-smoke.yml b/.github/workflows/run-downstream-smoke.ymlindex 22997f4e2..068ca2c26 100644--- a/.github/workflows/run-downstream-smoke.yml+++ b/.github/workflows/run-downstream-smoke.yml@@ -16,6 +16,9 @@ env:BOTOCORE_VERSION: "1.43.118"CACHETOOLS_VERSION: "7.2.4"REDIS_ENTRAID_VERSION: "1.2.2"+ AGNO_VERSION: "3.1.12"+ AGENT_FRAMEWORK_VERSION: "1.24.0"+ OPENAI_AGENTS_VERSION: "0.24.0"on:push:@@ -67,6 +70,9 @@ jobs:botocore: ${{ steps.versions.outputs.botocore }}cachetools: ${{ steps.versions.outputs.cachetools }}redis-entraid: ${{ steps.versions.outputs.redis-entraid }}+ agno: ${{ steps.versions.outputs.agno }}+ agent-framework: ${{ steps.versions.outputs.agent-framework }}+ openai-agents: ${{ steps.versions.outputs.openai-agents }}steps:- uses: actions/checkout@v7with:@@ -113,6 +119,9 @@ jobs:botocore=$(pick botocore "$BOTOCORE_VERSION")cachetools=$(pick cachetools "$CACHETOOLS_VERSION")redis_entraid=$(pick redis-entraid "$REDIS_ENTRAID_VERSION")+ agno=$(pick agno "$AGNO_VERSION")+ agent_framework=$(pick agent-framework-core "$AGENT_FRAMEWORK_VERSION")+ openai_agents=$(pick openai-agents "$OPENAI_AGENTS_VERSION"){echo "pydantic-ai=$pydantic_ai"echo "langchain-mcp-adapters=$adapters"@@ -120,6 +129,9 @@ jobs:echo "botocore=$botocore"echo "cachetools=$cachetools"echo "redis-entraid=$redis_entraid"+ echo "agno=$agno"+ echo "agent-framework=$agent_framework"+ echo "openai-agents=$openai_agents"} | tee -a "$GITHUB_OUTPUT" > versions.txt{echo "### Downstream smoke plan"@@ -249,6 +261,70 @@ jobs:if: always() && hashFiles('junit.xml') != ''run: python3 fastmcp/tests/downstream/_harness.py junit.xml "langchain ${{ needs.plan.outputs.langchain }} MCP test suite"+ agno-suite:+ name: agno test suite+ needs: plan+ runs-on: ubuntu-latest+ timeout-minutes: 15+ steps:+ - uses: actions/checkout@v7+ with:+ path: fastmcp++ - uses: actions/checkout@v7+ with:+ repository: agno-agi/agno+ ref: v${{ needs.plan.outputs.agno }}+ path: agno+ persist-credentials: false++ - uses: actions/download-artifact@v8+ with:+ name: fastmcp-wheels+ path: dist++ - name: Install uv+ uses: astral-sh/[email protected]+ with:+ python-version: "3.12"++ # agno's MCPTools builds its connections on fastmcp.Client and AgentOS serves+ # MCP through FastMCP. Install it the way agno's own CI does, with FastMCP+ # from the wheels under test.+ - name: Install agno+ run: |+ uv venv --quiet venv+ VIRTUAL_ENV=$PWD/venv uv pip install --quiet \+ -e agno/libs/agnoctl -e "agno/libs/agno[os,mcp,pages,openai]" \+ pytest pytest-asyncio pytest-mock aiosqlite \+ "fastmcp @ file://$(ls $GITHUB_WORKSPACE/dist/fastmcp-4*.whl)" \+ "fastmcp-slim @ file://$(ls $GITHUB_WORKSPACE/dist/fastmcp_slim-*.whl)"+ echo "$PWD/venv/bin" >> "$GITHUB_PATH"++ - name: Check the build under test is installed+ run: >-+ python -c "import fastmcp, mcp, importlib.metadata as m;+ assert fastmcp.__version__ == '${{ needs.plan.outputs.fastmcp }}', fastmcp.__version__;+ print('fastmcp', fastmcp.__version__, '· mcp', m.version('mcp'), '· agno', m.version('agno'))"++ - name: Run agno's MCP tests+ working-directory: agno/libs/agno+ run: >-+ python -m pytest -p no:cacheprovider -q+ --junitxml=$GITHUB_WORKSPACE/junit.xml+ tests/unit/tools/test_mcp.py+ tests/unit/tools/test_mcp_pagination.py+ tests/unit/tools/test_mcp_toolbox_lifecycle.py+ tests/unit/os/test_mcp_*.py+ tests/unit/os/test_public_mcp_config.py+ tests/unit/os/test_registry_mcp_tools.py+ tests/integration/os/test_mcp_protocol_versions.py+ tests/integration/os/test_register_mcp_tools.py++ - name: Summarize+ if: always() && hashFiles('junit.xml') != ''+ run: python3 fastmcp/tests/downstream/_harness.py junit.xml "agno ${{ needs.plan.outputs.agno }} MCP test suite"+smoke:name: ${{ matrix.consumer }} smokeneeds: plan@@ -271,6 +347,26 @@ jobs:--with "langchain[mcp]==${{ needs.plan.outputs.langchain }}"--with "fastmcp @ file://$GITHUB_WORKSPACE/$(ls dist/fastmcp-4*.whl)"--with "fastmcp-slim @ file://$GITHUB_WORKSPACE/$(ls dist/fastmcp_slim-*.whl)"+ # agno[mcp] depends on fastmcp and connects through fastmcp.Client.+ - consumer: agno+ script: smoke_agno.py+ with: >-+ --with "agno[mcp]==${{ needs.plan.outputs.agno }}"+ --with "fastmcp @ file://$GITHUB_WORKSPACE/$(ls dist/fastmcp-4*.whl)"+ --with "fastmcp-slim @ file://$GITHUB_WORKSPACE/$(ls dist/fastmcp_slim-*.whl)"+ # Agent Framework and the OpenAI Agents SDK connect with the mcp SDK's own+ # client, so they reach FastMCP over the wire. Agent Framework's MCP+ # dependencies (mcp, tenacity) come from its `all` extra; they are named+ # here so the job does not resolve every model provider.+ - consumer: agent-framework+ script: smoke_agent_framework.py+ with: >-+ --with "agent-framework-core==${{ needs.plan.outputs.agent-framework }}"+ --with "mcp>=2.2,<3" --with "tenacity>=9.1.4,<9.2"+ - consumer: openai-agents+ script: smoke_openai_agents.py+ with: >-+ --with "openai-agents==${{ needs.plan.outputs.openai-agents }}"# The adapters pin mcp<2, so they reach FastMCP over the wire.- consumer: langchain-mcp-adaptersscript: smoke_langchain_mcp_adapters.pydiff --git a/tests/downstream/README.md b/tests/downstream/README.mdindex a39a33740..6b6ab12c7 100644--- a/tests/downstream/README.md+++ b/tests/downstream/README.md@@ -11,6 +11,10 @@ against servers started from the checkout.| langchain test suite | `langchain.mcp`'s own unit and integration tests at a pinned tag | wheels overlaid on langchain's locked test environment || pydantic-ai smoke | `smoke_pydantic_ai.py` | client-only `fastmcp-slim[client]`, as `pydantic-ai-slim[mcp]` installs it || langchain.mcp smoke | `smoke_langchain_mcp.py`, including a `ClientGroup` of a legacy HTTP server and a modern stdio server | `fastmcp`, as `langchain[mcp]` installs it |+| agno test suite | agno's own `MCPTools` and AgentOS MCP tests at a pinned tag | wheels installed with agno the way agno's CI installs it |+| agno smoke | `smoke_agno.py`, in both protocol eras over stdio | `fastmcp`, as `agno[mcp]` installs it |+| Microsoft Agent Framework smoke | `smoke_agent_framework.py` (no SSE: Agent Framework has no SSE client) | none: it connects with the `mcp` SDK's client, so it reaches FastMCP over the wire |+| OpenAI Agents SDK smoke | `smoke_openai_agents.py` | none: it connects with the `mcp` SDK's client, so it reaches FastMCP over the wire || langchain-mcp-adapters smoke | `smoke_langchain_mcp_adapters.py` | none: the adapters pin `mcp<2`, so they reach FastMCP over the wire || redis credential providers smoke | `smoke_redis_credentials.py`: `TasksExtension` tasks through rotating credentials from AWS's ElastiCache IAM provider (botocore) and redis-entraid's streaming Entra ID provider, against a local `redis-server` | `fastmcp`, `fastmcp-slim`, and `fastmcp-tasks` wheels |@@ -51,6 +55,17 @@ uv run --isolated --no-project --no-config \--with langchain-mcp-adapters --with langchain \python tests/downstream/smoke_langchain_mcp_adapters.py+uv run --isolated --no-project --no-config \+ --with 'agno[mcp]' --with "$full" --with "$slim" \+ python tests/downstream/smoke_agno.py++uv run --isolated --no-project --no-config \+ --with agent-framework-core --with 'mcp>=2.2,<3' --with tenacity \+ python tests/downstream/smoke_agent_framework.py++uv run --isolated --no-project --no-config --with openai-agents \+ python tests/downstream/smoke_openai_agents.py+# needs redis-server on PATHuv run --isolated --no-project --no-config \--with "$full" --with "$slim" --with "$tasks" \diff --git a/tests/downstream/smoke_agent_framework.py b/tests/downstream/smoke_agent_framework.pynew file mode 100644index 000000000..33ea6e848--- /dev/null+++ b/tests/downstream/smoke_agent_framework.py@@ -0,0 +1,215 @@+"""Drive a FastMCP server through Microsoft Agent Framework's MCP tools.++Agent Framework connects with the `mcp` SDK's own client, not FastMCP's, so it+reaches FastMCP over the wire. It runs in its own environment against servers+started from the checkout:++ uv run --isolated --no-project --no-config --with agent-framework-core \+ --with "mcp>=2.2,<3" --with tenacity \+ python tests/downstream/smoke_agent_framework.py+"""++import asyncio+import json+from collections.abc import MutableSequence+from importlib.metadata import version+from typing import Any++from _harness import (+ PROXY_GAPS,+ TOOLS,+ Report,+ serve,+ server_env,+ stdio_command,+)+from agent_framework import (+ Agent,+ BaseChatClient,+ ChatResponse,+ Content,+ FunctionInvocationLayer,+ MCPStdioTool,+ MCPStreamableHTTPTool,+ Message,+)+from agent_framework.exceptions import ToolExecutionException+++class ScriptedChatClient(FunctionInvocationLayer, BaseChatClient):+ """Call add and forecast on the first turn, then answer with what they returned."""++ def _inner_get_response(+ self,+ *,+ messages: MutableSequence[Message],+ stream: bool,+ options: dict[str, Any],+ **kwargs: Any,+ ) -> Any:+ async def respond() -> ChatResponse:+ results = [+ str(c.result)+ for m in messages+ for c in m.contents+ if c.type == "function_result"+ ]+ if results:+ return ChatResponse(+ messages=Message(role="assistant", contents=[" | ".join(results)])+ )+ calls = [+ Content.from_function_call(+ call_id="call-add", name="add", arguments='{"a": 2, "b": 3}'+ ),+ Content.from_function_call(+ call_id="call-forecast",+ name="forecast",+ arguments='{"city": "Chicago", "days": 2}',+ ),+ ]+ return ChatResponse(messages=Message(role="assistant", contents=calls))++ return respond()+++def texts(contents: Any) -> list[str]:+ return [c.text for c in contents if c.type == "text"]+++async def exercise(+ report: Report, make_tool: Any, gaps: dict[str, str] | None = None+) -> None:+ gaps = gaps or {}+ async with make_tool() as mcp:++ async def lists_tools() -> None:+ names = {f.name for f in mcp.functions}+ assert TOOLS <= names, sorted(names)++ async def agent_loop() -> None:+ agent = Agent(client=ScriptedChatClient(), tools=[mcp])+ response = await agent.run("add 2 and 3, then get the Chicago forecast")+ assert "5" in response.text and "sunny" in response.text, response.text++ async def structured_output() -> None:+ [text] = texts(await mcp.call_tool("forecast", city="Oslo"))+ expected = {"city": "Oslo", "celsius": 21.5, "conditions": ["sunny"]}+ assert json.loads(text) == expected, text++ async def tool_error() -> None:+ try:+ await mcp.call_tool("divide", a=1, b=0)+ except ToolExecutionException as error:+ assert "divide by zero" in str(error), error+ return+ raise AssertionError("divide by zero did not raise")++ async def image() -> None:+ [block] = await mcp.call_tool("snapshot")+ assert block.type == "data" and block.media_type == "image/png", (+ block.to_dict()+ )+ assert block.uri.startswith("data:image/png;base64,"), block.uri++ async def mixed_content() -> None:+ blocks = await mcp.call_tool("attachments")+ shapes = [(b.type, b.text or b.uri) for b in blocks]+ assert shapes[:2] == [("text", "see attached"), ("text", "buy milk")], (+ shapes+ )+ assert shapes[2][1] == "config://app", shapes++ async def float_count_output_schema() -> None:+ [text] = texts(await mcp.call_tool("stamp"))+ assert json.loads(text) == {"when": "2026-09-22T00:00:00Z"}, text++ async def prompt() -> None:+ assert "x = 1" in await mcp.get_prompt("review", code="x = 1")++ async def call_after_timeout() -> None:+ async with make_tool(request_timeout=1) as short:+ try:+ await short.call_tool("sleep", seconds=5)+ except ToolExecutionException:+ pass+ else:+ raise AssertionError("a 5s call finished inside a 1s timeout")+ assert texts(await short.call_tool("add", a=1, b=1)) == [+ '{"result": 2}'+ ]++ for check in (+ lists_tools,+ agent_loop,+ structured_output,+ tool_error,+ image,+ mixed_content,+ float_count_output_schema,+ prompt,+ call_after_timeout,+ ):+ name = check.__name__.replace("_", " ")+ await report.check(name, check, known_gap=gaps.get(name))+++async def main() -> None:+ report = Report(+ "agent-framework",+ {+ "agent-framework-core": version("agent-framework-core"),+ "mcp": version("mcp"),+ },+ )+ command, args = stdio_command()+ with report.transport("stdio"):+ await exercise(+ report,+ lambda **kw: MCPStdioTool(+ name="smoke", command=command, args=args, env=server_env(), **kw+ ),+ )++ # Agent Framework has no SSE client, only stdio, streamable HTTP, and websocket.+ for transport, label in (("http", "streamable HTTP"), ("proxy", "FastMCP proxy")):+ with report.transport(label), serve(transport) as server:++ async def rejects_missing_token() -> None:+ try:+ async with MCPStreamableHTTPTool(name="smoke", url=server.url):+ pass+ except Exception:+ return+ raise AssertionError("connected without a bearer token")++ async def header_provider() -> None:+ seen: list[dict[str, Any]] = []++ def provide(kwargs: dict[str, Any]) -> dict[str, str]:+ seen.append(kwargs)+ return server.headers++ async with MCPStreamableHTTPTool(+ name="smoke", url=server.url, header_provider=provide+ ) as mcp:+ assert texts(await mcp.call_tool("add", a=4, b=4)) == [+ '{"result": 8}'+ ]+ assert seen, "header_provider was never called"++ await report.check("rejects missing bearer token", rejects_missing_token)+ await report.check("header provider", header_provider)+ await exercise(+ report,+ lambda **kw: MCPStreamableHTTPTool(+ name="smoke", url=server.url, static_headers=server.headers, **kw+ ),+ gaps=PROXY_GAPS if transport == "proxy" else None,+ )++ report.finish()+++if __name__ == "__main__":+ asyncio.run(main())diff --git a/tests/downstream/smoke_agno.py b/tests/downstream/smoke_agno.pynew file mode 100644index 000000000..e5b696f2b--- /dev/null+++ b/tests/downstream/smoke_agno.py@@ -0,0 +1,262 @@+"""Drive FastMCP through agno's MCPTools, as an agno user installs it.++`agno[mcp]` depends on `fastmcp` and builds every connection with+`fastmcp.Client` and FastMCP's transports, so this runs in its own environment+with the build under test. The servers run from the checkout:++ uv run --isolated --no-project --no-config --with 'agno[mcp]' \+ --with "fastmcp @ file://$PWD/$(ls dist/fastmcp-4*.whl)" \+ --with "fastmcp-slim @ file://$PWD/$(ls dist/fastmcp_slim-*.whl)" \+ python tests/downstream/smoke_agno.py+"""++import asyncio+import json+import os+from importlib.metadata import version+from typing import Any++from _harness import (+ PROXY_GAPS,+ TOOLS,+ Report,+ quiet,+ serve,+ server_env,+ stdio_command,+)+from agno.agent import Agent+from agno.models.base import Model+from agno.models.message import MessageMetrics+from agno.models.response import ModelResponse+from agno.tools.mcp import MCPTools+from mcp import StdioServerParameters++import fastmcp+++class ScriptedModel(Model):+ """Call add and forecast on the first turn, then answer with what they returned."""++ def __init__(self) -> None:+ super().__init__(id="scripted", name="scripted", provider="smoke")++ def _respond(self, messages: list[Any]) -> ModelResponse:+ results = [str(m.content) for m in messages if m.role == "tool"]+ if results:+ return ModelResponse(+ role="assistant",+ content=" | ".join(results),+ response_usage=MessageMetrics(),+ )+ return ModelResponse(+ role="assistant",+ tool_calls=[+ {+ "id": "call-add",+ "type": "function",+ "function": {"name": "add", "arguments": '{"a": 2, "b": 3}'},+ },+ {+ "id": "call-forecast",+ "type": "function",+ "function": {+ "name": "forecast",+ "arguments": '{"city": "Chicago", "days": 2}',+ },+ },+ ],+ response_usage=MessageMetrics(),+ )++ def invoke(self, messages: list[Any], *args: Any, **kwargs: Any) -> ModelResponse:+ return self._respond(messages)++ async def ainvoke(+ self, messages: list[Any], *args: Any, **kwargs: Any+ ) -> ModelResponse:+ return self._respond(messages)++ def invoke_stream(self, messages: list[Any], *args: Any, **kwargs: Any) -> Any:+ yield self._respond(messages)++ async def ainvoke_stream(+ self, messages: list[Any], *args: Any, **kwargs: Any+ ) -> Any:+ yield self._respond(messages)++ def _parse_provider_response(self, response: Any, **kwargs: Any) -> ModelResponse:+ return response++ def _parse_provider_response_delta(self, response: Any) -> ModelResponse:+ return response+++async def exercise(+ report: Report, make_tools: Any, gaps: dict[str, str] | None = None+) -> None:+ gaps = gaps or {}+ async with make_tools() as mcp:++ async def call(name: str, **kwargs: Any) -> Any:+ return await mcp.functions[name].entrypoint(**kwargs)++ async def lists_tools() -> None:+ assert TOOLS <= set(mcp.functions), sorted(mcp.functions)++ async def uses_fastmcp_client() -> None:+ assert isinstance(mcp.session, fastmcp.Client), type(mcp.session)++ async def agent_loop() -> None:+ agent = Agent(model=ScriptedModel(), tools=[mcp], telemetry=False)+ run = await agent.arun("add 2 and 3, then get the Chicago forecast")+ assert "5" in str(run.content) and "sunny" in str(run.content), run.content++ async def structured_output() -> None:+ result = await call("forecast", city="Oslo")+ expected = {"city": "Oslo", "celsius": 21.5, "conditions": ["sunny"]}+ assert json.loads(result.content) == expected, result.content++ async def tool_error() -> None:+ result = await call("divide", a=1, b=0)+ assert result.content.startswith("Error from MCP tool 'divide'"), result+ assert "divide by zero" in result.content, result.content++ async def image() -> None:+ result = await call("snapshot")+ [picture] = result.images+ assert picture.mime_type == "image/png" and picture.content, picture++ async def audio() -> None:+ result = await call("chime")+ [sound] = result.audios+ assert sound.mime_type == "audio/wav" and sound.content, sound++ async def mixed_content() -> None:+ result = await call("attachments")+ assert "see attached" in result.content, result.content+ assert "buy milk" in result.content, result.content++ async def float_count_output_schema() -> None:+ result = await call("stamp")+ assert json.loads(result.content) == {"when": "2026-09-22T00:00:00Z"}, (+ result.content+ )++ async def liveness() -> None:+ assert await mcp.is_alive()++ for check in (+ lists_tools,+ uses_fastmcp_client,+ agent_loop,+ structured_output,+ tool_error,+ image,+ audio,+ mixed_content,+ float_count_output_schema,+ liveness,+ ):+ name = check.__name__.replace("_", " ")+ await report.check(name, check, known_gap=gaps.get(name))++ async def call_after_timeout() -> None:+ # agno's timeout also bounds the handshake, and a stdio server can take+ # over a second to start, so leave it room.+ async with make_tools(timeout_seconds=3) as short:+ result = await short.functions["sleep"].entrypoint(seconds=6)+ assert "Error" in str(result.content) or "timed out" in str(+ result.content+ ), result+ result = await short.functions["add"].entrypoint(a=1, b=1)+ assert result.content == "2", result.content++ await report.check(+ "call after timeout",+ call_after_timeout,+ known_gap=gaps.get("call after timeout"),+ )+++async def main() -> None:+ report = Report(+ "agno",+ {+ "agno": version("agno"),+ "fastmcp": fastmcp.__version__,+ "mcp": version("mcp"),+ },+ )++ async def installed_build_is_under_test() -> None:+ expected = os.environ.get("FASTMCP_EXPECTED_VERSION")+ assert expected in (None, fastmcp.__version__), (+ f"expected {expected}, got {fastmcp.__version__}"+ )++ command, args = stdio_command()+ stdio = StdioServerParameters(command=command, args=args, env=server_env())+ for mode in ("legacy", "auto"):+ # agno logs the timeout a check causes on purpose.+ with report.transport(f"stdio ({mode})"), quiet("agno", "agno-agent"):+ if mode == "legacy":+ await report.check(+ "installed build is under test", installed_build_is_under_test+ )+ await exercise(+ report,+ lambda mode=mode, **kw: MCPTools(+ server_params=stdio, transport="stdio", protocol_mode=mode, **kw+ ),+ )++ for transport, label, kind in (+ ("http", "streamable HTTP", "streamable-http"),+ ("sse", "SSE", "sse"),+ ("proxy", "FastMCP proxy", "streamable-http"),+ ):+ # The SDK's SSE reader logs a traceback when a session closes mid-stream.+ with (+ report.transport(label),+ serve(transport) as server,+ quiet("mcp.client.sse", "agno", "agno-agent"),+ ):++ async def rejects_missing_token() -> None:+ try:+ async with MCPTools(url=server.url, transport=kind) as mcp:+ listed = sorted(mcp.functions)+ except Exception:+ return+ assert not listed, f"listed tools without a bearer token: {listed}"++ async def header_provider() -> None:+ seen: list[int] = []++ def provide() -> dict[str, str]:+ seen.append(1)+ return server.headers++ async with MCPTools(+ url=server.url, transport=kind, header_provider=provide+ ) as mcp:+ result = await mcp.functions["add"].entrypoint(a=4, b=4)+ assert result.content == "8", result+ assert seen, "header_provider was never called"++ await report.check("rejects missing bearer token", rejects_missing_token)+ await report.check("header provider", header_provider)+ await exercise(+ report,+ lambda kind=kind, server=server, **kw: MCPTools(+ url=server.url, transport=kind, headers=server.headers, **kw+ ),+ gaps=PROXY_GAPS if transport == "proxy" else None,+ )++ report.finish()+++if __name__ == "__main__":+ asyncio.run(main())diff --git a/tests/downstream/smoke_openai_agents.py b/tests/downstream/smoke_openai_agents.pynew file mode 100644index 000000000..3a9d3bf46--- /dev/null+++ b/tests/downstream/smoke_openai_agents.py@@ -0,0 +1,252 @@+"""Drive a FastMCP server through the OpenAI Agents SDK's MCP servers.++The Agents SDK connects with the `mcp` SDK's own client, not FastMCP's, so it+reaches FastMCP over the wire. It runs in its own environment against servers+started from the checkout:++ uv run --isolated --no-project --no-config --with openai-agents \+ python tests/downstream/smoke_openai_agents.py+"""++import asyncio+import json+from importlib.metadata import version+from typing import Any++from _harness import (+ PROXY_GAPS,+ TEMPLATE_READS,+ TOOLS,+ Report,+ quiet,+ serve,+ server_env,+ stdio_command,+)+from agents import Agent, ModelResponse, Runner, Usage+from agents.mcp import (+ MCPServer,+ MCPServerSse,+ MCPServerStdio,+ MCPServerStreamableHttp,+)+from agents.models.interface import Model+from openai.types.responses import (+ ResponseFunctionToolCall,+ ResponseOutputMessage,+ ResponseOutputText,+)+++class ScriptedModel(Model):+ """Call add and forecast on the first turn, then answer with what they returned."""++ async def get_response(self, *args: Any, **kwargs: Any) -> ModelResponse:+ items = kwargs.get("input", args[1] if len(args) > 1 else [])+ outputs = [+ str(item.get("output"))+ for item in (items if isinstance(items, list) else [])+ if isinstance(item, dict) and item.get("type") == "function_call_output"+ ]+ if outputs:+ output: list[Any] = [+ ResponseOutputMessage(+ id="msg-1",+ type="message",+ role="assistant",+ status="completed",+ content=[+ ResponseOutputText(+ type="output_text", text=" | ".join(outputs), annotations=[]+ )+ ],+ )+ ]+ else:+ output = [+ ResponseFunctionToolCall(+ id="fc-add",+ call_id="call-add",+ type="function_call",+ name="add",+ arguments='{"a": 2, "b": 3}',+ ),+ ResponseFunctionToolCall(+ id="fc-forecast",+ call_id="call-forecast",+ type="function_call",+ name="forecast",+ arguments='{"city": "Chicago", "days": 2}',+ ),+ ]+ return ModelResponse(output=output, usage=Usage(), response_id=None)++ def stream_response(self, *args: Any, **kwargs: Any) -> Any:+ raise NotImplementedError+++async def exercise(+ report: Report, make_server: Any, gaps: dict[str, str] | None = None+) -> None:+ gaps = gaps or {}+ async with make_server() as server:+ assert isinstance(server, MCPServer)++ async def lists_tools() -> None:+ names = {tool.name for tool in await server.list_tools()}+ assert TOOLS <= names, sorted(names)++ async def server_info() -> None:+ # The SDK fills `server_initialize_result` only from a handshake-era+ # initialize, which the 2026-07-28 era no longer sends, so read the+ # server's identity off the session it negotiated.+ info = server.session.server_info+ assert info.name == "downstream-smoke", info++ async def agent_loop() -> None:+ agent = Agent(name="smoke", model=ScriptedModel(), mcp_servers=[server])+ result = await Runner.run(+ agent, "add 2 and 3, then get the Chicago forecast"+ )+ output = str(result.final_output)+ assert "5" in output and "sunny" in output, output++ async def structured_output() -> None:+ result = await server.call_tool("forecast", {"city": "Oslo"})+ expected = {"city": "Oslo", "celsius": 21.5, "conditions": ["sunny"]}+ assert result.structured_content == expected, result++ async def tool_error() -> None:+ try:+ result = await server.call_tool("divide", {"a": 1, "b": 0})+ except Exception as error:+ assert "divide by zero" in str(error), error+ return+ assert result.is_error and "divide by zero" in str(result.content), result++ async def image() -> None:+ [block] = (await server.call_tool("snapshot", {})).content+ assert block.type == "image" and block.mime_type == "image/png", block++ async def mixed_content() -> None:+ blocks = (await server.call_tool("attachments", {})).content+ shapes = [+ (b.type, b.text if b.type == "text" else getattr(b, "resource", b))+ for b in blocks+ ]+ assert [t for t, _ in shapes] == ["text", "resource", "resource_link"], (+ shapes+ )+ assert shapes[0][1] == "see attached" and shapes[1][1].text == "buy milk"+ assert str(blocks[2].uri) == "config://app", blocks[2]++ async def float_count_output_schema() -> None:+ result = await server.call_tool("stamp", {})+ assert result.structured_content == {"when": "2026-09-22T00:00:00Z"}, result++ async def prompt() -> None:+ result = await server.get_prompt("review", {"code": "x = 1"})+ assert "x = 1" in str(result.messages[0].content), result++ async def resources() -> None:+ [content] = (await server.read_resource("config://app")).contents+ assert json.loads(content.text) == {"mode": "smoke"}, content++ async def resource_templates() -> None:+ listed = await server.list_resource_templates()+ assert "greeting://{name}" in {+ t.uri_template for t in listed.resource_templates+ }, listed+ [content] = (await server.read_resource("greeting://nate")).contents+ assert content.text == "hello, nate", content++ async def template_literals_and_list_queries() -> None:+ texts = [+ (await server.read_resource(uri)).contents[0].text+ for uri in TEMPLATE_READS+ ]+ assert texts == list(TEMPLATE_READS.values()), texts++ for check in (+ lists_tools,+ server_info,+ agent_loop,+ structured_output,+ tool_error,+ image,+ mixed_content,+ float_count_output_schema,+ prompt,+ resources,+ resource_templates,+ template_literals_and_list_queries,+ ):+ name = check.__name__.replace("_", " ")+ await report.check(name, check, known_gap=gaps.get(name))++ async def call_after_timeout() -> None:+ async with make_server(client_session_timeout_seconds=1) as short:+ try:+ result = await short.call_tool("sleep", {"seconds": 5})+ except Exception:+ pass+ else:+ raise AssertionError(f"a 5s call finished inside 1s: {result}")+ result = await short.call_tool("add", {"a": 1, "b": 1})+ assert result.structured_content == {"result": 2}, result++ await report.check(+ "call after timeout",+ call_after_timeout,+ known_gap=gaps.get("call after timeout"),+ )+++async def main() -> None:+ report = Report(+ "openai-agents",+ {"openai-agents": version("openai-agents"), "mcp": version("mcp")},+ )+ command, args = stdio_command()+ with report.transport("stdio"):+ await exercise(+ report,+ lambda **kw: MCPServerStdio(+ {"command": command, "args": args, "env": server_env()}, **kw+ ),+ )++ for transport, label, server_class in (+ ("http", "streamable HTTP", MCPServerStreamableHttp),+ ("sse", "SSE", MCPServerSse),+ ("proxy", "FastMCP proxy", MCPServerStreamableHttp),+ ):+ # The SDK's SSE reader logs a traceback when a session closes mid-stream.+ with (+ report.transport(label),+ serve(transport) as server,+ quiet("mcp.client.sse", "openai.agents"),+ ):++ async def rejects_missing_token() -> None:+ try:+ async with server_class({"url": server.url}) as mcp:+ await mcp.list_tools()+ except Exception:+ return+ raise AssertionError("listed tools without a bearer token")++ await report.check("rejects missing bearer token", rejects_missing_token)+ await exercise(+ report,+ lambda server_class=server_class, server=server, **kw: server_class(+ {"url": server.url, "headers": server.headers}, **kw+ ),+ gaps=PROXY_GAPS if transport == "proxy" else None,+ )++ report.finish()+++if __name__ == "__main__":+ asyncio.run(main())