A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://blog.marcnuri.com/mcp-tool-annotations-introduction below:

MCP Tool Annotations: Adding Metadata and Context to Your AI Tools

Introduction

As artificial intelligence (AI) applications become more sophisticated and interact with increasingly complex external systems, better tool metadata becomes crucial. Although the Model Context Protocol (MCP) was introduced only a couple of months ago, it is very much alive and evolving quickly. One of its latest advancements is the introduction of MCP Tool annotations.

Annotations provide a layer of metadata that enhances the interaction between AI models and external tools, making it easier for AI models, clients, and users to understand how these tools behave and what they can do.

In this post, I’ll walk through what Tool annotations are, why they matter, and give a few examples based on the Kubernetes MCP Server.

What are MCP Tool Annotations?

MCP Tool annotations are specialized metadata that you can attach to your MCP tools to communicate their behavior characteristics to the MCP client. Think of them as labels that describe what your tool does and how it behaves, similar to how you might label physical tools in a workshop.

These annotations serve as advisory hints that help client applications make informed decisions about tool usage, display appropriate user interfaces, and implement safety controls.

Note

Annotations are hints provided by the MCP server and are informational only. They do not enforce any behavior or restrictions on the tool itself. Don't blindly trust them, as they are not guaranteed to be accurate or complete.

Why are MCP Tool Annotations Important?

MCP Tool annotations allow servers to express the behavior of their tools in a standardized way. By using annotations, tools become self-descriptive, which brings several benefits:

Available MCP Tool Annotations

The MCP specification defines several standard annotations that cover the most common tool behavior patterns:

Annotation Type Description title string

A human-readable title for the tool, useful for displaying in user interfaces. This is particularly useful when your tool's function name isn't descriptive enough for end users.

readOnlyHint boolean

Indicates whether the tool only reads data without making any modifications. This is crucial for tools that query information versus those that change system state.

destructiveHint boolean

For non-read-only tools, this signals whether the changes made are destructive or reversible. This helps client applications implement appropriate warnings and confirmations.

idempotentHint boolean

Specifies whether repeated identical calls have the same effect as a single call. This is important for understanding whether a tool can be safely retried.

openWorldHint boolean

Indicates whether the tool interacts with external systems beyond the local environment. This helps in understanding the tool's scope and potential dependencies.

A Real-World Example: Kubernetes MCP Server

Let's look at how these annotations can be applied in a real-world scenario using the Kubernetes MCP Server as an example.

The Kubernetes MCP Server provides a set of tools to interact with Kubernetes clusters, and it uses MCP Tool annotations to enhance the user experience.

For instance, consider the following tool definition for the helm_list function:

{mcp.NewTool("helm_list",
	mcp.WithDescription("List all the Helm releases in the current or provided namespace (or in all namespaces if specified)"),
	mcp.WithString("namespace", mcp.Description("Namespace to list Helm releases from (Optional, all namespaces if not provided)")),
	mcp.WithBoolean("all_namespaces", mcp.Description("If true, lists all Helm releases in all namespaces ignoring the namespace argument (Optional)")),
	// Tool annotations
	mcp.WithTitleAnnotation("Helm: List"),
	mcp.WithReadOnlyHintAnnotation(true),
	mcp.WithDestructiveHintAnnotation(false),
	mcp.WithOpenWorldHintAnnotation(true),
), s.helmList},

In this example, the tool helm_list is defined with several annotations:

For more examples, check the Kubernetes MCP Server mcp package which contains many other tools with various annotations.

Best Practices for MCP Tool Annotations

When implementing tool annotations, consider the following guidelines:

Conclusion

MCP Tool annotations provide a powerful way to enhance your AI tools with essential metadata that improves user experience and system safety. By thoughtfully applying these annotations to your tools, you create more robust and user-friendly AI integrations.

In my Kubernetes MCP Server, annotations help users understand the difference between safe query operations and potentially destructive cluster modifications, making the tool more trustworthy and easier to use in production environments.

As you build your own MCP servers, remember that annotations are about communication: they help bridge the gap between what your tool does technically and what users need to know to use it effectively.

You Might Also Like

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4