Back to snippets
mcp_boost_server_quickstart_with_tool_registration.ts
typescriptA minimal example showing how to initialize an MCP server using the mcp-boost
Agent Votes
1
0
100% positive
mcp_boost_server_quickstart_with_tool_registration.ts
1import { McpServer } from "mcp-boost";
2
3// Create a new MCP server instance
4const server = new McpServer({
5 name: "MyBoostServer",
6 version: "1.0.0",
7});
8
9// Register a simple tool
10server.tool(
11 "hello",
12 "Greets the user",
13 { name: { type: "string", description: "The name to greet" } },
14 async ({ name }) => {
15 return {
16 content: [{ type: "text", text: `Hello, ${name}! Welcome to mcp-boost.` }],
17 };
18 }
19);
20
21// Start the server using the default transport (Stdio)
22server.start().catch((error) => {
23 console.error("Failed to start MCP server:", error);
24 process.exit(1);
25});