Skip to content

mcp: tool calls during scan-in-progress return empty without indication #371

@justrach

Description

@justrach

Symptom

A fresh MCP server with no preloaded snapshot answers `codedb_search` / `codedb_outline` / `codedb_word` / etc. with empty / "file not indexed" responses while the initial scan is still walking the project. Agents read these as authoritative — the call ran, the answer is just empty — and move on.

Repro

```
{
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"1"}}}'
printf '%s\n' '{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}'
printf '%s\n' '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"codedb_status"}}'
printf '%s\n' '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"codedb_search","arguments":{"query":"handleSearch"}}}'
sleep 2
printf '%s\n' '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"codedb_search","arguments":{"query":"handleSearch"}}}'
} | CODEDB_ROOT=/path/to/repo ~/bin/codedb mcp
```

id=2 status: `files: 0`. id=3 search: `0 results`. id=4 (after 2s): `2 results`.

Failing test

`tests.test.issue-bug2: tool calls during scan-in-progress hint at scan state`

Fix

Append a one-line "scan still in progress (state=...)" note when the tool's output looks empty/unindexed AND `getScanState() != .ready`.

Labels

bug, ux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions