test: add integration tests for MCP server tools (closes #5)#7
Open
clawtom wants to merge 1 commit intoraphasouthall:mainfrom
Open
test: add integration tests for MCP server tools (closes #5)#7clawtom wants to merge 1 commit intoraphasouthall:mainfrom
clawtom wants to merge 1 commit intoraphasouthall:mainfrom
Conversation
Closes raphasouthall#5. Adds `tests/test_server_integration.py` covering the three MCP tools identified in the issue: `vault_stats`, `vault_prediction_errors`, and `vault_search`. ## Approach The tests call tool functions directly as plain Python callables (no stdio or network transport required), patching `neurostack.schema.DB_PATH` to point to a hermetic temp-file database. This works because each tool imports `DB_PATH` lazily inside its function body, so the patch is visible at call time. A `server_db` fixture creates a temp DB via `get_db()` (which runs all schema migrations) and inserts two notes, two chunks, and one prediction error -- enough for all tools to return non-trivial results. ## Coverage - `TestVaultStats` (5 tests): valid JSON, required keys, counts match test data, stale-summary detection, empty vault - `TestVaultPredictionErrors` (6 tests): valid JSON, required keys, returns inserted error, error-type filter, resolve clears error, empty vault - `TestVaultSearch` (5 tests): valid JSON, keyword FTS finds matching note, result fields, no-match returns empty list, top_k limit `vault_search` uses `mode="keyword"` (pure FTS5) throughout -- this avoids needing the Ollama embedding service, consistent with the issue's "tests don't need to run over the network" requirement. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Closes #5.
Adds
tests/test_server_integration.pycovering the three MCP tools from the issue:vault_stats,vault_prediction_errors, andvault_search.Approach
The tests call tool functions directly as plain Python callables — no stdio or network transport needed. Each test patches
neurostack.schema.DB_PATHto point to a hermetic temp-file database. This works because each tool importsDB_PATHlazily inside its function body, so the patch is visible at call time.A
server_dbfixture creates a temp DB viaget_db()(which runs all schema migrations) and inserts two notes, two chunks, and one prediction error — enough for all tools to return non-trivial results.Coverage
TestVaultStats(5 tests): valid JSON, required keys, counts match test data, stale-summary detection, empty vaultTestVaultPredictionErrors(6 tests): valid JSON, required keys, returns inserted error, error-type filter, resolve clears error, empty vaultTestVaultSearch(5 tests): valid JSON, keyword FTS finds matching note, result fields, no-match returns empty list, top_k limitvault_searchusesmode="keyword"(pure FTS5) throughout — no Ollama embedding service needed, consistent with the issue requirement.🤖 Generated with Claude Code