Skip to main content
Glama

state_manage

Backup, restore, or export HashPilot MCP server state for persistence, migration, disaster recovery, and debugging purposes.

Instructions

Manage HashPilot MCP server state through backup/restore/export operations.

OPERATIONS:

  • backup: Create timestamped backup (excludes private keys by default for security)

  • restore: Restore state from backup file (can merge or replace)

  • export: Export state to JSON for inspection or sharing

USE THIS FOR: State persistence, migration, disaster recovery, debugging.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationYesState management operation
includePrivateKeysNoInclude private keys (INSECURE - use with caution)
outputPathNoOutput file path (for backup/export)
backupPathNoBackup file to restore from
mergeNoMerge with existing state instead of replacing
formatNoExport format (default: pretty)

Implementation Reference

  • Primary handler for 'state_manage' tool. Routes 'backup', 'restore', 'export' operations to stateTools helpers with unified error handling and logging.
    export async function stateManage(args: {
      operation: 'backup' | 'restore' | 'export';
      // Backup/Export specific
      includePrivateKeys?: boolean;
      outputPath?: string;
      filename?: string;
      format?: 'json' | 'compact' | 'pretty';
      // Restore specific
      backupPath?: string;
      merge?: boolean;
    }): Promise<ToolResult> {
      try {
        logger.info('State management operation', { operation: args.operation });
    
        switch (args.operation) {
          case 'backup':
            return await stateTools.backupState({
              includePrivateKeys: args.includePrivateKeys,
              outputPath: args.outputPath,
              filename: args.filename,
            });
    
          case 'restore':
            return await stateTools.restoreState({
              backupPath: args.backupPath!,
              merge: args.merge,
            });
    
          case 'export':
            return await stateTools.exportState({
              outputPath: args.outputPath!,
              format: args.format,
              includePrivateKeys: args.includePrivateKeys,
            });
    
          default:
            return {
              success: false,
              error: `Unknown state operation: ${args.operation}`,
            };
        }
      } catch (error) {
        logger.error('State management failed', { operation: args.operation, error });
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
        };
      }
    }
  • Tool schema definition including name, description, and inputSchema validation for the 'state_manage' tool.
      {
        name: 'state_manage',
        description: `Manage HashPilot MCP server state through backup/restore/export operations.
    
    OPERATIONS:
    - backup: Create timestamped backup (excludes private keys by default for security)
    - restore: Restore state from backup file (can merge or replace)
    - export: Export state to JSON for inspection or sharing
    
    USE THIS FOR: State persistence, migration, disaster recovery, debugging.`,
        inputSchema: {
          type: 'object' as const,
          properties: {
            operation: {
              type: 'string',
              enum: ['backup', 'restore', 'export'],
              description: 'State management operation',
            },
            includePrivateKeys: {
              type: 'boolean',
              description: 'Include private keys (INSECURE - use with caution)',
            },
            outputPath: {
              type: 'string',
              description: 'Output file path (for backup/export)',
            },
            backupPath: {
              type: 'string',
              description: 'Backup file to restore from',
            },
            merge: {
              type: 'boolean',
              description: 'Merge with existing state instead of replacing',
            },
            format: {
              type: 'string',
              enum: ['json', 'compact', 'pretty'],
              description: 'Export format (default: pretty)',
            },
          },
          required: ['operation'],
        },
      },
  • src/index.ts:594-596 (registration)
    Registration in the main tool dispatch switch statement in index.ts, which calls the stateManage handler.
    case 'state_manage':
      result = await stateManage(args as any);
      break;
  • Helper function backupState called by state_manage for backup operations, interacts with stateService.
    export async function backupState(args: {
      outputPath?: string;
      includePrivateKeys?: boolean;
      filename?: string;
    }): Promise<ToolResult> {
      try {
        logger.info('Creating state backup', {
          includePrivateKeys: args.includePrivateKeys,
        });
    
        // Warning for including private keys
        if (args.includePrivateKeys) {
          logger.warn('⚠️  WARNING: Backup includes UNENCRYPTED private keys!');
          logger.warn('⚠️  Store this backup securely and never share it.');
        }
    
        const result = await stateService.backup(args.includePrivateKeys || false, args.outputPath);
    
        return {
          success: true,
          data: result,
          metadata: {
            executedVia: 'state_service',
            command: 'state backup',
          },
        };
      } catch (error) {
        logger.error('Failed to backup state', { error });
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
        };
      }
    }
  • Helper function restoreState called by state_manage for restore operations.
    export async function restoreState(args: {
      backupPath: string;
      merge?: boolean;
    }): Promise<ToolResult> {
      try {
        logger.info('Restoring state from backup', {
          backupPath: args.backupPath,
          merge: args.merge,
        });
    
        const result = await stateService.restore(args.backupPath, args.merge || false);
    
        return {
          success: true,
          data: result,
          metadata: {
            executedVia: 'state_service',
            command: 'state restore',
          },
        };
      } catch (error) {
        logger.error('Failed to restore state', { error });
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
        };
      }
    }
  • Helper function exportState called by state_manage for export operations.
    export async function exportState(args: {
      outputPath: string;
      format?: 'json' | 'compact' | 'pretty';
      includePrivateKeys?: boolean;
    }): Promise<ToolResult> {
      try {
        logger.info('Exporting state', {
          outputPath: args.outputPath,
          format: args.format,
        });
    
        // Warning for including private keys
        if (args.includePrivateKeys) {
          logger.warn('⚠️  WARNING: Export includes UNENCRYPTED private keys!');
          logger.warn('⚠️  Store this export securely and never share it.');
        }
    
        const result = await stateService.export(
          args.outputPath,
          args.format || 'pretty',
          args.includePrivateKeys || false
        );
    
        return {
          success: true,
          data: result,
          metadata: {
            executedVia: 'state_service',
            command: 'state export',
          },
        };
      } catch (error) {
        logger.error('Failed to export state', { error });
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
        };
      }
    }
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: backup excludes private keys by default for security, restore can merge or replace, and export produces JSON for inspection/sharing. It doesn't mention potential side effects, error conditions, or performance characteristics, but provides solid operational context.

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 perfectly structured and front-loaded: first sentence states the core purpose, followed by clear operation definitions, then usage guidelines. Every sentence earns its place with zero waste. The bullet format enhances readability without sacrificing conciseness.

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

Completeness4/5

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

For a state management tool with 6 parameters, 100% schema coverage, and no output schema, the description provides strong context about operations and use cases. It could be more complete by mentioning what 'state' specifically includes or providing examples of when to choose backup vs export, but it covers the essential behavioral aspects well given the structured data available.

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 baseline is 3. The description adds minimal parameter semantics beyond the schema - it mentions timestamped backups, JSON export format, and merge/replace behavior, but these are largely implied by parameter names. The description doesn't significantly enhance understanding of individual parameters beyond what the schema provides.

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 verbs ('manage', 'backup', 'restore', 'export') and resources ('HashPilot MCP server state'). It distinguishes itself from all sibling tools by focusing on state management operations rather than account, contract, network, or documentation functions.

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

Usage Guidelines5/5

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

The 'USE THIS FOR' section explicitly provides usage contexts: 'State persistence, migration, disaster recovery, debugging.' This gives clear guidance on when to select this tool versus the many sibling tools for different purposes like account management, contract deployment, or network operations.

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