From 1c6d7889dd3e8873eaa1c9bf73e519109d064ce1 Mon Sep 17 00:00:00 2001 From: Dan Barr Date: Tue, 1 Jul 2025 17:33:51 -0400 Subject: [PATCH] Add note about VS Code and FastMCP streamable HTTP --- .../guides-cli/client-configuration.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/toolhive/guides-cli/client-configuration.md b/docs/toolhive/guides-cli/client-configuration.md index 3bfb5f9a..3b08f07b 100644 --- a/docs/toolhive/guides-cli/client-configuration.md +++ b/docs/toolhive/guides-cli/client-configuration.md @@ -241,3 +241,29 @@ connectivity. Refer to your containerization platform's documentation for details on how to configure network access between containers and the host. + +### VS Code can't connect to some streamable-http servers + +You might encounter errors with Visual Studio Code connecting to some +Python-based MCP servers using the Streamable HTTP transport protocol: + +```text +[info] Connection state: Error Error sending message to http://localhost:49574/mcp: TypeError: fetch failed +[error] Server exited before responding to `initialize` request. +``` + +This is a known interaction between VS Code and the FastMCP SDK used by +Python-based MCP servers. If you inspect the HTTP connection, you'll see a +`307 Temporary Redirect` response, which VS Code doesn't handle correctly. + +There are two workarounds: + +1. Change the URL in your VS Code settings to add a trailing slash to the MCP + server URL. For example, change `http://localhost:49574/mcp` to + `http://localhost:49574/mcp/`. You'll need to re-apply this if you stop and + restart the MCP server. +2. If the MCP server supports SSE, switch to using the SSE transport instead of + Streamable HTTP. + +You can track a proposed fix for this issue in the +[MCP Python SDK repository](https://github.com/modelcontextprotocol/python-sdk/pull/781).