Skip to main content
Glama

MCP Python Server — API Wrapper

by cdryampi

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 🚀

-
security - not tested
F
license - not found
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

实现模型上下文协议的 Python 服务器,它公开用于查询外部 API 的工具,与 Claude Desktop 和 ChatGPT Desktop 兼容。

  1. ✨ 特点
    1. 🚀 要求
      1. 📁 项目结构
        1. ⚙️ 安装
          1. 使用 pip
          2. 带紫外线(推荐)
          3. MCP 的安装
          4. 使用 .env 安装
          5. 安装依赖项
          6. 环境变量
        2. 👷 快速入门(Quickstart)
          1. 创建服务器server.py
          2. 在开发模式下本地运行
          3. 以生产模式运行
        3. 🚀 与 Claude/Desktop 集成
          1. 🤖 在 Claude/Desktop 中使用
            1. 🎁 奖励:工具扩展
              1. 🔍 资源

                Related MCP Servers

                • -
                  security
                  A
                  license
                  -
                  quality
                  A Python-based server that implements the Model Context Protocol to interface with Claude Desktop as an MCP client, supporting interaction through efficient memory management.
                  Last updated -
                  1
                  MIT License
                • -
                  security
                  F
                  license
                  -
                  quality
                  A Model Context Protocol server that enables AI assistants like Claude to perform Python development tasks through file operations, code analysis, project management, and safe code execution.
                  Last updated -
                  5
                  • Linux
                  • Apple
                • -
                  security
                  A
                  license
                  -
                  quality
                  A streamlined foundation for building Model Context Protocol servers in Python, designed to make AI-assisted development of MCP tools easier and more efficient.
                  Last updated -
                  15
                  MIT License
                • A
                  security
                  F
                  license
                  A
                  quality
                  A Python-based Model Context Protocol server that integrates with Claude Desktop, allowing users to connect to Hubble API services by configuring the server with their Hubble API key.
                  Last updated -
                  7
                  • Apple

                View all related MCP servers

                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/cdryampi/MCP'

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