forked from innovacion/searchbox
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:
31
tests/test_mcp/test_mcp.py
Normal file
31
tests/test_mcp/test_mcp.py
Normal 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"}
|
||||
Reference in New Issue
Block a user