mcp: ResourceNotFoundError produces invalid JSON for some URIs, terminating the session
What
ResourceNotFoundError builds its error data with fmt.Sprintf({"uri":%q}, uri). Go's %q quoting is not JSON: DEL becomes \x7f, and some non-printable runes (e.g. the tag characters in the Scotland flag emoji 🏴, U+E0067…) become \U000e0067. The resulting Data is invalid JSON.
Repro
Against any server with resources, call resources/read with an unregistered URI such as "file:///del\u007f.txt". The server calls ResourceNotFoundError(uri) (Server.readResource), encoding the response fails, and the client gets EOF instead of a "Resource not found" error. Every later request on that session fails too.
Root cause
Marshaling the response fails on the invalid json.RawMessage. jsonrpc2.Connection.write treats the failure as a broken writer and shuts down the connection. A single client-chosen URI therefore takes down the whole session.
Proposed fix
Build the data with json.Marshal(struct{ URI string json:"uri" }{uri}). The exported API does not change.