A handler that throws McpError produces a double-prefixed message on the client
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 68/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- typescript
- Domínio
- api, backend-api-design
Direção de pesquisa
Comece em Protocol._onresponse e McpError.fromError, seguindo tanto _requestResolvers quanto os caminhos normais de resposta descritos no relatório. Reproduza a rejeição de callTool por meio de InMemoryTransport e, em seguida, verifique se a mensagem de erro recebe o prefixo apenas uma vez, sem causar regressão na ramificação UrlElicitationRequired. Está concluído quando as respostas McpError lançadas chegam ao cliente com um único prefixo de erro MCP.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
What happens
A request handler that throws McpError produces a message the client shows with the prefix twice.
Reproduced with the SDK alone over InMemoryTransport on 1.24.3, and the code path is unchanged in the
current 1.30.0:
server.setRequestHandler(CallToolRequestSchema, async () => {
throw new McpError(ErrorCode.MethodNotFound, "Unknown tool: nope");
});
// ...
try { await client.callTool({ arguments: {}, name: "nope" }); }
catch (e) { console.log("client received:", e.message); }
server threw: MCP error -32601: Unknown tool: nope
client received: MCP error -32601: MCP error -32601: Unknown tool: nope
Why
Three steps, each defensible alone:
McpError's constructor callssuper(`MCP error ${code}: ${message}`), so.messagealready carries
the prefix.- The server serialises a thrown error as
message: error.message, so the prefix travels inside the
JSON-RPCerror.messagefield. Protocol._onresponseconverts it back withMcpError.fromError(response.error.code, response.error.message, response.error.data), whose default branch returns
new McpError(code, message, data)and prefixes what is already prefixed. I confirmed at runtime that
this is the path acallToolrejection takes, by counting calls intofromError: exactly one.
_onresponse also holds a new McpError(...) conversion in its _requestResolvers branch, for queued
responses, which double-prefixes for the same reason.
Throwing McpError is the SDK's own mechanism and shared/protocol throws it in several places itself, so
this is the default result rather than a misuse.
What I expected
One prefix. Either the JSON-RPC error.message carries the bare message, or the client stops re-wrapping a
message that already has the prefix.
Not checked
Only InMemoryTransport, and only a callTool rejection. The one branch of fromError that does not take
the default path is UrlElicitationRequired carrying elicitations, which returns
UrlElicitationRequiredError; that class calls super with the same code, so I would expect it to prefix
too, but I did not exercise it.
- Linguagem predominante
- TypeScript
- Estrelas
- 13.7k
- Forks
- 2.4k
- Merge médio
- 2d 7h
- PRs com merge (30d)
- 26
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de modelcontextprotocol/typescript-sdk
-
[v2] createMcpHandler legacy fallback misses an abort that happens before it subscribesTalvez já em andamento @mariano-aguero assumiu há 5 dias. Abertav2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
modelcontextprotocol/typescript-sdk#3136 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[v2] requireBearerAuth: drop error="invalid_token" when no credentials were sent and resource_metadata is set (RFC 6750 §3.1)Talvez já em andamento @Anandumv assumiu há 4 dias. Abertav2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
modelcontextprotocol/typescript-sdk#3124 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
The `maxToolInputElements` refusal lacks the `Input validation error:` prefix that the schema refusal carriesTalvez já em andamento @barry166 assumiu há 8 dias. Abertav1 v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
modelcontextprotocol/typescript-sdk#3111 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
server: registeredResource.update and registeredResourceTemplate.update desync title and metadata.title when updating metadata aloneTalvez já em andamento @SameRainbows assumiu há 3 dias. Abertav1 v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
modelcontextprotocol/typescript-sdk#3103 · 6 comentários ·
Mantenedores costumam responder em até 1 dia
-
[v1.x] Protocol.request keeps its abort listener after the request resolved, so a later abort sends notifications/cancelled for an answered request (1.30.0)Talvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertav1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
modelcontextprotocol/typescript-sdk#3090 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
Todas as issues de modelcontextprotocol/typescript-sdk
Issues semelhantes
-
area: infrastructure bug priority: low
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
snapotter-hq/SnapOtter#4575 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
Mantenedores costumam responder em até 1 dia
-
documentation server-memory v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
modelcontextprotocol/servers#5457 ·
Mantenedores costumam responder em até 1 dia
-
comp: ssr comp: zones type: feature version: current (v17+)
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
angular/angularfire#3836 ·
Mantenedores costumam responder em até 3 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia