A HTTP server that provides a REST API interface to Model Context Protocol (MCP) servers.
- REST API Interface: Convert MCP protocol to HTTP REST API
- Authentication: Bearer token authentication support
- Configuration: JSON-based MCP server configuration
- Docker Support: Full Docker containerization with multi-stage builds
- Health Checks: Built-in health checking capabilities
- Logging: Comprehensive debug logging
# Make the build script executable
chmod +x docker-build.sh
# Build and start the container
./docker-build.sh
# Or with custom options
./docker-build.sh --port 8080 --tag v1.0.0
# Start the service
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the service
docker-compose down
# Build the image
docker build -t mcp-http-server .
# Run the container
docker run -d \
--name mcp-http-server \
-p 3000:3000 \
--env-file .env \
mcp-http-server
Create a .env
file (copy from .env.example
):
# HTTP Server Authentication
HTTP_API_KEY=your-secret-api-key-here
DISABLE_AUTH=false
# MCP Server Configuration
MCP_CONFIG_FILE=mcp_servers.config.json
MCP_SERVER_KEY=brave-search
Edit mcp_servers.config.json
to configure MCP servers:
{
"brave-search": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-brave-search"]
}
}
Include Bearer token in Authorization header:
curl -X POST http://localhost:3000/api/v1 \
-H "Authorization: Bearer your-secret-api-key-here" \
-H "Content-Type: application/json" \
-d '{"command": "your-mcp-command"}'
Example for tools/list
:
curl -X POST http://localhost:3000/api/v1 \
-H "Authorization: Bearer your-secret-api-key-here" \
-H "Content-Type: application/json" \
-d '{"command": "{\"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"tools/list\", \"params\": {}}"}'
Set DISABLE_AUTH=true
in your .env
file:
curl -X POST http://localhost:3000/api/v1 \
-H "Content-Type: application/json" \
-d '{"command": "your-mcp-command"}'
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install Node.js dependencies globally (for MCP servers)
npm install -g @modelcontextprotocol/server-brave-search
# Build and run
cargo build --release
./target/release/mcp-http-server
# Build only (no run)
./docker-build.sh --build-only
# Build without cache
./docker-build.sh --no-cache
# Custom port
./docker-build.sh --port 8080
- Stage 1 (Builder): Rust + Node.js environment for building
- Stage 2 (Runtime): Minimal Node.js runtime with compiled binary
- Non-root user execution
- Minimal runtime dependencies
- Optional Bearer token authentication
- Health check endpoints
- Runtime: Node.js (for npx and MCP servers)
- Build: Rust toolchain
- MCP Servers: Various npm packages (installed dynamically)
# Check container health
docker ps
# Manual health check
curl -f http://localhost:3000/api/v1 \
-X POST \
-H "Content-Type: application/json" \
-d '{"command":"test"}'
# Docker logs
docker logs -f mcp-http-server
# Docker Compose logs
docker-compose logs -f
- Node.js/npx not found: Ensure Node.js is installed in the container
- MCP server startup failure: Check network connectivity for npm package downloads
- Permission denied: Verify file permissions and user configuration
- Port conflicts: Change the port mapping in Docker commands
Enable debug logging:
# Set environment variable
export RUST_LOG=debug
# Or in .env file
RUST_LOG=debug
This project is open source. Please refer to the LICENSE file for details.