cairo-custom
Generate custom Cairo smart contracts with configurable features like access control, upgradeability, and pausability using OpenZeppelin Contracts libraries.
Instructions
Make a custom smart contract.
Returns the source code of the generated contract, formatted in a Markdown code block. Does not write to disk.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name of the contract | |
| pausable | No | Whether privileged accounts will be able to pause specifically marked functionality. Useful for emergency response. | |
| access | No | The type of access control to provision. Ownable is a simple mechanism with a single account authorized for all privileged actions. Roles is a flexible mechanism with a separate role for each privileged action. A role can have many authorized accounts. | |
| upgradeable | No | Whether the smart contract is upgradeable. | |
| info | No | Metadata about the contract and author |
Implementation Reference
- Handler function that processes inputs for the 'cairo-custom' tool, constructs CustomOptions, generates Cairo code using the external 'custom.print' function, and returns formatted text content.async ({ name, pausable, access, upgradeable, info }) => { const opts: CustomOptions = { name, pausable, access, upgradeable, info, }; return { content: [ { type: 'text', text: safePrintCairoCodeBlock(() => custom.print(opts)), }, ], }; },
- Zod schema defining inputs for 'cairo-custom': required name, optional pausable, and common fields (access, upgradeable, info).export const customSchema = { name: z.string().describe(commonDescriptions.name), pausable: z.boolean().optional().describe(commonDescriptions.pausable), ...commonSchema, } as const satisfies z.ZodRawShape;
- packages/mcp/src/cairo/tools/custom.ts:8-31 (registration)Registers the 'cairo-custom' tool on the MCP server with name, prompt, schema, and handler function.export function registerCairoCustom(server: McpServer): RegisteredTool { return server.tool( 'cairo-custom', makeDetailedPrompt(cairoPrompts.Custom), customSchema, async ({ name, pausable, access, upgradeable, info }) => { const opts: CustomOptions = { name, pausable, access, upgradeable, info, }; return { content: [ { type: 'text', text: safePrintCairoCodeBlock(() => custom.print(opts)), }, ], }; }, ); }
- packages/mcp/src/cairo/tools.ts:18-28 (registration)Includes registerCairoCustom in the getRegisterFunctions map for 'Custom' kind, called by registerCairoTools.return { ERC20: () => registerCairoERC20(server), ERC721: () => registerCairoERC721(server), ERC1155: () => registerCairoERC1155(server), Account: () => registerCairoAccount(server), Multisig: () => registerCairoMultisig(server), Governor: () => registerCairoGovernor(server), Vesting: () => registerCairoVesting(server), Custom: () => registerCairoCustom(server), }; }
- packages/mcp/src/server.ts:26-26 (registration)Calls registerCairoTools during MCP server setup, which includes the cairo-custom tool.registerCairoTools(server);