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

Aberta
#3,131 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@Muzzy5150 já está trabalhando nisso.

Desde 31/10/2026.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
48/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
node.js, typescript
Domínio
api, backend

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
13.8k
Forks
2.5k
Merge médio
6d 23h
PRs com merge (30d)
2

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de modelcontextprotocol/typescript-sdk

Todas as issues de modelcontextprotocol/typescript-sdk

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.