Intelligent Agent Hub Service - MCP Proxy Forwarding Solution
Features • Quick Start • Project Architecture • API Endpoints • Deployment Guide • Contributing
English | 简体中文
WebAgent is an open-source intelligent agent hub service that provides core MCP (Model Context Protocol) proxy forwarding functionality.
- 🔄 MCP Proxy Forwarding: Full support for Model Context Protocol proxy forwarding
- 📡 SSE Connection Management: Support for Server-Sent Events real-time communication
- 🌐 Streamable HTTP: Support for streaming HTTP request handling
- 🏥 Health Checks: Comprehensive health check endpoints for monitoring and operations
- 🔒 Security Middleware: Built-in CORS, Helmet, and other security middleware
- 📝 Complete Logging: Winston-based logging system with sensitive information masking
- 🚀 Production Ready: PM2 process management support, suitable for production deployment
- Node.js: >= 22.0.0
- pnpm: >= 10 (recommended)
# Clone the repository
git clone https://github.com/opentiny/web-agent.git
cd web-agent
# Install dependencies
pnpm installCopy the example configuration file and modify as needed:
cp example.env .envEnvironment Variables:
| Variable | Description | Default |
|---|---|---|
AGENT_PORT |
Service listening port | 3000 |
AGENT_HOST |
Listening address | 0.0.0.0 |
NODE_ENV |
Runtime environment | development |
CORS_ORIGIN |
CORS origin list (comma-separated) | http://localhost:3000 |
# Development mode (hot reload)
pnpm dev
# Build production version
pnpm build
# Run production version
pnpm start
# Run with PM2
pnpm pm2:startweb-agent/
├── src/
│ ├── app.ts # Application entry point
│ ├── server.ts # Server startup file
│ ├── Logger.ts # Winston logger configuration
│ ├── config/
│ │ ├── index.ts # Application configuration
│ │ └── logger.ts # Logger configuration
│ ├── middleware/
│ │ ├── index.ts # Middleware entry point
│ │ ├── corsMiddleware.ts # CORS handling
│ │ ├── errorMiddleware.ts # Error handling
│ │ ├── loggingMiddleware.ts # Request logging
│ │ ├── requestIdMiddleware.ts # Request ID
│ │ ├── securityMiddleware.ts # Security headers
│ │ └── validationMiddleware.ts # Request validation
│ ├── routes/
│ │ ├── index.ts # Routes entry point
│ │ ├── health.ts # Health check routes
│ │ └── v1/
│ │ ├── index.ts # v1 API routes entry
│ │ └── webmcp.ts # MCP proxy routes
│ └── utils/
│ └── ... # Utility functions
├── ecosystem.config.cjs # PM2 configuration
├── example.env # Environment variables example
├── package.json
└── tsconfig.json
- MCP Proxy Module (
routes/v1/webmcp.ts): Core functionality module that handles MCP protocol proxy forwarding, supporting both SSE and Streamable HTTP transport modes - Middleware Layer (
middleware/): Provides a complete request processing pipeline, including security, logging, validation, etc. - Configuration Module (
config/): Centralized application configuration management with environment variable overrides
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Get system status and version info |
/health/detailed |
GET | Get detailed health status (memory, CPU, etc.) |
/health/metrics |
GET | Get performance metrics |
All MCP-related endpoints are prefixed with /api/v1/webmcp:
| Endpoint | Method | Description |
|---|---|---|
/api/v1/webmcp/ping |
GET | Connection test |
/api/v1/webmcp/sse |
GET | SSE connection endpoint |
/api/v1/webmcp/messages |
POST | Message forwarding endpoint |
/api/v1/webmcp/mcp |
ALL | Streamable HTTP MCP endpoint |
/api/v1/webmcp/list |
GET | Get all client sessions |
/api/v1/webmcp/remoter |
GET | Get all controller sessions |
/api/v1/webmcp/tools |
GET | Get client tool list |
/api/v1/webmcp/client |
GET | Query single client info |
/api/v1/webmcp/reset |
GET | Reset all connections |
You can use the MCP Inspector tool to connect for debugging:
# SSE Mode
http://localhost:3000/api/v1/webmcp/sse?sessionId=<your-session-id>
# Streamable HTTP Mode
http://localhost:3000/api/v1/webmcp/mcp?sessionId=<your-session-id>
# Use nodemon for hot reload
pnpm dev# Start
pnpm pm2:start
# Check status
pm2 status
# View logs
pnpm pm2:logs
# Stop
pnpm pm2:stop
# Restart
pnpm pm2:restartFROM node:22-alpine
WORKDIR /app
COPY package.json ./
RUN corepack enable && pnpm install --prod
COPY dist ./dist
ENV NODE_ENV=production
ENV AGENT_PORT=3000
ENV AGENT_HOST=0.0.0.0
EXPOSE 3000
CMD ["node", "dist/server.js"]upstream webagent {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://webagent;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
# SSE Support
proxy_buffering off;
proxy_read_timeout 86400;
}
}The project provides an ecosystem.config.cjs configuration file:
- Single instance Fork mode
- Auto-restart when memory exceeds 1GB
- Automatic log file management
- Graceful shutdown support
pnpm dev # Run in development mode
pnpm build # Build production version
pnpm start # Run production version
pnpm lint # Code linting
pnpm lint:fix # Auto-fix lint issues
pnpm format # Format code
pnpm format:check # Check formatting- ESLint + Prettier for code standards
- TypeScript strict mode
- Follow Express.js best practices
Issues and Pull Requests are welcome!
- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request