ワンクリックで
mcp-tool-registration
How to register new MCP tools — tool object pattern, Zod schemas, handler conventions, and conditional registration.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
How to register new MCP tools — tool object pattern, Zod schemas, handler conventions, and conditional registration.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Complete Figma REST API reference — all endpoints, tier levels, auth, geometry parameters, and rate limits.
Design token extraction pipeline — frequency counting, semantic naming, token replacement, and varRef stripping.
Release workflow — release-please, npm publish, server.json version sync, and MCP registry publishing.
SVG vector generation from Figma VECTOR nodes — caching, path merging, bounds calculation, and disk writing.
| name | mcp-tool-registration |
| description | How to register new MCP tools — tool object pattern, Zod schemas, handler conventions, and conditional registration. |
I know the MCP tool registration conventions in this codebase.
Every tool is a const object with this shape (from src/mcp/tools/getFigmaDesignTool.ts):
export const myTool = {
name: "tool_name", // snake_case MCP name
description: "...", // brief description
parametersSchema, // Zod schema (validation + MCP input schema)
handler: myToolHandler, // async (params, figmaService, ...) => MCPResult
} as const;
const parametersSchema = z.object({
fileKey: z
.string()
.regex(/^[a-zA-Z0-9]+$/, "File key must be alphanumeric")
.describe("The key of the Figma file..."),
optionalParam: z.number().optional().describe("..."),
});
export type MyToolParams = z.infer<typeof parametersSchema>;
async function handler(params, figmaService, ...) {
try {
const validated = parametersSchema.parse(params);
// business logic
return { content: [{ type: "text", text: result }] };
} catch (error) {
const message = error instanceof Error ? error.message : JSON.stringify(error);
Logger.error("Context:", message);
return { isError: true, content: [{ type: "text", text: `Failed: ${message}` }] };
}
}
Rules:
parametersSchema.parse(params) at entry{ content: [...] } on success{ isError: true, content: [...] } on failureLogger.error/warn/log — no raw console.errorsrc/mcp/index.ts)server.registerTool(
myTool.name,
{
title: "My Tool",
description: myTool.description,
inputSchema: myTool.parametersSchema,
annotations: { readOnlyHint: true },
},
(params) => myTool.handler(params, figmaService /* extra deps */),
);
Tools that depend on configuration (e.g., skipImageDownloads) use a guard:
if (!options.skipImageDownloads) {
server.registerTool(imageFillsTool.name, { ... }, ...);
}
src/mcp/tools/index.tsexport { myTool } from "./my-tool";
export type { MyToolParams } from "./my-tool";
Use this when: