Make MCP server optional dependency

The fastmcp server code is now an optional dependency that can be
installed with the "mcp" extra. Core vector search functionality is
available without the MCP server dependency.
This commit is contained in:
2025-09-26 17:12:37 +00:00
parent 250dfa728e
commit b1021bcbd5
11 changed files with 140 additions and 46 deletions

View File

@@ -0,0 +1,31 @@
import json
from fastembed import TextEmbedding
from fastmcp import Client
from mcp.types import TextContent
async def test_call_tool(embedding_model: TextEmbedding, run_mcp: str):
input = "Quien es el mas guapo?"
collection = "dummy_collection"
embedding: list[float] = list(embedding_model.embed(input))[0].tolist()
client = Client(run_mcp)
async with client:
name = "semantic_search"
body = {"embedding": embedding, "collection": collection}
result = await client.call_tool(name, body)
content_block = result.content[0]
assert isinstance(content_block, TextContent)
deserialized_result = json.loads(content_block.text)
top_result = deserialized_result[0]
assert top_result["chunk_id"] == "0"
assert top_result["score"] > 0.7
assert top_result["payload"] == {"text": "Rick es el mas guapo"}