Back to Challenges
Hello World
Build ServerBeginnerCreate your first MCP server with a simple greeting tool.
Steps to Complete
1Create project
mkdir hello-mcp && cd hello-mcp
npm init -y
npm install @modelcontextprotocol/sdk zod2Create server file
// Save as index.js
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({
name: "hello-world-server",
version: "1.0.0",
});
// Simple greeting tool
server.tool(
"greet",
"Greet a user by name",
{
name: z.string().describe("The name to greet"),
},
async ({ name }) => ({
content: [{
type: "text",
text: `Hello, ${name}! Welcome to MCP! 👋`,
}],
})
);
// Tool with no parameters
server.tool(
"hello",
"Say hello to the world",
{},
async () => ({
content: [{
type: "text",
text: "Hello, World! 🌍",
}],
})
);
const transport = new StdioServerTransport();
await server.connect(transport);3Add to Claude Desktop
// Add to claude_desktop_config.json
{
"mcpServers": {
"hello-world": {
"command": "node",
"args": ["path/to/hello-mcp/index.js"]
}
}
}Try it in the Playground
Hello World Server
Your first MCP server
Loading...
Success Criteria
- ✓Server starts without errors
- ✓
greettool accepts a name parameter - ✓
hellotool returns "Hello, World!"