Skip to main content

Un servidor MCP que actúa como puente HTTP

Project description

MCP ↔ HTTP Bridge

Servidor MCP local (stdio) que expone dinámicamente las tools de un servidor HTTP externo.

Cliente MCP (Claude Code / CLI)
        ↕  stdio
  mcp_server.py   ← servidor MCP local
        ↕  HTTP
  http_server.py  ← tu backend con las tools

Requisitos

pip install mcp httpx fastapi uvicorn

Arrancar

1. Servidor HTTP (en una terminal)

python http_server.py
# → http://127.0.0.1:8000

Puedes verificar las tools disponibles en:

GET http://127.0.0.1:8000/tools

2. Servidor MCP (lo gestiona el cliente)

El servidor MCP se lanza automáticamente por el cliente MCP vía stdio.
Configúralo en ~/.claude.json (Claude Code):

{
  "mcpServers": {
    "http-bridge": {
      "command": "python",
      "args": ["/ruta/absoluta/a/mcp_server.py"]
    }
  }
}

Añadir tus propias tools

Solo tienes que modificar http_server.py:

  1. Añade un dict a la lista TOOLS con name, description e inputSchema.
  2. Añade una función run_mi_tool(args) con la lógica.
  3. Registra la función en TOOL_HANDLERS.

El servidor MCP las detectará automáticamente sin cambios.

# Ejemplo en http_server.py

TOOLS.append({
    "name": "reverse_text",
    "description": "Invierte un texto.",
    "inputSchema": {
        "type": "object",
        "properties": {
            "text": {"type": "string"}
        },
        "required": ["text"]
    }
})

def run_reverse_text(args):
    return {"result": args["text"][::-1]}

TOOL_HANDLERS["reverse_text"] = run_reverse_text

Contrato HTTP

Método Ruta Descripción
GET /tools Lista todas las tools disponibles
POST /tools/{name} Ejecuta la tool name con el body JSON

Respuesta de /tools:

{
  "tools": [
    {
      "name": "calculator",
      "description": "...",
      "inputSchema": { ... }
    }
  ]
}

Respuesta de /tools/{name}:

{ "result": { ... } }

Estructura de archivos

.
├── http_server.py   # Backend HTTP con las tools
├── mcp_server.py    # Servidor MCP local (stdio)
└── README.md

Para inspeccionar el servidor mcp

npx @modelcontextprotocol/inspector python C:\Users\acamp\Documents\SynologyDrive\mcp-http-server\mcp_server.py npx @modelcontextprotocol/inspector python /home/chrzrd/SynologyDrive/mcp-testaserver-http/mcp_server.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_testaserver_http-0.1.4.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_testaserver_http-0.1.4-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_testaserver_http-0.1.4.tar.gz.

File metadata

  • Download URL: mcp_testaserver_http-0.1.4.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for mcp_testaserver_http-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6be9c2d641e710c5b97ab6f07e51142ee93ffacde237b64e666c981be8c6903f
MD5 4f1ec36026840c2b5cea31e9ba8baa3a
BLAKE2b-256 b1d29cefd3097961d0f1905663cb2f252edbe88dc0f83f53faccd1476d2cc706

See more details on using hashes here.

File details

Details for the file mcp_testaserver_http-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_testaserver_http-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fd9c74e6e26e78a7c859a6ef76f0bc083000ba95a48c4e2cc6c41c5ebe4cf67c
MD5 dc1f4f8ed366419a9052a23fdb47d5ac
BLAKE2b-256 b0441debe27559021160098fc9e9ba7042c7959ba87d201d99db0f1cc3e99eda

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page