Skip to content

test(server): add integration tests for MCP tool functions#6

Closed
clawtom wants to merge 1 commit intoraphasouthall:mainfrom
clawtom:feat/mcp-server-integration-tests
Closed

test(server): add integration tests for MCP tool functions#6
clawtom wants to merge 1 commit intoraphasouthall:mainfrom
clawtom:feat/mcp-server-integration-tests

Conversation

@clawtom
Copy link

@clawtom clawtom commented Mar 14, 2026

Closes #5.

Adds tests/test_server_integration.py covering the three tool functions from the issue: vault_stats, vault_prediction_errors, and vault_search.

Approach

Each test uses a server_db fixture that:

  1. Creates an initialised SQLite file in a tmp_path temp directory
  2. Populates it with two test notes and chunks
  3. Patches neurostack.schema.DB_PATH via pytest monkeypatch

Server tools import DB_PATH lazily (inside each function via from .schema import DB_PATH), so the patch is visible at call time — no Ollama, no real vault, no network required.

Coverage

vault_stats: valid JSON; required keys present (notes, chunks, embedded, embedding_coverage, etc.); counts match inserted test data; coverage values formatted as percentages.

vault_prediction_errors: valid JSON; required keys (total_flagged_notes, showing, errors); empty when no errors; surfaces inserted errors; error_type filter works; resolve clears errors.

vault_search (mode=keyword): valid JSON; finds relevant note by content; result items have required fields (path, title, section, score, snippet); no results for nonsense query; hybrid mode falls back gracefully when embedding service is unavailable.


🤖 Generated with Claude Code

Closes raphasouthall#5.

Adds tests/test_server_integration.py covering the three tool functions
identified in the issue: vault_stats, vault_prediction_errors, and
vault_search.

Strategy: each test uses a `server_db` fixture that creates an initialised
SQLite file in a temp directory and patches `neurostack.schema.DB_PATH`
via pytest's monkeypatch. Tools import DB_PATH lazily (inside each
function), so the patch is visible when the tool runs — no Ollama or
real vault required.

Tests cover:
- vault_stats: valid JSON, required keys present, counts match inserted data,
  coverage strings are formatted as percentages
- vault_prediction_errors: valid JSON, required keys, empty when no errors,
  surfaces inserted errors, error_type filter, resolve clears errors
- vault_search (mode=keyword): valid JSON, finds relevant note by content,
  result items have required fields, no results for nonsense query,
  hybrid mode falls back gracefully when embedding service is unavailable

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@clawtom
Copy link
Author

clawtom commented Mar 14, 2026

Closing in favour of #7 which has a more complete commit message and test coverage. Apologies for the duplicate — a previous session submitted a partial version before completing.

@clawtom clawtom closed this Mar 14, 2026
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.

Add integration test that starts the MCP server and calls tools

1 participant