Skip to main content
Glama

hardhat_project

Manage Hardhat project lifecycle for Hedera blockchain development. Initialize projects, compile contracts, run tests, and handle configuration for smart contract deployment.

Instructions

Manage Hardhat project lifecycle operations.

OPERATIONS:

  • init: Initialize new Hardhat project with Hedera configuration

  • compile: Compile Solidity contracts (with force option)

  • test: Run Mocha/Chai tests with filtering

  • clean: Clean artifacts and cache

  • flatten: Flatten contracts for verification

  • get_artifacts: Retrieve compiled ABI and bytecode

  • get_accounts: List available accounts with balances

  • config_network: Generate Hedera network config snippet

  • run_task: Execute custom Hardhat task

  • list_tasks: List all available tasks

USE FOR: Project setup, compilation, testing, and configuration management.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationYesProject operation to perform
directoryNoAbsolute path to Hardhat project directory (required for all operations except init which creates it)
networksNoNetworks to configure (for init)
solidityNoSolidity version (for init)
typescriptNoUse TypeScript (for init)
forceNoForce recompilation (for compile)
testFilesNoTest files to run (for test)
grepNoTest filter pattern (for test)
networkNoNetwork name
contractPathNoContract file path (for flatten)
contractNameNoContract name (for get_artifacts)
taskNoTask name (for run_task)
paramsNoTask parameters (for run_task)

