feat: track crawl run employee changes and verify dismissals
This commit is contained in:
16
app/mcp.py
16
app/mcp.py
@@ -8,6 +8,8 @@ from app.config import Settings, get_settings
|
||||
from app.db import get_db
|
||||
from app.models import CrawlRun, Employee
|
||||
from app.security import mcp_protected_resource_metadata, require_mcp_auth
|
||||
from app.services.admin_data import run_detail_payload
|
||||
from app.version import BACKEND_VERSION
|
||||
|
||||
router = APIRouter(prefix="/mcp")
|
||||
metadata_router = APIRouter()
|
||||
@@ -47,6 +49,15 @@ TOOLS = [
|
||||
"description": "Return the latest crawl run status.",
|
||||
"inputSchema": {"type": "object", "properties": {}},
|
||||
},
|
||||
{
|
||||
"name": "get_crawl_run_details",
|
||||
"description": "Return detailed employee changes and errors for one crawl run.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {"run_id": {"type": "integer"}},
|
||||
"required": ["run_id"],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -66,7 +77,7 @@ async def mcp_http(
|
||||
if method == "initialize":
|
||||
result = {
|
||||
"protocolVersion": "2024-11-05",
|
||||
"serverInfo": {"name": "miem-employees", "version": "0.1.0"},
|
||||
"serverInfo": {"name": "miem-employees", "version": BACKEND_VERSION},
|
||||
"capabilities": {"tools": {}},
|
||||
}
|
||||
elif method == "tools/list":
|
||||
@@ -95,6 +106,9 @@ def _call_tool(db: Session, name: str, arguments: dict) -> dict:
|
||||
if name == "get_crawl_status":
|
||||
run = db.scalar(select(CrawlRun).order_by(desc(CrawlRun.started_at)).limit(1))
|
||||
return _tool_response(_run_payload(run) if run else {"status": "never_run"})
|
||||
if name == "get_crawl_run_details":
|
||||
run = db.get(CrawlRun, int(arguments["run_id"]))
|
||||
return _tool_response(run_detail_payload(db, run) if run else {"error": "not_found"})
|
||||
raise ValueError(f"Unknown tool: {name}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user