Skip to content

Bug: graphiti compose fails with 'tuple' object has no attribute 'add_referent' #10

@alissonaguiar

Description

@alissonaguiar

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

  1. 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
  2. Launch services (step 2):

    graphiti compose   # This works
    graphiti up -d
  3. Create a project (step 3):

    cd /path/to/my-kg
    graphiti init my-kg        # This works
  4. Rerun compose (as instructed in step 3):

    cd /path/to/mcp-graphiti
    graphiti compose && graphiti up -d
  5. Error occurs at step 4 when graphiti compose tries to generate docker-compose.yml with 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-base references x-graphiti-mcp-base
  • x-graphiti-mcp-base uses 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:

  1. Converting all CommentedMap objects to plain Python dict objects before writing
  2. Removing all anchor definitions (x-* keys) and merge keys (<<) from the data structure
  3. 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 init command works correctly
  • The error only occurs when graphiti compose tries to include the new project in the generated docker-compose.yml
  • The base services (neo4j, graphiti-mcp-root) are already in base-compose.yaml and work fine
  • The issue appears when adding new project services that should inherit from x-graphiti-mcp-custom-base

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions