modelcontextprotocol / modelcontextprotocol/rust-sdk
Empty cacheScope on tools/list drops every tool
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.9k
- Forks
- 645
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 36
Description
Describe the bug
Some hosted MCP servers send cacheScope: "" on tools/list and resources/read results. SEP-2549 only allows "public", "private", or omitting the field, so serde rejects the empty string. Because ServerResult is an untagged enum, that failure does not stay on ListToolsResult. The payload falls through to CustomResult, and the client ends up with no tools.
Negative ttlMs is already normalized. Empty cacheScope is not.
To Reproduce
Deserialize a valid tools/list result that includes an empty cache scope:
{
"tools": [{ "name": "search", "inputSchema": { "type": "object" } }],
"ttlMs": 0,
"cacheScope": ""
}
On current main this does not parse as ListToolsResult.
Expected behavior
Treat an exact empty cacheScope the same as an omitted field (None). Unknown values such as "shared" or " " should still fail.
Additional context
I hit this against a hosted server that emits cacheScope: "" on an otherwise valid tools/list body. The tools were present on the wire and disappeared after decode.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the serde deserialization for cacheScope in the tools/list and resources/read result types, then reproduce the provided JSON as a focused test. Done means an exact empty string is treated like an omitted field, tools remain available, and values such as "shared" or " " still fail.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100