MCP Python Server — API Wrapper

by cdryampi

Integrations

  • Supports configuration through environment variables for API keys and endpoints, allowing secure storage of authentication credentials

MCP Python Server – API Wrapper

Dieses Projekt erstellt einen MCP-Server in Python, der ein Tool zum Abfragen einer externen API bereitstellt. Kompatibel mit Claude Desktop oder ChatGPT Desktop, die das Model Context Protocol (MCP) unterstützen.

✨ Funktionen

  • Verfügbarmachen eines Tools über MCP
  • HTTP-Abfrage an eine externe API
  • Direkte Integration mit Claude/Desktop über claude.json

🚀 Voraussetzungen

  • Python 3.9+
  • mcp[cli] (installierbar über pip oder uv)
  • Claude oder ChatGPT Desktop (mit MCP-Unterstützung)

📁 Projektstruktur

. ├── 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.

⚙️ Installation

Mit Pip

pip install "mcp[cli]"

Mit UV (empfohlen)

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

Installation des MCP

mcp install mi_script.py

Installation mit .env

mcp install mi_script.py -f .env

Installation von Abhängigkeiten

pip install -r requirements.txt

Umgebungsvariablen

Erstellen Sie eine .env Datei im Projektstamm, um optionale Umgebungsvariablen zu definieren:

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

👷 Schnellstart (Schnellstart)

Erstellen Sie den Server 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

Lokal im Entwicklermodus ausführen

mcp dev server.py

Im Produktionsmodus ausführen

mcp run server.py

Oder mit UV:

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

🚀 Integration mit Claude/Desktop

Suchen Sie claude.json im Konfigurationsordner Claude/Desktop:

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

Beispiel:

{ "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" ] } } }

🤖 Verwendung innerhalb von Claude/Desktop

Sie können das Modell fragen:

Verwenden Sie das Tool consult_api mit dem Parameter „ping“

Und das Modell verwendet Ihren MCP-Server, um einen HTTP-Aufruf in Echtzeit zu tätigen.


🎁 Bonus: Tools-Erweiterung

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

🔍 Ressourcen


✅ Mit Liebe gemacht und 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.

Ein Python-Server, der das Model Context Protocol implementiert und Tools zum Abfragen externer APIs bereitstellt, die mit Claude Desktop und ChatGPT Desktop kompatibel sind.

  1. ✨ Funktionen
    1. 🚀 Voraussetzungen
      1. 📁 Projektstruktur
        1. ⚙️ Installation
          1. Mit Pip
          2. Mit UV (empfohlen)
          3. Installation des MCP
          4. Installation mit .env
          5. Installation von Abhängigkeiten
          6. Umgebungsvariablen
        2. 👷 Schnellstart (Schnellstart)
          1. Erstellen Sie den Server server.py
          2. Lokal im Entwicklermodus ausführen
          3. Im Produktionsmodus ausführen
        3. 🚀 Integration mit Claude/Desktop
          1. 🤖 Verwendung innerhalb von Claude/Desktop
            1. 🎁 Bonus: Tools-Erweiterung
              1. 🔍 Ressourcen

                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
                  Python
                  MIT License
                • -
                  security
                  F
                  license
                  -
                  quality
                  A Model Context Protocol server that allows management and execution of Blender Python scripts, enabling users to create, edit and run scripts in a headless Blender environment through natural language interfaces.
                  Last updated -
                  4
                  Python
                • -
                  security
                  F
                  license
                  -
                  quality
                  A Model Context Protocol server that allows Claude to make API requests on your behalf, providing tools for testing various APIs including HTTP requests and OpenAI integrations without sharing your API keys in the chat.
                  Last updated -
                  Python
                  • Linux
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  A Model Context Protocol server that provides a comprehensive interface for interacting with the ConnectWise Manage API, simplifying API discovery, execution, and management for both developers and AI assistants.
                  Last updated -
                  46
                  2
                  Python
                  • Linux
                  • Apple

                View all related MCP servers

                ID: 0zme075ivr