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

@@ -14,15 +14,16 @@ maintaining a consistent interface for the semantic search workflow.
from abc import ABC, abstractmethod
from typing import TypeVar
from ..models import Condition, SearchRow
from ..models import Chunk, Condition, SearchRow
ResponseType = TypeVar("ResponseType")
ConditionType = TypeVar("ConditionType")
ChunkType = TypeVar("ChunkType")
__all__ = ["BaseEngine"]
class BaseEngine[ResponseType, ConditionType](ABC):
class BaseEngine[ResponseType, ConditionType, ChunkType](ABC):
"""Abstract base class for vector search engines.
This class defines the interface that all vector search engine implementations
@@ -34,6 +35,8 @@ class BaseEngine[ResponseType, ConditionType](ABC):
For example, list[ScoredPoint] for Qdrant.
ConditionType: The backend-specific filter/condition type.
For example, models.Filter for Qdrant.
ChunkType: The backend-specific chunk type.
For example, models.Point for Qdrant.
The class implements the Template Method pattern where semantic_search()
orchestrates calls to the abstract methods that subclasses must implement.
@@ -192,3 +195,16 @@ class BaseEngine[ResponseType, ConditionType](ABC):
embedding, collection, limit, transformed_conditions, threshold
)
return self.transform_response(response)
@abstractmethod
async def create_index(self, name: str, size: int) -> bool: ...
@abstractmethod
def transform_chunk(self, chunk: Chunk) -> ChunkType: ...
@abstractmethod
async def run_upload_chunk(self, index_name: str, chunk: ChunkType) -> bool: ...
async def upload_chunk(self, index_name: str, chunk: Chunk) -> bool:
transformed_chunk = self.transform_chunk(chunk)
return await self.run_upload_chunk(index_name, transformed_chunk)