build_request_url
Build a URL pre-filled with Freedom of Information request details for a UK public authority, including optional title, body, and tags.
Instructions
Build a prefilled WhatDoTheyKnow request URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| authority_slug | Yes | ||
| title | No | ||
| default_letter | No | ||
| body | No | ||
| tags | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| authority_slug | Yes | ||
| url | Yes |
Implementation Reference
- server.py:242-273 (handler)The tool handler for 'build_request_url'. Builds a prefilled WhatDoTheyKnow request URL from optional title, default_letter, body, and tags parameters. Registered with the @mcp.tool decorator with tags {'public', 'compose'}.
@mcp.tool( annotations=ToolAnnotations( readOnlyHint=True, idempotentHint=True, openWorldHint=True, ), tags={"public", "compose"}, ) def build_request_url( authority_slug: str, title: str | None = None, default_letter: str | None = None, body: str | None = None, tags: list[str] | None = None, ) -> NewRequestLink: """Build a prefilled WhatDoTheyKnow request URL.""" params: dict[str, str] = {} if title: params["title"] = title if default_letter: params["default_letter"] = default_letter if body: params["body"] = body if tags: params["tags"] = " ".join(tags) query = urlencode(params, doseq=False) url = f"{BASE_URL}/new/{authority_slug}" if query: url = f"{url}?{query}" return NewRequestLink(authority_slug=authority_slug, url=url) - server.py:63-65 (schema)Pydantic model used as the return type for build_request_url, containing authority_slug and the constructed URL.
class NewRequestLink(BaseModel): authority_slug: str url: HttpUrl - server.py:242-249 (registration)Registration of build_request_url as an MCP tool via the @mcp.tool decorator, marking it as read-only, idempotent, and open-world.
@mcp.tool( annotations=ToolAnnotations( readOnlyHint=True, idempotentHint=True, openWorldHint=True, ), tags={"public", "compose"}, )