feat(mcp-server): add init_docset MCP tool - #28
Merged
Conversation
Exposes docset initialization directly as an MCP tool so agents can initialize uninitialized docsets without needing to invoke the CLI. The new `init_docset` tool mirrors the CLI `init` command: it downloads and prepares all configured sources (git_repo, local_folder, archive), writes the per-source and overall metadata files, and invalidates the config cache so subsequent `search_docs` calls pick up the new state. - Add `@codemcp/knowledge-content-loader` dependency to mcp-server - Register `init_docset` in both ListTools responses (with/without config) - Implement handler reusing GitRepoLoader / ArchiveLoader / createSymlinks https://claude.ai/code/session_014fPGYkZQTaWzSuLcDejZQD
…bfolder)
Fixes two related bugs in createSymlinks:
1. Path with no trailing slash (eg. /temp/demo): the directory name "demo"
was appended as a subfolder, producing demo-docset/demo/ instead of
exposing the contents at the docset root.
2. Path with trailing slash (eg. /temp/demo/): split("/").pop() returned
an empty string, which fell back to the hardcoded name "unknown",
producing demo-docset/unknown/.
Root cause: the function symlinked the source directory itself, deriving
the link name from the path string.
Fix: iterate over the entries inside the source directory and create one
symlink per entry directly inside targetDir. This matches the behaviour
of git_repo and archive sources, which also populate the docset root
without an extra named subfolder. The trailing-slash case is a non-issue
because we now read directory contents rather than parsing the path string.
https://claude.ai/code/session_014fPGYkZQTaWzSuLcDejZQD
the init tool should now be resolved automagically
mrsimpson
force-pushed
the
claude/add-docset-init-tool-67LEv
branch
from
March 10, 2026 07:58
04c7b0a to
8f8acd5
Compare
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.
Exposes docset initialization directly as an MCP tool so agents can
initialize uninitialized docsets without needing to invoke the CLI.
The new
init_docsettool mirrors the CLIinitcommand: it downloadsand prepares all configured sources (git_repo, local_folder, archive),
writes the per-source and overall metadata files, and invalidates the
config cache so subsequent
search_docscalls pick up the new state.@codemcp/knowledge-content-loaderdependency to mcp-serverinit_docsetin both ListTools responses (with/without config)https://claude.ai/code/session_014fPGYkZQTaWzSuLcDejZQD