The platform for continuously improving AI agents.
"""MCP tool annotation mapping."""
from __future__ import annotations
from typing import TYPE_CHECKING
from mcp.types import ToolAnnotations
if TYPE_CHECKING:
from overbae.services.mcp.catalog import ToolDefinition
# The MCP specification's value for an omitted hint; the manifest leaves those out.
SPEC_DEFAULTS = {
"readOnlyHint": False,
"destructiveHint": True,
"idempotentHint": False,
"openWorldHint": True,
}
def annotations_for(definition: ToolDefinition) -> ToolAnnotations:
hints = {
"readOnlyHint": definition.read_only,
"destructiveHint": definition.destructive,
"idempotentHint": definition.idempotent,
"openWorldHint": definition.open_world,
}
return ToolAnnotations(
**{key: value for key, value in hints.items() if value != SPEC_DEFAULTS[key]}
)