Skip to main content
Glama

Chuck Norris Jokes MCP Server

by AlexuLag
server.py1.26 kB
from mcp.server.fastmcp import FastMCP import httpx import asyncio import sys # Create an MCP server mcp = FastMCP("ChuckNorrisJokes") async def fetch_joke() -> str: """Obtiene un chiste aleatorio de Chuck Norris""" async with httpx.AsyncClient() as client: response = await client.get("https://api.chucknorris.io/jokes/random") if response.status_code == 200: joke_data = response.json() return joke_data["value"] else: return "Lo siento, no pude obtener un chiste en este momento." @mcp.tool( "chistecitos", "Obtiene un chiste aleatorio de Chuck Norris" ) async def get_chuck_norris_joke() -> str: """Obtiene un chiste aleatorio de Chuck Norris usando la API pública""" return await fetch_joke() async def show_joke(): """Muestra un chiste aleatorio""" joke = await fetch_joke() print("\n🎭 Chiste de Chuck Norris:") print(f"\"{joke}\"\n") async def main(): if len(sys.argv) > 1 and sys.argv[1] == "--joke": await show_joke() return # Obtener y mostrar un chiste al iniciar await show_joke() # Iniciar el servidor MCP await mcp.run_sse_async() if __name__ == "__main__": asyncio.run(main())

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AlexuLag/jokes-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server