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

This project creates an MCP server in Python that exposes a tool for querying an external API. It is compatible with Claude Desktop or ChatGPT Desktop that support the Model Context Protocol (MCP).

✨ Features

  • Exposing a tool via MCP
  • HTTP query to an external API
  • Direct integration with Claude/Desktop via claude.json

🚀 Requirements

  • Python 3.9+
  • mcp[cli] (installable via pip or uv)
  • Claude or ChatGPT Desktop (with MCP support)

📁 Project structure

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

With pip

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

Installation of the MCP

mcp install mi_script.py

Installation with .env

mcp install mi_script.py -f .env

Installation of dependencies

pip install -r requirements.txt

Environment variables

Create a .env file in the project root to define optional environment variables:

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

👷 Quick Start (Quickstart)

Create the 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

Run locally in dev mode

mcp dev server.py

Run in production mode

mcp run server.py

Or with uv:

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

🚀 Integration with Claude/Desktop

Locate claude.json in the Claude/Desktop configuration folder:

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

Example:

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

🤖 Use within Claude/Desktop

You can ask the model:

Use the consult_api tool with the "ping" parameter

And the model will use your MCP server to make a real-time HTTP call.


🎁 Bonus: Tools Extension

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

🔍 Resources


✅ Made with love and 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.

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

  1. ✨ Features
    1. 🚀 Requirements
      1. 📁 Project structure
        1. ⚙️ Installation
          1. With pip
          2. With UV (recommended)
          3. Installation of the MCP
          4. Installation with .env
          5. Installation of dependencies
          6. Environment variables
        2. 👷 Quick Start (Quickstart)
          1. Create the server server.py
          2. Run locally in dev mode
          3. Run in production mode
        3. 🚀 Integration with Claude/Desktop
          1. 🤖 Use within Claude/Desktop
            1. 🎁 Bonus: Tools Extension
              1. 🔍 Resources

                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