File size: 11,746 Bytes
eb846d0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
---
title: 'Server Management'
description: 'Centrally manage multiple MCP servers with hot-swappable configuration'
---
## Overview
MCPHub's server management system allows you to centrally configure, monitor, and control multiple MCP (Model Context Protocol) servers from a single dashboard. All changes are applied in real-time without requiring server restarts.
## Adding MCP Servers
### Via Dashboard
1. **Access the Dashboard**: Navigate to `http://localhost:3000` and log in
2. **Click "Add Server"**: Located in the servers section
3. **Fill Server Details**:
- **Name**: Unique identifier for the server
- **Command**: Executable command (e.g., `npx`, `uvx`, `python`)
- **Arguments**: Array of command arguments
- **Environment Variables**: Key-value pairs for environment setup
- **Working Directory**: Optional working directory for the command
### Via Configuration File
Edit your `mcp_settings.json` file:
```json
{
"mcpServers": {
"server-name": {
"command": "command-to-run",
"args": ["arg1", "arg2"],
"env": {
"API_KEY": "your-api-key",
"CONFIG_VALUE": "some-value"
},
"cwd": "/optional/working/directory"
}
}
}
```
### Via API
Use the REST API to add servers programmatically:
```bash
curl -X POST http://localhost:3000/api/servers \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{
"name": "fetch-server",
"command": "uvx",
"args": ["mcp-server-fetch"],
"env": {}
}'
```
## Popular MCP Server Examples
<AccordionGroup>
<Accordion title="Web Fetch Server">
Provides web scraping and HTTP request capabilities:
```json
{
"fetch": {
"command": "uvx",
"args": ["mcp-server-fetch"]
}
}
```
**Available Tools:**
- `fetch`: Make HTTP requests
- `fetch_html`: Scrape web pages
- `fetch_json`: Get JSON data from APIs
</Accordion>
<Accordion title="Playwright Browser Automation">
Browser automation for web interactions:
```json
{
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest", "--headless"]
}
}
```
**Available Tools:**
- `playwright_navigate`: Navigate to web pages
- `playwright_screenshot`: Take screenshots
- `playwright_click`: Click elements
- `playwright_fill`: Fill forms
</Accordion>
<Accordion title="File System Operations">
File and directory management:
```json
{
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/allowed/path"]
}
}
```
**Available Tools:**
- `read_file`: Read file contents
- `write_file`: Write to files
- `create_directory`: Create directories
- `list_directory`: List directory contents
</Accordion>
<Accordion title="SQLite Database">
Database operations:
```json
{
"sqlite": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-sqlite", "/path/to/database.db"]
}
}
```
**Available Tools:**
- `execute_query`: Execute SQL queries
- `describe_tables`: Get table schemas
- `create_table`: Create new tables
</Accordion>
<Accordion title="Slack Integration">
Slack workspace integration:
```json
{
"slack": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-slack"],
"env": {
"SLACK_BOT_TOKEN": "xoxb-your-bot-token",
"SLACK_TEAM_ID": "T1234567890"
}
}
}
```
**Available Tools:**
- `send_slack_message`: Send messages to channels
- `list_slack_channels`: List available channels
- `get_slack_thread`: Get thread messages
</Accordion>
<Accordion title="GitHub Integration">
GitHub repository operations:
```json
{
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token"
}
}
}
```
**Available Tools:**
- `create_or_update_file`: Create/update repository files
- `search_repositories`: Search GitHub repositories
- `create_issue`: Create issues
- `create_pull_request`: Create pull requests
</Accordion>
<Accordion title="Google Drive">
Google Drive file operations:
```json
{
"gdrive": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-gdrive"],
"env": {
"GDRIVE_CLIENT_ID": "your-client-id",
"GDRIVE_CLIENT_SECRET": "your-client-secret",
"GDRIVE_REDIRECT_URI": "your-redirect-uri"
}
}
}
```
**Available Tools:**
- `gdrive_search`: Search files and folders
- `gdrive_read`: Read file contents
- `gdrive_create`: Create new files
</Accordion>
<Accordion title="Amap Maps (China)">
Chinese mapping and location services:
```json
{
"amap": {
"command": "npx",
"args": ["-y", "@amap/amap-maps-mcp-server"],
"env": {
"AMAP_MAPS_API_KEY": "your-api-key"
}
}
}
```
**Available Tools:**
- `search_location`: Search for locations
- `get_directions`: Get route directions
- `reverse_geocode`: Convert coordinates to addresses
</Accordion>
</AccordionGroup>
## Server Lifecycle Management
### Starting Servers
Servers are automatically started when:
- MCPHub boots up
- A server is added via the dashboard or API
- A server configuration is updated
- A stopped server is manually restarted
### Stopping Servers
You can stop servers:
- **Via Dashboard**: Toggle the server status switch
- **Via API**: Send a POST request to `/api/servers/{name}/toggle`
- **Automatically**: Servers stop if they crash or encounter errors
### Restarting Servers
Servers are automatically restarted:
- When configuration changes are made
- After environment variable updates
- When manually triggered via dashboard or API
## Server Status Monitoring
### Status Indicators
Each server displays a status indicator:
- 🟢 **Running**: Server is active and responding
- 🟡 **Starting**: Server is initializing
- 🔴 **Stopped**: Server is not running
- ⚠️ **Error**: Server encountered an error
### Real-time Logs
View server logs in real-time:
1. **Dashboard Logs**: Click on a server to view its logs
2. **API Logs**: Access logs via `/api/logs` endpoint
3. **Streaming Logs**: Subscribe to log streams via WebSocket
### Health Checks
MCPHub automatically performs health checks:
- **Initialization Check**: Verifies server starts successfully
- **Tool Discovery**: Confirms available tools are detected
- **Response Check**: Tests server responsiveness
- **Resource Monitoring**: Tracks CPU and memory usage
## Configuration Management
### Environment Variables
Servers can use environment variables for configuration:
```json
{
"server-name": {
"command": "python",
"args": ["server.py"],
"env": {
"API_KEY": "${YOUR_API_KEY}",
"DEBUG": "true",
"MAX_CONNECTIONS": "10"
}
}
}
```
**Environment Variable Expansion:**
- `${VAR_NAME}`: Expands to environment variable value
- `${VAR_NAME:-default}`: Uses default if variable not set
- `${VAR_NAME:+value}`: Uses value if variable is set
### Working Directory
Set the working directory for server execution:
```json
{
"server-name": {
"command": "./local-script.sh",
"args": [],
"cwd": "/path/to/server/directory"
}
}
```
### Command Variations
Different ways to specify server commands:
<Tabs>
<Tab title="npm/npx">
```json
{
"npm-server": {
"command": "npx",
"args": ["-y", "package-name", "--option", "value"]
}
}
```
</Tab>
<Tab title="Python/uvx">
```json
{
"python-server": {
"command": "uvx",
"args": ["package-name", "--config", "config.json"]
}
}
```
</Tab>
<Tab title="Direct Python">
```json
{
"direct-python": {
"command": "python",
"args": ["-m", "module_name", "--arg", "value"]
}
}
```
</Tab>
<Tab title="Local Script">
```json
{
"local-script": {
"command": "./server.sh",
"args": ["--port", "8080"],
"cwd": "/path/to/script"
}
}
```
</Tab>
</Tabs>
## Advanced Features
### Hot Reloading
MCPHub supports hot reloading of server configurations:
1. **Config File Changes**: Automatically detects changes to `mcp_settings.json`
2. **Dashboard Updates**: Immediately applies changes made through the web interface
3. **API Updates**: Real-time updates via REST API calls
4. **Zero Downtime**: Graceful server restarts without affecting other servers
### Resource Limits
Control server resource usage:
```json
{
"resource-limited-server": {
"command": "memory-intensive-server",
"args": [],
"limits": {
"memory": "512MB",
"cpu": "50%",
"timeout": "30s"
}
}
}
```
### Dependency Management
Handle server dependencies:
<AccordionGroup>
<Accordion title="Auto-installation">
MCPHub can automatically install missing packages:
```json
{
"auto-install-server": {
"command": "npx",
"args": ["-y", "package-that-might-not-exist"],
"autoInstall": true
}
}
```
</Accordion>
<Accordion title="Pre-installation Scripts">
Run setup scripts before starting servers:
```json
{
"setup-server": {
"preStart": ["npm install", "pip install -r requirements.txt"],
"command": "python",
"args": ["server.py"]
}
}
```
</Accordion>
</AccordionGroup>
## Troubleshooting
<AccordionGroup>
<Accordion title="Server Won't Start">
**Check the following:**
- Command is available in PATH
- All required environment variables are set
- Working directory exists and is accessible
- Network ports are not blocked
- Dependencies are installed
**Debug steps:**
1. Check server logs in the dashboard
2. Test command manually in terminal
3. Verify environment variable expansion
4. Check file permissions
</Accordion>
<Accordion title="Server Keeps Crashing">
**Common causes:**
- Invalid configuration parameters
- Missing API keys or credentials
- Resource limits exceeded
- Dependency conflicts
**Solutions:**
1. Review server logs for error messages
2. Test with minimal configuration
3. Verify all credentials and API keys
4. Check system resource availability
</Accordion>
<Accordion title="Tools Not Appearing">
**Possible issues:**
- Server not fully initialized
- Tool discovery timeout
- Communication protocol mismatch
- Server reporting errors
**Debug steps:**
1. Wait for server initialization to complete
2. Check server logs for tool registration messages
3. Test direct communication with server
4. Verify MCP protocol compatibility
</Accordion>
</AccordionGroup>
## Next Steps
<CardGroup cols={2}>
<Card title="Group Management" icon="users" href="/features/group-management">
Organize servers into logical groups
</Card>
<Card title="Smart Routing" icon="route" href="/features/smart-routing">
Set up AI-powered tool discovery
</Card>
<Card title="API Reference" icon="code" href="/api-reference/servers">
Server management API documentation
</Card>
<Card title="Configuration Guide" icon="cog" href="/configuration/mcp-settings">
Detailed configuration options
</Card>
</CardGroup>
|