get_joke
Generate a random joke using the Python MCP Server Template. This tool is designed to integrate humor into applications, enhancing user experience with a quick and simple API call.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_server.py:11-15 (handler)The handler function for the 'get_joke' tool, registered via @mcp.tool() decorator. It fetches a random joke from the API and returns the setup followed by the punchline.@mcp.tool() async def get_joke() -> str: response = httpx.get("https://official-joke-api.appspot.com/random_joke") joke_data = response.json() return joke_data["setup"] + "\n" + joke_data["punchline"]