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:
- Añade un dict a la lista
TOOLSconname,descriptioneinputSchema. - Añade una función
run_mi_tool(args)con la lógica. - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_testaserver_http-0.1.3.tar.gz.
File metadata
- Download URL: mcp_testaserver_http-0.1.3.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e24af355e54ecde7d5abd48c5b206159c8b91e51cd8407ee986b343c1a05f7c3
|
|
| MD5 |
cb5dada47c2594438339e56a08a4e9a2
|
|
| BLAKE2b-256 |
e74b5e8720b785e034d4a9879660c1b987b4b2653a5b39fecdea50336bdc12e0
|
File details
Details for the file mcp_testaserver_http-0.1.3-py3-none-any.whl.
File metadata
- Download URL: mcp_testaserver_http-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c35d8506ba6332e9caff391907f9d9b53065261dd673542518ec69fa5da4a9b
|
|
| MD5 |
fb5f87ce355c02bdf6753116a47df542
|
|
| BLAKE2b-256 |
a178b8dd6f0b65848b01437074e1338ff6b5ef06e82dff491381f78f0ae155f6
|