- Created tool_docs table with pgvector support (migration 015) - Added 5 MCP tools: tool_doc_add, tool_doc_search, tool_doc_get, tool_doc_list, tool_doc_export - Imported 268 tools from TOOLS.md to database - Enables semantic search for tool documentation (when embeddings available) - Reduces context pollution (TOOLS.md is 11,769 lines, now queryable) Task: CF-249 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
37 lines
1.6 KiB
SQL
37 lines
1.6 KiB
SQL
-- Migration 015: Tool Documentation
|
|
-- Creates tool_docs table for queryable tool documentation with semantic search
|
|
-- Dependencies: 001_base_schema.sql (pgvector extension)
|
|
|
|
-- Tool documentation table
|
|
CREATE TABLE IF NOT EXISTS tool_docs (
|
|
id SERIAL PRIMARY KEY,
|
|
tool_name TEXT NOT NULL,
|
|
category TEXT NOT NULL CHECK (category IN ('mcp', 'cli', 'script', 'internal', 'deprecated')),
|
|
title TEXT NOT NULL,
|
|
description TEXT NOT NULL,
|
|
usage_example TEXT,
|
|
parameters JSONB, -- Structured parameter definitions
|
|
notes TEXT, -- Additional notes, gotchas, tips
|
|
tags TEXT[], -- Searchable tags (e.g., ['backup', 'database', 'postgresql'])
|
|
source_file TEXT, -- Original source file (TOOLS.md, script path, etc.)
|
|
embedding vector(1024), -- Semantic search embedding
|
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
);
|
|
|
|
-- Indexes for fast lookups
|
|
CREATE INDEX IF NOT EXISTS idx_tool_docs_name ON tool_docs(tool_name);
|
|
CREATE INDEX IF NOT EXISTS idx_tool_docs_category ON tool_docs(category);
|
|
CREATE INDEX IF NOT EXISTS idx_tool_docs_tags ON tool_docs USING gin(tags);
|
|
|
|
-- HNSW index for semantic similarity search
|
|
CREATE INDEX IF NOT EXISTS idx_tool_docs_embedding ON tool_docs USING hnsw (embedding vector_cosine_ops);
|
|
|
|
-- Full-text search on title + description
|
|
CREATE INDEX IF NOT EXISTS idx_tool_docs_fts ON tool_docs
|
|
USING gin(to_tsvector('english', title || ' ' || description || ' ' || COALESCE(notes, '')));
|
|
|
|
-- Record migration
|
|
INSERT INTO schema_migrations (version) VALUES ('015_tool_docs')
|
|
ON CONFLICT (version) DO NOTHING;
|