Date: February 22, 2026
Purpose: Break down MCP (Model Context Protocol) integration to fundamental truths before implementation
Core Problem: AI agents need context about vector databases during migration, but currently operate blind.
Solution: Expose VectorMigrate capabilities via MCP (Model Context Protocol) so AI assistants can:
- Query migration status
- Start/stop migrations
- Get schema recommendations
- Validate migrations
- Access logs and metrics
Constraints:
- Security: No direct database access via MCP
- Read-only by default: Write operations require explicit authorization
- Audit trail: All MCP operations logged
- Rate limiting: Prevent abuse
MCP servers expose capabilities to AI assistants. They do NOT:
- Store data (use existing state tracker)
- Execute migrations directly (use orchestrator)
- Manage connections (use adapter factory)
Implication: MCP server is a thin wrapper around existing components.
AI assistants work best with:
- Clear schemas (JSON Schema)
- Enumerated options (not free text)
- Examples in responses
- Error messages with suggestions
Implication: Every MCP tool must have JSON Schema + examples.
AI assistants may retry operations. We must handle:
- Duplicate "start migration" requests → Return existing migration ID
- Repeated "get status" calls → Cache recent results
- Cancelled then restarted migrations → Create new ID, don't reuse
Implication: Track operation history, use idempotency keys.
AI assistants have limited context (typically 8K-128K tokens). We must:
- Keep responses concise (<1K tokens typical)
- Paginate large result sets
- Summarize when possible
- Provide "get more details" tools
Implication: Default to summaries, offer drill-down.
MCP servers run with AI assistant access. We must:
- Never expose API keys in responses
- Sanitize URLs (remove credentials)
- Validate all inputs (SQL injection, path traversal)
- Rate limit per client
- Log all operations
Implication: Security review before any MCP tool.
We cannot test MCP with unit tests alone. We need:
- Mock AI assistant (simulates Claude/GPT)
- Recorded conversations (for regression testing)
- Integration tests with real MCP clients
- Security penetration testing
Implication: Build mock assistant early.
Purpose: Basic MCP server structure
Why first: All other components depend on MCP protocol
Interface:
type MCPServer interface {
Start(ctx context.Context, addr string) error
Stop() error
RegisterTool(name string, handler ToolHandler) error
}Implementation Decision: Use official MCP SDK if available, otherwise minimal HTTP+JSON-RPC.
Purpose: Register and manage MCP tools
Why first: Tools must be registered before exposure
Interface:
type ToolRegistry interface {
Register(tool *Tool) error
Get(name string) (*Tool, error)
List() []*Tool
Execute(ctx context.Context, name string, args map[string]interface{}) (interface{}, error)
}Implementation: In-memory registry with validation.
Purpose: Query migration status
Why second: Most common operation, read-only (safe)
Schema:
{
"name": "migration_status",
"description": "Get current status of a migration",
"inputSchema": {
"type": "object",
"properties": {
"migration_id": {"type": "string", "description": "Migration ID"}
},
"required": ["migration_id"]
}
}Response:
{
"migration_id": "mig-123",
"status": "in_progress",
"progress": {
"total_records": 10000,
"migrated_records": 5000,
"percentage": 50.0
},
"started_at": "2026-02-22T10:00:00Z"
}Purpose: List all migrations
Why second: Discovery operation, read-only
Schema: Supports filtering by status, date range
Purpose: Get schema mapping recommendations
Why second: Helps AI assistants guide users
Input: Source schema, target type
Output: Recommended field mappings, type conversions
Purpose: Start a new migration
Why third: Write operation, requires authorization
Security: Require API key or OAuth token
Purpose: Stop in-progress migration
Why third: Write operation, irreversible
Purpose: Run validation checks
Why third: Can be expensive, rate limit
Purpose: Stream progress updates
Why optional: Requires WebSocket/SSE, complex
Purpose: Query migration logs
Why optional: Sensitive data, careful filtering needed
Purpose: Get performance metrics
Why optional: Requires metrics backend
- Day 1-2: Research MCP specification, choose SDK
- Day 3-4: Implement MCP server skeleton
- Day 5: Implement tool registry
- Day 6-7: Add logging + security middleware
- Day 1-2: migration_status tool
- Day 3: list_migrations tool
- Day 4-5: schema_recommendation tool
- Day 6-7: Testing with mock AI assistant
- Day 1-2: start_migration tool (with auth)
- Day 3: stop_migration tool
- Day 4: validate_migration tool
- Day 5-7: Security audit + penetration testing
- Day 1-2: Error message improvements
- Day 3-4: User documentation
- Day 5: Example conversations
- Day 6-7: Beta testing with real AI assistants
- ❌ BAD:
tools.go(500 lines, all tools) - ✅ GOOD:
status_tool.go,list_tool.go,start_tool.go(each <150 lines)
- Define input schema explicitly
- Include descriptions for all fields
- Provide examples
- Validate inputs before execution
- No secrets in responses
- Input validation (whitelist, not blacklist)
- Rate limiting per client
- Audit logging for all operations
- Unit tests for tool logic
- Integration tests with mock AI assistant
- Recorded conversations for regression testing
- Security penetration testing
- If stuck for >1 hour, stop and reassess
- Write failing test to isolate issue
- Ask for help with specific error message
- Never commit broken code "to debug later"
Impact: Database credentials exposed
Mitigation:
- Security review before any tool
- Automated secret scanning in CI
- Penetration testing
- Bug bounty program
Impact: Slow responses, timeouts
Mitigation:
- Caching for read operations
- Pagination for large result sets
- Rate limiting
- Performance benchmarks
Impact: AI assistants break after update
Mitigation:
- Semantic versioning
- Backward compatibility for 1 major version
- Deprecation warnings
- Migration guide
Impact: Unauthorized operations
Mitigation:
- Explicit authorization for write operations
- Confirmation dialogs for dangerous operations
- Audit trail
- Rollback capability
- All tools respond in <500ms (p95)
- Zero security vulnerabilities (pen test passed)
- 90%+ test coverage
- Works with Claude, GPT-4, Gemini
- AI assistants can complete migration without human intervention
- Clear error messages with suggestions
- Progress updates every 5 seconds
- Easy to troubleshoot issues
- 10+ AI assistants integrated in first month
- Documentation complete with examples
- Community contributions (tools, extensions)
Start with Layer 1, Item 1.1: MCP Server Skeleton
File: internal/mcp/server.go
Lines of Code: ~150 (interface + minimal HTTP server)
Tests: internal/mcp/server_test.go (~100 lines)
Commit Message: "Add MCP server skeleton (Layer 1, Item 1.1)"
Why this first:
- Smallest surface area (just protocol handling)
- No external dependencies (pure Go HTTP+JSON)
- All other components depend on it
- Easy to test in isolation
Ready to implement? Let's start with the MCP server skeleton.