The Hello World Server
Let's create a server that simply returns a greeting.
Basic Code
typescript import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new Server({ name: "hello-world", version: "1.0.0", }, { capabilities: { resources: {}, tools: {} } });
async function main() { const transport = new StdioServerTransport(); await server.connect(transport); }
main().catch(console.error);
This server does nothing yet, but it initializes the protocol connection.
Assignment: Compile this code using tsc and run it. It should hang—this means it is waiting for input on Stdio!