[BUG] MCP over HTTP can't read a JSON reply that starts with a byte order mark
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 85/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- json, ruby
- Ambito
- backend-api-design
Direzione di ricerca
Inizia con RubyLLM::MCP::HTTP::Stream#feed, dove il primo carattere determina se la risposta viene analizzata come JSON o come flusso di eventi. Esegui il caso fornito bundle exec ruby -Ilib repro.rb e ispeziona i test vicini dei flussi HTTP MCP. La modifica è completa quando una risposta JSON con il prefisso BOM UTF-8 continua a essere analizzata correttamente, mentre la gestione del JSON semplice e dei flussi di eventi continua a funzionare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Basic checks
- I searched existing issues - this hasn't been reported
- I can reproduce this consistently
- This is a RubyLLM bug, not my application code
What's broken?
RubyLLM::MCP can't read a JSON reply that starts with a UTF-8 byte order mark. MCP::HTTP::Stream#feed tells JSON from an event stream by the first character. With the mark in front, that character is neither { nor [, so the reply goes to the event stream parser, which drops the mark and then ignores the JSON line as an unknown field. The request raises as if the server had not answered.
RFC 8259 (section 8.1) says a sender must not add the mark, and that a parser may ignore it. The event stream side already does. I found this by reading the code, and I don't know of a public server that sends one.
How to reproduce
From the repo root, bundle exec ruby -Ilib repro.rb:
require "ruby_llm"
require "webmock"
WebMock.enable!
BOM = "\xEF\xBB\xBF".b
RESULTS = {
"server/discover" => { resultType: "complete", supportedVersions: ["2026-07-28"], capabilities: { tools: {} } },
"tools/list" => { resultType: "complete", tools: [{ name: "search", inputSchema: { type: "object" } }] }
}
WebMock::API.stub_request(:post, "https://mcp.example.com/mcp").to_return do |request|
call = JSON.parse(request.body)
body = { jsonrpc: "2.0", id: call["id"], result: RESULTS.fetch(call["method"], {}) }.to_json
{ body: (ENV["PLAIN"] ? "" : BOM) + body, headers: { "Content-Type" => "application/json" } }
end
class Docs < RubyLLM::MCP
url "https://mcp.example.com/mcp"
end
puts Docs.new.tools.map(&:name).inspect
With PLAIN=1, which leaves the mark out, it prints ["search"].
Expected behavior
["search"]
What actually happened
mcp.example.com did not answer initialize (RubyLLM::MCP::Error)
Environment
- Ruby version: 4.0.9
- RubyLLM version: 2.2.3, main at c0889f414
- Provider: none, the MCP server is stubbed
- OS: macOS arm64
- Lingua principale
- Ruby
- Stelle
- 4.5k
- Fork
- 543
- Merge medio
- 11h 38m
- PR unite (30g)
- 410
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di crmne/ruby_llm
-
[FEATURE] config.price cannot set image pricesForse già presa @alfredszhao-art l’ha presa 2 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
I maintainer di solito rispondono entro 1 giorno
-
[BUG] XLSX date-times on January 1, 1904 lose the dateForse già presa @yorzi l’ha presa oggi. Apertabug
Difficoltà 3/5 Mezza giornata Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 Mezza giornata Idoneità per principianti 48/100
crmne/ruby_llm#1876 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] after_fallback reports a fallback as failed when after_message raises on its replyForse già presa @yorzi l’ha presa 2 giorni fa. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
crmne/ruby_llm#1861 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Agent.create resolves the model before applying the agent contextForse già presa @yorzi l’ha presa 2 giorni fa. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di crmne/ruby_llm
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
swombat/souls-house#1203 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
we-promise/sure#5924 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
CircuitVerse/CircuitVerse#8342 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
free_port can hand one port to two callers, so the fixed-port http tests fail in parallel runsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
erkamyaman/rust-anything#963 ·
I maintainer di solito rispondono entro 1 giorno