Skip to content

Commit e19e4b3

Browse files
authored
[ENH] Add support for collection.fork, update tool prompts with regex (#46)
1 parent 078dc67 commit e19e4b3

File tree

5 files changed

+179
-25
lines changed

5 files changed

+179
-25
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ jobs:
1919
uses: actions/setup-python@v4
2020
with:
2121
python-version: ${{ matrix.python-version }}
22+
- name: Install uv
23+
run: |
24+
curl -LsSf https://astral.sh/uv/install.sh | sh
25+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
2226
- name: Install dependencies
2327
run: |
24-
python -m pip install --upgrade pip
25-
pip install -e ".[test]"
26-
pip install pytest pytest-asyncio pytest-cov
28+
uv sync --extra test
2729
- name: Run tests
2830
run: |
29-
pytest tests/ --cov=chroma_mcp --cov-report=xml
31+
uv run pytest tests/ --cov=chroma_mcp --cov-report=xml
3032
- name: Upload coverage
3133
uses: codecov/codecov-action@v3
3234
with:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.2.6] - 08/14/2025
9+
10+
- Update chromadb to 1.0.16
11+
- Add tool prompts for regex support
12+
- Add new `chroma_fork_collection` tool support
13+
814
## [0.2.5] - 06/18/2025
915

1016
- Update chromadb to 1.0.13

pyproject.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "chroma-mcp"
3-
version = "0.2.5"
3+
version = "0.2.6"
44
description = "Chroma MCP Server - Vector Database Integration for LLM Applications"
55
readme = "README.md"
66
requires-python = ">=3.10"
@@ -16,14 +16,12 @@ classifiers = [
1616
"Topic :: Software Development :: Libraries :: Python Modules"
1717
]
1818
dependencies = [
19-
"chromadb>=1.0.13",
19+
"chromadb>=1.0.16",
2020
"cohere>=5.14.2",
2121
"httpx>=0.28.1",
22-
"mcp[cli]>=1.2.1",
22+
"mcp[cli]==1.6.0",
2323
"openai>=1.70.0",
2424
"pillow>=11.1.0",
25-
"pytest>=8.3.5",
26-
"pytest-asyncio>=0.26.0",
2725
"python-dotenv>=0.19.0",
2826
"typing-extensions>=4.13.1",
2927
"voyageai>=0.3.2",
@@ -43,10 +41,16 @@ chroma-mcp = "chroma_mcp:main"
4341

4442
[project.optional-dependencies]
4543
sentence-transformers = ["sentence-transformers>=4.1.0"]
44+
test = [
45+
"pytest>=8.3.5",
46+
"pytest-asyncio>=0.26.0",
47+
"pytest-cov>=4.1.0",
48+
]
4649

4750
[tool.pytest.ini_options]
4851
testpaths = ["tests"]
4952
python_files = ["test_*.py"]
53+
asyncio_default_fixture_loop_scope = "function"
5054

5155
[tool.ruff]
5256
select = ["E", "F", "B", "I"]

src/chroma_mcp/server.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,27 @@ async def chroma_modify_collection(
293293
return f"Successfully modified collection {collection_name}: updated {' and '.join(modified_aspects)}"
294294
except Exception as e:
295295
raise Exception(f"Failed to modify collection '{collection_name}': {str(e)}") from e
296-
296+
297+
@mcp.tool()
298+
async def chroma_fork_collection(
299+
collection_name: str,
300+
new_collection_name: str,
301+
) -> str:
302+
"""Fork a Chroma collection.
303+
304+
Args:
305+
collection_name: Name of the collection to fork
306+
new_collection_name: Name of the new collection to create
307+
metadata: Optional metadata dict to add to the new collection
308+
"""
309+
client = get_chroma_client()
310+
try:
311+
collection = client.get_collection(collection_name)
312+
collection.fork(new_collection_name)
313+
return f"Successfully forked collection {collection_name} to {new_collection_name}"
314+
except Exception as e:
315+
raise Exception(f"Failed to fork collection '{collection_name}': {str(e)}") from e
316+
297317
@mcp.tool()
298318
async def chroma_delete_collection(collection_name: str) -> str:
299319
"""Delete a Chroma collection.
@@ -394,6 +414,13 @@ async def chroma_query_documents(
394414
- Logical AND: {"$and": [{"field1": {"$eq": "value1"}}, {"field2": {"$gt": 5}}]}
395415
- Logical OR: {"$or": [{"field1": {"$eq": "value1"}}, {"field1": {"$eq": "value2"}}]}
396416
where_document: Optional document content filters
417+
Examples:
418+
- Contains: {"$contains": "value"}
419+
- Not contains: {"$not_contains": "value"}
420+
- Regex: {"$regex": "[a-z]+"}
421+
- Not regex: {"$not_regex": "[a-z]+"}
422+
- Logical AND: {"$and": [{"$contains": "value1"}, {"$not_regex": "[a-z]+"}]}
423+
- Logical OR: {"$or": [{"$regex": "[a-z]+"}, {"$not_contains": "value2"}]}
397424
include: List of what to include in response. By default, this will include documents, metadatas, and distances.
398425
"""
399426
if not query_texts:
@@ -434,6 +461,13 @@ async def chroma_get_documents(
434461
- Logical AND: {"$and": [{"field1": {"$eq": "value1"}}, {"field2": {"$gt": 5}}]}
435462
- Logical OR: {"$or": [{"field1": {"$eq": "value1"}}, {"field1": {"$eq": "value2"}}]}
436463
where_document: Optional document content filters
464+
Examples:
465+
- Contains: {"$contains": "value"}
466+
- Not contains: {"$not_contains": "value"}
467+
- Regex: {"$regex": "[a-z]+"}
468+
- Not regex: {"$not_regex": "[a-z]+"}
469+
- Logical AND: {"$and": [{"$contains": "value1"}, {"$not_regex": "[a-z]+"}]}
470+
- Logical OR: {"$or": [{"$regex": "[a-z]+"}, {"$not_contains": "value2"}]}
437471
include: List of what to include in response. By default, this will include documents, and metadatas.
438472
limit: Optional maximum number of documents to return
439473
offset: Optional number of documents to skip before returning results

0 commit comments

Comments
 (0)