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

Abierto
#3,131 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Muzzy5150 ya está trabajando en esto.

Desde el 31/10/2026.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
node.js, typescript
Área
api, backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
13.8k
Forks
2.5k
Merge medio
6 d 23 h
PR fusionados (30 d)
2

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/typescript-sdk

Todos los issues de modelcontextprotocol/typescript-sdk

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.