feat(mcp): ensure_kb + ground_paper grounding tools (+ fastmcp 3.x test fix)#28
Merged
Conversation
…reen baseline) fastmcp 3.2.4 removed mcp._tool_manager; the @mcp.tool() functions remain directly callable at module level. Replace _tool_manager._tools[name].fn access with a module-attr lookup (_tool_fn) and mcp._list_tools() for enumeration; accommodate generate_report's new message_id kwarg in the fake engine; refresh stale tool-count constants (15->49; ==->>= for the non-exhaustive EXPECTED_TOOLS). 8 failing -> 21 passing. Pre-existing issue, surfaced while adding grounding tools. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two thin MCP tools for ASB grounding, composing existing tools: - ensure_kb(doi, mode='paper'): idempotently create + ingest a per-paper KB named asb-paper-<doi> (matches the ASB binder slug). Skips re-ingest when the KB already has chunks. Reuses create_knowledge_base + add_dois_to_kb. - ground_paper(doi, question, tier='paper'|'si'): ensure_kb, then a RAG query (generate_report) scoped to that KB; tier='si' steers toward the SI. Both degrade gracefully to _json_error; registered in _TOOL_NAMES. 14 new tests. Perspicacite side of the asb-skill-collections grounding consolidation: /ground and the binder can now install + query a skill's source-paper KB via the MCP. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
lfnothias
added a commit
that referenced
this pull request
Jun 23, 2026
PR #28 added the ensure_kb and ground_paper MCP tools but did not add their required-argument fixtures to _TOOL_ARGS, so test_tool_inventory invoked them with no args and raised TypeError, failing CI. Add the missing entries using the existing fake-DOI convention. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the Perspicacité side of the ASB grounding consolidation — two thin MCP tools so an agent (via the asb-skill-collections
/groundcommand or the bundled binder) can install + query a skill's source-paper KB on demand:ensure_kb(doi, mode="paper")— idempotently create + ingest a per-paper KB namedasb-paper-<doi>(slug matches the ASB binder convention exactly). Returnsstatus: "exists"(skips re-ingest when the KB already has chunks) or"created"with chunk counts. Reusescreate_knowledge_base+add_dois_to_kb.ground_paper(doi, question, tier="paper"|"si")—ensure_kb, then a RAG query (generate_report) scoped to that paper's KB.tier="si"steers retrieval toward the supplementary information. Returns{kb_slug, answer, sources}.Both are thin compositions of existing tools, degrade gracefully to
_json_error(never raise), and are registered in_TOOL_NAMES.Why
This is the MCP-owned, on-first-query grounding path designed in the asb-skill-collections consolidation (asb side already merged: HolobiomicsLab/asb-skill-collections#5, #6). The asb packs ship the
/groundcommand + binder; these tools are what make the KB "auto-install + query via the MCP" in-session.Commits
test(mcp)— fastmcp 3.x test migration (separate commit). The MCP test suite was red at baseline (8/21 failing):fastmcp3.2.4 removedmcp._tool_manager, which the tests still used. Migrated to module-attr tool access (_tool_fn) +mcp._list_tools()enumeration; accommodatedgenerate_report's newmessage_idkwarg; refreshed stale tool-count constants. 8 failing → 21 passing. (Pre-existing issue, surfaced while adding these tools.)feat(mcp)— the two tools + 14 new tests (idempotency, create path, zero-chunk re-ingest, graceful failure, SI hint, error propagation).Suite: 35 passed (
tests/test_mcp_server.py, via.venv).Notes / review points
generate_reporthas nocontextparam, so thetier="si"hint is prepended to the query string rather than passed separately. If you'd prefer a first-classcontext/SI-steering arg ongenerate_report, say so and I'll wire it.ensure_kb'smodeparam is reserved (currently unused) to match the agreed signature./ground, but if you want async/background ingest, that's a follow-up.🤖 Generated with Claude Code