Add ToolAnnotations to all 11 MCP tools (title, readOnlyHint, destructiveHint, idempotentHint)#356
Merged
jongalloway merged 2 commits intomainfrom Feb 24, 2026
Conversation
…, idempotent hints) Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add ToolAnnotations to all MCP tools
Add ToolAnnotations to all 11 MCP tools (title, readOnlyHint, destructiveHint, idempotentHint)
Feb 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds MCP SDK 1.0 ToolAnnotations (Title, ReadOnly, Destructive, Idempotent) to all 11 MCP tools, enabling AI assistants to make better decisions about when to auto-approve operations, when to show confirmation prompts, and how to display tools to users. The implementation uses native McpServerToolAttribute properties and follows a "most-permissive-action" strategy for consolidated tools.
Changes:
- Added
Titleproperty to all 11 MCP tool attributes with human-readable display names - Marked 3 info/query tools (
DotnetHelp,DotnetServerCapabilities,DotnetServerInfo) asReadOnly = true, Idempotent = true - Marked 7 tools with destructive actions as
Destructive = true(Project, Package, Solution, Tool, Workload, DevCerts, EntityFramework) - Added 6 new tests (3 reflection-based, 3 protocol-based) to verify annotations are correctly set and appear in MCP protocol responses
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| DotNetMcp/Tools/Sdk/DotNetCliTools.Sdk.Consolidated.cs | Added Title ".NET SDK & Templates" (no ReadOnly/Destructive - template management is non-destructive) |
| DotNetMcp/Tools/Cli/DotNetCliTools.Workload.Consolidated.cs | Added Title and Destructive=true (Uninstall action) |
| DotNetMcp/Tools/Cli/DotNetCliTools.Tool.Consolidated.cs | Added Title and Destructive=true (Uninstall action) |
| DotNetMcp/Tools/Cli/DotNetCliTools.Solution.cs | Added Title and Destructive=true (Remove action) |
| DotNetMcp/Tools/Cli/DotNetCliTools.Project.Consolidated.cs | Added Title and Destructive=true (Clean action) |
| DotNetMcp/Tools/Cli/DotNetCliTools.Package.Consolidated.cs | Added Title and Destructive=true (Remove/ClearCache actions) |
| DotNetMcp/Tools/Cli/DotNetCliTools.Misc.cs | Added Title, ReadOnly, and Idempotent to 3 info/query tools |
| DotNetMcp/Tools/Cli/DotNetCliTools.EntityFramework.Consolidated.cs | Added Title and Destructive=true (DatabaseDrop/MigrationsRemove actions) |
| DotNetMcp/Tools/Cli/DotNetCliTools.DevCerts.Consolidated.cs | Added Title and Destructive=true (CertificateClean/SecretsClear actions) |
| DotNetMcp.Tests/Tools/ToolMetadataSerializationTests.cs | Added 3 reflection tests verifying Title, ReadOnly/Idempotent, and Destructive annotations |
| DotNetMcp.Tests/Server/McpConformanceTests.cs | Added 3 integration tests verifying annotations appear in MCP protocol's tools/list response |
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.
MCP SDK 1.0's
ToolAnnotationssupport (readOnlyHint,destructiveHint,idempotentHint,title) was unused. These hints enable AI clients to auto-approve safe operations, show confirmation UI for destructive ones, and display human-readable titles.Changes
Annotations via native
McpServerToolAttributepropertiesUses
Title,ReadOnly,Destructive, andIdempotenton[McpServerTool]— the native approach that maps directly to the MCP protocol'sToolAnnotationsstruct.Annotation mapping (most-permissive-action strategy for consolidated tools)
DotnetProjectDotnetPackageDotnetSolutionDotnetSdkDotnetToolDotnetWorkloadDotnetDevCertsDotnetEfDotnetHelpDotnetServerCapabilitiesDotnetServerInfoTests
ToolMetadataSerializationTests— 3 new reflection tests verifyingTitle,ReadOnly/Idempotent, andDestructiveon all annotated methodsMcpConformanceTests— 3 new integration tests verifyingReadOnlyHint,DestructiveHint, andTitleappear correctly in thetools/listprotocol responseOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.