
This project was created with create-xmcp-app.
First, run the development server:
npm run dev# oryarn dev# orpnpm dev
This will start the MCP server with the selected transport method.
This project uses the structured approach where tools are automatically discovered from the src/tools directory. Each tool is defined in its own file with the following structure:
import { z } from 'zod'import { type InferSchema } from 'xmcp'// Define the schema for tool parametersexport const schema = {a: z.number().describe('First number to add'),b: z.number().describe('Second number to add'),}// Define tool metadataexport const metadata = {name: 'add',description: 'Add two numbers together',annotations: {title: 'Add Two Numbers',readOnlyHint: true,destructiveHint: false,idempotentHint: true,},}// Tool implementationexport default async function add({ a, b }: InferSchema<typeof schema>) {return {content: [{ type: 'text', text: String(a + b) }],}}
To add a new tool:
.ts file in the src/tools directoryschema object defining the tool parameters using Zodmetadata object with tool informationTo build your project for production:
npm run build# oryarn build# orpnpm build
This will compile your TypeScript code and output it to the dist directory.
You can run the server for the transport built with:
node dist/http.jsnode dist/stdio.jsAlternatively, you can use the script which will automatically start the appropriate transport based on your project configuration:
npm run start# oryarn start# orpnpm start
The start script will automatically run either the HTTP or STDIO transport depending on which transport method was selected when you initialized the project.