Skip to main content
Glama
OpenZeppelin

OpenZeppelin Contracts MCP Server

Official
by OpenZeppelin

cairo-governor

Generate smart contract source code for implementing DAO governance with customizable voting parameters, timelocks, and upgradeability options.

Instructions

Make a contract to implement governance, such as for a DAO.

Returns the source code of the generated contract, formatted in a Markdown code block. Does not write to disk.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesThe name of the contract
delayYesThe delay since proposal is created until voting starts, in readable date time format matching /^(\d+(?:\.\d+)?) +(second|minute|hour|day|week|month|year)s?$/, default is "1 day".
periodYesThe length of period during which people can cast their vote, in readable date time format matching /^(\d+(?:\.\d+)?) +(second|minute|hour|day|week|month|year)s?$/, default is "1 week".
votesNoThe type of voting to use. Either erc20votes, meaning voting power with a votes-enabled ERC20 token. Either erc721votes, meaning voting power with a votes-enabled ERC721 token. Voters can entrust their voting power to a delegate.
clockModeNoThe clock mode used by the voting token. For now, only timestamp mode where the token uses voting durations expressed as timestamps is supported. For Governor, this must be chosen to match what the ERC20 or ERC721 voting token uses.
timelockNoWhether to add a delay to actions taken by the Governor. Gives users time to exit the system if they disagree with governance decisions. If "openzeppelin", Module compatible with OpenZeppelin's TimelockController.
decimalsNoThe number of decimals to use for the contract, default is 18 for ERC20Votes and 0 for ERC721Votes (because it does not apply to ERC721Votes).
proposalThresholdNoMinimum number of votes an account must have to create a proposal, default is 0.
quorumModeNoThe type of quorum mode to use, either by percentage or absolute value.
quorumPercentNoThe percent required, in cases of quorumMode equals percent.
quorumAbsoluteNoThe absolute quorum required, in cases of quorumMode equals absolute.
settingsNoWhether to allow governance to update voting settings (delay, period, proposal threshold).
upgradeableNoWhether the smart contract is upgradeable.
appNameNoRequired when votes is enabled, for hashing and signing typed structured data. Name for domain separator implementing SNIP12Metadata trait. Prevents two applications from producing the same hash.
appVersionNoRequired when votes is enabled, for hashing and signing typed structured data. Version for domain separator implementing SNIP12Metadata trait. Prevents two versions of the same application from producing the same hash.
infoNoMetadata about the contract and author

Implementation Reference

  • Function that registers the 'cairo-governor' MCP tool, providing the tool name, detailed prompt description, input schema, and execution handler that generates Cairo Governor contract code using OpenZeppelin Wizard.
    export function registerCairoGovernor(server: McpServer): RegisteredTool {
      return server.tool(
        'cairo-governor',
        makeDetailedPrompt(cairoPrompts.Governor),
        governorSchema,
        async ({
          name,
          delay,
          period,
          votes,
          clockMode,
          timelock,
          decimals,
          proposalThreshold,
          quorumMode,
          quorumPercent,
          quorumAbsolute,
          settings,
          upgradeable,
          appName,
          appVersion,
          info,
        }) => {
          const opts: GovernorOptions = {
            name,
            delay,
            period,
            votes,
            clockMode,
            timelock,
            decimals,
            proposalThreshold,
            quorumMode,
            quorumPercent,
            quorumAbsolute,
            settings,
            upgradeable,
            appName,
            appVersion,
            info,
          };
          return {
            content: [
              {
                type: 'text',
                text: safePrintCairoCodeBlock(() => governor.print(opts)),
              },
            ],
          };
        },
      );
    }
  • Zod schema defining the input validation and descriptions for the cairo-governor tool parameters.
    export const governorSchema = {
      name: z.string().describe(commonDescriptions.name),
      delay: z.string().describe(cairoGovernorDescriptions.delay),
      period: z.string().describe(cairoGovernorDescriptions.period),
      votes: z.enum(['erc20votes', 'erc721votes']).optional().describe(cairoGovernorDescriptions.votes),
      clockMode: z.enum(['timestamp']).optional().describe(cairoGovernorDescriptions.clockMode),
      timelock: z
        .union([z.literal(false), z.literal('openzeppelin')])
        .optional()
        .describe(cairoGovernorDescriptions.timelock),
      decimals: z.number().optional().describe(cairoGovernorDescriptions.decimals),
      proposalThreshold: z.string().optional().describe(cairoGovernorDescriptions.proposalThreshold),
      quorumMode: z.enum(['percent', 'absolute']).optional().describe(cairoGovernorDescriptions.quorumMode),
      quorumPercent: z.number().optional().describe(cairoGovernorDescriptions.quorumPercent),
      quorumAbsolute: z.string().optional().describe(cairoGovernorDescriptions.quorumAbsolute),
      settings: z.boolean().optional().describe(cairoGovernorDescriptions.settings),
      upgradeable: commonSchema.upgradeable,
      appName: z.string().optional().describe(cairoCommonDescriptions.appName),
      appVersion: z.string().optional().describe(cairoCommonDescriptions.appVersion),
      info: commonSchema.info,
    } as const satisfies z.ZodRawShape;
  • The tool handler logic that maps input parameters to GovernorOptions and prints the Cairo code using the OpenZeppelin governor wizard.
    async ({
      name,
      delay,
      period,
      votes,
      clockMode,
      timelock,
      decimals,
      proposalThreshold,
      quorumMode,
      quorumPercent,
      quorumAbsolute,
      settings,
      upgradeable,
      appName,
      appVersion,
      info,
    }) => {
      const opts: GovernorOptions = {
        name,
        delay,
        period,
        votes,
        clockMode,
        timelock,
        decimals,
        proposalThreshold,
        quorumMode,
        quorumPercent,
        quorumAbsolute,
        settings,
        upgradeable,
        appName,
        appVersion,
        info,
      };
      return {
        content: [
          {
            type: 'text',
            text: safePrintCairoCodeBlock(() => governor.print(opts)),
          },
        ],
      };
    },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it generates contract source code (a creation/mutation operation), returns it formatted in Markdown code blocks, and explicitly states 'Does not write to disk' (important for understanding output handling). However, it doesn't mention potential side effects, error conditions, or performance considerations like rate limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise and front-loaded: two sentences that directly state the tool's purpose and output format, with zero wasted words. Every sentence earns its place by providing essential information without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (16 parameters, no output schema, no annotations), the description is minimal. It covers the basic purpose and output format but lacks details on return values (beyond 'Markdown code block'), error handling, or integration context. For a governance contract generator with many parameters, more contextual guidance would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 16 parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema, maintaining the baseline score of 3. It doesn't explain parameter interactions or provide examples beyond the schema's details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verb ('Make a contract') and resource ('to implement governance, such as for a DAO'), and distinguishes it from siblings by focusing on governance contracts rather than other contract types like ERC20, ERC721, or multisig. The mention of returning source code in Markdown format adds further specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for governance implementation, but lacks explicit guidance on when to use this tool versus alternatives like 'solidity-governor' or other contract generators. It mentions 'Does not write to disk,' which provides some context, but no clear when-not-to-use scenarios or prerequisites are stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OpenZeppelin/contracts-wizard'

If you have feedback or need assistance with the MCP directory API, please join our Discord server