feat(mcp): add update and embed tools#632
Open
estrenuo wants to merge 15 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a new describe block with a real on-disk collection (alpha.md + beta.md), isolated SQLite DB, and YAML config for upcoming update/embed tool tests. Includes mcpRequest helper and initSession() per-test helper. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the stub handler with real re-indexing logic using listCollections + reindexCollection. Adds runShellCommand helper for optional pre-index shell commands. Updates fixture beforeAll to use createStore schema initialization instead of initTestDatabase to ensure documents_fts schema is compatible with reindexCollection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <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.
Summary
updateandembedso an agent can re-index collections and generate vector embeddings without shelling out to the CLI.updateaccepts optionalcollection(scope to one) andrunUpdateCommand(opt-ingit pulletc.); failing update_command marks that collection skipped and continues.embedis incremental by default; opt-inforce: truewipes and regenerates all vectors.buildInstructionsupdated: existingqmd embedCLI hints replaced with tool-styleCall the \embed` tool` plus a new "Maintenance:" tool list.Implementation notes
reindexCollectionandgenerateEmbeddingsfromsrc/store.tsviastore.internal.progressNotification— the agent flow is short by design.EmbedResult.docsProcessedis mapped todocsEmbeddedat the tool boundary so the public MCP shape is stable independent of the internal field name.runShellCommand(private helper) executes the YAML-configured update_command viash -c. Documented as trusted-source-only.Test plan
npx vitest run test/mcp.test.ts— 65/65 passing.qmd-featMCP server registered locally):tools/listshowsupdateandembedalongside existing tools.updatewith no args re-indexedmyrag(2 new, 5 updated, 454 unchanged, 5 orphaned cleaned, 133ms; surfacedneedsEmbedding: 7).embedwith no args embedded the 7 pending docs (120 chunks, 0 errors, 14.2s, force=false).runShellCommandsecurity note (src/mcp/server.ts, JSDoc above the helper) — confirm the trusted-source-only wording is acceptable.docsProcessed→docsEmbeddedis acceptable as the public MCP shape.🤖 Generated with Claude Code