[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3

Server Initialization

🛠️ Tools & Functions7 min70 BASE XP

Setting Up the Server

Building an MCP server is straightforward using the official SDKs. You define your server metadata and attach a transport.

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";

// 1. Create the server
const server = new McpServer({
  name: "weather-server",
  version: "1.0.0"
});

// 2. Connect transport
async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
}
main();

The McpServer class is a high-level wrapper that manages the JSON-RPC state machine so you can focus entirely on your business logic.

SYNAPSE VERIFICATION
QUERY 1 // 3
What is the role of the `McpServer` class in the TypeScript SDK?
It provides a low-level byte stream.
It wraps the JSON-RPC protocol to provide a high-level API for business logic.
It is a REST API framework like Express.
It generates LLM tokens.
Watch: 139x Rust Speedup
Server Initialization | Tools & Functions — MCP Academy