docs: cover the remaining Tier 1 audit items (#3325)

This commit is contained in:
Max 2026-08-17 20:18:30 +01:00 • committed by GitHub
commit 9057285683
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,30 @@
from mcp.server import Server, ServerRequestContext
from mcp.types import CallToolRequestParams, CallToolResult, ListToolsResult, PaginatedRequestParams, TextContent, Tool
FIND_BOOK = Tool(
name="find_book",
description="Find one book by ISBN, or by title and author.",
input_schema={
"type": "object",
"properties": {
"isbn": {"type": "string", "pattern": "^[0-9]{13}$"},
"title": {"type": "string"},
"author": {"type": "string"},
},
"oneOf": [{"required": ["isbn"]}, {"required": ["title", "author"]}],
"additionalProperties": False,
},
)
async def list_tools(ctx: ServerRequestContext, params: PaginatedRequestParams | None) -> ListToolsResult:
return ListToolsResult(tools=[FIND_BOOK])
async def call_tool(ctx: ServerRequestContext, params: CallToolRequestParams) -> CallToolResult:
args = params.arguments or {}
found = f"ISBN {args['isbn']}" if "isbn" in args else f"{args['title']!r} by {args['author']}"
return CallToolResult(content=[TextContent(type="text", text=f"Found {found} on shelf C-3.")])
server = Server("Bookshop", on_list_tools=list_tools, on_call_tool=call_tool)