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-оболочка

В этом проекте создается MCP-сервер на Python, который предоставляет инструмент для запросов к внешнему API. Совместимо с Claude Desktop или ChatGPT Desktop, которые поддерживают протокол контекста модели (MCP).

✨ Особенности

  • Демонстрация инструмента через MCP
  • HTTP-запрос к внешнему API
  • Прямая интеграция с Claude/Desktop через claude.json

🚀 Требования

  • Питон 3.9+
  • mcp[cli] (устанавливается через pip или uv)
  • Claude или ChatGPT Desktop (с поддержкой MCP)

📁 Структура проекта

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

⚙️ Установка

С пипом

pip install "mcp[cli]"

С УФ (рекомендуется)

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

Установка МКП

mcp install mi_script.py

Установка с .env

mcp install mi_script.py -f .env

Установка зависимостей

pip install -r requirements.txt

Переменные среды

Создайте файл .env в корне проекта для определения необязательных переменных среды:

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

👷 Быстрый старт (Quickstart)

Создайте сервер 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

Запустить локально в режиме разработки

mcp dev server.py

Запуск в производственном режиме

mcp run server.py

Или с помощью uv:

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

🚀 Интеграция с Claude/Desktop

Найдите claude.json в папке конфигурации Claude/Desktop:

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

Пример:

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

🤖 Использовать в Claude/Desktop

Вы можете задать вопрос модели:

Используйте инструмент consult_api с параметром «ping»

А модель будет использовать ваш MCP-сервер для совершения HTTP-вызовов в реальном времени.


🎁 Бонус: Расширение инструментов

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

🔍 Ресурсы


✅ Сделано с любовью и 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. С пипом
          2. С УФ (рекомендуется)
          3. Установка МКП
          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
                  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