Skip to content

Python: Run the local CI MCP server on mcp 2.x - #10077

Closed
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-local-mcp-server-mcp2
Closed

Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:contrib/python-local-mcp-server-mcp2

Conversation

@1aifanatic

Copy link
Copy Markdown
Contributor

Motivation & Context

.github/actions/setup-local-mcp-server starts python/scripts/local_mcp_streamable_http_server.py so the MCP integration tests run against a deterministic local server. The script still imports mcp.server.fastmcp.FastMCP, which doesn't exist in the locked mcp 2.3.0. The server exits on import, the action's health check fails, and it falls back to the external vars.LOCAL_MCP__URL. There's no failure, just a quiet switch to the remote server.

The two integration tests that use LOCAL_MCP_URL would fail against any server anyway. They assert tool.session is not None, but with mcp 2.x MCPTool connects through mcp.Client, and the deprecated session property is None on that path. Details in #10075.

Description & Review Guide

  • What are the major changes?
    • scripts/local_mcp_streamable_http_server.py uses mcp.server.mcpserver.MCPServer. In 2.x, host, port and path move from the constructor to run(transport="streamable-http", ...). The tool sets structured_output=False so it keeps returning plain text. The /healthz route and the CLI arguments are unchanged.
    • test_streamable_http_integration checks tool.is_connected instead of session.
    • test_mcp_connection_reset_integration makes its simulated failure on the normalized connection (tool._connection.call_tool) and checks that the connection, not the session, is replaced after reconnecting.
  • What is the impact of these changes? CI's MCP integration jobs use the local server again, and both integration tests pass against it. No runtime code changes.
  • What do you want reviewers to focus on? The reset test now reaches into tool._connection. That's the object the tool reconnects through, but if you'd rather keep integration tests off private attributes, I can rework it.

Verification:

  • I started the server locally and ran the action's own check: list the tools, then call search_agent_framework_docs. The tool lists and returns the expected text.
  • LOCAL_MCP_URL=http://127.0.0.1:8011/mcp uv run pytest packages/core/tests/core/test_mcp.py -m integration passes (2 tests). On main both fail with assert None is not None.
  • The non-integration test_mcp.py suite still passes (512 tests), and pyright and mypy are clean on the script.

Related Issue

Fixes #10075

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Claude Code helped find the stale import with a type-check scan, port the server, update the integration tests, verify them against the local server, and draft this description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the mcp 2.x migration of the local test server and integration tests.

No open issues 🎉

What changed in this PR

Updates the local Python CI MCP server and its integration tests for mcp 2.x, addressing #10075 without changing framework runtime code.

Changes:

  • Replaces FastMCP with MCPServer and moves HTTP configuration to run(), preserving plain-text tool output.
  • Updates integration tests to check connection state and verify reconnection through the normalized connection rather than the deprecated session.
File Description
python/​scripts/​local_mcp_streamable_http_server.py Migrates the local test server to mcp 2.x APIs while preserving CLI options and health checks.
python/​packages/​core/​tests/​core/​test_mcp.py Updates connection assertions and simulated failure handling for the mcp 2.x client path.

Review effort: Balanced

@eavanvalkenburg

Copy link
Copy Markdown
Member

Thanks Naveen Chatlapalli (@1aifanatic) for the update. We’re going to make the MCP 2.x local CI server change as part of our maintainer-owned GitHub Actions and tooling updates tracked in #10075, so I’m closing this PR. No workflow runs from this head will be authorized.

This branch was previously deployed

1 inactive deployment
github-app-auth — e30d9e55 Deployed Nov 4, 2026 by 1aifanatic via team_check #8666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Local CI MCP server fails to start on mcp 2.x, so MCP integration tests fall back to the external URL

3 participants