Skip to content

Conversation

Tyler-Hardin
Copy link

When multiple crates with index.html are found, now prefers the directory that matches the crate name exactly (with hyphens converted to underscores). Previously it would crash.

Current behavior:

tyler@asus:~/rust-docs-mcp-server$ git checkout upstream/main -q
tyler@asus:~/rust-docs-mcp-server$ OPENAI_API_BASE="http://localhost:11434/v1" OPENAI_API_KEY="sk-local" EMBEDDING_MODEL="mxbai-embed-large:latest" LLM_MODEL="qwen3-coder:30b-a3b-q8_0" cargo run -- clap
   Compiling rustdocs_mcp_server v1.3.1 (/home/tyler/rust-docs-mcp-server)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.02s
     Running `target/debug/rustdocs_mcp_server clap`
Target Spec: clap, Parsed Name: clap, Version Req: *, Features: None
Cache file path: "/home/tyler/.local/share/rustdocs-mcp-server/clap/_/no_features/embeddings.bin"
Cache file not found. Will generate.
Proceeding with documentation loading and embedding generation.
Loading documents for crate: clap (Version Req: *, Features: None)
Error: DocLoader(CargoLib(Expected exactly one subdirectory containing index.html within '/tmp/nix-shell.N6frLD/.tmp9Y1mXf/doc', but found 2. Cannot determine the correct documentation path.))

With fix:

tyler@asus:~/rust-docs-mcp-server$ git checkout fixclap -q
tyler@asus:~/rust-docs-mcp-server$ OPENAI_API_BASE="http://localhost:11434/v1" OPENAI_API_KEY="sk-local" EMBEDDING_MODEL="mxbai-embed-large:latest" LLM_MODEL="qwen3-coder:30b-a3b-q8_0" cargo run -- clap
   Compiling rustdocs_mcp_server v1.3.1 (/home/tyler/rust-docs-mcp-server)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.47s
     Running `target/debug/rustdocs_mcp_server clap`
Target Spec: clap, Parsed Name: clap, Version Req: *, Features: None
Cache file path: "/home/tyler/.local/share/rustdocs-mcp-server/clap/_/no_features/embeddings.bin"
Cache file not found. Will generate.
Proceeding with documentation loading and embedding generation.
Loading documents for crate: clap (Version Req: *, Features: None)
Looking for documentation in: /tmp/nix-shell.N6frLD/.tmpzuexAF/doc
Target crate directory name: clap
  Found directory: src
    -> No index.html
  Found directory: search.desc
    -> No index.html
  Found directory: trait.impl
    -> No index.html
  Found directory: type.impl
    -> No index.html
  Found directory: static.files
    -> No index.html
  Found directory: clap
    -> Has index.html
    -> MATCHES target crate name!
Using documentation path: /tmp/nix-shell.N6frLD/.tmpzuexAF/doc/clap
[DEBUG] Found 84 total HTML files initially.
[DEBUG] Filtered down to 73 files to process.
Finished document loading. Found 70 final documents.
Loaded 70 documents.
Generating embeddings...
Finished generating embeddings. Successfully processed 61 documents (110459 tokens).
Embedding generation cost for 110459 tokens: $0.002209
Saving generated documents and embeddings to: "/home/tyler/.local/share/rustdocs-mcp-server/clap/_/no_features/embeddings.bin"
Warning: Embedding not found for document path: parser/struct.RawValues.html. Skipping from cache.
Warning: Embedding not found for document path: parser/struct.ValuesRef.html. Skipping from cache.
Warning: Embedding not found for document path: parser/struct.IdsRef.html. Skipping from cache.
Warning: Embedding not found for document path: builder/struct.Arg.html. Skipping from cache.
Warning: Embedding not found for document path: parser/struct.ArgMatches.html. Skipping from cache.
Warning: Embedding not found for document path: parser/struct.Indices.html. Skipping from cache.
Warning: Embedding not found for document path: builder/struct.Str.html. Skipping from cache.
Warning: Embedding not found for document path: builder/struct.Command.html. Skipping from cache.
Warning: Embedding not found for document path: parser/struct.Values.html. Skipping from cache.
Cache saved successfully (61 items).
Initializing server for crate: clap (Version Req: *, Features: None)
Rust Docs MCP server starting via stdio...

The warnings are due to TOKEN_LIMIT.

When multiple crates with index.html are found, now prefers the directory
that matches the crate name exactly (with hyphens converted to underscores).
Previously it would crash.
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.

1 participant