Skip to content

Conversation

@abhay-agarwal
Copy link
Contributor

@abhay-agarwal abhay-agarwal commented May 17, 2025

I added the new tool annotation feature to the tool call macro. Currently it just parses the annotation field as json, so that one might potentially be able to simply copy and paste the field from elsewhere into the macro invocation. This might not be optimal for several reasons, one being that the signature must be written in camel case, with no indication to the user that a non-camel-cased value is incorrect, even if they looked at the expanded macro. A solution to this would be to create a wrapper over ToolAnnotations (or annotate ToolAnnotations itself) with deny_unknown_fields. However, this would also prevent the annotation macro from being future proof (currently if the annotation were to be deprecated, then we could silently ignore it).

Here's an example usage taken from the test I added

        #[tool(
            name = "direct-annotated-tool",
            annotations = {
                title: "Annotated Tool", 
                readOnlyHint: true
            }
        )]
        pub async fn direct_annotated_tool(&self, #[tool(param)] input: String) -> String {
            format!("Direct: {}", input)
        }

@abhay-agarwal abhay-agarwal force-pushed the feat/annotations-in-tool-macro branch from b2fbdcc to 86b8abf Compare May 18, 2025 01:57
Copy link
Collaborator

@4t145 4t145 left a comment

Choose a reason for hiding this comment

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

LGTM

I need to fix ci error introduced by lasted merge before merge this.

@4t145 4t145 self-requested a review May 18, 2025 06:16
@4t145
Copy link
Collaborator

4t145 commented May 18, 2025

Could you please merge the main branch and then we can run ci again? Also fix the commit message ci by the way.

skip serializing the tool annotations if none, fixes mcp inspector
@abhay-agarwal abhay-agarwal force-pushed the feat/annotations-in-tool-macro branch from 86b8abf to 12b4310 Compare May 18, 2025 07:51
@abhay-agarwal
Copy link
Contributor Author

abhay-agarwal commented May 18, 2025

Could you please merge the main branch and then we can run ci again? Also fix the commit message ci by the way.

Sounds good, I just squashed and reworded.

@4t145
Copy link
Collaborator

4t145 commented May 18, 2025

Ci failed again but never mind, I will make it lowercase when merge. And thank you for PR.

@4t145 4t145 merged commit 68ddea3 into modelcontextprotocol:main May 18, 2025
8 of 9 checks passed
@github-actions github-actions bot mentioned this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants