cairo-custom
Generate custom smart contracts with OpenZeppelin Contracts libraries. Define contract name, access control, pausability, and upgradeability. Outputs source code in Markdown for easy integration without writing to disk.
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 |
|---|---|---|---|
| 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. | |
| info | No | Metadata about the contract and author | |
| name | Yes | The name of the contract | |
| pausable | No | Whether privileged accounts will be able to pause specifically marked functionality. Useful for emergency response. | |
| upgradeable | No | Whether the smart contract is upgradeable. |
Implementation Reference
- The handler function for the 'cairo-custom' tool. It constructs CustomOptions from input parameters (name, pausable, access, upgradeable, info) and generates Cairo code by calling custom.print(opts) from the @openzeppelin/wizard-cairo library, then returns it wrapped in a text content response using safePrintCairoCodeBlock.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 the input validation for the 'cairo-custom' tool, including required 'name', optional 'pausable', and spreads in commonSchema (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)The registration of the 'cairo-custom' tool using server.tool(), specifying the name 'cairo-custom', a detailed prompt from cairoPrompts.Custom, the customSchema for input validation, and the 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)), }, ], }; }, ); }