Skip to content

Conversation

@PatD42
Copy link
Contributor

@PatD42 PatD42 commented Dec 6, 2025

Summary

  • Add list_projects() and delete_project() methods to MemgraphIngestor class for project-scoped database operations
  • Add 3 new MCP tools: list_projects, delete_project, wipe_database
  • Modify index_repository to use project-scoped deletion instead of wiping entire database

This enables indexing multiple repositories without losing data from other projects when re-indexing a single repository.

Changes

graph_service.py

  • list_projects(): Returns list of all indexed project names
  • delete_project(project_name): Deletes all nodes with qualified_name starting with the project name prefix, preserving other projects

mcp/tools.py

  • list_projects: MCP tool to list all indexed projects
  • delete_project: MCP tool to delete a specific project
  • wipe_database: MCP tool to clear entire database (requires confirmation flag)
  • index_repository: Updated to use delete_project() instead of clean_database(), preserving other projects

Test plan

  • Verify imports work correctly
  • Run MCP tools integration tests (5/5 passed)
  • Run type inference tests (2/2 passed)
  • Manual testing with Memgraph to verify project isolation works

🤖 Generated with Claude Code

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]>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @PatD42, 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 system's ability to manage knowledge graphs for multiple codebases. By introducing project-specific data handling and deletion mechanisms, it ensures that indexing or re-indexing one repository no longer impacts data from other projects, thereby improving data integrity and operational flexibility for users working with diverse codebases.

Highlights

  • Multi-Project Support: Introduced methods and tools to manage multiple projects within the knowledge graph database, allowing for isolated data handling.
  • Project-Scoped Deletion: Implemented functionality to delete data for a specific project without affecting other indexed projects.
  • New MCP Tools: Added list_projects, delete_project, and wipe_database tools to provide granular control over indexed data within the Memgraph knowledge graph.
  • Improved Indexing Workflow: Modified the index_repository tool to perform project-scoped re-indexing, preventing accidental data loss from other projects when re-indexing a single repository.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 by adding tools to list and delete projects, and updating the repository indexing logic to be project-scoped. The changes are well-implemented, adding list_projects, delete_project, and wipe_database tools and their corresponding service methods. The index_repository tool is correctly modified to use delete_project, preventing data loss from other projects during re-indexing. I have one suggestion to improve the efficiency and atomicity of the project deletion logic in graph_service.py by combining two separate database queries into a single one.

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]>
@PatD42
Copy link
Contributor Author

PatD42 commented Dec 7, 2025

Addressing Gemini's atomicity concern:

Simplified delete_project() to use a single atomic query instead of count + delete:

# Before (2 queries, not atomic):
count_result = self.fetch_all("MATCH (n) ... RETURN count(n)")
self._execute_query("MATCH (n) ... DETACH DELETE n")
return node_count

# After (1 query, atomic):
self._execute_query("MATCH (n) ... DETACH DELETE n")

Why not use Gemini's suggestion?

Gemini proposed WITH n DETACH DELETE n RETURN count(n), but RETURN count(n) after DETACH DELETE n may not work correctly since the nodes are deleted before the count.

The simpler solution: just drop the count. It was only used for logging/cosmetic purposes and isn't essential for correctness.

PatD42 and others added 2 commits December 6, 2025 21:21
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant