一键导入
create-tool
Create a new xmcp tool with schema, metadata, and handler. Use when the user wants to add a new tool to their xmcp project.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create a new xmcp tool with schema, metadata, and handler. Use when the user wants to add a new tool to their xmcp project.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guide for designing effective MCP servers with agent-friendly tools. Use when creating a new MCP server, designing MCP tools, or improving existing MCP server architecture.
Design MCP prompts to expose reusable prompt templates. Use when creating parameterized prompts in xmcp.
Design MCP resources to expose content for LLM consumption. Use when creating static or dynamic resources in xmcp.
Best practices for designing UI widgets in xmcp. Use when creating interactive widgets for GPT Apps or MCP Apps, choosing between React components and template literals, designing widget layouts, handling state and data fetching, or troubleshooting widget rendering issues.
| name | create-tool |
| description | Create a new xmcp tool with schema, metadata, and handler. Use when the user wants to add a new tool to their xmcp project. |
| metadata | {"argument-hint":"[tool-name]"} |
You are helping the user create a new xmcp tool. Follow this interactive workflow.
Before generating any code, ask the user these questions using AskUserQuestion:
Tool name (if not provided as argument): What should the tool be named? (Use kebab-case)
Handler type: Ask which handler type they need:
Schema fields: What parameters should the tool accept? Ask for:
Annotations: Ask about behavior hints:
Widget support (if Template Literal or React): Ask if they need:
Create the tool file in src/tools/ with the appropriate extension:
.ts for Standard and Template Literal handlers.tsx for React Component handlerssrc/tools/{tool-name}.ts # or .tsx for React
Every xmcp tool has three main exports:
// 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 | .ts |
| Standard (async) | API calls, database queries | .ts |
| Template Literal | HTML widgets, iframes, scripts | .ts |
| React Component | Interactive stateful UIs | .tsx |
| No Parameters | Tools that don't need input | .ts |
| With Extra Args | Auth/context-dependent tools | .ts |
| Annotation | Use When |
|---|---|
readOnlyHint: true | Tool doesn't modify environment |
destructiveHint: true | Tool may delete/modify data |
idempotentHint: true | Repeated calls have same effect |
openWorldHint: true | Tool interacts with external world |
For complete code templates including:
Read: references/templates.md
src/tools/{tool-name}.ts (or .tsx).describe() for all parametersname and descriptionSuggest running pnpm build to verify the tool compiles correctly.