update_request_state
Update the status of a Freedom of Information request to reflect your assessment of its state.
Instructions
Update the user-assessed state of a request through the experimental write API.
Requires WDTK_API_KEY in the server environment.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| request_id | Yes | ||
| state | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:419-444 (handler)The tool handler function 'update_request_state' decorated with @mcp.tool. Takes request_id and state, checks for WDTK_API_KEY, validates state via UpdateRequestStatePayload, and POSTs to the WDTK write API endpoint.
@mcp.tool( annotations=ToolAnnotations(destructiveHint=True, openWorldHint=True), tags={"write", "admin"}, ) @_timed_tool async def update_request_state( request_id: int, state: str, ctx: Context = CurrentContext(), ) -> dict[str, Any]: """ Update the user-assessed state of a request through the experimental write API. Requires WDTK_API_KEY in the server environment. """ api_key = os.getenv("WDTK_API_KEY") if not api_key: return {"error": "Write API unavailable: WDTK_API_KEY not configured. Requires an authority-level key from the WhatDoTheyKnow admin interface."} payload = UpdateRequestStatePayload(state=state) await ctx.info(f"Updating request {request_id} to state={state}") return await wdtk.post_form_json( f"/api/v2/request/{request_id}/update.json", api_key=api_key, json_payload=payload.model_dump(mode="json"), ) - server.py:93-94 (schema)Pydantic model UpdateRequestStatePayload with a single 'state' field validated against allowed values: waiting_response, rejected, successful, partially_successful.
class UpdateRequestStatePayload(BaseModel): state: str = Field(pattern="^(waiting_response|rejected|successful|partially_successful)$") - server.py:419-423 (registration)Tool registered via @mcp.tool decorator with annotations=ToolAnnotations(destructiveHint=True, openWorldHint=True) and tags={'write', 'admin'}. Also wrapped with @_timed_tool for metrics.
@mcp.tool( annotations=ToolAnnotations(destructiveHint=True, openWorldHint=True), tags={"write", "admin"}, )