Skip to main content
Build MCP servers with the Smithery CLI and SDK. This is required for Hosted and Local publishing.
You can also build MCP servers with frameworks like xmcp and publish them on Smithery via the URL method.

Quick Start

npx create-smithery@latest
Follow the prompts to scaffold a TypeScript MCP server.

Server Structure

Your server exports a createServer function:
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

export default function createServer({ config }) {
  const server = new McpServer({
    name: "My Server",
    version: "1.0.0",
  });

  server.registerTool("hello", {
    description: "Say hello",
    inputSchema: { name: z.string() },
  }, async ({ name }) => ({
    content: [{ type: "text", text: `Hello, ${name}!` }],
  }));

  return server.server;
}

Session Configuration (Optional)

Let users provide API keys or settings:
export const configSchema = z.object({
  apiKey: z.string().meta({
    "x-from": { header: "x-api-key" }
  }).describe("Your API key"),
  model: z.string().default("gpt-4").describe("Model to use"),
});
See Session Configuration for details on headers vs query params.

Stateful Servers (Optional)

For session persistence:
export const stateful = true;
Only use if necessary. Stateless servers are more efficient.

Local Development

npm run dev
Opens Smithery Chat to test your tools.

package.json

{
  "name": "my-mcp-server",
  "version": "1.0.0",
  "type": "module",
  "module": "./src/index.ts",
  "scripts": {
    "dev": "smithery dev",
    "build": "smithery build"
  },
  "dependencies": {
    "@modelcontextprotocol/sdk": "^1.25.1",
    "zod": "^4"
  },
  "devDependencies": {
    "@smithery/cli": "^2.2.1"
  }
}

Next Steps

Once your server is ready, publish it.