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

@@ -16,14 +16,16 @@ from typing import final, override
from qdrant_client import AsyncQdrantClient, models
from ..config import Settings
from ..models import Condition, Match, MatchAny, MatchExclude, SearchRow
from ..models import Chunk, Condition, Match, MatchAny, MatchExclude, SearchRow
from .base_engine import BaseEngine
__all__ = ["QdrantEngine"]
@final
class QdrantEngine(BaseEngine[list[models.ScoredPoint], models.Filter]):
class QdrantEngine(
BaseEngine[list[models.ScoredPoint], models.Filter, models.PointStruct]
):
"""Qdrant vector database engine implementation.
This class provides a concrete implementation of the BaseEngine interface
@@ -195,3 +197,30 @@ class QdrantEngine(BaseEngine[list[models.ScoredPoint], models.Filter]):
with_vectors=False,
score_threshold=threshold,
)
@override
async def create_index(self, name: str, size: int) -> bool:
return await self.client.create_collection(
collection_name=name,
vectors_config=models.VectorParams(
size=size, distance=models.Distance.COSINE
),
)
@override
async def run_upload_chunk(
self, index_name: str, chunk: models.PointStruct
) -> bool:
result = await self.client.upsert(
collection_name=index_name,
points=[chunk],
)
return result.status == models.UpdateStatus.ACKNOWLEDGED
@override
def transform_chunk(self, chunk: Chunk) -> models.PointStruct:
return models.PointStruct(
id=chunk.id,
vector=chunk.vector,
payload=chunk.payload.model_dump(),
)