MCPcopy
hub / github.com/MinishLab/semble / _call_tool

Function _call_tool

tests/test_mcp.py:22–39  ·  view source on GitHub ↗

Patch SembleIndex.from_path with a fake index and invoke the tool, returning the text.

(
    cache: _IndexCache,
    tool: str,
    args: dict[str, Any],
    *,
    index_method: str,
    index_return: list[SearchResult],
    index_chunks: list[Chunk] | None = None,
)

Source from the content-addressed store, hash-verified

20
21
22async def _call_tool(
23 cache: _IndexCache,
24 tool: str,
25 args: dict[str, Any],
26 *,
27 index_method: str,
28 index_return: list[SearchResult],
29 index_chunks: list[Chunk] | None = None,
30) -> str:
31 """Patch SembleIndex.from_path with a fake index and invoke the tool, returning the text."""
32 fake_index = MagicMock()
33 getattr(fake_index, index_method).return_value = index_return
34 if index_chunks is not None:
35 fake_index.chunks = index_chunks
36 with patch("semble.mcp.SembleIndex.from_path", return_value=fake_index):
37 server = create_server(cache)
38 result = await server.call_tool(tool, args)
39 return _tool_text(result)
40
41
42@pytest.fixture()

Callers 1

test_tool_outputFunction · 0.85

Calls 2

create_serverFunction · 0.90
_tool_textFunction · 0.85

Tested by

no test coverage detected