createMcpHonoApp: JSON body middleware has a size limit but no time limit (stalled body holds the request open)

Offen
#3,131 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@Muzzy5150 arbeitet bereits daran.

Seit 31.10.2026.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
node.js, typescript
Bereich
api, backend

Rechercherichtung

Start by locating createMcpHonoApp's JSON body middleware and the readRequestBody helper in @modelcontextprotocol/server, then trace how request-body errors become HTTP responses. The issue suggests adding a body-arrival deadline that returns 408 and closes the connection, but leaves the design open. Done means stalled bodies are bounded while the existing size limit still works; add coverage for both behaviors.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

v1 v2

Summary

createMcpHonoApp's JSON body middleware bounds how many bytes it reads (maxRequestBodySize) but not how long the body takes to arrive. A client that sends part of a body and then stalls keeps the request open with no response from the middleware. The only limit is the underlying HTTP server's own timeout (for Node, server.requestTimeout, 300 s by default).

Reproduction

@modelcontextprotocol/hono 2.0.2, @modelcontextprotocol/server 2.3.1, @hono/node-server 2.1.5, Node 24.

import { serve } from '@hono/node-server';
import { createMcpHonoApp } from '@modelcontextprotocol/hono';
import { request } from 'node:http';

const app = createMcpHonoApp({ host: '127.0.0.1' });
app.all('/mcp', (c) => c.text('unreachable while the body is stalled'));
const server = serve({ fetch: app.fetch, port: 0, hostname: '127.0.0.1' }, ({ port }) => {
  const req = request(`http://127.0.0.1:${port}/mcp`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'Content-Length': '100' },
  }, (res) => console.log('responded', res.statusCode));
  req.write('{'); // 1 of 100 declared bytes, then nothing
  setTimeout(() => { console.log('still open after 3s'); req.destroy(); server.close(); }, 3000);
});

Output: still open after 3s. The request is held until the client leaves or the server's timeout fires.

Expected

An option to bound body arrival time (for example a bodyTimeoutMs), answering 408 and closing the connection when it expires. The readRequestBody helper in @modelcontextprotocol/server could accept an AbortSignal for the same purpose, so adapters can supply their own deadline.

Impact

Low for a loopback development server. For a deployed server, each stalled request holds a connection and a handler slot until the server's timeout.

I am not asking for a particular design, only noting that the size limit has no time counterpart. We document the gap and rely on the server timeout meanwhile.

Vorherrschende Sprache
TypeScript
Sterne
13.8k
Forks
2.5k
Ø Merge
6 T. 23 Std.
Gemergte PRs (30 T.)
2

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modelcontextprotocol/typescript-sdk

Alle Issues in modelcontextprotocol/typescript-sdk

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.