mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 08:03:26 +02:00
# Run the default (stdio) server
```npx @modelcontextprotocol/server-everything```
# Or specify stdio explicitly
```npx @modelcontextprotocol/server-everything stdio```
# Run the SSE server
```npx @modelcontextprotocol/server-everything sse```
# Run the streamable HTTP server
```npx @modelcontextprotocol/server-everything streamableHttp```
* In src/everything/index.ts
- refactor/extracted contents to stdio.ts
- replaced with code that
- Gets the single argument from the commandline as scriptName
- switches on scriptName
- imports the appropriate server script or outputs usage options
- scripts run on import
* In src/everything/stdio.ts
- added console log "Starting default (STDIO) server..."
* In src/everything/sse.ts
- added console log "Starting SSE server..."
* In src/everything/streamableHttp.ts
- added console log "Starting Streamable HTTP server..."
* This fixes #1594
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
// Parse command line arguments first
|
|
const args = process.argv.slice(2);
|
|
const scriptName = args[0] || 'stdio';
|
|
|
|
async function run() {
|
|
try {
|
|
// Dynamically import only the requested module to prevent all modules from initializing
|
|
switch (scriptName) {
|
|
case 'stdio':
|
|
// Import and run the default server
|
|
await import('./stdio.js');
|
|
break;
|
|
case 'sse':
|
|
// Import and run the SSE server
|
|
await import('./sse.js');
|
|
break;
|
|
case 'streamableHttp':
|
|
// Import and run the streamable HTTP server
|
|
await import('./streamableHttp.js');
|
|
break;
|
|
default:
|
|
console.error(`Unknown script: ${scriptName}`);
|
|
console.log('Available scripts:');
|
|
console.log('- stdio');
|
|
console.log('- sse');
|
|
console.log('- streamableHttp');
|
|
process.exit(1);
|
|
}
|
|
} catch (error) {
|
|
console.error('Error running script:', error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
run();
|