Add MCP tools for migration inspection (bd-627d Phase 3)
- Add inspect_migration() tool - calls bd migrate --inspect --json - Add get_schema_info() tool - calls bd info --schema --json - Implements abstract methods in BdClientBase - CLI client calls commands directly - Daemon client raises NotImplementedError (rare admin commands) Phase 3 complete. Agents can now inspect migrations via MCP before running them. Amp-Thread-ID: https://ampcode.com/threads/T-de7e1141-87ac-4b4a-9cea-1b7bc4d51da9 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -18,7 +18,9 @@ from beads_mcp.tools import (
|
||||
beads_blocked,
|
||||
beads_close_issue,
|
||||
beads_create_issue,
|
||||
beads_get_schema_info,
|
||||
beads_init,
|
||||
beads_inspect_migration,
|
||||
beads_list_issues,
|
||||
beads_quickstart,
|
||||
beads_ready_work,
|
||||
@@ -512,6 +514,39 @@ async def debug_env(workspace_root: str | None = None) -> str:
|
||||
return "".join(info)
|
||||
|
||||
|
||||
@mcp.tool(
|
||||
name="inspect_migration",
|
||||
description="Get migration plan and database state for agent analysis.",
|
||||
)
|
||||
@with_workspace
|
||||
async def inspect_migration(workspace_root: str | None = None) -> dict:
|
||||
"""Get migration plan and database state for agent analysis.
|
||||
|
||||
AI agents should:
|
||||
1. Review registered_migrations to understand what will run
|
||||
2. Check warnings array for issues (missing config, version mismatch)
|
||||
3. Verify missing_config is empty before migrating
|
||||
4. Check invariants_to_check to understand safety guarantees
|
||||
|
||||
Returns migration plan, current db state, warnings, and invariants.
|
||||
"""
|
||||
return await beads_inspect_migration()
|
||||
|
||||
|
||||
@mcp.tool(
|
||||
name="get_schema_info",
|
||||
description="Get current database schema for inspection.",
|
||||
)
|
||||
@with_workspace
|
||||
async def get_schema_info(workspace_root: str | None = None) -> dict:
|
||||
"""Get current database schema for inspection.
|
||||
|
||||
Returns tables, schema version, config, sample issue IDs, and detected prefix.
|
||||
Useful for verifying database state before migrations.
|
||||
"""
|
||||
return await beads_get_schema_info()
|
||||
|
||||
|
||||
async def async_main() -> None:
|
||||
"""Async entry point for the MCP server."""
|
||||
await mcp.run_async(transport="stdio")
|
||||
|
||||
Reference in New Issue
Block a user