Repository navigation
feat: find_documents, opt-in library discovery for the MCP server (0.46.0) - #40
Merged
Merged
Conversation
…oots - load_cache treats any failure as an unusable cache (OverflowError for an Infinity size, RecursionError for deep nesting) and rejects a non-finite listed_at; a list from the future counts as stale. A damaged cache file no longer stops the server at warm(). - scan_root skips and counts (skipped_files) a PDF that cannot be stat'ed or whose path is not valid UTF-8: such a path broke save_cache and, returned to the agent, killed the stdio transport on serialization. skipped_files is persisted (cache schema 2) and reported per root. - create_local_mcp_server loads .env before reading DATASHEETINDEX_LIBRARY_ROOTS and the cache's output dir.
…d entries A root or cached path that is not valid UTF-8 no longer reaches the cache name, tool description or JSON-RPC writer; a child whose type cannot be read is counted in skipped_folders; docs say .env applies to a source checkout only.
…n advanced section
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
Adds
find_documents, an opt-in MCP tool that lists PDFs under configured library folders, so an agent can find the right datasheet when its own shell cannot see the library. Release 0.46.0.The case that prompted it: the MCP server runs on a Windows host and can read a network share of ~1,400 PDFs, but the agent's shell runs in a Linux dev container and cannot. Only the server can see the library, so only the server can do the finding; choosing the PDF stays with the agent.
What changes
DATASHEETINDEX_LIBRARY_ROOTS: one or more folders (UNC, local, mapped drive), separated byos.pathsep. Unset or blank: nothing changes, the server serves its five tools. Set: a sixth tool appears and the server instructions gain one sentence pointing the agent at it..envis honoured on a source checkout.find_documents(query, limit=50, refresh=false): case-insensitive AND match of whitespace-separated terms against each PDF's path below its root (folders and file name; never the root itself). Returns full server-side paths, ready forbuild_datasheetunchanged, plusmodifiedandsize_kb;total_matchesandtruncatedtell the agent to narrow the query; per-rootstatus(ok/refreshing/scanning/unavailable),listed_at,skipped_folders,skipped_files.<output dir>/library, valid for one day, written atomically. Stale or missing lists are rescanned in a background thread at server start, so a slow share is scanned before the agent asks. A stale list is served at once while it refreshes; only a root with no list (orrefresh=true) makes a call wait, bounded at 30 s.Design decisions
create_datasheet_tool_defs()/create_datasheet_tools_server(): embedders did not opt into a filesystem lister, and their five-tool surface is unchanged.tools/defs.pyandtools/registry.pyare untouched.build_datasheet's contract is unchanged and an agent on a different OS never joins path segments itself._on_call_toolcover it unchanged.Testing
tests/test_library.py(new) andtests/test_mcp_server.py: matching, scanning (symlinks/junctions, unreadable folders and files, non-UTF-8 names), cache round-trip and damage, background refresh and bounded waits with an injected clock, overlapping roots, opt-in registration,.envloading, end-to-endfind_documents->build_datasheet.[llm]extra andsdkgroup against a live gateway: 1399 passed, 0 skipped.unavailable, returned paths open inbuild_datasheet,limit: 501rejected by schema validation, nothing written to stdout.