tool_that_access_request
Retrieve user request data by providing a username through the Simple HTTP MCP Server, enabling remote execution of Python functions with type safety and async support.
Instructions
Access the request.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | The username of the user |
Implementation Reference
- tests/app/tools.py:50-58 (handler)The handler function implementing the core logic of 'tool_that_access_request'. It accesses the request headers, updates the context with the called tool, and returns a personalized message based on the input username and a test header.async def tool_that_access_request( args: Arguments[ToolThatAccessRequest], ) -> ToolThatAccessRequestOutput: """Access the request.""" test_header = args.request.headers.get("X-TEST-HEADER") args.get_state_key("context", Context).add_called_tool("tool_that_access_request") return ToolThatAccessRequestOutput( message=f"Hello {args.inputs.username} you are authenticated with {test_header}", )
- tests/app/tools.py:42-43 (schema)Pydantic input schema for the 'tool_that_access_request' tool, defining the 'username' field.class ToolThatAccessRequest(BaseModel): username: str = Field(description="The username of the user")
- tests/app/tools.py:46-47 (schema)Pydantic output schema for the 'tool_that_access_request' tool, defining the 'message' field.class ToolThatAccessRequestOutput(BaseModel): message: str = Field(description="The message to the user")
- tests/app/tools.py:107-111 (registration)Registration of the 'tool_that_access_request' tool in the TOOLS tuple, specifying the function, input schema, and output schema.Tool( func=tool_that_access_request, inputs=ToolThatAccessRequest, output=ToolThatAccessRequestOutput, ),