Implementation Reference

  • Primary handler function that implements the 'hardhat_project' tool logic. Dispatches to Hardhat-specific operations (init, compile, test, etc.) using imported helpers from hardhat.ts.
    export async function hardhatProjectManage(args: {
      operation: 'init' | 'compile' | 'test' | 'clean' | 'flatten' | 'get_artifacts' | 'get_accounts' | 'config_network' | 'run_task' | 'list_tasks';
      // Init-specific
      directory?: string;
      networks?: Array<'mainnet' | 'testnet' | 'previewnet' | 'local'>;
      solidity?: string;
      typescript?: boolean;
      // Compile-specific
      force?: boolean;
      // Test-specific
      testFiles?: string[];
      grep?: string;
      network?: string;
      // Flatten-specific
      contractPath?: string;
      // Get artifacts-specific
      contractName?: string;
      // Run task-specific
      task?: string;
      params?: any;
    }): Promise<ToolResult> {
      try {
        logger.info('Hardhat project operation', { operation: args.operation });
    
        switch (args.operation) {
          case 'init':
            return await hardhatTools.hardhatInit({
              directory: args.directory,
              networks: args.networks,
              solidity: args.solidity,
              typescript: args.typescript,
            });
    
          case 'compile':
            return await hardhatTools.hardhatCompile({ force: args.force, directory: args.directory });
    
          case 'test':
            return await hardhatTools.hardhatTest({
              testFiles: args.testFiles,
              grep: args.grep,
              network: args.network,
              directory: args.directory,
            });
    
          case 'clean':
            return await hardhatTools.hardhatClean({ directory: args.directory });
    
          case 'flatten':
            return await hardhatTools.hardhatFlatten({ files: args.contractPath ? [args.contractPath] : undefined, directory: args.directory });
    
          case 'get_artifacts':
            return await hardhatTools.hardhatGetArtifacts({ contractName: args.contractName, directory: args.directory });
    
          case 'get_accounts':
            return await hardhatTools.hardhatGetAccounts({ directory: args.directory });
    
          case 'config_network':
            // Config network generates a config snippet, doesn't require all params
            return {
              success: true,
              data: {
                network: args.network || 'testnet',
                message: 'Use hardhat_contract with operation "deploy" and network parameter for actual deployment',
              },
            };
    
          case 'run_task':
            return await hardhatTools.hardhatRunTask({
              task: args.task!,
              params: args.params,
              directory: args.directory,
            });
    
          case 'list_tasks':
            return await hardhatTools.hardhatListTasks({ directory: args.directory });
    
          default:
            throw new Error(`Unknown operation: ${args.operation}`);
        }
      } catch (error) {
        logger.error('Hardhat project operation failed', { operation: args.operation, error });
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
        };
      }
    }
  • Input schema and description definition for the 'hardhat_project' tool, exported in hardhatFoundryToolDefinitions array.
      {
        name: 'hardhat_project',
        description: `Manage Hardhat project lifecycle operations.
    
    OPERATIONS:
    - init: Initialize new Hardhat project with Hedera configuration
    - compile: Compile Solidity contracts (with force option)
    - test: Run Mocha/Chai tests with filtering
    - clean: Clean artifacts and cache
    - flatten: Flatten contracts for verification
    - get_artifacts: Retrieve compiled ABI and bytecode
    - get_accounts: List available accounts with balances
    - config_network: Generate Hedera network config snippet
    - run_task: Execute custom Hardhat task
    - list_tasks: List all available tasks
    
    USE FOR: Project setup, compilation, testing, and configuration management.`,
        inputSchema: {
          type: 'object' as const,
          properties: {
            operation: {
              type: 'string',
              enum: ['init', 'compile', 'test', 'clean', 'flatten', 'get_artifacts', 'get_accounts', 'config_network', 'run_task', 'list_tasks'],
              description: 'Project operation to perform',
            },
            directory: { type: 'string', description: 'Absolute path to Hardhat project directory (required for all operations except init which creates it)' },
            networks: {
              type: 'array',
              items: { type: 'string', enum: ['mainnet', 'testnet', 'previewnet', 'local'] },
              description: 'Networks to configure (for init)',
            },
            solidity: { type: 'string', description: 'Solidity version (for init)' },
            typescript: { type: 'boolean', description: 'Use TypeScript (for init)' },
            force: { type: 'boolean', description: 'Force recompilation (for compile)' },
            testFiles: { type: 'array', items: { type: 'string' }, description: 'Test files to run (for test)' },
            grep: { type: 'string', description: 'Test filter pattern (for test)' },
            network: { type: 'string', description: 'Network name' },
            contractPath: { type: 'string', description: 'Contract file path (for flatten)' },
            contractName: { type: 'string', description: 'Contract name (for get_artifacts)' },
            task: { type: 'string', description: 'Task name (for run_task)' },
            params: { type: 'object', description: 'Task parameters (for run_task)' },
          },
          required: ['operation'],
        },
      },
  • src/index.ts:647-649 (registration)
    Tool handler registration in the main MCP server request handler switch statement, mapping 'hardhat_project' calls to hardhatProjectManage function.
    case 'hardhat_project':
      result = await hardhatProjectManage(args as any);
      break;
  • src/index.ts:524-524 (registration)
    Registration of the tool definition/schema by spreading hardhatFoundryToolDefinitions into optimizedToolDefinitions array used for ListTools.
    ...hardhatFoundryToolDefinitions,
  • Import of helper functions from hardhat.ts used by the hardhatProjectManage dispatcher (e.g., hardhatInit, hardhatCompile, etc.). Actual exec logic in src/tools/hardhat.ts (ID:24511902).
    import * as hardhatTools from './hardhat.js';
    import * as foundryTools from './foundry.js';
    
    /**
     * Composite Hardhat Project Management Tool
     * Consolidates project-level operations into 1 tool
     */
    export async function hardhatProjectManage(args: {
      operation: 'init' | 'compile' | 'test' | 'clean' | 'flatten' | 'get_artifacts' | 'get_accounts' | 'config_network' | 'run_task' | 'list_tasks';
      // Init-specific
      directory?: string;
      networks?: Array<'mainnet' | 'testnet' | 'previewnet' | 'local'>;
      solidity?: string;
      typescript?: boolean;
      // Compile-specific
      force?: boolean;
      // Test-specific
      testFiles?: string[];
      grep?: string;
      network?: string;
      // Flatten-specific
      contractPath?: string;
      // Get artifacts-specific
      contractName?: string;
      // Run task-specific
      task?: string;
      params?: any;
    }): Promise<ToolResult> {
      try {
        logger.info('Hardhat project operation', { operation: args.operation });
    
        switch (args.operation) {
          case 'init':
            return await hardhatTools.hardhatInit({
              directory: args.directory,
              networks: args.networks,
              solidity: args.solidity,
              typescript: args.typescript,
            });
    
          case 'compile':
            return await hardhatTools.hardhatCompile({ force: args.force, directory: args.directory });
    
          case 'test':
            return await hardhatTools.hardhatTest({
              testFiles: args.testFiles,
              grep: args.grep,
              network: args.network,
              directory: args.directory,
            });
    
          case 'clean':
            return await hardhatTools.hardhatClean({ directory: args.directory });
    
          case 'flatten':
            return await hardhatTools.hardhatFlatten({ files: args.contractPath ? [args.contractPath] : undefined, directory: args.directory });
    
          case 'get_artifacts':
            return await hardhatTools.hardhatGetArtifacts({ contractName: args.contractName, directory: args.directory });
    
          case 'get_accounts':
            return await hardhatTools.hardhatGetAccounts({ directory: args.directory });
    
          case 'config_network':
            // Config network generates a config snippet, doesn't require all params
            return {
              success: true,
              data: {
                network: args.network || 'testnet',
                message: 'Use hardhat_contract with operation "deploy" and network parameter for actual deployment',
              },
            };
    
          case 'run_task':
            return await hardhatTools.hardhatRunTask({
              task: args.task!,
              params: args.params,
              directory: args.directory,
            });
    
          case 'list_tasks':
            return await hardhatTools.hardhatListTasks({ directory: args.directory });
    
          default:
            throw new Error(`Unknown operation: ${args.operation}`);
        }
      } catch (error) {
        logger.error('Hardhat project operation failed', { operation: args.operation, error });
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While it lists operations, it doesn't explain critical behavioral aspects: which operations are read-only vs. mutating, what permissions are required, whether operations have side effects, or how errors are handled. For a complex tool with 13 parameters and no annotations, this represents a significant gap in behavioral transparency.

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

Conciseness4/5

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

The description is well-structured with clear sections (OPERATIONS, USE FOR) and uses bullet points for readability. While comprehensive, it could be more concise - some operation descriptions could be streamlined, and the structure is effective but not perfectly front-loaded with the most critical information.

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?

For a complex tool with 13 parameters, no annotations, and no output schema, the description provides adequate operational overview but lacks critical context. It doesn't explain return values, error conditions, or behavioral constraints. The description covers what the tool does but not how it behaves or what results to expect, leaving significant gaps given the tool's complexity.

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 13 parameters thoroughly. The description adds minimal value beyond the schema - it mentions 'force option' for compile and 'filtering' for test, but doesn't provide additional semantic context about parameter usage, dependencies, or constraints beyond what's in the schema descriptions.

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 tool 'Manage[s] Hardhat project lifecycle operations' and lists 10 specific operations, providing a comprehensive overview of its functionality. However, it doesn't explicitly differentiate from sibling tools like 'hardhat_contract' or 'foundry_project' which might have overlapping functionality in the same domain.

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 'USE FOR' section provides general guidance ('Project setup, compilation, testing, and configuration management'), but doesn't specify when to choose this tool over alternatives like 'hardhat_contract' or 'foundry_project'. The guidance is helpful but lacks explicit comparison with sibling tools that handle similar blockchain development tasks.

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/justmert/hashpilot'

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