-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Bug: graphiti compose fails with 'tuple' object has no attribute 'add_referent'
Description
When running graphiti compose after initializing a project with graphiti init, the command fails with the following error:
Error: Failed to generate docker-compose.yml file: 'tuple' object has no attribute 'add_referent'
Steps to Reproduce
-
Follow the Quick Start guide:
pipx install 'git+https://github.com/rawr-ai/mcp-graphiti.git' git clone https://github.com/rawr-ai/mcp-graphiti.git cd mcp-graphiti cp .env.example .env # fill in Neo4j credentials and your OpenAI key
-
Launch services (step 2):
graphiti compose # This works graphiti up -d -
Create a project (step 3):
cd /path/to/my-kg graphiti init my-kg # This works
-
Rerun compose (as instructed in step 3):
cd /path/to/mcp-graphiti graphiti compose && graphiti up -d
-
Error occurs at step 4 when
graphiti composetries to generatedocker-compose.ymlwith the new project.
Expected Behavior
The graphiti compose command should successfully generate docker-compose.yml including the new project service.
Actual Behavior
The command fails with:
Error: Failed to generate docker-compose.yml file: 'tuple' object has no attribute 'add_referent'
Environment
- OS: macOS (darwin 25.1.0)
- Python: 3.x
- graphiti CLI: installed via pipx
- Docker: Running
Root Cause Analysis
The error occurs in graphiti_cli/logic/compose_generator.py when trying to write the docker-compose.yml file. The issue is related to how ruamel.yaml handles YAML anchors and merge keys (<<:) from base-compose.yaml.
The base-compose.yaml file uses nested YAML anchors:
x-graphiti-mcp-custom-basereferencesx-graphiti-mcp-basex-graphiti-mcp-baseuses merge keys to combine*mcp-env,*neo4j-connection, and*mcp-healthcheck
When ruamel.yaml's round-trip loader processes these anchors and the code tries to serialize them back to YAML, it encounters internal anchor reference objects that can't be properly serialized, resulting in the 'tuple' object has no attribute 'add_referent' error.
Workaround
As a temporary workaround, you can manually create or edit docker-compose.yml based on the structure in base-compose.yaml, or wait for a fix.
Suggested Fix
The issue can be resolved by:
- Converting all
CommentedMapobjects to plain Pythondictobjects before writing - Removing all anchor definitions (
x-*keys) and merge keys (<<) from the data structure - Ensuring all services are converted to plain dictionaries without any ruamel.yaml-specific objects
The fix should be applied in graphiti_cli/logic/compose_generator.py before calling write_yaml_file().
Additional Context
- The
graphiti initcommand works correctly - The error only occurs when
graphiti composetries to include the new project in the generateddocker-compose.yml - The base services (neo4j, graphiti-mcp-root) are already in
base-compose.yamland work fine - The issue appears when adding new project services that should inherit from
x-graphiti-mcp-custom-base