graphiti/mcp_server/docs/cursor_rules.md
Daniel Chalef 3c25268afc feat: Major MCP server refactor with improved structure and CI/CD
- Reorganized MCP server into clean, scalable directory structure:
  - `src/config/` - Configuration modules (schema, managers, provider configs)
  - `src/services/` - Services (queue, factories)
  - `src/models/` - Data models (entities, responses)
  - `src/utils/` - Utilities (formatting, helpers)
  - `tests/` - All test files
  - `config/` - Configuration files (YAML, examples)
  - `docker/` - Docker setup files
  - `docs/` - Documentation

- Added `main.py` wrapper for seamless transition
- Maintains existing command-line interface
- All deployment scripts continue to work unchanged

- **Queue Service Interface Fix**: Fixed missing `add_episode()` and `initialize()` methods
  - Server calls at `graphiti_mcp_server.py:276` and `:755` now work correctly
  - Eliminates runtime crashes on startup and episode processing
- Updated imports throughout restructured codebase
- Fixed Python module name conflicts (renamed `types/` to `models/`)

- **MCP Server Tests Action** (`.github/workflows/mcp-server-tests.yml`)
  - Runs on PRs targeting main with `mcp_server/**` changes
  - Configuration validation, syntax checking, unit tests
  - Import structure validation, dependency verification
  - Main.py wrapper functionality testing

- **MCP Server Lint Action** (`.github/workflows/mcp-server-lint.yml`)
  - Code formatting with ruff (100 char line length, single quotes)
  - Comprehensive linting with GitHub-formatted output
  - Type checking with pyright (baseline approach for existing errors)
  - Import sorting validation

- Added ruff and pyright configuration to `mcp_server/pyproject.toml`
- Proper tool configuration for the new structure
- Enhanced development dependencies with formatting/linting tools

- All existing tests moved and updated for new structure
- Import paths updated throughout test suite
- Validation scripts enhanced for restructured codebase

- **Improved Maintainability**: Clear separation of concerns
- **Better Scalability**: Organized structure supports growth
- **Enhanced Developer Experience**: Proper linting, formatting, type checking
- **Automated Quality Gates**: CI/CD ensures code quality on every PR
- **Zero Breaking Changes**: Maintains full backwards compatibility

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 08:50:48 -07:00

34 lines
2.4 KiB
Markdown

## Instructions for Using Graphiti's MCP Tools for Agent Memory
### Before Starting Any Task
- **Always search first:** Use the `search_nodes` tool to look for relevant preferences and procedures before beginning work.
- **Search for facts too:** Use the `search_facts` tool to discover relationships and factual information that may be relevant to your task.
- **Filter by entity type:** Specify `Preference`, `Procedure`, or `Requirement` in your node search to get targeted results.
- **Review all matches:** Carefully examine any preferences, procedures, or facts that match your current task.
### Always Save New or Updated Information
- **Capture requirements and preferences immediately:** When a user expresses a requirement or preference, use `add_memory` to store it right away.
- _Best practice:_ Split very long requirements into shorter, logical chunks.
- **Be explicit if something is an update to existing knowledge.** Only add what's changed or new to the graph.
- **Document procedures clearly:** When you discover how a user wants things done, record it as a procedure.
- **Record factual relationships:** When you learn about connections between entities, store these as facts.
- **Be specific with categories:** Label preferences and procedures with clear categories for better retrieval later.
### During Your Work
- **Respect discovered preferences:** Align your work with any preferences you've found.
- **Follow procedures exactly:** If you find a procedure for your current task, follow it step by step.
- **Apply relevant facts:** Use factual information to inform your decisions and recommendations.
- **Stay consistent:** Maintain consistency with previously identified preferences, procedures, and facts.
### Best Practices
- **Search before suggesting:** Always check if there's established knowledge before making recommendations.
- **Combine node and fact searches:** For complex tasks, search both nodes and facts to build a complete picture.
- **Use `center_node_uuid`:** When exploring related information, center your search around a specific node.
- **Prioritize specific matches:** More specific information takes precedence over general information.
- **Be proactive:** If you notice patterns in user behavior, consider storing them as preferences or procedures.
**Remember:** The knowledge graph is your memory. Use it consistently to provide personalized assistance that respects the user's established preferences, procedures, and factual context.