← Back to Dashboard
1. Server Initialization2. Defining Tool Schemas3. Tool Execution & Errors

Server Initialization

📚 Tools & Functions7 min70 XP⌨ Hands-on lab

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.

⌨ HANDS-ON LABPython SDK: Serve & Inspect
⭐ +150 XP

Build the Python side of MCP: install the official SDK with CLI extras, then open your server in the Inspector with one command.

1Install the official MCP Python SDK with CLI extras via pip.
2Launch your server.py in the MCP Inspector using the SDK's dev command.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 2 — type "hint" if stuck
🧪 Knowledge Check
Press 1-4 to select1 of 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.
Server Initialization Tutorial | Tools & Functions — MCP Academy