-
-
Notifications
You must be signed in to change notification settings - Fork 279
feat: add multi-project support to MCP tools #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add project-scoped database operations that allow managing multiple projects in the knowledge graph without interference: - list_projects(): List all indexed projects in the database - delete_project(): Delete a specific project while preserving others - wipe_database(): Clear entire database (requires confirmation) - index_repository(): Now uses project-scoped deletion instead of full wipe This enables indexing multiple repositories without losing data from other projects when re-indexing a single repository. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Update system prompts for Cypher generation to: - Add LIMIT 50 to all listing queries to prevent overwhelming responses - Use count() aggregation for "how many" queries instead of returning all items - Add explicit examples for counting patterns This addresses the issue where asking "how many classes are there?" would return all 478 classes with full details (~23.6k tokens) instead of just the count. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Simplify delete_project() to use a single DETACH DELETE query instead of count + delete (two separate queries). This addresses atomicity concerns raised in code review. Changes: - graph_service.py: Remove count query, single atomic delete - mcp/tools.py: Remove deleted_nodes from responses - tests: Update to verify delete_project called instead of clean_database 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Fix empty project name when using relative paths like `.` or `./`.
`Path('.').name` returns empty string, causing broken qualified names.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Summary of ChangesHello @vitali87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the multi-project capabilities of the MCP tools, allowing users to manage multiple codebases within the knowledge graph more effectively. It provides granular control over project data, enabling selective deletion and re-indexing, while also improving query performance and accuracy through optimized Cypher queries and robust path handling. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces multi-project support, a significant and well-implemented feature. The changes are clean, consistent, and include updated documentation and tests. The approach of using project-scoped deletion is robust. Additionally, the optimization of Cypher queries with LIMIT 50 and improved prompts is a great enhancement. I have one minor suggestion for improving code formatting consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
Added multi-project support to MCP tools enabling project isolation in the knowledge graph. Three new tools (list_projects, delete_project, wipe_database) provide project management capabilities, and index_repository now uses project-scoped deletion instead of wiping the entire database.
Key Changes
- Added project-scoped deletion query (
CYPHER_DELETE_PROJECT) to remove only nodes belonging to a specific project - Modified
index_repositoryto calldelete_project(project_name)instead ofclean_database(), preserving other projects - Fixed repo path resolution to use
repo_path.resolve().namefor consistent project naming with relative paths - Added
LIMIT 50to Cypher example queries to prevent token explosion from large result sets - Updated prompts with query optimization guidance for aggregation queries
Critical Issue Found
The CYPHER_DELETE_PROJECT query has a logic bug that prevents complete project deletion. It only matches nodes with qualified_name property, missing File nodes (use path), Folder nodes (use path), and ExternalPackage nodes (use name). This will leave orphaned nodes in the database after deletion.
Style Issues
Multiple violations of the TypedDict constructor requirement - the code uses dict literals instead of explicit TypedDict constructors in the new tool handlers.
Confidence Score: 2/5
- This PR has a critical logic bug that will cause incomplete project deletion, leaving orphaned data in the database
- Score reflects the critical deletion bug in CYPHER_DELETE_PROJECT that only removes nodes with qualified_name, missing File/Folder/ExternalPackage nodes. While the feature architecture is sound and tests pass, the core deletion functionality is broken. Multiple style violations (TypedDict constructors) are present but non-critical.
- Pay close attention to
codebase_rag/cypher_queries.py- the CYPHER_DELETE_PROJECT query must be fixed before merging
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| codebase_rag/cypher_queries.py | 2/5 | Added project management queries and LIMIT 50 optimization. Critical issue: CYPHER_DELETE_PROJECT only deletes nodes with qualified_name, missing File/Folder nodes. |
| codebase_rag/mcp/tools.py | 3/5 | Added list_projects, delete_project, wipe_database tools. Changed index_repository to use project-scoped deletion. Multiple TypedDict constructor violations (style). |
| codebase_rag/services/graph_service.py | 4/5 | Added list_projects and delete_project methods to MemgraphIngestor. Clean implementation following existing patterns. |
| codebase_rag/types_defs.py | 3/5 | Added ListProjectsResult and DeleteProjectResult TypedDicts. Fields should not all be optional - success path requires certain fields. |
| codebase_rag/graph_updater.py | 5/5 | Changed project_name to use repo_path.resolve().name instead of repo_path.name. Good fix for relative path handling. |
| codebase_rag/tests/test_mcp_query_and_index.py | 5/5 | Updated tests to verify delete_project is called instead of clean_database. Tests properly validate project isolation behavior. |
Sequence Diagram
sequenceDiagram
participant User
participant MCP as MCPToolsRegistry
participant Ingestor as MemgraphIngestor
participant Updater as GraphUpdater
participant DB as Memgraph Database
Note over User,DB: New Feature: list_projects
User->>MCP: list_projects()
MCP->>Ingestor: list_projects()
Ingestor->>DB: CYPHER_LIST_PROJECTS
DB-->>Ingestor: project names
Ingestor-->>MCP: list[str]
MCP-->>User: ListProjectsResult
Note over User,DB: New Feature: delete_project
User->>MCP: delete_project(project_name)
MCP->>Ingestor: list_projects()
Ingestor->>DB: CYPHER_LIST_PROJECTS
DB-->>Ingestor: projects
Ingestor-->>MCP: projects
MCP->>MCP: validate project exists
MCP->>Ingestor: delete_project(project_name)
Ingestor->>DB: CYPHER_DELETE_PROJECT
DB-->>Ingestor: deletion complete
Ingestor-->>MCP: success
MCP-->>User: DeleteProjectResult
Note over User,DB: New Feature: wipe_database
User->>MCP: wipe_database(confirm=true)
MCP->>MCP: check confirm flag
MCP->>Ingestor: clean_database()
Ingestor->>DB: CYPHER_DELETE_ALL
DB-->>Ingestor: all data deleted
Ingestor-->>MCP: success
MCP-->>User: success message
Note over User,DB: Modified: index_repository (project-scoped)
User->>MCP: index_repository()
MCP->>MCP: project_name = Path.resolve().name
MCP->>Ingestor: delete_project(project_name)
Ingestor->>DB: CYPHER_DELETE_PROJECT
DB-->>Ingestor: project data deleted
Ingestor-->>MCP: success
MCP->>Updater: GraphUpdater(repo_path, ...)
MCP->>Updater: run()
Updater->>Ingestor: ensure_node_batch(...)
Updater->>Ingestor: ensure_relationship_batch(...)
Ingestor->>DB: batch insert nodes/rels
DB-->>Ingestor: success
Ingestor-->>Updater: success
Updater-->>MCP: indexing complete
MCP-->>User: success with project_name
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully introduces multi-project support to the MCP tools, a significant and valuable enhancement. The new tools for listing, deleting, and wiping projects are well-implemented, and the core logic change in index_repository to use project-scoped deletion is correct in principle. The addition of comprehensive integration tests is particularly commendable as it provides strong confidence in the new multi-project functionality. Other improvements like the LIMIT 50 query optimization and the fix for relative path resolution are also great additions.
I've found one critical issue with the project deletion query that could lead to data corruption in a multi-project setup, and one medium-severity suggestion for a minor refactoring to improve code clarity. Both comments are valid and have been included in the review.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces significant and well-implemented multi-project support for the MCP tools. The addition of list_projects, delete_project, and wipe_database tools, along with the modification of index_repository to be project-scoped, is a great enhancement. The changes are robust, with comprehensive integration and unit tests that ensure project isolation. The optimizations to Cypher queries using LIMIT and the fix for relative path resolution are also valuable improvements. Overall, this is a high-quality contribution.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces significant multi-project support to the MCP tools, including new functionalities for listing, deleting, and wiping projects. The indexing logic has been updated to be project-scoped, which is a crucial improvement. I appreciate the performance optimization of adding LIMIT to Cypher queries and the fix for resolving relative repository paths. The new integration tests provide good coverage for the new features. I have a couple of minor suggestions to improve code quality and performance.
| KEY_FROM_VAL = "from_val" | ||
| KEY_TO_VAL = "to_val" | ||
| KEY_VERSION_SPEC = "version_spec" | ||
| KEY_PREFIX = "prefix" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
list_projects,delete_project, andwipe_databaseMCP toolsindex_repositoryto use project-scoped deletion instead of wiping entire databaseBased on PR #178 by @PatD42. Code adapted to project coding standards.
Closes #178
Test plan