rustytokens MCP test fails: index_create succeeds but search_text returns "no index found" #9

Closed
opened 2026-09-18 21:13:40 +02:00 by endergebnis · 0 comments
Owner

Issue

The rustytokens stdio MCP smoke test fails after updating to the latest version. The index_create tool runs without error, but search_text immediately after returns an error saying no index was found.

Reproduction

  1. Clone rustytokens
  2. Build: cargo build --release
  3. Run the MCP server with a temporary workspace containing a Python file
  4. Call rustytokens__index_create with the workspace path
  5. Call rustytokens__search_text with the same path - returns error: no index found

Expected behavior

search_text should find results after a successful index_create.

Actual behavior

error: no index found for .. Run `rustytokens index create <path>` first.

Environment

  • rustytokens: latest from main (post v0.1.0)
  • Python: 3.13.11
  • ctags: Universal Ctags

Root cause analysis

The MCP server has two different ways of resolving project paths:

  1. Tool arguments: index_create and index_update accept a path argument from the tool call (Path::new(req_str(args, "path", name)?))
  2. CLI parameter: search_text and other search tools use the project parameter from the CLI's --project argument (&cli.project)

When rustytokens serve is called without --project, it defaults to . (current working directory). If index_create is called with a different path (e.g., /tmp/test_ws), the index is created with a key derived from /tmp/test_ws, but search_text looks for an index with a key derived from ..

The project_db_path function uses xxh3 to generate a key from the canonicalized path:

let key = project_key(&canon.to_string_lossy());

So /tmp/test_ws and . produce different keys → different database files → "no index found" error.

Proposed fix

Either:

  1. Add an optional path argument to search_text (like codebase_detect) that overrides the CLI project
  2. Have the MCP server remember the last indexed project and use it for subsequent searches
  3. Always pass the path from index_create to subsequent search calls

Test code reference

tests/test_rustytokens_smoke.py::test_rustytokens_stdio_index_and_search

## Issue The rustytokens stdio MCP smoke test fails after updating to the latest version. The `index_create` tool runs without error, but `search_text` immediately after returns an error saying no index was found. ## Reproduction 1. Clone rustytokens 2. Build: `cargo build --release` 3. Run the MCP server with a temporary workspace containing a Python file 4. Call `rustytokens__index_create` with the workspace path 5. Call `rustytokens__search_text` with the same path - returns `error: no index found` ## Expected behavior `search_text` should find results after a successful `index_create`. ## Actual behavior ``` error: no index found for .. Run `rustytokens index create <path>` first. ``` ## Environment - rustytokens: latest from main (post v0.1.0) - Python: 3.13.11 - ctags: Universal Ctags ## Root cause analysis The MCP server has two different ways of resolving project paths: 1. **Tool arguments**: `index_create` and `index_update` accept a `path` argument from the tool call (`Path::new(req_str(args, "path", name)?)`) 2. **CLI parameter**: `search_text` and other search tools use the `project` parameter from the CLI's `--project` argument (`&cli.project`) When `rustytokens serve` is called without `--project`, it defaults to `.` (current working directory). If `index_create` is called with a different path (e.g., `/tmp/test_ws`), the index is created with a key derived from `/tmp/test_ws`, but `search_text` looks for an index with a key derived from `.`. The `project_db_path` function uses `xxh3` to generate a key from the canonicalized path: ```rust let key = project_key(&canon.to_string_lossy()); ``` So `/tmp/test_ws` and `.` produce different keys → different database files → "no index found" error. ## Proposed fix Either: 1. Add an optional `path` argument to `search_text` (like `codebase_detect`) that overrides the CLI project 2. Have the MCP server remember the last indexed project and use it for subsequent searches 3. Always pass the `path` from `index_create` to subsequent search calls ## Test code reference `tests/test_rustytokens_smoke.py::test_rustytokens_stdio_index_and_search`
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: endergebnis/rustytokens#9