Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

A request whose `id` is not an i64 or a string is parsed as a notification

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

Mantenedores costumam responder em até 3 dias

@talhayme já está trabalhando nisso.

Desde 12/10/2026.

  • #1346 de @talhayme — aberto

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
62/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
rust

Direção de pesquisa

Start with the JsonRpcMessage untagged enum and NumberOrString parsing in the message model; the issue provides a reproducer using ClientJsonRpcMessage and serde_json::from_str. Check how parsing distinguishes requests from notifications and how invalid ids can be reported as -32600 Invalid Request. Done means the listed id cases no longer silently parse as notifications.

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

Descrição

bug P1 ready for work T-core T-model

Describe the bug
JsonRpcMessage is #[serde(untagged)]. When id is present but does not deserialize as NumberOrString (i64 or string), the Request variant fails and the message falls through to Notification, which ignores the extra id field. The server then never answers, so the client waits until its own timeout instead of getting -32600 Invalid Request.

To Reproduce (main at 808124b)

let raw = r#"{"jsonrpc":"2.0","id":1.0,"method":"tools/list"}"#;
let msg: rmcp::model::ClientJsonRpcMessage = serde_json::from_str(raw).unwrap();
assert!(matches!(msg, rmcp::model::ClientJsonRpcMessage::Request(_))); // fails: Notification

Same result for 9223372036854775808 (i64::MAX + 1), 1e2, 1.5, true and null. 9223372036854775807 parses as a request.

Expected behavior
A message that carries id and method is a request. If the id is not one the SDK supports, reject it with -32600 rather than treating it as a notification. 1.0 and 1e2 are integral JSON numbers and could reasonably be accepted as 1 and 100.

Additional context
Found by running the same request ids through several SDKs. The Go SDK has a related report in modelcontextprotocol/go-sdk#1376. I checked message parsing only, not a live server.

I'd like to send a fix: decide request vs notification by the presence of id, and report an invalid id as an error.

AI disclosure: found and drafted with Claude Code; I reviewed it and ran the cases above.

Linguagem predominante
Rust
Estrelas
4k
Forks
662
Merge médio
3d 19h
PRs com merge (30d)
35

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

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/rust-sdk

Todas as issues de modelcontextprotocol/rust-sdk

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

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