feat(macros): support macros in doc attributes for tool macro#444
Merged
jokemanfire merged 1 commit intomodelcontextprotocol:mainfrom Sep 23, 2025
Merged
feat(macros): support macros in doc attributes for tool macro#444jokemanfire merged 1 commit intomodelcontextprotocol:mainfrom
jokemanfire merged 1 commit intomodelcontextprotocol:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for macros in doc attributes for both the tool and prompt macros, enabling the use of external documentation sources like #[doc = include_str!(...)] instead of just literal strings.
- Changes the description field type from
StringtoExprin both tool and prompt attribute structs - Updates the
extract_doc_linefunction to handle macro expressions and preserve them in the generated code - Adds comprehensive test coverage for the new macro support functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/rmcp-macros/src/tool.rs | Updates tool macro to support macro expressions in doc attributes and adds test for include_str! usage |
| crates/rmcp-macros/src/prompt.rs | Updates prompt macro to support macro expressions in doc attributes and adds corresponding test case |
| crates/rmcp-macros/src/common.rs | Modifies extract_doc_line function to handle both literal strings and macro expressions, using concat! for combining multiple doc lines |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
jokemanfire
approved these changes
Sep 22, 2025
Add tests and return syn::Result from extract_doc_line to propagate parsing errors.
6004a06 to
f19312e
Compare
Closed
Merged
Merged
takumi-earth
pushed a commit
to earthlings-dev/rmcp
that referenced
this pull request
Jan 27, 2026
…extprotocol#444) Add tests and return syn::Result from extract_doc_line to propagate parsing errors.
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.
Add support for macros in doc attributes parsed by the tool macro.
Motivation and Context
Currently the
#[tool]macro only supports literal strings for#[doc]attributes, and some codebases use external docs, .e.g,#[doc = include_str!(...)].How Has This Been Tested?
Test cases have been added.
Breaking Changes
N/A
Types of changes
Checklist
Additional context