# LibreChat Integration

This guide walks you through setting up the Project Memory MCP server with LibreChat.

## Prerequisites

- LibreChat installed and configured
- Node.js version 14.0.0 or higher

## Configuration

Add the following configuration to your `librechat.yaml`:

```yaml
endpoints:
  agents:
    # Increase recursion limit to handle complex knowledge graphs
    recursionLimit: 75
    servers:
      memory:
        type: stdio
        # Use npx to run the MCP server directly
        command: npx
        args:
          - -y
          - '@ldavis9000aws/mcp-project-memory'
          - start
          - project-memory.json
        # Give enough time for dependency installation if needed
        initTimeout: 30000
```

## Environment Variables

If your MCP server needs access to environment variables, add them explicitly in the LibreChat configuration:

```yaml
endpoints:
  agents:
    servers:
      memory:
        env:
          VARIABLE_NAME: ${VARIABLE_NAME}  # This uses the value from LibreChat's environment
```

## Best Practices

1. **Memory File Location**: 
   - Specify a file path for the memory storage
   - If you don't provide a path, it will use a default "memory.json" in the current directory

2. **Recursion Limit**:
   - Set `recursionLimit: 75` to ensure complex knowledge graph operations work properly
   - Default value (25) may cause errors with deep graph operations

3. **Initial Timeout**:
   - Set `initTimeout` to at least 30 seconds when using NPX
   - This allows time for dependency installation if needed

4. **Environment Variables**:
   - System/user environment variables are not automatically inherited
   - Pass required environment variables explicitly via the `env:` section

## Testing the Integration

Add the following to a conversation with Claude via LibreChat:

```
Use the project memory tool to create a simple test project by executing:

1. Create a project entity
2. Create a component entity 
3. Create a relation between them
```

If successful, Claude will use the MCP tools and you'll see the knowledge graph being populated.

## Advanced Usage

For production environments, consider:

- Installing the package globally
- Using a specific memory file path
- Setting up the daemon mode for background operation

For more information, refer to the main README documentation.