Loading...
Loading...
Create a new xmcp tool with schema, metadata, and handler. Use when the user wants to add a new tool to their xmcp project.
npx skill4agent add xmcp-dev/skills create-toolsrc/tools/.ts.tsxsrc/tools/{tool-name}.ts # or .tsx for React// 1. Schema (optional) - Define parameters with Zod
export const schema = { /* ... */ };
// 2. Metadata (optional) - Tool configuration
export const metadata: ToolMetadata = { /* ... */ };
// 3. Handler (required) - Default export function
export default function handler(params) { /* ... */ }import { z } from "zod";
import { type InferSchema, type ToolMetadata } from "xmcp";| Type | Use Case | File Extension |
|---|---|---|
| Standard (string) | Simple queries, calculations | |
| Standard (async) | API calls, database queries | |
| Template Literal | HTML widgets, iframes, scripts | |
| React Component | Interactive stateful UIs | |
| No Parameters | Tools that don't need input | |
| With Extra Args | Auth/context-dependent tools | |
| Annotation | Use When |
|---|---|
| Tool doesn't modify environment |
| Tool may delete/modify data |
| Repeated calls have same effect |
| Tool interacts with external world |
references/templates.mdsrc/tools/{tool-name}.ts.tsx.describe()namedescriptionpnpm build