type: module and
tsconfig.json. This tutorial separates the tool from the server so you can reuse it.
1. Define the tool
src/tools/greet.ts
2. Compose the server
src/server.ts
greet becomes the exposed name. A definition can be reused in another server without rewriting it. listen() starts the transport; it does not wait for the server to shut down.
3. Run it through a client
After compiling, configure your MCP client to launchnode with the absolute path to dist/server.js. A stdio server speaks through stdin/stdout; running it in a terminal may appear to wait silently because it is waiting for protocol messages.
Compile your application:
Keep stdout clean. MCP owns stdout. Send application diagnostics to stderr withconsole.error()rather thanconsole.log().