diff --git a/src/mcp_server_qdrant/mcp_server.py b/src/mcp_server_qdrant/mcp_server.py index 58a7cc0..7d08beb 100644 --- a/src/mcp_server_qdrant/mcp_server.py +++ b/src/mcp_server_qdrant/mcp_server.py @@ -98,6 +98,13 @@ class QdrantMCPServer(FastMCP): collection_name: Annotated[ str, Field(description="The collection to store the information in") ], + project: Annotated[ + str, + Field( + description="Project name, e.g. devops, stereo-hysteria, voice-assistant. " + "Use 'global' for cross-project knowledge (servers, network, user preferences)." + ), + ] = "global", # The `metadata` parameter is defined as non-optional, but it can be None. # If we set it to be optional, some of the MCP clients, like Cursor, cannot # handle the optional parameter correctly. @@ -112,12 +119,17 @@ class QdrantMCPServer(FastMCP): Store some information in Qdrant. :param ctx: The context for the request. :param information: The information to store. + :param project: The project name to tag this memory with. :param metadata: JSON metadata to store with the information, optional. :param collection_name: The name of the collection to store the information in, optional. If not provided, the default collection is used. :return: A message indicating that the information was stored. """ - await ctx.debug(f"Storing information {information} in Qdrant") + await ctx.debug(f"Storing information {information} in Qdrant (project={project})") + + if metadata is None: + metadata = {} + metadata["project"] = project entry = Entry(content=information, metadata=metadata) diff --git a/src/mcp_server_qdrant/qdrant.py b/src/mcp_server_qdrant/qdrant.py index 0030cac..5d64061 100644 --- a/src/mcp_server_qdrant/qdrant.py +++ b/src/mcp_server_qdrant/qdrant.py @@ -211,8 +211,14 @@ class QdrantConnector: sparse_vectors_config=sparse_config, ) - # Create payload indexes if configured + # Always index metadata.project for efficient filtering + await self._client.create_payload_index( + collection_name=collection_name, + field_name="metadata.project", + field_schema=models.PayloadSchemaType.KEYWORD, + ) + # Create payload indexes if configured if self._field_indexes: for field_name, field_type in self._field_indexes.items(): await self._client.create_payload_index(