Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Fix the CLI .js deprecation warning and a dead error-message link (#6453)

nate nowack118ce1d1a980
diff --git a/fastmcp_slim/fastmcp/cli/client.py b/fastmcp_slim/fastmcp/cli/client.py
index 5e6a190fb..13637e9f1 100644
--- a/fastmcp_slim/fastmcp/cli/client.py
+++ b/fastmcp_slim/fastmcp/cli/client.py
@@ -30,7 +30,7 @@ from fastmcp.client.elicitation import ElicitResult
from fastmcp.client.transports.base import ClientTransport
from fastmcp.client.transports.http import StreamableHttpTransport
from fastmcp.client.transports.sse import SSETransport
-from fastmcp.client.transports.stdio import StdioTransport
+from fastmcp.client.transports.stdio import NodeStdioTransport, StdioTransport
from fastmcp.skills.client import SkillsClientExtension
from fastmcp.skills.models import MCPSkill
from fastmcp.utilities.logging import get_logger
@@ -125,8 +125,7 @@ def resolve_server_spec(
command="fastmcp",
args=["run", str(resolved_path), "--no-banner"],
)
- # .js β€” pass through for Client's infer_transport
- return spec
+ return NodeStdioTransport(script_path=path.resolve())
# 3. Name-based resolution (bare name or source:name)
try:
diff --git a/fastmcp_slim/fastmcp/server/http.py b/fastmcp_slim/fastmcp/server/http.py
index 7bab7ed24..f9f473c7b 100644
--- a/fastmcp_slim/fastmcp/server/http.py
+++ b/fastmcp_slim/fastmcp/server/http.py
@@ -105,13 +105,13 @@ class StreamableHTTPASGIApp:
"passed to the parent ASGI application (e.g., FastAPI or Starlette). "
"Please ensure you are setting `lifespan=mcp_app.lifespan` in your "
"parent app's constructor, where `mcp_app` is the application instance "
- "returned by `fastmcp_instance.http_app()`. \\n"
+ "returned by `fastmcp_instance.http_app()`.\n"
"For more details, see the FastMCP ASGI integration documentation: "
- "https://gofastmcp.com/deployment/asgi"
+ "https://gofastmcp.com/deployment/http#integration-with-web-frameworks"
)
# Raise a new RuntimeError that includes the original error's message
# for full context, but leads with the more helpful guidance.
- raise RuntimeError(f"{new_error_message}\\nOriginal error: {e}") from e
+ raise RuntimeError(f"{new_error_message}\nOriginal error: {e}") from e
else:
# Re-raise other RuntimeErrors if they don't match the specific message
raise
diff --git a/tests/cli/test_client_commands.py b/tests/cli/test_client_commands.py
index 23b2f3ed3..cdd268e32 100644
--- a/tests/cli/test_client_commands.py
+++ b/tests/cli/test_client_commands.py
@@ -33,7 +33,7 @@ from fastmcp.client.auth.oauth import OAuth
from fastmcp.client.client import CallToolResult
from fastmcp.client.transports.http import StreamableHttpTransport
from fastmcp.client.transports.sse import SSETransport
-from fastmcp.client.transports.stdio import StdioTransport
+from fastmcp.client.transports.stdio import NodeStdioTransport, StdioTransport
from fastmcp.mcp_config import RemoteMCPServer
from fastmcp.settings import Settings
from fastmcp.utilities.tests import temporary_settings
@@ -401,6 +401,17 @@ class TestResolveServerSpec:
assert result.command == "fastmcp"
assert result.args == ["run", str(py_file.resolve()), "--no-banner"]
+ def test_js_file_builds_client_without_deprecation_warning(self, tmp_path: Path):
+ js_file = tmp_path / "server.js"
+ js_file.write_text("// empty")
+ result = resolve_server_spec(str(js_file))
+ assert isinstance(result, NodeStdioTransport)
+ assert result.command == "node"
+ assert result.args == [str(js_file.resolve())]
+ with warnings.catch_warnings():
+ warnings.simplefilter("error")
+ Client(result)
+
def test_json_mcp_config(self, tmp_path: Path):
config_file = tmp_path / "mcp.json"
config = {"mcpServers": {"test": {"url": "http://localhost:8000"}}}
diff --git a/tests/server/http/test_task_group_error.py b/tests/server/http/test_task_group_error.py
new file mode 100644
index 000000000..6fe24c0b1
--- /dev/null
+++ b/tests/server/http/test_task_group_error.py
@@ -0,0 +1,27 @@
+import pytest
+
+from fastmcp.server.http import StreamableHTTPASGIApp
+
+
+async def test_uninitialized_task_group_error_points_to_lifespan_docs():
+ app = StreamableHTTPASGIApp(session_manager=None)
+
+ async def receive():
+ return {"type": "http.request"}
+
+ async def send(message):
+ pass
+
+ with pytest.raises(RuntimeError) as exc_info:
+ await app({"type": "http"}, receive, send)
+
+ message = str(exc_info.value)
+ assert "\\n" not in message
+ assert "`fastmcp_instance.http_app()`.\nFor more details" in message
+ assert (
+ "https://gofastmcp.com/deployment/http#integration-with-web-frameworks"
+ in message
+ )
+ assert message.endswith(
+ "\nOriginal error: Task group is not initialized. Make sure to use run()."
+ )