return error: _b.throwIfAborted is not a function.
whatever I click (e.g. list resources/list templates/list prompts), It always return the error: _b.throwIfAborted is not a function.
However, when I am using cline + mcp server, it works pretty well and no errors have occured.
further bug reports:
Uncaught (in promise) TypeError: b. throwIfAborted is not a function at index-CgrYmEaq.js: 16291
at new Promise (
the steps that I install mcp is: 0. powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
- uv init weather
- cd weather
- uv venv
- .venv\Scripts\activate
- uv add "mcp[cli]" httpx
- pip install fastmcp
- write weather.py
- mcp dev weather.py
Hi, do you have the code that you're actually running for the weather.py server here?
from typing import Any
import httpx
from mcp.server.fastmcp import FastMCP
# Initialize FastMCP server
mcp = FastMCP("weather")
# Constants
NWS_API_BASE = "https://api.weather.gov"
USER_AGENT = "weather-app/1.0"
async def make_nws_request(url: str) -> dict[str, Any] | None:
"""Make a request to the NWS API with proper error handling."""
headers = {
"User-Agent": USER_AGENT,
"Accept": "application/geo+json"
}
async with httpx.AsyncClient() as client:
try:
response = await client.get(url, headers=headers, timeout=30.0)
response.raise_for_status()
return response.json()
except Exception:
return None
def format_alert(feature: dict) -> str:
"""Format an alert feature into a readable string."""
props = feature["properties"]
return f"""
Event: {props.get('event', 'Unknown')}
Area: {props.get('areaDesc', 'Unknown')}
Severity: {props.get('severity', 'Unknown')}
Description: {props.get('description', 'No description available')}
Instructions: {props.get('instruction', 'No specific instructions provided')}
"""
@mcp.tool()
async def get_alerts(state: str) -> str:
"""Get weather alerts for a US state.
Args:
state: Two-letter US state code (e.g. CA, NY)
"""
url = f"{NWS_API_BASE}/alerts/active/area/{state}"
data = await make_nws_request(url)
if not data or "features" not in data:
return "Unable to fetch alerts or no alerts found."
if not data["features"]:
return "No active alerts for this state."
alerts = [format_alert(feature) for feature in data["features"]]
return "\n---\n".join(alerts)
@mcp.tool()
async def get_forecast(latitude: float, longitude: float) -> str:
"""Get weather forecast for a location.
Args:
latitude: Latitude of the location
longitude: Longitude of the location
"""
# First get the forecast grid endpoint
points_url = f"{NWS_API_BASE}/points/{latitude},{longitude}"
points_data = await make_nws_request(points_url)
if not points_data:
return "Unable to fetch forecast data for this location."
# Get the forecast URL from the points response
forecast_url = points_data["properties"]["forecast"]
forecast_data = await make_nws_request(forecast_url)
if not forecast_data:
return "Unable to fetch detailed forecast."
# Format the periods into a readable forecast
periods = forecast_data["properties"]["periods"]
forecasts = []
for period in periods[:5]: # Only show next 5 periods
forecast = f"""
{period['name']}:
Temperature: {period['temperature']}°{period['temperatureUnit']}
Wind: {period['windSpeed']} {period['windDirection']}
Forecast: {period['detailedForecast']}
"""
forecasts.append(forecast)
return "\n---\n".join(forecasts)
if __name__ == "__main__":
# Initialize and run the server
mcp.run(transport='stdio')
Looks as if the request is possibly malformed. We need to do some troubleshooting here.
Some observations
-
throwIfAbortedis being called in therequestmethod oftransport.tsclass in the typescript-sdk. -
The
requestmethod is called with three parameters:request(the JSON-RPC request object),resultSchema(a schema for validating the response), and optionaloptions. Ifoptionsincludes anAbortSignal(via thesignalproperty), thethrowIfAbortedis executed to check if the signal has already been aborted. -
It seems to be think it has an
options.signalthat does not have athrowIfAbortedmethod. -
There is similar report in the python-sdk repo, but
throwIfAborteddoes not appear in the python-sdk. -
Both these issues are talking to a python server, and I haven't seen any indication that this issue is happening with servers based on other sdks
Some questions
- Is there a bug in how the Inspector is forming requests?
- Is the inspector creating a malformed request based on some off-spec conversation with the server?
- Can we duplicate this issue with a server that isn't written in python?
@claude please help suggest next steps for this open issue, including answering the open questions from the latest comment.
Claude finished @olaservo's task —— View job
Analysis: "_b.throwIfAborted is not a function" Issue
Based on my investigation of the MCP Inspector codebase, I can provide answers to the open questions and suggest next steps.
Key Findings
Error Source: The error originates from the TypeScript SDK (@modelcontextprotocol/sdk v1.17.2), specifically in the Client.request() method at line 180 in client/src/lib/hooks/useConnection.ts. The minified variable name _b suggests this is coming from compiled/bundled SDK code, not the Inspector's source.
AbortSignal Handling in Inspector: The Inspector correctly creates AbortController instances and passes the signal to the MCP client:
// useConnection.ts:150
const abortController = new AbortController();
const mcpRequestOptions: RequestOptions = {
signal: options?.signal ?? abortController.signal,
// ...other options
};
response = await mcpClient.request(request, schema, mcpRequestOptions);
No Python-Specific Handling: I found no special handling for Python servers vs other SDK implementations in the Inspector codebase. All MCP servers are treated identically regardless of their implementation language.
Answering @cliffhall's Questions
Q: Is there a bug in how the Inspector is forming requests?
A: No. The Inspector correctly forms requests and passes valid AbortSignal objects. The issue appears to be within the SDK itself.
Q: Is the inspector creating a malformed request based on some off-spec conversation with the server?
A: No evidence suggests this. The Inspector uses standard MCP protocol methods (resources/list, prompts/list, tools/list) and follows the TypeScript SDK's documented patterns.
Q: Can we duplicate this issue with a server that isn't written in python?
A: This would be the most valuable diagnostic step. The error appears SDK-side, so it should occur regardless of server implementation language.
Suggested Next Steps
- Reproduce with Non-Python Server: Test the Inspector against servers built with the TypeScript, Go, or other SDKs to determine if this is Python-specific
- SDK Version Testing: Test with different versions of
@modelcontextprotocol/sdkto identify when this regression was introduced - Debug Build: Create a development build that preserves source maps to get a clearer stack trace showing the exact SDK location
- AbortSignal Polyfill: Consider adding explicit AbortSignal feature detection/polyfilling for environments that might have incomplete implementations
- Upstream Issue: If confirmed as an SDK bug, file an issue against the TypeScript SDK repository with reproduction steps
The evidence strongly suggests this is a regression in the TypeScript SDK's handling of AbortSignal, likely introduced in a recent version where the throwIfAborted method is being called on an object that doesn't implement it properly.
Closing as this issue has been inactive for a while and have not seen other reports of this issue since this.