Public inbound-processing completion seam for reusable bounded admission

Aberta
#3,020 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
18/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
api, backend

Direção de pesquisa

This is a public API design question, so start by asking the maintainers whether the seam fits, not by coding. Read how Protocol._onrequest removes its abort-controller entry in its finally, and how serveStdio routes inbound messages to onmessage. Done would mean agreed API shape plus lifecycle tests covering cancellation, rejected handlers, invalid envelopes, unknown methods and failed sends.

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

Descrição

v1 v2

Problem

A transport can bound concurrently admitted requests, but its public onmessage callback returns void. It cannot observe when the corresponding inbound SDK handler has finished result validation/encoding, response sending and internal cleanup.

Releasing admission on transport.send is premature: Protocol._onrequest deletes its abort-controller entry in a later finally. Cancellation can suppress sending entirely while an asynchronous handler is still running. Keeping all request IDs and reservations for the connection lifetime avoids premature reuse, but prevents a bounded, indefinitely usable connection.

Reproduction

Use a Server with a handler held by a deferred promise and a transport whose send is separately deferred. Dispatch a request, cancel it while the handler is held, and observe that no response is sent. The handler can still be running after cancellation. For a successful request, hold send: neither handler return nor entry into send establishes final processing completion.

This applies to ordinary SDK resource accounting, independently of SSH or application-specific authorization. It does not propose any wire-protocol change or claim that local completion proves remote-effect rollback.

Proposed public seam

An optional transport-side per-message processing-completion callback, propagated through serveStdio opening/queue routing and invoked once after actual SDK processing and owned response sends settle. A request's callback must run after its handler controller is removed, including cancellation, rejected handlers, invalid envelopes, unknown methods and failed response sends. Notifications need their own actual handler completion. Connection close alone must not complete unfinished handlers.

The callback is local metadata, never a JSON-RPC field. Applications keep admission policy and physical downstream-operation accounting; the SDK retains negotiation, dispatch, framing and cleanup. Existing callers without the callback retain their behavior.

I would like to contribute a focused implementation and adversarial lifecycle tests. Would this transport-side completion seam fit the SDK's public API direction?

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.