Skip to content

Fix MCP example server and client for mcp 2.x - #466

Open
1Ash0 wants to merge 1 commit into
google-deepmind:mainfrom
1Ash0:fix/mcp-v2-compat
Open

1Ash0 wants to merge 1 commit into
google-deepmind:mainfrom
1Ash0:fix/mcp-v2-compat

Conversation

@1Ash0

@1Ash0 1Ash0 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes the bundled MCP example work with mcp 2.x, the version pinned in requirements.txt.

  • servers/file_reader_server.py: mcp.server.fastmcp was removed in v2; use mcp.server.mcpserver.MCPServer.
  • mcp_client.py: MCPClient.list_tools() read tool.inputSchema, which is input_schema in v2 and raised AttributeError. This second breakage is not mentioned in the issue. Removed the pyrefly: ignore comments that were hiding both errors.
  • Added concordia/contrib/tools/__init__.py. Without it find_packages skips the folder (so the MCP module is likely not shipped by pip install gdm-concordia[mcp]), and pytest put the folder on sys.path, so import mcp found the local mcp/ directory instead of the library.
  • Added the first tests for this folder. CI never caught any of this because nothing imported it. The tests skip when mcp is not installed.

This is v2-only, to match the pin. I did not touch setup.py (the mcp extra is still unbounded) or requirements.txt.

Fixes #435

Validation

Ubuntu 24.04, Python 3.14, installed with bin/install.sh (hash-pinned requirements.txt):

  • pytest concordia: 1456 passed, 80 skipped
  • pylint --errors-only concordia: no errors
  • pyrefly check concordia: 0 errors

Also:

  • On unmodified main, 5 of the 6 new tests fail with the fastmcp ImportError and the inputSchema AttributeError; with the fix all 6 pass.
  • The new tests pass on mcp 2.0.0, 2.0.1, 2.1.1, 2.2.0 and 2.3.0, and on Python 3.12, 3.13 and 3.14.
  • Without mcp installed, the 6 tests skip instead of failing.
  • pyink --check and isort --check --profile google are clean.

Migrate the file reader server to mcp.server.mcpserver.MCPServer and read Tool.input_schema in MCPClient.list_tools. Add the missing concordia/contrib/tools/__init__.py so the module is packaged and importable by tests, and add the first tests for this folder.
copybara-service Bot pushed a commit that referenced this pull request Nov 9, 2026
--
6f86d61 by 1Ash0 <asmitshaw3533@gmail.com>:

Fix MCP example server and client for mcp 2.x

Migrate the file reader server to mcp.server.mcpserver.MCPServer and read Tool.input_schema in MCPClient.list_tools. Add the missing concordia/contrib/tools/__init__.py so the module is packaged and importable by tests, and add the first tests for this folder.

COPYBARA_INTEGRATE_REVIEW=#466 from 1Ash0:fix/mcp-v2-compat 6f86d61
PiperOrigin-RevId: 1017276509
Change-Id: I4e828cb43fc2e84b16ff3abad305502345b8ba40

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP example server fails on mcp 2.x: file_reader_server.py imports mcp.server.fastmcp (requirements.txt pins mcp==2.0.0)

2 participants