Skip to content

feat(mcp-server): add init_docset MCP tool - #28

Merged
mrsimpson merged 3 commits into
mainfrom
claude/add-docset-init-tool-67LEv
Mar 10, 2026
Merged

feat(mcp-server): add init_docset MCP tool#28
mrsimpson merged 3 commits into
mainfrom
claude/add-docset-init-tool-67LEv

Conversation

@mrsimpson

Copy link
Copy Markdown
Collaborator

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

claude and others added 3 commits March 10, 2026 08:58
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
mrsimpson force-pushed the claude/add-docset-init-tool-67LEv branch from 04c7b0a to 8f8acd5 Compare March 10, 2026 07:58
@mrsimpson
mrsimpson merged commit 59c72c2 into main Mar 10, 2026
1 check passed
@mrsimpson
mrsimpson deleted the claude/add-docset-init-tool-67LEv branch March 10, 2026 08:00
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.

2 participants