mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-18 16:13:22 +02:00
In src/everything:
* Refactor / move streamableHttp.ts, sse.ts, and stdio.ts to transports/
* Move everything.ts to server/ for reference
* Add server/index.js
- exports the createServer function
- import registerTools from tools/index.js
- in createServer()
- read instructions.md and include in ServerOptions for McpServer constructor
- construct McpServer instead of Server
- call registerTools, passing server
* Add tools/echo.ts
- define EchoSchema
- define tool config
- export addToolEcho function
- in addToolEcho()
- register handler for Echo tool
* Add tools/index.ts
- import addToolEcho
- export registerTools function
- in registerTools()
- call addToolEcho
25 lines
559 B
JavaScript
25 lines
559 B
JavaScript
#!/usr/bin/env node
|
|
|
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
import { createServer } from "../server/index.js";
|
|
|
|
console.error("Starting default (STDIO) server...");
|
|
|
|
async function main() {
|
|
const transport = new StdioServerTransport();
|
|
const { server } = createServer();
|
|
|
|
await server.connect(transport);
|
|
|
|
// Cleanup on exit
|
|
process.on("SIGINT", async () => {
|
|
await server.close();
|
|
process.exit(0);
|
|
});
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error("Server error:", error);
|
|
process.exit(1);
|
|
});
|