commit
Prepare code for review by running quality checks, creating conventional commits, and opening pull requests. Use when the user…
Guide for adding new MCP tools with consistent patterns for schemas, tool definitions, registry updates, and Better Auth integration
$ npx -y skills add decocms/studio --skill add-mcp-tools --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/add-mcp-toolsContext preview
The summary Claude sees to decide when to auto-load this skill.
Guide for adding new MCP tools with consistent patterns for schemas, tool definitions, registry updates, and Better Auth integration
name: add-mcp-tools description: Guide for adding new MCP tools with consistent patterns for schemas, tool definitions, registry updates, and Better Auth integration
This guide documents the pattern for adding new MCP tools to Studio codebase. Follow this checklist to ensure consistency with existing tools.
MCP tools are exposed via the Model Context Protocol and allow programmatic management of resources. Each tool follows a consistent pattern with:
When adding a new domain of tools (e.g., `apiKeys`, `webhooks`, `secrets`), create the following structure:
apps/api/src/tools/<domain>/ ├── schema.ts # Zod schemas for entities and operations ├── create.ts # <DOMAIN>_CREATE tool ├── list.ts # <DOMAIN>_LIST tool ├── update.ts # <DOMAIN>_UPDATE tool ├── delete.ts # <DOMAIN>_DELETE tool └── index.ts # Barrel export
Define Zod schemas for:
// apps/api/src/tools/<domain>/schema.ts
import { z } from "zod";
// Entity schema (what's returned in list operations)
export const MyEntitySchema = z.object({
id: z.string(),
name: z.string(),
// ... other fields
createdAt: z.union([z.string(), z.date()]),
});
export type MyEntity = z.infer<typeof MyEntitySchema>;
// Create schemas
export const MyCreateInputSchema = z.object({
name: z.string().min(1).max(255),
// ... other fields
});
export const MyCreateOutputSchema = z.object({
item: MyEntitySchema,
});
// List schemas
export const MyListInputSchema = z.object({
// pagination, filters, etc.
});
export const MyListOutputSchema = z.object({
items: z.array(MyEntitySchema),
});
// Update schemas
export const MyUpdateInputSchema = z.object({
id: z.string(),
// ... partial fields
});
export const MyUpdateOutputSchema = z.object({
item: MyEntitySchema,
});
// Delete schemas
export const MyDeleteInputSchema = z.object({
id: z.string(),
});
export const MyDeleteOutputSchema = z.object({
success: z.boolean(),
id: z.string(),
});Each tool file follows this pattern:
// apps/api/src/tools/<domain>/create.ts
import { defineTool } from "../../core/define-tool";
import { getUserId, requireAuth, requireOrganization } from "../../core/studio-context";
import { MyCreateInputSchema, MyCreateOutputSchema } from "./schema";
export const MY_DOMAIN_CREATE = defineTool({
name: "MY_DOMAIN_CREATE",
description: "Create a new resource",
inputSchema: MyCreateInputSchema,
outputSchema: MyCreateOutputSchema,
handler: async (input, ctx) => {
// 1. Require authentication
requireAuth(ctx);
// 2. Require organization (if org-scoped)
const organization = requireOrganization(ctx);
// 3. Check authorization
await ctx.access.check();
// 4. Get user ID
const userId = getUserId(ctx);
if (!userId) {
throw new Error("User ID required");
}
// 5. Perform operation
// Option A: Use ctx.boundAuth for Better Auth operations
const result = await ctx.boundAuth.myDomain.create({ ... });
// Option B: Use ctx.storage for custom storage operations
const result = await ctx.storage.myDomain.create({ ... });
// 6. Return result
return { item: result };
},
});// apps/api/src/tools/<domain>/index.ts
export { MY_DOMAIN_CREATE } from "./create";
export { MY_DOMAIN_LIST } from "./list";
export { MY_DOMAIN_UPDATE } from "./update";
export { MY_DOMAIN_DELETE } from "./delete";
// Export schemas for external use
export * from "./schema";Add tool names and metadata:
// apps/api/src/tools/registry.ts
// 1. Add to ToolCategory type (if new category)
export type ToolCategory = "Organizations" | "Connections" | "My Domain";
// 2. Add to ALL_TOOL_NAMES array
const ALL_TOOL_NAMES = [
// ... existing tools
"MY_DOMAIN_CREATE",
"MY_DOMAIN_LIST",
"MY_DOMAIN_UPDATE",
"MY_DOMAIN_DELETE",
] as const;
// 3. Add to MANAGEMENT_TOOLS array
export const MANAGEMENT_TOOLS: ToolMetadata[] = [
// ... existing tools
{
name: "MY_DOMAIN_CREATE",
description: "Create resource",
category: "My Domain",
},
{
name: "MY_DOMAIN_LIST",
description: "List resources",
category: "My Domain",
},
{
name: "MY_DOMAIN_UPDATE",
description: "Update resource",
category: "My Domain",
},
{
name: "MY_DOMAIN_DELETE",
description: "Delete resource",
category: "My Domain",
dangerous: true,
},
];
// 4. Add to TOOL_LABELS
const TOOL_LABELS: Record<ToolName, string> = {
// ... existing labels
MY_DOMAIN_CREATE: "Create resource",
MY_DOMAIN_LIST: "List resources",
MY_DOMAIN_UPDATE: "Update resource",
MY_DOMAIN_DELETE: "Delete resource",
};
// 5. Update getToolsByCategory if new category
export function getToolsByCategory() {
const grouped: Record<string, ToolMetadata[]> = {
Organizations: [],
Connections: [],
"My Domain": [], // Add new category
};
// ...
}// apps/api/src/tools/index.ts
import * as MyDomainTools from "./myDomain";
export { MyDomainTools };
export const ALL_TOOLS = [
// ... existing tools
MyDomainTools.MY_DOMAIN_CREATE,
MyDomainTools.MY_DOMAIN_LIST,
MyDomainTools.MY_DOMAIN_UPDATE,
MyDomaiOpen-source control plane for your AI agents. Connect tools, hire agents, track every token and dollar
Prepare code for review by running quality checks, creating conventional commits, and opening pull requests. Use when the user…
Run Studio locally with chats and task runs executing in real Freestyle sandboxes, reachable through an ngrok tunnel. Use when…
Operate the user's deco Studio (decocms) organization from the terminal with their own login. Use when the user asks to read or…
Create and maintain an org's brand as a folder the whole platform reads: colors, type, voice, logo and a deck theme. Use this…
Read and extract text, tables, and structure from .docx Word documents. Use when the user uploads or references a Word file to…
Route a file to the right reader by extension (pptx, docx, xlsx, pdf, and plain text). Use as the entry point when asked to read…