Set read-only annotation hints on each tool for security

This commit is contained in:
Fahad
2025-06-26 13:16:00 +04:00
parent 2bed3a0774
commit 0237fb3419
7 changed files with 67 additions and 12 deletions

View File

@@ -43,11 +43,11 @@ class ListModelsTool(BaseTool):
def get_input_schema(self) -> dict[str, Any]:
"""Return the JSON schema for the tool's input"""
return {
"type": "object",
"properties": {"model": {"type": "string", "description": "Model to use (ignored by listmodels tool)"}},
"required": [],
}
return {"type": "object", "properties": {}, "required": []}
def get_annotations(self) -> Optional[dict[str, Any]]:
"""Return tool annotations indicating this is a read-only tool"""
return {"readOnlyHint": True}
def get_system_prompt(self) -> str:
"""No AI model needed for this tool"""
@@ -57,6 +57,9 @@ class ListModelsTool(BaseTool):
"""Return the Pydantic model for request validation."""
return ToolRequest
def requires_model(self) -> bool:
return False
async def prepare_prompt(self, request: ToolRequest) -> str:
"""Not used for this utility tool"""
return ""