mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 08:03:26 +02:00
Update server-everything to allow choosing the transport on the command line.
# 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
This commit is contained in:
26
src/everything/stdio.ts
Normal file
26
src/everything/stdio.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||
import { createServer } from "./everything.js";
|
||||
|
||||
console.log('Starting default (STDIO) server...');
|
||||
|
||||
async function main() {
|
||||
const transport = new StdioServerTransport();
|
||||
const {server, cleanup} = createServer();
|
||||
|
||||
await server.connect(transport);
|
||||
|
||||
// Cleanup on exit
|
||||
process.on("SIGINT", async () => {
|
||||
await cleanup();
|
||||
await server.close();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error("Server error:", error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user