Skip to main content
Glama

db.init

Initialize database tables for the VulneraMCP bug bounty platform to store vulnerability findings and security tool data during first-time setup.

Instructions

Initialize database tables (run once on first setup)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registers the 'db.init' MCP tool, including input schema (empty) and inline handler that invokes createTables() and formats the result.
    server.tool(
      'db.init',
      {
        description: 'Initialize database tables (run once on first setup)',
        inputSchema: {
          type: 'object',
          properties: {},
        },
      },
      async (): Promise<ToolResult> => {
        try {
          await createTables();
          return formatToolResult(true, { message: 'Database tables created successfully' });
        } catch (error: any) {
          return formatToolResult(false, null, error.message);
        }
      }
    );
  • Core implementation logic for 'db.init': creates PostgreSQL tables for findings, test_results, and training_data with appropriate indexes.
    export async function createTables(): Promise<void> {
      const client = await initPostgres().connect();
      try {
        await client.query(`
          CREATE TABLE IF NOT EXISTS findings (
            id SERIAL PRIMARY KEY,
            target VARCHAR(500) NOT NULL,
            type VARCHAR(100) NOT NULL,
            severity VARCHAR(20) NOT NULL,
            description TEXT NOT NULL,
            payload TEXT,
            response TEXT,
            timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
            score INTEGER,
            status VARCHAR(20) DEFAULT 'new',
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
          );
    
          CREATE INDEX IF NOT EXISTS idx_findings_target ON findings(target);
          CREATE INDEX IF NOT EXISTS idx_findings_type ON findings(type);
          CREATE INDEX IF NOT EXISTS idx_findings_severity ON findings(severity);
          CREATE INDEX IF NOT EXISTS idx_findings_timestamp ON findings(timestamp);
        `);
    
        await client.query(`
          CREATE TABLE IF NOT EXISTS test_results (
            id SERIAL PRIMARY KEY,
            target VARCHAR(500) NOT NULL,
            test_type VARCHAR(100) NOT NULL,
            success BOOLEAN NOT NULL,
            score INTEGER DEFAULT 0,
            result_data JSONB,
            error_message TEXT,
            payload TEXT,
            response_data TEXT,
            timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
          );
    
          CREATE INDEX IF NOT EXISTS idx_test_results_target ON test_results(target);
          CREATE INDEX IF NOT EXISTS idx_test_results_type ON test_results(test_type);
          CREATE INDEX IF NOT EXISTS idx_test_results_success ON test_results(success);
          CREATE INDEX IF NOT EXISTS idx_test_results_score ON test_results(score);
        `);
    
        await client.query(`
          CREATE TABLE IF NOT EXISTS training_data (
            id SERIAL PRIMARY KEY,
            source VARCHAR(50) NOT NULL,
            source_id VARCHAR(200),
            vulnerability_type VARCHAR(100) NOT NULL,
            target_pattern TEXT,
            payload_pattern TEXT,
            success_pattern TEXT,
            failure_pattern TEXT,
            context_data JSONB,
            score INTEGER DEFAULT 0,
            learned_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
          );
    
          CREATE INDEX IF NOT EXISTS idx_training_source ON training_data(source);
          CREATE INDEX IF NOT EXISTS idx_training_type ON training_data(vulnerability_type);
        `);
      } finally {
        client.release();
      }
    }

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/telmon95/VulneraMCP'

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