Skip to main content
Glama

db.init

Initialize database tables for storing vulnerability findings and security scan results in a bug bounty platform.

Instructions

Initialize database tables (run once on first setup)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for 'db.init' tool that invokes createTables() to initialize the database tables and returns success/error result.
    async (): Promise<ToolResult> => { try { await createTables(); return formatToolResult(true, { message: 'Database tables created successfully' }); } catch (error: any) { return formatToolResult(false, null, error.message); } }
  • Input schema for 'db.init' tool, which takes no parameters.
    inputSchema: { type: 'object', properties: {}, },
  • Registration of the 'db.init' tool on the MCP server, including schema and handler.
    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); } } );
  • Supporting function createTables() that creates the findings, test_results, and training_data tables 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(); } }
  • src/index.ts:46-46 (registration)
    Invocation of registerDatabaseTools which registers all database tools including 'db.init'.
    registerDatabaseTools(server);

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