npm package: @nakamurau1/memory-bank-mcp-server
Description: MCP server for accessing Cline Memory Bank files
Latest version: 0.2.0

# Memory Bank MCP Server

Model Context Protocol (MCP) server for interacting with Cline's Memory Bank documentation system.

## Installation

### Using Docker

```bash
# Build the Docker image
docker build -t memory-bank-mcp-server .

# Run the Docker container
docker run -i --rm \
  --mount type=bind,src=/absolute/path/to/your/project,dst=/projects/your-project \
  memory-bank-mcp-server /projects
```

### Using npm

```bash
npm install @nakamurau1/memory-bank-mcp-server
```

### Using npx (No Installation Required)

You can run the server directly without installation using npx:

```bash
npx @nakamurau1/memory-bank-mcp-server
```

A shorter alias is also available:

```bash
npx --package=@nakamurau1/memory-bank-mcp-server mbmcp
```

## Features

- `loadMemoryBank` tool: Loads and combines core Memory Bank files from a specified project directory.

## Usage

### Command Line

Run the server directly from the command line:

```bash
npx @nakamurau1/memory-bank-mcp-server
```

The server will start and listen for MCP requests on standard input/output.

### Configuration with Claude Desktop or other MCP clients

#### Using NPX

Add this to your `claude_desktop_config.json` or similar configuration file:

```json
{
  "mcpServers": {
    "memoryBank": {
      "command": "npx",
      "args": [
        "-y",
        "--package=@nakamurau1/memory-bank-mcp-server",
        "memory-bank-mcp-server"
      ]
    }
  }
}
```

You can also use the shorter alias command:

```json
{
  "mcpServers": {
    "memoryBank": {
      "command": "npx",
      "args": [
        "-y",
        "--package=@nakamurau1/memory-bank-mcp-server",
        "mbmcp"
      ]
    }
  }
}
```

#### Using Docker

Add this to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "memoryBank": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "--mount",
        "type=bind,src=/absolute/path/to/your/project,dst=/projects/your-project",
        "memory-bank-mcp-server",
        "/projects"
      ]
    }
  }
}
```

> **Note**: All directories must be mounted to `/projects` by default. You can mount multiple directories by adding more `--mount` arguments. Using the `ro` flag will make the directory read-only (e.g., `dst=/projects/your-project,ro`).

### As an MCP Server in Code

```javascript
// Example server startup
import { startServer } from '@nakamurau1/memory-bank-mcp-server';

// Start the server with default settings
startServer();
```

### From a Client

```javascript
// Example client code using @modelcontextprotocol/sdk
import { McpClient, StdioClientTransport } from '@modelcontextprotocol/sdk';

// Connect to the server
const transport = new StdioClientTransport({ command: 'npx @nakamurau1/memory-bank-mcp-server' });
const client = new McpClient({ transport });

// Call the loadMemoryBank tool
const result = await client.callTool("loadMemoryBank", {
  projectPath: "/absolute/path/to/your/project",
  memoryBankDir: "memory-bank" // Optional, defaults to "memory-bank"
});

console.log(result);
```

## File Format

The `loadMemoryBank` tool uses the following format for separating files in the output:

```
=== [1/6] MEMORY BANK: projectbrief.md ===

[Content of projectbrief.md]

=== [2/6] MEMORY BANK: productContext.md ===

[Content of productContext.md]

...
```

## Development

### Docker Build

Build the Docker image:

```bash
docker build -t memory-bank-mcp-server .
```

### Setup

1. Clone the repository
2. Install dependencies:
   ```bash
   npm install
   ```
3. Build the project:
   ```bash
   npm run build
   ```

### Testing

Run the tests:

```bash
npm test
```

This will run the integration tests which verify the server's functionality by:
- Starting the MCP server as a child process
- Sending JSONRPC requests to the server
- Verifying the response contains properly formatted Memory Bank content

Note: The tests expect the output to be formatted as shown in the "File Format" section above. If you modify the output format in `memoryBankLoader.ts`, make sure to update the test expectations in `integration.test.ts` accordingly.

## Configuration

### Tool Parameters

- `projectPath` (required): Absolute path to your project directory.
- `memoryBankDir` (optional): Name of the directory containing Memory Bank files (defaults to "memory-bank").

## Troubleshooting

### Common Issues

- **File Access Errors**: Ensure the server has read permissions for the specified `projectPath`.
- **Invalid Path Errors**: Make sure `projectPath` is an absolute path and correctly points to a directory containing Memory Bank files.
- **Memory Bank Files Not Found**: Check that your memory bank files are in the correct directory (default: `memory-bank/`).

### Logging

If you encounter issues, you can debug by examining the server output for error messages.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

MIT