Add readOnlyHint MCP tool annotations to Memgraph MCP server#213
Open
bbartels wants to merge 3 commits into
Open
Add readOnlyHint MCP tool annotations to Memgraph MCP server#213bbartels wants to merge 3 commits into
bbartels wants to merge 3 commits into
Conversation
…otations Add `readOnlyHint` MCP tool annotations to Memgraph MCP server
|
|
Contributor
Author
|
@antejavor Oh I see, happy to! Alternatively feel free to just make this change there as well if it would be more convenient :) |
Author
|
The main reason we need this is that it informs our mcp gateway whether or not a tool should be invokable from a readonly context! |
Author
|
Also just a note, the cla requires a full address, feel like that might be a bit intrusive for some individuals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Memgraph MCP server enforced read-only mode at runtime but never advertised
readOnlyHintin tool metadata, leaving MCP clients unable to distinguish read-only tools from potentially mutating ones.Changes
server.py— tool annotation updates@mcp.tool(annotations={"readOnlyHint": True}):list_databases,get_configuration,get_index,get_constraint,get_schema,get_storage,get_triggers,get_procedures,get_betweenness_centrality,get_page_rank,get_node_neighborhood,search_node_vectorsrun_queryusesreadOnlyHint=READ_ONLY_MODE— the hint mirrors the runtimeMCP_READ_ONLYenv var so clients see accurate metadata in both modes:use_databaseleft unannotated — it mutates session state even though it doesn't write to the graph.Uses FastMCP 3.x dict-style annotation API (
annotations={"readOnlyHint": ...}), which maps directly tomcp.types.ToolAnnotations.tests/test_tool_annotations.py— new test file15 unit tests verifying:
readOnlyHint=Trueuse_databasedoes not havereadOnlyHint=Truerun_queryexposesreadOnlyHint=TruewhenMCP_READ_ONLY=trueandreadOnlyHintis notTruewhenMCP_READ_ONLY=false