Skip to content

fix(docs): use correct Parameters<T> syntax in tool examples#814

Open
lutz-grex wants to merge 1 commit intomodelcontextprotocol:mainfrom
lutz-grex:fix/readme-tool-param-syntax
Open

fix(docs): use correct Parameters<T> syntax in tool examples#814
lutz-grex wants to merge 1 commit intomodelcontextprotocol:mainfrom
lutz-grex:fix/readme-tool-param-syntax

Conversation

@lutz-grex
Copy link
Copy Markdown

The README examples used #[tool(param)] on function parameters, which is not a supported syntax and fails to compile. Replace with the Parameters<T> wrapper pattern that the macros actually expect.

Closes #812

Motivation and Context

Users copying the README tool examples get a compile error:

error: expected non-macro attribute, found attribute macro `tool`

The #[tool(param)] attribute on function parameters was never implemented. The correct pattern is Parameters<T>
with a struct deriving JsonSchema, as used in examples/servers/src/common/calculator.rs.

How Has This Been Tested?

  • Copied the old README example into a standalone project - confirmed the compile error from README example cannot run #812
  • Copied the fixed example - compiles clean with cargo check
  • Verified the pattern matches the existing calculator example in examples/servers/src/common/calculator.rs

Breaking Changes

None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Both the English (README.md) and Chinese (docs/readme/README.zh-cn.md) READMEs contained the same incorrect
examples - both are fixed in this PR.

The README examples used `#[tool(param)]` on function parameters,
which is not a supported syntax and fails to compile. Replace with
the `Parameters<T>` wrapper pattern that the macros actually expect.

Closes modelcontextprotocol#812
@lutz-grex lutz-grex requested a review from a team as a code owner April 17, 2026 14:28
@github-actions github-actions bot added the T-documentation Documentation improvements label Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-documentation Documentation improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

README example cannot run

1 participant