inspector icon indicating copy to clipboard operation
inspector copied to clipboard

Tools tab times out ("Request timed out") against a connected, OAuth-authenticated Streamable HTTP server running FastMCP's stateless_http=True mode

Open hongwei1 opened this issue 3 months ago • 6 comments

Which version line?

v2 — current (@modelcontextprotocol/inspector@latest)

Which client?

Web

Inspector version

2.4.0 (reproduced both via npx @modelcontextprotocol/inspector and a global npm install -g @modelcontextprotocol/inspector install — same binary version, same result)

Node version

v26.5.0

Operating system (and browser, for the web client)

macOS 26.5.2, Chrome

Transport

Streamable HTTP

MCP server under inspection

Server: https://k8s-mcp2.openbankproject.com/mcp — a public, OAuth 2.1-protected FastMCP (Python) server (the Open Bank Project's MCP server, fronting their sandbox banking API). Protocol era: modern (negotiated 2025-11-25; also reproduces with 2025-06-18) OAuth: yes — Dynamic Client Registration + authorization code + PKCE (S256) against a separate OIDC provider (k8s-oidc.openbankproject.com). DCR, the authorization redirect, and the token exchange all succeed; the Inspector UI shows Connected after login, and initialize / notifications/initialized complete.

This server is public and self-service, so this should be directly reproducible without needing any credentials from me: anyone can create a free test account at https://k8s-portal.openbankproject.com/register (name/email/username/password, no approval step) and log in with it when the Inspector's OAuth flow redirects to the sign-in page.

