Skip to content

docs(skill): prefer MCP server / CLI over grep for external-agent search - #265

Open
sebastianbraun25 wants to merge 10 commits into
VectifyAI:mainfrom
sebastianbraun25:feat/issue-264-skill-update
Open

docs(skill): prefer MCP server / CLI over grep for external-agent search#265
sebastianbraun25 wants to merge 10 commits into
VectifyAI:mainfrom
sebastianbraun25:feat/issue-264-skill-update

Conversation

@sebastianbraun25

Copy link
Copy Markdown

Note

This PR was created in collaboration between a human and AI: implementation, tests, and
PR text were created by an AI assistant under the guidance and review of the human author.

Problem

skills/openkb/SKILL.md currently tells external agents (GitHub Copilot, Claude Code,
Cursor, etc.) to fall back to grep -r for keyword search and to read wiki/index.md in
full for taxonomy/document discovery. Neither is ideal at scale: grep has no relevance
ranking (a document that merely repeats a generic word often outranks one actually about
the topic), and reading the full index.md costs an increasing number of tokens as the KB
grows, with no guarantee the agent's attention lands on the one-liner that actually matches.

Since #260/#261 (CLI) and #262/#263 (MCP server), the same taxonomy-browsing and
tiered-search capability the internal openkb query/openkb chat agent uses is also
reachable from outside the OpenKB process — but the skill didn't mention either yet.

Solution / Changes

skills/openkb/SKILL.md updated, in order of preference:

  1. MCP available: list_taxonomy then scope-restricted search_wiki — mirrors the
    internal agent's own search strategy exactly.
  2. No MCP, shell available: openkb list-taxonomy/openkb search (same underlying
    functions, CLI-exposed).
  3. Neither available: fall back to reading wiki/index.md in full / grep -r, as
    before.

Specifically:

  • "See what's available": leads with list_taxonomy (MCP) / openkb list-taxonomy (CLI)
    ahead of reading the full index.md.
  • "Read content" table: two new rows for search_wiki (MCP) / openkb search (CLI) ahead
    of the existing grep row, plus a short note on why BM25 ranking beats raw grep
    occurrence count (with a concrete "case" vs. "in case of error" example).
  • "When the KB doesn't have the answer" and the openkb query LLM-cost guidance updated to
    reference the new search options alongside grep.

Documentation-only change — no behavior change to the underlying tools/CLI/MCP server
(#259/#261/#263), so no test updates needed (no existing test reads this bundled
SKILL.md's content).

Testing

  • pytest full suite green — 1283 passed (18 pre-existing, environment-specific Windows
    failures unrelated to this change are unaffected and unchanged in count). ruff/mypy
    are no-ops for a Markdown-only diff but were run for completeness.

Dependencies

Issues

Resolves #264

Sebastian Braun added 10 commits August 28, 2026 16:25
Adds a dependency-free BM25 full-text index (openkb/fulltext_index.py) over concepts/entities/summaries pages, exposed as a new search_wiki tool alongside index.md-driven navigation in build_query_agent. Additive hybrid retrieval: surfaces pages whose one-line index summary omits a buried detail, without replacing existing navigation. Resolves VectifyAI#233.
…axonomy accessors

- fulltext_index.py: extract shared _BM25Scorer from WikiFullTextIndex
  (no behavior change), add Locator (line/page) on SearchHit, add
  TieredWikiSearch with three independent tiers over summaries/ (briefs +
  full body) and sources/ (whole-file .md + per-page PageIndex .json,
  never the whole long doc as one BM25 unit).
- frontmatter.py: add resolve_description()/body_only() shared helpers
  (kept separate from agent.compiler._resolve_description, which is under
  active unrelated development).
- agent/tools.py: add list_taxonomy_items()/get_taxonomy_item() for
  semantic browsing of persisted concepts/entities (pending candidates
  in PendingTopicsStore are structurally excluded).
- No wiring into CLI/MCP/query-agent yet (follow-up PRs); WikiFullTextIndex
  and agent.tools.search_wiki keep their existing signature/behavior.
…o query/chat agent

- cli.py: new 'openkb list-taxonomy [--kind concept|entity] [--json]' and
  'openkb search <query> [--scope briefs,summaries,sources] [--top-k N]
  [--json]' commands.
- agent/tools.py: search_wiki now searches the new tiered
  briefs/summaries/sources index instead of the old combined
  concepts+entities+summaries index (concepts/entities move to the new
  list_taxonomy tool - semantic browsing, not keyword search); new
  list_taxonomy() text-formatting wrapper over list_taxonomy_items().
- agent/query.py (+ chat.py via tool inheritance): wires list_taxonomy and
  the retiered search_wiki in as agent tools; search strategy instructions
  updated to browse taxonomy first, then use scope-restricted search_wiki
  as a keyword fallback.
- README.md: updated hybrid-retrieval paragraph and command table.
- Intentional behavior change to agent.tools.search_wiki (scope param,
  concepts/entities out of scope, output grouped by tier) - safe since
  VectifyAI#234/VectifyAI#259, which introduced it, are not yet merged upstream; existing
  tests updated to the new contract.
- New openkb/mcp_server.py: FastMCP server with list_taxonomy and
  search_wiki tools, thin wrappers over agent.tools.list_taxonomy_items
  and fulltext_index.TieredWikiSearch. No index cache (rebuilt fresh per
  call, same as the CLI/agent). find_kb_dir() mirrors cli.py's KB
  resolution as a lightweight standalone copy so starting the MCP server
  doesn't pull in cli.py's much heavier import chain.
- pyproject.toml: add explicit 'mcp==1.27.1' pin (already resolved
  transitively via openai-agents/PR VectifyAI#207 for MCP client support; this
  formalizes the now-also-server-side usage) and a new 'openkb-mcp'
  console script entry point. uv.lock regenerated accordingly.
- README.md: new 'Using with an MCP client' section with a sample
  mcpServers config.
- tests/test_mcp_server.py: KB resolution (cwd walk, global default
  fallback, not-found), list_taxonomy/search_wiki tool behavior, scope
  validation.
- skills/openkb/SKILL.md: 'See what's available' now leads with
  list_taxonomy (MCP) / 'openkb list-taxonomy' (CLI) before falling back
  to reading the full index.md.
- 'Read content' table adds search_wiki (MCP) / 'openkb search' (CLI)
  rows ahead of the existing grep fallback, with a note on why BM25
  ranking beats raw grep occurrence count.
- 'When the KB doesn't have the answer' and the openkb-query guidance
  updated to reference the new search options alongside grep.
- Documentation-only change; no behavior change to the underlying
  tools/CLI/MCP server (VectifyAI#259/VectifyAI#261/VectifyAI#263).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(skill): prefer MCP server / CLI over grep for external-agent search

1 participant