Skip to content

Migrate to the MCP Python SDK 2.x - #50

Open
mpasternak wants to merge 1 commit into
effytech:mainfrom
mpasternak:mcp-sdk-v2
Open

mpasternak wants to merge 1 commit into
effytech:mainfrom
mpasternak:mcp-sdk-v2

Conversation

@mpasternak

Copy link
Copy Markdown

Problem

The server is built on mcp.server.fastmcp.FastMCP, which belongs to the 1.x line of the MCP Python SDK. With mcp[cli]>=1.3.0 unbounded in pyproject.toml, a fresh uvx freshdesk-mcp resolves to the 2.x SDK, where mcp.server.fastmcp is gone — the server fails at import.

What this does

Moves the server onto mcp.server.MCPServer from SDK 2.0.

  • FastMCP("freshdesk-mcp")MCPServer("freshdesk-mcp", version=__version__). The tool and prompt decorators are unchanged — all 59 @mcp.tool() functions and both prompts register exactly as before, so this is not a rewrite of the tool surface.
  • Dependencies: pin mcp==2.0.0, raise the pydantic floor to >=2.12,<3 (required by SDK 2.x), and drop build from the runtime dependencies — it's a build-backend tool the server never imports. uv.lock regenerated accordingly.
  • MCPServer takes the server version explicitly. Rather than adding a third place to bump on every release, __version__ stays defined only in freshdesk_mcp/__init__.py and server.py reads it.
  • Version bump 1.2.0 → 1.3.0.

Tests

New tests/test_mcp_v2.py:

  1. in-process check that the server object is an MCPServer and exposes the expected tools;
  2. a real end-to-end stdio round trip against a subprocess of the server — initializetools/listprompts/list — which is what actually catches an SDK API break.

Tool/prompt counts are asserted as >= on purpose, so the open PRs that add tools won't break this on merge.

New .github/workflows/ci.yml runs those tests plus tests/test_company_functions.py::TestParseHeaderFunction and uv build on Python 3.10, 3.12 and 3.14. Green on my fork; locally 6 passed.

tests/test-fd-mcp.py and the rest of test_company_functions.py are not in the CI selection — they need live Freshdesk credentials.

Notes for maintainers

  • mcp==2.0.0 is an exact pin, deliberately conservative for an SDK that just went through a major. Happy to relax it to mcp>=2,<3 if you prefer.
  • Unrelated, spotted while touching the docs: the README's manual-start example (uvx freshdesk-mcp --env FRESHDESK_API_KEY=...) doesn't work — uvx has no --env flag and the server reads plain environment variables. Left it alone here to keep this PR to the SDK migration.

🤖 Generated with Claude Code

https://claude.ai/code/session_012ytwHf2AcXX4ZzN4Zd6c6i

The server was built on `mcp.server.fastmcp.FastMCP`, which is part of the
1.x line of the MCP Python SDK. This moves it to `mcp.server.MCPServer`
from SDK 2.0.

Changes:
- `FastMCP("freshdesk-mcp")` -> `MCPServer("freshdesk-mcp", version=...)`.
  The tool/prompt decorators are unchanged, so all 59 tools and both
  prompts are registered exactly as before.
- Pin `mcp==2.0.0`, raise the pydantic floor to `>=2.12,<3` (required by
  SDK 2.x) and drop `build` from the runtime dependencies - it is a build
  backend tool, not something the server imports at runtime.
- `__version__` now lives in `freshdesk_mcp/__init__.py` only and is read
  by `server.py`, so `MCPServer(version=...)` does not become a third
  place to bump on every release.
- Bump 1.2.0 -> 1.3.0.
- Add `tests/test_mcp_v2.py`: an in-process check of the registered tools
  plus an end-to-end stdio round trip (initialize -> tools/list ->
  prompts/list) against a real subprocess of the server.
- Add a CI workflow running those tests plus `uv build` on Python 3.10,
  3.12 and 3.14.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ytwHf2AcXX4ZzN4Zd6c6i
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.

1 participant