Skip to content

feat(macros): support macros in doc attributes for tool macro#444

Merged
jokemanfire merged 1 commit intomodelcontextprotocol:mainfrom
rliang:fix/doc-include
Sep 23, 2025
Merged

feat(macros): support macros in doc attributes for tool macro#444
jokemanfire merged 1 commit intomodelcontextprotocol:mainfrom
rliang:fix/doc-include

Conversation

@rliang
Copy link
Copy Markdown
Contributor

@rliang rliang commented Sep 18, 2025

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

  • 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

Copilot AI review requested due to automatic review settings September 18, 2025 13:51
@github-actions github-actions bot added the T-macros Macro changes label Sep 18, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 String to Expr in both tool and prompt attribute structs
  • Updates the extract_doc_line function 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.

Add tests and return syn::Result from extract_doc_line to propagate parsing errors.
@jokemanfire jokemanfire merged commit a11c4de into modelcontextprotocol:main Sep 23, 2025
11 checks passed
@github-actions github-actions bot mentioned this pull request Sep 23, 2025
@jamadeo jamadeo mentioned this pull request Sep 24, 2025
@github-actions github-actions bot mentioned this pull request Sep 24, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-macros Macro changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants