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 服务器—API 包装器

该项目用 Python 创建了一个 MCP 服务器,它公开了一个用于查询外部 API 的工具。与支持模型上下文协议 (MCP) 的 Claude Desktop 或 ChatGPT Desktop 兼容。

✨ 特点

  • 通过 MCP 公开工具
  • 对外部 API 的 HTTP 查询
  • 通过 claude.json 直接与 Claude/Desktop 集成

🚀 要求

  • Python 3.9+
  • mcp[cli](可通过 pip 或 uv 安装)
  • Claude 或 ChatGPT 桌面版(支持 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

pip install "mcp[cli]"

带紫外线(推荐)

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

MCP 的安装

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/Desktop 配置文件夹中找到 claude.json:

  • 在 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 中使用

你可以问模特:

使用带有“ping”参数的consult_api工具

并且该模型将使用您的 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. 使用 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
                  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