Skip to main content
Glama

configure_clarinet_project

Set up Clarinet project for specific blockchain networks, add dependencies, and configure development environment settings for Stacks smart contract development.

Instructions

Configure Clarinet project settings for different networks, add dependencies, and set up development environment.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkYesNetwork configuration to set up
requirementsNoAdditional requirements or dependencies

Implementation Reference

  • The main handler implementation for the 'configure_clarinet_project' tool. It generates comprehensive configuration instructions, network settings, deployment plans, and development environment setup for Clarinet projects based on the provided network and requirements.
    export const configureClarinetsProjectTool: Tool<undefined, typeof ProjectConfigScheme> = {
      name: "configure_clarinet_project",
      description: "Configure Clarinet project settings for different networks, add dependencies, and set up development environment.",
      parameters: ProjectConfigScheme,
      execute: async (args, context) => {
        try {
          await recordTelemetry({ action: "configure_clarinet_project" }, context);
          
          const network = args.network;
          const requirements = args.requirements || [];
          
          return `# Clarinet Project Configuration
    
    ## Network Configuration: ${network.toUpperCase()}
    
    ### settings/${network.charAt(0).toUpperCase() + network.slice(1)}.toml
    
    \`\`\`toml
    ${getNetworkConfig(network)}
    \`\`\`
    
    ## Updated Clarinet.toml
    
    \`\`\`toml
    [project]
    name = "my-stacks-project"
    authors = ["Your Name <your.email@example.com>"]
    description = "A Stacks blockchain project using Clarity smart contracts"
    telemetry = true
    cache_dir = "./.clarinet/cache"
    requirements = [${requirements.map(req => `"${req}"`).join(', ')}]
    
    [repl]
    costs_version = 3
    parser_version = 2
    
    [repl.analysis]
    passes = ["check_checker"]
    
    [repl.analysis.check_checker]
    strict = true
    trusted_sender = false
    trusted_caller = false
    callee_filter = true
    
    # Development settings
    [repl.development]
    mine_empty_blocks = true
    deployment_fee_rate = 10
    
    # Contract definitions will be added here
    # [contracts.my-contract]
    # path = "contracts/my-contract.clar" 
    # clarity_version = 2
    # epoch = "2.4"
    \`\`\`
    
    ${requirements.length > 0 ? generateRequirementsConfig(requirements) : ''}
    
    ## Environment Setup
    
    ### 1. Development Environment
    \`\`\`bash
    # Install development dependencies
    npm init -y
    npm install --save-dev @hirosystems/clarinet-sdk @stacks/transactions
    
    # Set up environment variables
    echo "STACKS_NETWORK=${network}" > .env
    echo "CLARINET_MODE=development" >> .env
    \`\`\`
    
    ### 2. Network-Specific Settings
    
    #### API Endpoints
    \`\`\`bash
    # ${network.toUpperCase()} endpoints
    ${getNetworkEndpoints(network)}
    \`\`\`
    
    ### 3. Deployment Configuration
    
    Create \`deployments/${network}-plan.yaml\`:
    
    \`\`\`yaml
    ---
    id: 0
    name: ${network}-deployment
    network: ${network}
    stacks-node: "${getStacksNodeUrl(network)}"
    bitcoin-node: "${getBitcoinNodeUrl(network)}"
    plan:
      batches:
        - id: 0
          transactions:
            # Your deployment transactions will be added here
            # - contract-publish:
            #     contract-name: my-contract
            #     expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
            #     cost: 50000
            #     path: contracts/my-contract.clar
    \`\`\`
    
    ### 4. Testing Configuration
    
    Update test configuration in \`tests/\`:
    
    \`\`\`typescript
    // Test configuration for ${network}
    export const testConfig = {
      network: "${network}",
      timeout: 30000,
      accounts: {
        deployer: "${getDefaultDeployer(network)}",
        wallet1: "${getDefaultWallet1(network)}",
        wallet2: "${getDefaultWallet2(network)}"
      },
      contracts: {
        // Your contract configurations
      }
    };
    \`\`\`
    
    ### 5. IDE Configuration
    
    #### VS Code Settings (\`.vscode/settings.json\`)
    \`\`\`json
    {
      "clarinet.enable": true,
      "clarinet.network": "${network}",
      "editor.formatOnSave": true,
      "[clarity]": {
        "editor.tabSize": 2,
        "editor.insertSpaces": true,
        "editor.rulers": [100]
      },
      "files.associations": {
        "*.clar": "clarity",
        "Clarinet.toml": "toml",
        "*.toml": "toml"
      },
      "emmet.includeLanguages": {
        "clarity": "lisp"
      }
    }
    \`\`\`
    
    ### 6. Development Workflow
    
    \`\`\`bash
    # 1. Start development environment
    clarinet console
    
    # 2. Interactive development commands
    > (contract-call? .my-contract some-function)
    > ::get_costs
    > ::get_contracts_by_trait
    > ::get_accounts
    
    # 3. Run tests for specific network
    clarinet test --${network}
    
    # 4. Deploy to network
    clarinet deployments generate --${network}
    clarinet deployments apply --${network}
    
    # 5. Monitor deployment
    clarinet deployments check --${network}
    \`\`\`
    
    ### 7. Security Configuration
    
    #### Network Security Settings
    \`\`\`toml
    # Add to your ${network} settings
    [security]
    enable_signers = true
    require_signatures = ${network === 'mainnet' ? 'true' : 'false'}
    max_contract_size = 1048576  # 1MB
    gas_limit = 15000000
    \`\`\`
    
    ### 8. Performance Optimization
    
    \`\`\`toml
    # Performance settings for ${network}
    [performance]
    parallel_testing = true
    cache_contracts = true
    optimize_builds = true
    cost_analysis = ${network === 'devnet' ? 'detailed' : 'summary'}
    \`\`\`
    
    ## Next Steps
    
    1. **Add Contracts**: Use \`generate_clarity_contract\` to add smart contracts
    2. **Write Tests**: Use \`generate_contract_tests\` for comprehensive testing
    3. **Configure CI/CD**: Set up automated testing and deployment
    4. **Monitor Performance**: Use cost analysis tools
    5. **Deploy**: Follow the deployment workflow for ${network}
    
    Your Clarinet project is now configured for ${network} development!`;
          
        } catch (error) {
          return `❌ Failed to configure project: ${error}`;
        }
      },
    };
  • Zod schema defining the input parameters for the configure_clarinet_project tool: network (devnet/testnet/mainnet) and optional requirements array.
    const ProjectConfigScheme = z.object({
      network: z.enum(["devnet", "testnet", "mainnet"]).describe("Network configuration to set up"),
      requirements: z.array(z.string()).optional().describe("Additional requirements or dependencies"),
    });
  • The tool is defined and exported as configureClarinetsProjectTool, which serves as its registration in the MCP tools system.
    export const configureClarinetsProjectTool: Tool<undefined, typeof ProjectConfigScheme> = {
      name: "configure_clarinet_project",
      description: "Configure Clarinet project settings for different networks, add dependencies, and set up development environment.",
      parameters: ProjectConfigScheme,
      execute: async (args, context) => {
        try {
          await recordTelemetry({ action: "configure_clarinet_project" }, context);
          
          const network = args.network;
          const requirements = args.requirements || [];
          
          return `# Clarinet Project Configuration
    
    ## Network Configuration: ${network.toUpperCase()}
    
    ### settings/${network.charAt(0).toUpperCase() + network.slice(1)}.toml
    
    \`\`\`toml
    ${getNetworkConfig(network)}
    \`\`\`
    
    ## Updated Clarinet.toml
    
    \`\`\`toml
    [project]
    name = "my-stacks-project"
    authors = ["Your Name <your.email@example.com>"]
    description = "A Stacks blockchain project using Clarity smart contracts"
    telemetry = true
    cache_dir = "./.clarinet/cache"
    requirements = [${requirements.map(req => `"${req}"`).join(', ')}]
    
    [repl]
    costs_version = 3
    parser_version = 2
    
    [repl.analysis]
    passes = ["check_checker"]
    
    [repl.analysis.check_checker]
    strict = true
    trusted_sender = false
    trusted_caller = false
    callee_filter = true
    
    # Development settings
    [repl.development]
    mine_empty_blocks = true
    deployment_fee_rate = 10
    
    # Contract definitions will be added here
    # [contracts.my-contract]
    # path = "contracts/my-contract.clar" 
    # clarity_version = 2
    # epoch = "2.4"
    \`\`\`
    
    ${requirements.length > 0 ? generateRequirementsConfig(requirements) : ''}
    
    ## Environment Setup
    
    ### 1. Development Environment
    \`\`\`bash
    # Install development dependencies
    npm init -y
    npm install --save-dev @hirosystems/clarinet-sdk @stacks/transactions
    
    # Set up environment variables
    echo "STACKS_NETWORK=${network}" > .env
    echo "CLARINET_MODE=development" >> .env
    \`\`\`
    
    ### 2. Network-Specific Settings
    
    #### API Endpoints
    \`\`\`bash
    # ${network.toUpperCase()} endpoints
    ${getNetworkEndpoints(network)}
    \`\`\`
    
    ### 3. Deployment Configuration
    
    Create \`deployments/${network}-plan.yaml\`:
    
    \`\`\`yaml
    ---
    id: 0
    name: ${network}-deployment
    network: ${network}
    stacks-node: "${getStacksNodeUrl(network)}"
    bitcoin-node: "${getBitcoinNodeUrl(network)}"
    plan:
      batches:
        - id: 0
          transactions:
            # Your deployment transactions will be added here
            # - contract-publish:
            #     contract-name: my-contract
            #     expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
            #     cost: 50000
            #     path: contracts/my-contract.clar
    \`\`\`
    
    ### 4. Testing Configuration
    
    Update test configuration in \`tests/\`:
    
    \`\`\`typescript
    // Test configuration for ${network}
    export const testConfig = {
      network: "${network}",
      timeout: 30000,
      accounts: {
        deployer: "${getDefaultDeployer(network)}",
        wallet1: "${getDefaultWallet1(network)}",
        wallet2: "${getDefaultWallet2(network)}"
      },
      contracts: {
        // Your contract configurations
      }
    };
    \`\`\`
    
    ### 5. IDE Configuration
    
    #### VS Code Settings (\`.vscode/settings.json\`)
    \`\`\`json
    {
      "clarinet.enable": true,
      "clarinet.network": "${network}",
      "editor.formatOnSave": true,
      "[clarity]": {
        "editor.tabSize": 2,
        "editor.insertSpaces": true,
        "editor.rulers": [100]
      },
      "files.associations": {
        "*.clar": "clarity",
        "Clarinet.toml": "toml",
        "*.toml": "toml"
      },
      "emmet.includeLanguages": {
        "clarity": "lisp"
      }
    }
    \`\`\`
    
    ### 6. Development Workflow
    
    \`\`\`bash
    # 1. Start development environment
    clarinet console
    
    # 2. Interactive development commands
    > (contract-call? .my-contract some-function)
    > ::get_costs
    > ::get_contracts_by_trait
    > ::get_accounts
    
    # 3. Run tests for specific network
    clarinet test --${network}
    
    # 4. Deploy to network
    clarinet deployments generate --${network}
    clarinet deployments apply --${network}
    
    # 5. Monitor deployment
    clarinet deployments check --${network}
    \`\`\`
    
    ### 7. Security Configuration
    
    #### Network Security Settings
    \`\`\`toml
    # Add to your ${network} settings
    [security]
    enable_signers = true
    require_signatures = ${network === 'mainnet' ? 'true' : 'false'}
    max_contract_size = 1048576  # 1MB
    gas_limit = 15000000
    \`\`\`
    
    ### 8. Performance Optimization
    
    \`\`\`toml
    # Performance settings for ${network}
    [performance]
    parallel_testing = true
    cache_contracts = true
    optimize_builds = true
    cost_analysis = ${network === 'devnet' ? 'detailed' : 'summary'}
    \`\`\`
    
    ## Next Steps
    
    1. **Add Contracts**: Use \`generate_clarity_contract\` to add smart contracts
    2. **Write Tests**: Use \`generate_contract_tests\` for comprehensive testing
    3. **Configure CI/CD**: Set up automated testing and deployment
    4. **Monitor Performance**: Use cost analysis tools
    5. **Deploy**: Follow the deployment workflow for ${network}
    
    Your Clarinet project is now configured for ${network} development!`;
          
        } catch (error) {
          return `❌ Failed to configure project: ${error}`;
        }
      },
    };

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/exponentlabshq/stacks-clarity-mcp'

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