@lvdaxianer/mcp-http-gateway
v1.0.6
Published
MCP HTTP Gateway - 将 LLM 工具调用转发到 HTTP REST API,支持熔断器、降级策略、缓存、Mock、SQLite 日志。版本策略:偶数版本(如 1.0、1.2)为稳定版,奇数版本(如 1.1、1.3)为快速迭代版。
Maintainers
Readme
MCP HTTP Gateway
A HTTP gateway service based on MCP protocol that forwards LLM tool call requests to HTTP REST interfaces.
Dual Mode (Dual Transport Mode)
Dual mode starts both STDIO and SSE transport modes simultaneously, allowing different clients to connect at the same time:
- Claude Code connects via STDIO
- VSCode / Other tools connect via SSE
Start Command
node dist/cli.cjs --transport=dual --sse-port=11114 --http-port=11115 --config=./tools.jsonPort Allocation
| Mode | SSE Port | Dashboard Port | Description |
|------|----------|---------------|-------------|
| dual | --sse-port (default 11114) | --http-port (default 11115) | SSE + STDIO running together |
| sse | --sse-port (default 11114) | SSE port - 1 | SSE mode only |
| stdio | None | --http-port (default 11112) | STDIO mode only |
MCP Configuration (Dual Mode)
{
"mcpServers": {
"http-gateway": {
"type": "sse",
"url": "http://localhost:11114/sse",
"description": "HTTP API Gateway (Dual Mode)"
}
}
}Access URLs After Startup
========================================
MCP HTTP Gateway Started
========================================
SSE Connection: http://localhost:11114/sse
Dashboard: http://localhost:11115/dashboard
Health: http://localhost:11115/health
========================================Global Safety Usage
Configuration Priority Mechanism
Configuration priority ensures safe configuration management:
CLI Parameters > SQLite Database > Config File > Default ValuesPriority Explanation:
| Source | Description | Safety |
|--------|-------------|--------|
| CLI Parameters | Passed via command line, highest priority | ✅ Most secure, unaffected by config files |
| SQLite Database | Runtime persisted configuration | ✅ Secure, audit trail available |
| Config File | tools.json file | ⚠️ Requires file permission control |
| Default Values | Built-in default configuration | ⚠️ Only as fallback |
Circuit Breaker Protection
Prevent cascading failures, protect backend service stability:
{
"circuitBreaker": {
"enabled": true,
"failureThreshold": 5, // Trigger after 5 consecutive failures
"successThreshold": 2, // Recover after 2 consecutive successes
"halfOpenTime": 30000 // Try recovery after 30s
}
}State Flow:
CLOSED→ Normal state, requests forwarded normallyOPEN→ Circuit breaker state, reject all requests, trigger fallbackHALF_OPEN→ Half-open state, allow limited requests to probe recovery
Fallback Strategy
Safe fallback chain when request fails:
Request Failed → Cache Fallback (ignore TTL) → Mock Fallback → Return ErrorConfiguration Example:
{
"fallback": {
"enabled": true,
"useExpiredCache": true, // Use expired cache as fallback
"useMockAsFallback": true // Use Mock data as fallback
}
}Security Best Practices
- No Hardcoded Secrets: Use
tokensconfig or environment variables - Log Sanitization: Sensitive info not logged
- Parameterized Queries: Prevent SQL injection
- Input Validation: All external inputs must be validated
Configuration Reference
📖 Full configuration parameters: See CONFIG_EN.md for detailed parameter descriptions, types, required/optional, and defaults.
Quick Start
# Install
npm install @lvdaxianer/mcp-http-gateway
# Start in Dual Mode
npx @lvdaxianer/mcp-http-gateway --transport=dual --config=./tools.jsonLicense
MIT
