Skip to content

Migrate to mcp 2.0 (FastMCP -> MCPServer) - #48

Open
8crsk wants to merge 1 commit into
glassflow:mainfrom
8crsk:migrate-mcp-2.0
Open

8crsk wants to merge 1 commit into
glassflow:mainfrom
8crsk:migrate-mcp-2.0

Conversation

@8crsk

@8crsk 8crsk commented Aug 1, 2026

Copy link
Copy Markdown

Closes #45.

What changed

Import path and class

-from mcp.server.fastmcp import FastMCP
+from mcp.server.mcpserver import MCPServer

Client transport helper, in the two tests that use it

-from mcp.client.streamable_http import streamablehttp_client
+from mcp.client.streamable_http import streamable_http_client

Transport configuration. This is the part worth reviewing. mcp 2.0 moved
host and port off the constructor onto run() and the app factories, and
Settings no longer carries them, so mcp.settings.host and
mcp.settings.port raise on access. Renaming the class alone would leave the
server unable to start.

Both values are now read into module-level constants and used directly at the
uvicorn call site:

-mcp = FastMCP("navflow",
-              host=os.getenv("NAVFLOW_MCP_HOST", "127.0.0.1"),
-              port=int(os.getenv("NAVFLOW_MCP_PORT", "8788")))
+MCP_HOST = os.getenv("NAVFLOW_MCP_HOST", "127.0.0.1")
+MCP_PORT = int(os.getenv("NAVFLOW_MCP_PORT", "8788"))
+
+mcp = MCPServer("navflow")
-    uvicorn.run(app, host=mcp.settings.host, port=mcp.settings.port)
+    uvicorn.run(app, host=MCP_HOST, port=MCP_PORT)

NAVFLOW_MCP_HOST and NAVFLOW_MCP_PORT behave exactly as before.

Pin moved from mcp>=1.2,<2 to mcp>=2,<3.

Left alone deliberately

httpx stays as it is. The SDK moved to httpx2, but that only affects
objects handed to the SDK, and this project passes only a URL and headers to
streamable_http_client. The httpx client here talks to navflowd and is
unrelated to the SDK.

Testing

I have not run the suite. test_mcp_auth.py and test_mcp_remote.py spawn
navflowd and bind ports, which I could not set up here. What I did verify is
that the changed files parse, that the only mcp.settings reference is the one
addressed above, and that no other v1 import paths remain in the tree. Please
run CI before merging rather than taking my word for it.

Happy to adjust anything, including the constant names if you would rather they
live somewhere else.


The mechanical renames came from mcp-codemod, a tool I wrote for this migration. It flagged the host/port move rather than attempting it, so that part was done by hand.

Closes the rename and the two changes that come with it.

Import path and class:
  mcp.server.fastmcp.FastMCP -> mcp.server.mcpserver.MCPServer

Client transport helper, in the two tests that use it:
  streamablehttp_client -> streamable_http_client

Transport configuration. mcp 2.0 moved host and port off the constructor onto
run() and the app factories, and Settings no longer carries them, so
mcp.settings.host / mcp.settings.port raise on access. Both values are now
read into module-level constants and used directly at the uvicorn call site.
Behaviour and the NAVFLOW_MCP_HOST / NAVFLOW_MCP_PORT environment variables
are unchanged.

Dependency pin moved from mcp>=1.2,<2 to mcp>=2,<3.

httpx is left alone deliberately. The SDK moved to httpx2, but that only
affects objects handed to the SDK, and this project passes only a URL and
headers to streamable_http_client. The httpx client here talks to navflowd
and is unrelated.

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.

OSS: migrate to mcp 2.0 (FastMCP -> MCPServer)

1 participant