Repository navigation
feat(narratives): report whether the MCP server serves every required tool - #550
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces the version-based MCP server capability checks with a strict required-tools check. It defines a set of six required tools (REQUIRED_TOOLS) that the agent needs to function correctly. The Capabilities class is updated to track missing tools and report a support status (supported, unsupported, or unknown) instead of a version generation string. A new function warn_on_missing_tools is introduced to log warnings when required tools are missing during the discovery phase. Tests, smoke scripts, and documentation are updated accordingly to reflect these changes. No review comments were provided, so there is no feedback to address.
juliawu
left a comment
There was a problem hiding this comment.
Thank you! This is a nice change!
Overview
On
main,/agent/healthreportsmcp.generation, a version label derived from the presence ofget_variable_metadataalone. A server that lacks one of the search or observation tools is still reported as1.3.x-or-later, and because the agent declares only the tools the server lists, the model is never offered the missing tool and nothing records the gap.This change defines the six required MCP 1.3.x tools (
REQUIRED_TOOLS), addsrequired_tools_presentandmissing_toolstoCapabilities, reportsmissing_toolsin/agent/health, logs a warning once per turn when required tools are missing, and makes the post-deploy smoke test fail in that case.It also replaces
mcp.generationwithmcp.support, which issupported,unsupported, orunknown. The old label named a server version, but the code never reads a version: it only checks which tools are listed. A later server that drops a required tool, or a server of any version that serves all six, would be mislabeled by a version name. A server that providesget_variable_metadatawithout all six tools, or a 1.2.x server (which only provides two tools), is now reported asunsupported. The agent loop that follows this PR requires all six tools (the server-side fetch functions in the upcoming per-turn table cache PR call the three observation tools directly), and the remaining 1.2.x parsing inmcp/data_utils.pywill be removed later in the sequence./agent/healthanddeploy/smoke.shuse the new fields now, the discovery phase uses the sameCapabilitiesproperties, and theTOOL_*constants will be used by the server-side fetch functions in the upcoming per-turn table cache PR.Related Issues
Follows #544 and #547 (independent of #549).
Changes Made
mcp/capabilities.py: Defines constants for the six required MCP tools (TOOL_*andREQUIRED_TOOLS), addsrequired_tools_presentandmissing_toolstoCapabilities, replacesgenerationwithsupport(typed as aLiteralofsupported,unsupported, andunknown), reportssupportandmissing_toolsin the/agent/healthsummary, and addswarn_on_missing_tools()to log a warning when required tools are missing.workflows/chat_pipeline.py: Callswarn_on_missing_tools()during the discovery phase after fetching the tool list so missing tools are logged once per turn.deploy/smoke.sh: The capability check now fails, naming the missing tools, when/agent/healthreports that a required tool is missing, and it reportsmcp.support.docs/deployment.md,docs/architecture.md,AGENTS.md: Documents the new/agent/healthfields, themcp.supportvalues, and what happens when required tools are missing, and notes the required-tool check in themcp/layout entry.Testing Done
pnpm test:agent(uv run pytest): 910 passed (907 onmain; 3 tests added).pnpm test:ui(vitest run): 26 files, 286 passed.pnpm lint:ui(tsc --noEmitandbiome check): passed.pnpm lint:agent(ruff format --check,ruff check, andmypy --strict): passed across all 72 source files.pnpm build:ui: passed.pnpm lint:deploy:terraform fmt -check,pnpm run lint:shell, andpnpm run lint:dockerpassed (terraform validatefails with a pre-existing GCS backend configuration error onmain; no Terraform files were modified).deploy/smoke.shcheck 3: thec3function was extracted (sed -n '/^c3() {/,/^}/p' deploy/smoke.sh) and run withcurl_cmdstubbed to return a recorded/agent/healthresponse. The full six-tool response passed (6 tools, support supported); a two-tool response missingget_variable_metadataandsearch_child_indicatorsfailed and named both; a response from before this change, withoutsupport, failed and said the field is absent.shellcheckreports the same findings onsmoke.shas onmain.Checklist:
describe()payloads inmcp/capabilities_test.pyand the expected/agent/healthpayload inserver/routes/system_test.pywere updated for the new fields, and the default tool list inworkflows/chat_pipeline_test.pynow contains the six required tools)Manual
Verified with
pnpm dev:agentagainst public Data Commons (MCP_SERVER_URL=https://api.datacommons.org/mcp):GET /agent/healthon a fresh server returnedsupport: "unknown",tool_count: 0, and all six tools inmissing_tools.tools/listrefresh, and a laterGET /agent/healthreturnedsupport: "supported",tool_count: 6, andmissing_tools: [].POST /agent/chat/stream. The turn calledsearch_indicatorsandget_observations, streamed data, citations, a chart config, and follow-up questions, and completed normally with no missing-tools warning in the server log.Risk & Rollback
/agent/healthgainssupportandmissing_tools, and no longer returnsgeneration. Any monitoring that readsmcp.generationmust switch tomcp.support.deploy/smoke.shnow fails against a backend that lacks any required tool, including any 1.2.x backend. Incloudbuild/deploy-stamp.yaml, the smoke step runs after the new revision is serving, so a failure marks the build as failed without rolling back the revision, and turns still run with the tools the server provides. Turn execution, tool declarations, and the SSE stream are unchanged. Rollback is a clean revert of the PR.Follow-ups
TOOL_*constants to call the observation tools.mcp/data_utils.pywill be removed later in the agent loop sequence.Checklist
AGENTS.mdand followedCODING_GUIDELINES.md, plusFRONTEND.mdfor UI changes.Note: Only Maintainers can approve and merge PRs. Expected initial review time: 3 business days.