refactor(mcp): consolidate position params and centralize tool annotations - #319
Merged
Conversation
bug-ops
enabled auto-merge (squash)
August 5, 2026 01:34
This was referenced Aug 5, 2026
…ations
Collapse six byte-identical position-only param wrapper structs
(HoverParams, DefinitionParams, SignatureHelpParams,
GoToImplementationParams, GoToTypeDefinitionParams,
CallHierarchyPrepareParams) in mcp/tools.rs into direct use of
PositionParams. rmcp's schema validation already strips the top-level
title/description these wrappers carried before it reaches an MCP
client, so the six were structurally identical to PositionParams and
contributed nothing.
Replace the identical annotations(...) block repeated on all 20
#[tool(...)] handlers in mcp/server.rs with a single central pass:
retag the impl block #[tool_router(router = declared_tool_router)]
and fill in any route missing annotations via
McplsServer::tool_router(). Also collapse the redundant
`let result = { ... }; to_tool_result(result)` pattern in 19 of the
20 handlers down to a single to_tool_result(...) expression.
A golden-snapshot test (tool_surface.json, captured from
unmodified code) proves the client-visible tool surface -
names, descriptions, titles, and annotations for all 20 tools -
is byte-identical before and after this refactor.
BREAKING CHANGE: mcpls_core::mcp::{HoverParams, DefinitionParams,
CallHierarchyPrepareParams} are removed. Use
mcpls_core::mcp::PositionParams directly. No deprecation shim,
per pre-1.0 policy.
Closes #301, #302
bug-ops
force-pushed
the
mcp-tool-dispatch-dedup
branch
from
August 5, 2026 01:37
a38c068 to
766dba3
Compare
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.
Summary
HoverParams,DefinitionParams,SignatureHelpParams,GoToImplementationParams,GoToTypeDefinitionParams,CallHierarchyPrepareParams) inmcp/tools.rsinto direct use ofPositionParams. rmcp's schema validation already strips the top-leveltitle/descriptionthese wrappers carried before it reaches an MCP client, so the six contributed nothing beyondPositionParamsitself.annotations(...)block repeated on all 20#[tool(...)]handlers inmcp/server.rswith a single central pass inMcplsServer::tool_router(), and collapse the redundantlet result = { ... }; to_tool_result(result)pattern in 19 of 20 handlers to a single expression.tool_surface.json, captured from unmodified code) proves the client-visible tool surface (names, descriptions, titles, annotations for all 20 tools) is byte-identical before and after this refactor.Closes #301, closes #302.
Design note
An earlier draft of this refactor proposed a
macro_rules!-generated#[tool_router]block to also dedup the per-tool destructure/call/wrap boilerplate. That approach was withdrawn after adversarial review found a simpler mechanism (a ~10-line central annotations pass over the already-pubToolRouter::map) achieves the same deduplication without introducing project-specific macro machinery, an unformattable hand-aligned table, or macro-hygiene footguns — consistent with this project's MVP/no-premature-abstraction convention. Note that neither approach closes #301's statedline/characterargument-swap risk; that would require newtypes on theTranslator::handle_*signatures, tracked as a separate follow-up.Breaking change
mcpls_core::mcp::{HoverParams, DefinitionParams, CallHierarchyPrepareParams}are removed. Usemcpls_core::mcp::PositionParamsdirectly. No deprecation shim, per this project's pre-1.0 policy.Test plan
cargo +nightly fmt --all -- --checkcargo clippy --all-targets --all-features --workspace -- -D warningscargo nextest run --workspace --all-features --lib --bins(643 passed, 1 intentionally skipped)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --all-featurestest_tool_surface_matches_golden_snapshot) confirms zero client-visible change to the 20-tool MCP surfacermcp-3.0.0/rmcp-macros-3.0.0source (not just developer self-report) during review