Skip to main content
Glama

deploy-contract

Deploy smart contracts to blockchain networks using bytecode and constructor arguments. This tool enables secure contract deployment through MetaMask integration.

Instructions

Deploy a contract to the network, given bytecode, and constructor arguments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
abiYesThe contract's ABI.
argsNoArguments to pass when deploying the contract. Inferred from abi.
bytecodeYesThe contract's bytecode.

Implementation Reference

  • Executes the deployment of a smart contract using wagmi's deployContract function. Returns the transaction hash on success or an error message on failure.
    execute: async (args) => {
      try {
        const result = await deployContract(wagmiConfig, args);
        return {
          content: [
            {
              type: "text",
              text: JSONStringify({
                hash: result,
              }),
            },
          ],
        };
      }
      catch (error) {
        if (error instanceof TransactionExecutionError) {
          return {
            content: [
              {
                type: "text",
                text: error.cause.message,
              },
            ],
          };
        }
        return {
          content: [
            {
              type: "text",
              text: (error as Error).message,
            },
          ],
        };
      }
    },
  • Defines the tool name, description, and input schema using Zod for ABI, optional constructor arguments, and bytecode.
    name: "deploy-contract",
    description: "Deploy a contract to the network, given bytecode, and constructor arguments.",
    parameters: z.object({
      abi: Abi.describe("The contract's ABI."),
      args: z.unknown().array().optional().describe("Arguments to pass when deploying the contract. Inferred from abi."),
      bytecode: Calldata.describe("The contract's bytecode."),
    }),
  • Registers the "deploy-contract" tool with the FastMCP server, including schema and handler.
    export function registerDeployContractTools(server: FastMCP, wagmiConfig: Config): void {
      server.addTool({
        name: "deploy-contract",
        description: "Deploy a contract to the network, given bytecode, and constructor arguments.",
        parameters: z.object({
          abi: Abi.describe("The contract's ABI."),
          args: z.unknown().array().optional().describe("Arguments to pass when deploying the contract. Inferred from abi."),
          bytecode: Calldata.describe("The contract's bytecode."),
        }),
        execute: async (args) => {
          try {
            const result = await deployContract(wagmiConfig, args);
            return {
              content: [
                {
                  type: "text",
                  text: JSONStringify({
                    hash: result,
                  }),
                },
              ],
            };
          }
          catch (error) {
            if (error instanceof TransactionExecutionError) {
              return {
                content: [
                  {
                    type: "text",
                    text: error.cause.message,
                  },
                ],
              };
            }
            return {
              content: [
                {
                  type: "text",
                  text: (error as Error).message,
                },
              ],
            };
          }
        },
      });
    };
  • Calls registerDeployContractTools as part of the central tool registration in registerTools.
    registerDeployContractTools(server, wagmiConfig);
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states the tool performs a deployment (implying a write/mutation operation) but doesn't disclose critical traits: whether it requires authentication, consumes gas/transaction fees, has rate limits, returns a transaction hash or contract address, or what network effects occur. For a mutation tool with zero annotation coverage, this is inadequate.

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 a single, efficient sentence with zero wasted words. It front-loads the core purpose ('Deploy a contract to the network') and specifies key inputs. Every word earns its place, making it highly concise and well-structured.

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

Completeness2/5

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

For a complex mutation tool (contract deployment) with no annotations and no output schema, the description is insufficient. It lacks behavioral details (e.g., gas costs, return values), usage prerequisites, and error handling context. Given the high-stakes nature of blockchain deployments, more completeness is needed to guide an AI agent effectively.

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 fully documents parameters (abi, args, bytecode). The description mentions 'bytecode, and constructor arguments' but doesn't add meaningful context beyond the schema's descriptions (e.g., format details, validation rules). It omits 'abi' entirely. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('deploy') and target ('contract to the network'), with specific inputs mentioned ('bytecode, and constructor arguments'). It distinguishes from siblings like 'write-contract' by focusing on deployment rather than interaction. However, it doesn't explicitly differentiate from all possible deployment-related tools that might exist.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., needing a connected wallet, sufficient funds), nor does it contrast with sibling tools like 'write-contract' for contract interactions or 'send-transaction' for general transactions. Usage context is implied but not explicit.

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/Xiawpohr/metamask-mcp'

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