Skip to content

Commit a03d93c

Browse files
committed
Phase 9.1 Step 4: Merge count_documents into get_collection_info
- Removed standalone count_documents tool - Added include_count parameter to get_collection_info - Updated E2E tests to use get_collection_info with include_count=True - Updated tool list validation tests Tool count: 22 → 21 Breaking change: count_documents tool removed Migration: Use get_collection_info(database="db", include_count=True) Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
1 parent d7803cb commit a03d93c

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

src/maestro_mcp/server.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,10 @@ async def get_collection_info(
14221422
default=None,
14231423
description="Name of the collection to get info for. If not provided, uses the default collection.",
14241424
),
1425+
include_count: bool = Field(
1426+
default=False,
1427+
description="Include document count in the response",
1428+
),
14251429
) -> str:
14261430
"""Get information about a collection in a vector database."""
14271431
db = get_database_by_name(database)
@@ -1443,6 +1447,15 @@ async def get_collection_info(
14431447
return str(info_any)
14441448
info: dict[str, Any] = cast("dict[str, Any]", info_any)
14451449

1450+
# Add document count if requested
1451+
if include_count:
1452+
ok_count, count_any = await run_with_timeout(
1453+
db.count_documents(), "count_documents", get_timeout("read")
1454+
)
1455+
if ok_count:
1456+
count = int(count_any) if count_any is not None else 0
1457+
info["document_count"] = count
1458+
14461459
return (
14471460
f"Collection information for '{info.get('name')}' in vector database "
14481461
f"'{database}':\n{json.dumps(info, indent=2)}"

tests/e2e/test_functions.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,12 @@ async def run_document_operations_tests(client: Client, backend_name: str) -> No
159159
docs_list = []
160160
assert docs_list is not None, f"list_documents failed: {res}"
161161

162-
# Test count_documents
163-
res = await client.call_tool("count_documents", {"database": db_name})
162+
# Test get_collection_info with count
163+
res = await client.call_tool(
164+
"get_collection_info", {"database": db_name, "include_count": True}
165+
)
164166
if not hasattr(res, "data") and isinstance(res, str):
165-
assert res, f"count_documents failed: {res}"
167+
assert res, f"get_collection_info with count failed: {res}"
166168

167169
# Test delete_document (get a document ID first from list_documents)
168170
first_doc_id = None
@@ -702,10 +704,14 @@ async def run_full_flow_test(client: Client, backend_name: str) -> None:
702704
if not hasattr(res, "data"):
703705
pytest.fail(f"list_documents failed for {backend_name}: {res}")
704706

705-
# Count documents
706-
res = await client.call_tool("count_documents", {"database": db_name})
707+
# Count documents via get_collection_info
708+
res = await client.call_tool(
709+
"get_collection_info", {"database": db_name, "include_count": True}
710+
)
707711
if not hasattr(res, "data"):
708-
pytest.fail(f"count_documents failed for {backend_name}: {res}")
712+
pytest.fail(
713+
f"get_collection_info with count failed for {backend_name}: {res}"
714+
)
709715

710716
# Get collection info
711717
res = await client.call_tool("get_collection_info", {"database": db_name})

tests/test_mcp_server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ async def test_tool_definitions() -> None:
5959
"write_documents",
6060
"write_document",
6161
"list_documents",
62-
"count_documents",
6362
"delete_documents",
6463
"delete_document",
6564
"delete_collection",

tests/test_phase1_schema_validation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ async def test_all_tools_accessible() -> None:
127127
"write_document_to_collection",
128128
"list_documents",
129129
"list_documents_in_collection",
130-
"count_documents",
131130
"delete_documents",
132131
"delete_document",
133132
"delete_document_from_collection",

0 commit comments

Comments
 (0)