Implement corpus indexing and MCP search
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from mcp.shared.memory import create_connected_server_and_client_session
|
||||
|
||||
from corpus_mcp.server import create_server
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_mcp_server_exposes_search_and_description(
|
||||
corpus: tuple[Path, Path],
|
||||
) -> None:
|
||||
_, database = corpus
|
||||
server = create_server(database)
|
||||
|
||||
async with create_connected_server_and_client_session(
|
||||
server, raise_exceptions=True
|
||||
) as session:
|
||||
result = await session.call_tool("search_corpus", {"query": "SQLite"})
|
||||
tools = await session.list_tools()
|
||||
|
||||
assert result.isError is False
|
||||
assert result.structuredContent["matches"][0]["path"] == "notes.txt"
|
||||
assert {tool.name for tool in tools.tools} == {
|
||||
"search_corpus",
|
||||
"read_document_excerpt",
|
||||
"corpus_info",
|
||||
}
|
||||
assert "Test documentation" in server.instructions
|
||||
Reference in New Issue
Block a user