modelcontextprotocol / modelcontextprotocol/java-sdk

Reject listRoots if not supported by client, without sending any request

Open Beginner friendly
#1,067 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue P3
Dominant language
Java
Stars
3.7k
Forks
1.1k
Avg merge
1d 15h
Merged PRs (30d)
9

Description

Some requests in McpAsyncServerExchange make a point of failing fast if functionality not supported, such the condition on line 146

https://github.com/modelcontextprotocol/java-sdk/blob/fd004989b9484c9b81be6b03463396797b354804/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java#L141-L151

listRoots does not do the same

https://github.com/modelcontextprotocol/java-sdk/blob/fd004989b9484c9b81be6b03463396797b354804/mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java#L227-L230

For example, add this

if (this.clientCapabilities.roots() == null) { 
    return Mono.error(new IllegalStateException("Client must be configured with root listing capabilities")); 
} 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read mcp-core/src/main/java/io/modelcontextprotocol/server/McpAsyncServerExchange.java, especially the existing capability check around lines 141-151 and the listRoots entry point around lines 227-230. Confirm that an unsupported roots capability is rejected before any request is sent, with the specified error behavior, then run the relevant project tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.