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

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.1.tar.gz (7.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.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mcp_testaserver_http-0.1.1.tar.gz
Algorithm Hash digest
SHA256 45017e5ac3509a7718632bbccc8fec8546091b499cf2b35241ba65daa01d125f
MD5 38e0a346bcbe4e62c5b015a972f57587
BLAKE2b-256 b3b0a7c0b783ce926fd3b43c25e0965236b140c1caf501a2f74870f4081d568f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_testaserver_http-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d6fc57b72b50af7f31cac35c024f0f0e342889db4721be8eb500b17f6643a1cf
MD5 8fcebcf438ab80a99b84c4fffdecf32d
BLAKE2b-256 e98638f68944e07d273003f4dc9be88078c0688850e00e7670470d4d691a8b76

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