Skip to content

Commit 81f8301

Browse files
authored
feat(time): add tool annotations to get_current_time and convert_time (#3574) (#3581)
feat(time): add tool annotations Adds MCP ToolAnnotations to both time server tools (get_current_time, convert_time). Both are read-only, non-destructive, idempotent, and closed-world. Fixes #3574
1 parent c2ee97e commit 81f8301

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/time/src/mcp_server_time/server.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from mcp.server import Server
1010
from mcp.server.stdio import stdio_server
11-
from mcp.types import Tool, TextContent, ImageContent, EmbeddedResource, ErrorData, INVALID_PARAMS
11+
from mcp.types import Tool, ToolAnnotations, TextContent, ImageContent, EmbeddedResource, ErrorData, INVALID_PARAMS
1212
from mcp.shared.exceptions import McpError
1313

1414
from pydantic import BaseModel
@@ -142,6 +142,12 @@ async def list_tools() -> list[Tool]:
142142
},
143143
"required": ["timezone"],
144144
},
145+
annotations=ToolAnnotations(
146+
readOnlyHint=True,
147+
destructiveHint=False,
148+
idempotentHint=True,
149+
openWorldHint=False,
150+
),
145151
),
146152
Tool(
147153
name=TimeTools.CONVERT_TIME.value,
@@ -164,6 +170,12 @@ async def list_tools() -> list[Tool]:
164170
},
165171
"required": ["source_timezone", "time", "target_timezone"],
166172
},
173+
annotations=ToolAnnotations(
174+
readOnlyHint=True,
175+
destructiveHint=False,
176+
idempotentHint=True,
177+
openWorldHint=False,
178+
),
167179
),
168180
]
169181

0 commit comments

Comments
 (0)