MCP Python Server — API Wrapper

MCP Python Server — API Wrapper

A Python server implementing the Model Context Protocol that exposes tools for querying external APIs, compatible with Claude Desktop and ChatGPT Desktop.

Category
Visit Server

README

MCP Python Server — API Wrapper

Este proyecto crea un servidor MCP en Python que expone una herramienta para consultar una API externa. Compatible con Claude Desktop o ChatGPT Desktop que soporten el Model Context Protocol (MCP).

✨ Características

  • Exposición de una herramienta (tool) vía MCP
  • Consulta HTTP a una API externa
  • Integración directa con Claude/Desktop vía claude.json

🚀 Requisitos

  • Python 3.9+
  • mcp[cli] (instalable vía pip o uv)
  • Claude o ChatGPT Desktop (con soporte MCP)

📁 Estructura del proyecto

.
├── servidores/profile.py          # Servidor MCP con herramientas para interactuar con mi backend del curriculum.
├── server.py                     # Servidor MCP con herramienta "consultar_api".
├── .env                          # Variables opcionales para auth/API.
├── claude.json                   # Config. MCP para integrarlo directamente.
└── README.md                     # Este documento.

⚙️ Instalación

Con pip

pip install "mcp[cli]"

Con uv (recomendado)

uv init mcp-api-server
cd mcp-api-server
uv add "mcp[cli]"

Instación del MCP

mcp install mi_script.py

Inatalación con .env

mcp install mi_script.py -f .env

Instalación de dependencias

pip install -r requirements.txt

Variables de entorno

Crea un archivo .env en la raíz del proyecto para definir variables de entorno opcionales:

# .env
API_KEY=mi_api_key
API_URL=https://miapi.com/consulta

👷 Rápido Inicio (Quickstart)

Crear el servidor server.py

from mcp.server.fastmcp import FastMCP
import httpx

mcp = FastMCP("API Wrapper")

@mcp.tool(description="Consulta una API externa")
async def consultar_api(param: str) -> str:
    """Consulta una API externa con un parámetro y devuelve la respuesta."""
    async with httpx.AsyncClient() as client:
        r = await client.get(f"https://miapi.com/consulta?param={param}")
        return r.text

Ejecutar localmente en modo dev

mcp dev server.py

Ejecutar en modo producción

mcp run server.py

O con uv:

uv run --with mcp[cli] mcp run server.py

🚀 Integración con Claude/Desktop

Ubica claude.json en la carpeta de configuración de Claude/Desktop:

  • En Windows: %APPDATA%\Claude\claude.json
  • En Linux/macOS: ~/.claude/claude.json

Ejemplo:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/codigo/backend-curso-inkor/proyectos_memes"
      ]
    },
    "Demo": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "C:\\codigo\\backend-curso-inkor\\MCP\\server.py"
      ]
    }
  }
}

🤖 Uso dentro de Claude/Desktop

Puedes pedirle al modelo:

Usa la herramienta consultar_api con el parámetro "ping"

Y el modelo usará tu servidor MCP para hacer una llamada HTTP en tiempo real.


🎁 Bonus: extensión de herramientas

@mcp.tool()
async def traducir(texto: str, lang: str) -> str:
    return f"Traducido: {texto}{lang}"

🔍 Recursos

  • Documentación oficial MCP: https://docs.mcp.run/
  • Repositorio SDK Python: https://github.com/modelcontextprotocol/mcp

✅ Hecho con amor y httpx 🚀

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured