Skip to content

feat: Add tool annotations to scaffolding templates#111

Merged
jmhbh merged 2 commits intokagent-dev:mainfrom
bryankthompson:feat/add-tool-annotations
Feb 3, 2026
Merged

feat: Add tool annotations to scaffolding templates#111
jmhbh merged 2 commits intokagent-dev:mainfrom
bryankthompson:feat/add-tool-annotations

Conversation

@bryankthompson
Copy link
Contributor

Summary

Adds MCP tool annotations support to all framework templates (Go, TypeScript, Python, Java) to help LLMs better understand tool behavior and make safer decisions about tool execution.

Changes

Go (modelcontextprotocol/go-sdk)

  • Bump SDK from v0.2.0 to v1.2.0 for annotation support
  • Add Annotations field to MCPTool struct
  • Add annotations to echo.go.tmpl and tool.go.tmpl

TypeScript (@modelcontextprotocol/sdk)

  • Import ToolAnnotations type
  • Add annotations field to Tool interface
  • Add annotations to echo.ts.tmpl and tool.ts.tmpl
  • Include annotations in tools/list response

Python (FastMCP)

  • Import ToolAnnotations from mcp.types
  • Add annotations parameter to @mcp.tool() decorator
  • Add annotations to echo.py.tmpl and tool.py.tmpl

Java (io.modelcontextprotocol.sdk)

  • Add getAnnotations() method to Tool interface
  • Add annotations to Echo.java.tmpl and ToolTemplate.java.tmpl
  • Update MCPServer to include annotations in both stdio and HTTP responses

Why This Matters

Tool annotations are part of the MCP specification that enable:

  • Clients to auto-approve safe (read-only) operations
  • Better user prompts for destructive operations
  • Improved tool discovery and filtering
  • Semantic metadata that helps LLMs understand tool behavior

This change benefits all users who scaffold new MCP servers with kmcp, ensuring their generated projects include proper tool annotations from the start.

Testing

  • make lint passes
  • make test passes
  • Changes are limited to template files

Before/After

Before (generated tool):

const echo = {
  name: 'echo',
  description: 'Echo back the provided message',
  inputSchema: echoSchema,
  handler: async (params) => { ... }
};

After (generated tool):

const echo = {
  name: 'echo',
  description: 'Echo back the provided message',
  inputSchema: echoSchema,
  annotations: {
    title: 'Echo Message',
    readOnlyHint: true,
  },
  handler: async (params) => { ... }
};

References

Copy link
Contributor

@EItanya EItanya left a comment

Choose a reason for hiding this comment

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

These changes make sense to me. Can you sign the commits as per the DCO requirement

Add MCP tool annotations support to all framework templates (Go, TypeScript,
Python, Java) to help LLMs better understand tool behavior.

Changes by framework:

**Go (modelcontextprotocol/go-sdk):**
- Bump SDK from v0.2.0 to v1.2.0 for annotation support
- Add Annotations field to MCPTool struct
- Add annotations to echo.go.tmpl and tool.go.tmpl

**TypeScript (@modelcontextprotocol/sdk):**
- Import ToolAnnotations type
- Add annotations field to Tool interface
- Add annotations to echo.ts.tmpl and tool.ts.tmpl
- Include annotations in tools/list response

**Python (FastMCP):**
- Import ToolAnnotations from mcp.types
- Add annotations parameter to @mcp.tool() decorator
- Add annotations to echo.py.tmpl and tool.py.tmpl

**Java (io.modelcontextprotocol.sdk):**
- Add getAnnotations() method to Tool interface
- Add annotations to Echo.java.tmpl and ToolTemplate.java.tmpl
- Update MCPServer to include annotations in both stdio and HTTP responses

This change benefits all users who scaffold new MCP servers with kmcp,
ensuring their generated projects include proper tool annotations from
the start.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: bryankthompson <199543909+bryankthompson@users.noreply.github.com>
The Go SDK v1.2.0 has a completely different API compared to v0.2.0
that the templates were designed for. The migration requires updating
all Go templates including main.go, not just the tool files.

This reverts the Go-specific changes while keeping annotations for:
- TypeScript (@modelcontextprotocol/sdk)
- Python (FastMCP with mcp.types.ToolAnnotations)
- Java (io.modelcontextprotocol.sdk)

The Go templates will need a separate PR to migrate to the v1.2.0 API
before annotations can be added.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: bryankthompson <199543909+bryankthompson@users.noreply.github.com>
@bryankthompson bryankthompson force-pushed the feat/add-tool-annotations branch from 01119b9 to 502901f Compare February 3, 2026 11:49
@bryankthompson
Copy link
Contributor Author

Done! I've rebased on the latest main and added DCO sign-off to both commits. The DCO check should pass now. Thank you for the review!

@jmhbh jmhbh merged commit 80a3987 into kagent-dev:main Feb 3, 2026
5 checks passed
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.

3 participants