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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcp_testaserver_http-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 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.0.tar.gz
Algorithm Hash digest
SHA256 6ce04eff281a905b487c3516df956b54c607d5ed2bb863b90f2cda29fc281d24
MD5 4d6205dd9e7610c3e610464932b06b33
BLAKE2b-256 e07b138236d8eace42734930420869a218ba05b6901e14e8da2036f94c6c361e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_testaserver_http-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81065fc96ce5e4e149850d21e348cbe4654d95befe2a58c48b9c502de90d1a8c
MD5 2e7598bc125f6448091ae60bbf054265
BLAKE2b-256 7db055c0b2f70fe50e08aabdd1d1398b0d24c92637b387c75982104f86ee0706

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