diff --git a/src/contextseek/mcp/server.py b/src/contextseek/mcp/server.py index a43210e..c68ef5a 100644 --- a/src/contextseek/mcp/server.py +++ b/src/contextseek/mcp/server.py @@ -15,6 +15,11 @@ class ContextSeekMCPServer: client: ContextSeek + @classmethod + def with_default_client(cls) -> "ContextSeekMCPServer": + """Create a server backed by the default ContextSeek settings.""" + return cls(client=ContextSeek.from_settings()) + def list_tools(self) -> list[dict[str, Any]]: """Return MCP tool definitions.""" return [ diff --git a/tests/unit_tests/test_mcp_runtime.py b/tests/unit_tests/test_mcp_runtime.py new file mode 100644 index 0000000..3b5d98e --- /dev/null +++ b/tests/unit_tests/test_mcp_runtime.py @@ -0,0 +1,23 @@ +"""Tests for MCP runtime/server construction.""" + +from __future__ import annotations + +from io import StringIO + +from contextseek.mcp.runtime import run_stdio_server +from contextseek.mcp.server import ContextSeekMCPServer + + +def test_mcp_server_with_default_client_builds_tools() -> None: + server = ContextSeekMCPServer.with_default_client() + + assert isinstance(server, ContextSeekMCPServer) + assert any(tool["name"] == "contextseek_retrieve" for tool in server.list_tools()) + + +def test_stdio_server_falls_back_to_default_client_without_daemon(monkeypatch) -> None: + monkeypatch.setattr("contextseek.mcp.runtime._daemon_available", lambda base: False) + monkeypatch.setattr("sys.stdin", StringIO("")) + monkeypatch.setattr("sys.stdout", StringIO()) + + assert run_stdio_server() == 0