The server is started with mcp.run(..., stateless_http=True) (FastMCP's stateless HTTP mode) and, by design, never returns an Mcp-Session-Id header on initialize or on any subsequent request.

Steps to reproduce

  1. Fresh launch: npx @modelcontextprotocol/inspector (also reproduced with the global install).
  2. Add the server above as a Streamable HTTP server and connect.
  3. Complete the OAuth login when prompted — the Servers tab shows the server as Connected, with the negotiated protocol version shown next to it.
  4. Open the Tools tab.
  5. Wait — no tool list ever loads.

Expected behavior

tools/list should return promptly, the same as it does for every other client tested against this server (see below).

Actual behavior

The Tools tab shows:

Couldn't load tools
Request timed out
[Retry]

Clicking Retry repeats the same outcome. This is fully and consistently reproducible — same result across multiple fresh Inspector instances (npx-launched and globally-installed), across two separate browser profiles, and across two different OAuth-authenticated user identities on the target server.

Independently, calling the exact same server with the exact same OAuth access token via a plain curl tools/list request (both mcp-protocol-version: 2025-06-18 and 2025-11-25) returns the correct 6-tool list in well under 100ms every time. mcp-remote-based clients (e.g. Claude Desktop / Claude Code style connections) also connect to and use this server successfully. So the server itself, the OAuth flow, and the protocol version are not the cause — the failure is isolated to something in the Inspector web client's own Streamable HTTP session handling once it needs to send tools/list.

The one server characteristic that stands out: Mcp-Session-Id is never present in any response (initialize included), because the server intentionally runs in FastMCP's stateless_http=True mode. A bare GET to the MCP endpoint (the notification stream) does return 200 with content-type: text/event-stream and then stays open indefinitely without ever emitting an event — which is correct behavior for a notification channel, but I could not fully trace whether the Inspector's StreamableHTTPClientTransport (from @modelcontextprotocol/sdk) has an implicit dependency on session-id continuity between that channel and the tools/list POST that causes the request to be misrouted or never actually sent once no session id is available. I did not find an explicit blocking await on the notification stream in send()/start() while reading the SDK source, so I can't pin the exact line — flagging the stateless-server angle as the strongest lead rather than a confirmed root cause.

Possibly related: #2028 also describes an Inspector-side timeout against a FastMCP server (there over stdio/legacy, triggered by ctx.report_progress/ctx.info), which suggests FastMCP-server interop may be a recurring soft spot for the Inspector's request/response tracking, even though the trigger and transport differ from this report.

Logs, errors, or screenshots

Inspector's own Network panel entry for the hung request shows:

Request Headers
  accept: text/event-stream
  authorization: [REDACTED]
  mcp-protocol-version: 2025-11-25
Response Headers
  cache-control: no-cache, no-transform
  content-type: text/event-stream
  date: ...
  strict-transport-security: max-age=31536000; includeSubDomains
Response Body
  Long-lived stream — body not captured

Direct curl against the same server, same token, for comparison (succeeds instantly both times):

$ curl -s -X POST https://k8s-mcp2.openbankproject.com/mcp \
    -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
    -H "Accept: application/json, text/event-stream" \
    -H "mcp-protocol-version: 2025-11-25" \
    -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'

event: message
data: {"jsonrpc":"2.0","id":2,"result":{"tools":[...6 tools...]}}

initialize response headers for reference (no Mcp-Session-Id):

HTTP/2 200
date: ...
content-type: text/event-stream
cache-control: no-cache, no-transform
strict-transport-security: max-age=31536000; includeSubDomains

Happy to provide a redacted HAR export if that would help, on top of the live server above.

Already prototyped a fix?

No — I don't have a fix, just the isolation above (server confirmed healthy via curl/other clients; failure confirmed specific to the Inspector web client once a tools/list is attempted against a session-id-less server).

hongwei1 avatar Aug 28 '26 13:08 hongwei1

Strong isolation work, and the public server makes this reproducible in seconds. Your session-id hypothesis is the right scent: in stateless mode the server never issues Mcp-Session-Id, so per the streamable HTTP spec every POST /mcp response must come back on the POST itself (single JSON response or SSE within that response), not over the open GET notification stream. A tools/list timeout that never resolves smells like the client is waiting on the wrong channel for the response.

Three checks that will pin it:

  1. Replay the POST with the same access token and watch the response framing: curl -N -X POST with Accept: application/json, text/event-stream against the /mcp endpoint. If the server returns application/json with the tools/list result inline, the response arrives on the POST body and the transport should resolve immediately. If the server instead writes the response to the GET stream (which stateless mode forbids) or never writes it, the server is the one misbehaving despite working for other clients.

  2. Inspect the SDK transport pending-request routing: in StreamableHTTPClientTransport the awaited response for a POST is keyed by JSON-RPC id and fed from the POST response reader. If the same id is also being consumed or drained by the stream message handler (the code path for server-initiated notifications), the awaited promise can be consumed twice or never. A one-line log on both ingestion points shows which one eats the tools/list reply.

  3. The open GET stream is itself a suspect in stateless mode: with no session id the server may treat it as a dead channel, and some SDK versions keep a single background read loop that serializes behind it. Check whether a fresh transport that never opens the GET (start with a bare POST) resolves tools/list; that isolates the stream from the send path.

Regardless of which side owns it, a per-request timeout with a surfaced error would convert this hang into a diagnosable failure, and in stateless mode the transport should not hold an open notification stream at all, or open it lazily after the first successful POST.

We run a 36-connector MCP gateway in stateless mode and hit the same response-routing edge cases; the lazy-stream pattern is what held for us.

Ben-Home avatar Aug 28 '26 23:08 Ben-Home

I’m seeing a similar timeout with MCP Failure Lab:

https://github.com/anilloutombam/mcp-failure-lab

Environment:

  • MCP Inspector 2.4.0
  • Streamable HTTP
  • Modern protocol 2026-07-28
  • Endpoint: http://127.0.0.1:3000/mcp

Inspector connects and lists the tools, but calling ping remains pending and eventually reports Request timed out with an empty response body. Legacy mode works.

The server’s integration test pins 2026-07-28, connects through the real HTTP listener, lists the tools, and calls ping successfully. This may indicate an issue in Inspector’s Modern Streamable HTTP proxy path.

anilloutombam avatar Aug 29 '26 07:08 anilloutombam

Triage: Priority = Medium

Scored 8/16 with the priority rubric in .claude/skills/issue-triage. Added to project board #28 with Status Incoming — filed and scored, but not yet approved for work. A maintainer decides whether it moves to Todo.

Axis Score Reasoning
Severity / impact 4/5 The Tools tab — the Inspector's primary surface — is unusable against a connected server, and stateless_http=True is a common FastMCP deployment mode, so this is a whole class of servers rather than one host. Every other client tested against the same server works, so the Inspector is reporting something false about the server under test.
Urgency / staleness 3/5 Reproduces on published 2.4.0 and is wanted this milestone; not blocking other work or a release.
Signal bonuses +1 bug label. (No milestone — by rule, a pass-1 triage has none yet. No assignee, no reporter-set Fields → Priority, and one corroborating comment is not "high engagement".)
Total 8 Top of the Medium band (6–8).

Corroboration. @anilloutombam reports a similar modern-Streamable-HTTP timeout against a different server (mcp-failure-lab) where legacy mode works — the tools list loads there but a ping call hangs. Whether that is the same defect or a second one is worth establishing early, since a shared root cause in the modern Streamable HTTP path would raise this materially.

Thanks for the unusually complete report — the self-service public server, the stateless-mode detail, and the cross-client comparison are exactly what makes this actionable.

Scores are a starting point, not a verdict; a maintainer may override the band with a reason.

cliffhall avatar Aug 30 '26 05:08 cliffhall

Did this break after a FastMCP version bump, or was stateless_http mode never working for you? Curious if you tracked down whether it's an Inspector-side assumption or a FastMCP behavior change.

anythingoah avatar Sep 09 '26 03:09 anythingoah

TL;DR

I reproduced this exactly — the verbatim "Couldn't load tools / Request timed out", after a successful Connect, against a server where curl answers in under 100ms — and the cause is not in the Inspector, and not in FastMCP.

The trigger is a server that cannot serve a second concurrent request from the same client. The MCP client opens the standalone GET /mcp notification stream after initialize and before the first tools/list. On such a server that stream permanently occupies the only slot, so initialize always succeeds and every request after it hangs — which is precisely "shows Connected, then the Tools tab times out". curl is unaffected because it never holds a GET stream open.

There is a one-minute check at the bottom that confirms this against your server with no Inspector involved.


What I tested

Everything below ran against the current v2/main, building the stack up one layer at a time.

Test Setup Result
A Raw SDK v2 client → hand-rolled stateless server (never emits Mcp-Session-Id; GET /mcp returns 200 text/event-stream and stays open, silent) works
B Raw SDK v2 client → real FastMCP 4.0.3, stateless_http=True works
C Inspector's own node stack (InspectorClient + createTransportNode + fetch tracker + MessageTrackingTransport), auto and modern eras, against both of the above works
D Full web path — real headless Chromium → prod Hono backend → real FastMCP stateless Connected 527ms, Tools loaded in 418ms
E Full web path → fixture shaped like your deployment (stateless and GET returns 200 + stays open silently) Tools loaded in 965ms
F Same as E, but the fixture serves only one request at a time ❌ "Couldn't load tools" + "Request timed out"

So statelessness, the absent Mcp-Session-Id, the silent long-lived GET stream, the web bridge, and the protocol era are each individually fine, and fine in combination. Only F fails.

The mechanism

The fixture's own request log from run F is the whole finding:

POST /mcp  initialize
POST /mcp  notifications/initialized
GET  /mcp                     <- standalone notification stream, opened after initialize
(tools/list never reaches the handler at all)

tools/list is queued behind the GET and never runs. Sixty seconds later the SDK's per-request timeout fires and the Tools tab paints your exact error text. Meanwhile, against that very same fixture:

$ curl -s -X POST http://127.0.0.1:9779/mcp -H 'Content-Type: application/json' \
    -H 'Accept: application/json, text/event-stream' \
    -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
event: message
data: {"jsonrpc":"2.0","id":1,"result":{"tools":[…]}}

Instant — because a single curl never holds a notification stream open concurrently. That is the same contrast your report documents, and it is what makes the server look healthy under every check that doesn't hold a stream open.

This also explains the one entry in the Network panel you flagged: the accept: text/event-stream request with Long-lived stream — body not captured is the standalone GET, and on your server it is not merely idle — it is the thing blocking everything behind it.

Opening that stream is explicitly permitted client behavior in the Streamable HTTP transport (the client MAY open a GET SSE stream for server→client messages), so the Inspector isn't misbehaving by doing it.

Two corrections to the report's framing

FastMCP is not implicated. Real FastMCP 4.0.3 in stateless_http=True works end-to-end through the whole web stack (test D). It also answers the standalone GET /mcp with 405, whereas k8s-mcp2.openbankproject.com answers 200 with an open stream — so that behavior comes from the deployment in front of FastMCP, not from FastMCP.

You were not on the modern era. The Inspector's modern era pins 2026-07-28 and negotiates it via a server/discover probe; if the server doesn't offer it, connect fails hard with ERA_NEGOTIATION_FAILED rather than falling back (I hit exactly that error). Since you got a negotiated 2025-11-25 / 2025-06-18, the session was on auto, which fell back to the plain legacy initialize handshake. No modern-era code path is involved in this repro on either side.

Please confirm it on your server

This takes a minute and involves no Inspector at all.

Terminal 1 — hold the notification stream open, exactly as the client does:

curl -N -H "Authorization: Bearer $TOKEN" \
        -H "Accept: text/event-stream" \
        -H "mcp-protocol-version: 2025-11-25" \
        https://k8s-mcp2.openbankproject.com/mcp

Terminal 2, while that is still running — the same tools/list that works today:

curl -s -X POST https://k8s-mcp2.openbankproject.com/mcp \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "mcp-protocol-version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'

If terminal 2 now hangs where it previously returned in under 100ms, the server or its ingress is serializing requests and this is confirmed. The fix is on that side — worker/connection concurrency for the MCP route, so a held SSE stream doesn't starve subsequent POSTs.

What we may still do here

Neither of these is a defect, but both would have made this legible in minutes instead of a full investigation, so I've filed them separately:

  • #2317 — a per-server setting to suppress the standalone GET notification stream, which doubles as the definitive one-click diagnostic for this class;
  • #2318 — report outstanding-request and notification-stream state on a timeout, rather than a bare Request timed out.

Thanks for the report — the curl-vs-Inspector comparison, the stateless_http detail and the captured Network entry are what made this reproducible from the outside.

Fixture — reproduce all of the above locally (no credentials, no network)

Node ≥ 22. Save as stateless-server.mjs.

SERIAL=1 is the only knob that matters here: it models a server that serves one request at a time, so the long-lived GET occupies the single slot and everything after it queues. Every other path releases the slot; only the GET holds it. With SERIAL unset the same fixture works perfectly through the Inspector — that contrast is the point.

// Minimal stateless Streamable HTTP MCP server, hand-rolled to mimic
// FastMCP's stateless_http=True wire behavior:
//   - never emits Mcp-Session-Id (not on initialize, not anywhere)
//   - POST replies are SSE (text/event-stream), one `event: message` then close
//   - GET /mcp returns 200 text/event-stream and stays open forever, silent
//   - notifications (no id) get 202 with empty body
import http from "node:http";

const PORT = Number(process.env.PORT || 9777);
const PROTOCOL = process.env.PROTOCOL_VERSION || "2025-06-18";
// Knobs so we can vary one behavior at a time.
const GET_MODE = process.env.GET_MODE || "open"; // open | 405 | never-respond
const SEND_SESSION_ID = process.env.SEND_SESSION_ID === "1";
// SERIAL=1 models a server (or ingress) that serves one request at a time for
// this client: the long-lived GET stream occupies the single slot, so every
// later POST queues behind it forever. This is the shape #2187 describes.
const SERIAL = process.env.SERIAL === "1";
let slotBusy = false;
const slotQueue = [];
function acquireSlot(fn) {
  if (!SERIAL) return fn(() => {});
  const run = () => {
    slotBusy = true;
    fn(() => {
      slotBusy = false;
      const next = slotQueue.shift();
      if (next) next();
    });
  };
  if (slotBusy) slotQueue.push(run);
  else run();
}

const log = (...a) => console.log(new Date().toISOString(), ...a);

const TOOLS = [
  { name: "ping", description: "ping", inputSchema: { type: "object", properties: {} } },
  { name: "echo", description: "echo", inputSchema: { type: "object", properties: { s: { type: "string" } } } },
];

function handle(msg) {
  if (msg.method === "initialize") {
    return {
      jsonrpc: "2.0", id: msg.id,
      result: {
        protocolVersion: PROTOCOL,
        capabilities: { tools: { listChanged: false } },
        serverInfo: { name: "stateless-fixture", version: "1.0.0" },
      },
    };
  }
  if (msg.method === "tools/list") {
    return { jsonrpc: "2.0", id: msg.id, result: { tools: TOOLS } };
  }
  if (msg.method === "tools/call") {
    return { jsonrpc: "2.0", id: msg.id, result: { content: [{ type: "text", text: "pong" }] } };
  }
  if (msg.method === "resources/list") return { jsonrpc: "2.0", id: msg.id, result: { resources: [] } };
  if (msg.method === "prompts/list") return { jsonrpc: "2.0", id: msg.id, result: { prompts: [] } };
  return { jsonrpc: "2.0", id: msg.id, error: { code: -32601, message: `Method not found: ${msg.method}` } };
}

const server = http.createServer((req, res) => acquireSlot((releaseSlot) => {
  const url = new URL(req.url, `http://localhost:${PORT}`);
  if (url.pathname !== "/mcp") { res.writeHead(404).end(); releaseSlot(); return; }

  if (req.method === "GET") {
    log("GET /mcp  accept=", req.headers.accept, " session=", req.headers["mcp-session-id"]);
    if (GET_MODE === "405") { res.writeHead(405, { allow: "POST" }).end(); releaseSlot(); return; }
    if (GET_MODE === "never-respond") { return; } // hold the socket, never send headers
    res.writeHead(200, {
      "content-type": "text/event-stream",
      "cache-control": "no-cache, no-transform",
      connection: "keep-alive",
    });
    // Deliberately emit NOTHING — a silent notification channel held open.
    req.on("close", () => log("GET /mcp closed by client"));
    return;
  }

  if (req.method === "DELETE") { log("DELETE /mcp"); res.writeHead(405).end(); releaseSlot(); return; }

  if (req.method !== "POST") { res.writeHead(405).end(); releaseSlot(); return; }

  let body = "";
  req.on("data", (c) => (body += c));
  req.on("end", () => {
    let msg;
    try { msg = JSON.parse(body); } catch { res.writeHead(400).end(); releaseSlot(); return; }
    const msgs = Array.isArray(msg) ? msg : [msg];
    const requests = msgs.filter((m) => m.id !== undefined && m.id !== null && m.method);
    log("POST /mcp ", msgs.map((m) => m.method ?? `resp:${m.id}`).join(","),
        " accept=", req.headers.accept, " session=", req.headers["mcp-session-id"]);

    if (requests.length === 0) { res.writeHead(202).end(); releaseSlot(); return; }

    const headers = {
      "content-type": "text/event-stream",
      "cache-control": "no-cache, no-transform",
      connection: "keep-alive",
    };
    if (SEND_SESSION_ID) headers["mcp-session-id"] = "fixed-session-id";
    res.writeHead(200, headers);
    for (const r of requests) {
      res.write(`event: message\ndata: ${JSON.stringify(handle(r))}\n\n`);
    }
    res.end(); // stateless: close the per-request stream immediately
    releaseSlot();
  });
}));

server.listen(PORT, () => log(`stateless fixture on http://127.0.0.1:${PORT}/mcp  GET_MODE=${GET_MODE} SESSION_ID=${SEND_SESSION_ID} PROTOCOL=${PROTOCOL}`));

Reproduce the failure (test F):

PORT=9779 GET_MODE=open SERIAL=1 PROTOCOL_VERSION=2025-11-25 node stateless-server.mjs

Then connect the Inspector to http://127.0.0.1:9779/mcp over Streamable HTTP with protocol era auto, and open the Tools tab. It connects, then shows Couldn't load tools / Request timed out, and the fixture's log shows tools/list never arriving.

Reproduce the control (test E — identical server, concurrency restored):

PORT=9777 GET_MODE=open PROTOCOL_VERSION=2025-11-25 node stateless-server.mjs

Tools load in about a second.

The real-FastMCP control (test D), for completeness:

# fastmcp_stateless.py   —   uv pip install fastmcp   (tested on 4.0.3)
from fastmcp import FastMCP

mcp = FastMCP("obp-like-stateless")

@mcp.tool
def ping() -> str:
    """Simple liveness check."""
    return "pong"

@mcp.tool
def echo(s: str) -> str:
    """Echo a string back."""
    return s

if __name__ == "__main__":
    mcp.run(transport="http", host="127.0.0.1", port=9778, stateless_http=True)

Connects and lists tools through the Inspector without incident, on both auto and modern eras.

cliffhall avatar Sep 11 '26 03:09 cliffhall

I re-tested the MCP Failure Lab reproduction after the investigation above, and it appears to be a different case from the long-lived GET/request-serialization issue.

Environment:

  • MCP Inspector 2.4.0
  • Streamable HTTP
  • Modern (2026-07-28)
  • MCP Failure Lab
  • http://127.0.0.1:3000/mcp

Inspector behavior:

Connect       ✅
tools/list    ✅
tools/call
  └─ ping     ⏳ remains pending / eventually times out

Legacy mode works.

I tested the standalone GET directly:

curl -v -N \
  -H "Accept: text/event-stream" \
  -H "mcp-protocol-version: 2026-07-28" \
  http://127.0.0.1:3000/mcp

< HTTP/1.1 405 Method Not Allowed
< content-type: application/json

{"jsonrpc":"2.0","error":{"code":-32000,"message":"Method not allowed."},"id":null}

So there is no long-lived GET /mcp stream occupying the server.

I also ran the real HTTP integration test with 2026-07-28 pinned:

✓ initializes, discovers tools, invokes ping, and shuts down 38ms

Test Files  1 passed (1)
Tests       15 passed (15)

That test connects through the actual HTTP listener, discovers the tools, and successfully invokes ping.

So the GET-stream starvation mechanism identified above doesn't appear to explain this reproduction: GET /mcp terminates with 405, tools/list succeeds in Inspector, and only the subsequent tool invocation hangs in Modern mode.

If useful, I can open a separate issue with a minimal reproduction and capture the Inspector/server request sequence.

anilloutombam avatar Sep 11 '26 11:09 anilloutombam