Get the FREE Ultimate OpenClaw Setup Guide →

aider

WebSocket server that exposes Aider's AI coding capabilities through the Model Context Protocol (MCP) for programmatic access

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio larock22-aider-mcp node ./dist/mcp-server.js \
  --env LOG_LEVEL="info" \
  --env AIDER_MODEL="gpt-4o-mini" \
  --env OPENAI_API_KEY="your-openai-api-key" \
  --env WORKSPACES_DIR="./workspaces"

How to use

This MCP server wraps Aider and exposes its functionality over the MCP WebSocket protocol. Clients connect via JSON-RPC 2.0, initialize a session, and then call one of the exposed tools to interact with Aider in a multi-tenant, isolated workspace per client. The available tools let you run natural language commands, add files to Aider’s workspace, and execute shell commands through Aider. Typical flows include initializing the session, sending an aider_command to produce code or content, optionally adding files with aider_add_file to set up the workspace, and using aider_run_command to run build or test commands within Aider’s environment. The server handles completion detection, so clients receive results only after Aider finishes tasks, and each client’s work is kept separate in its own workspace.

How to install

Prerequisites:

  • Node.js 18+ installed on your system
  • Git (optional, for cloning)
  • An OpenAI API key

Steps:

  1. Clone the repository (if applicable)
  1. Install dependencies
  • npm install
  1. Create a local environment file
  • cp .env.example .env
  • Edit .env and provide your OpenAI API key and desired configuration, e.g.: OPENAI_API_KEY=sk-... AIDER_MODEL=gpt-4o-mini WORKSPACES_DIR=./workspaces
  1. Run the MCP protocol server (recommended)
  • npm run mcp
  1. Optional: run the custom WebSocket wrapper or other scripts
  • npm run dev
  • npm run build && npm start

Notes:

  • The MCP server is implemented in TypeScript and compiled to JavaScript in dist/
  • Ensure dist/mcp-server.js exists after building before starting the server

Additional notes

Tips and common issues:

  • Ensure OPENAI_API_KEY is set; missing key is a common startup failure.
  • If you see connection errors, verify the server is running (npm run mcp) and that the port in .env matches your client configuration.
  • Each client gets an isolated workspace; if you need to reset state, delete the corresponding directory in WORKSPACES_DIR.
  • If Aider cannot be found, install Aider and ensure it is available in PATH (as per the README's troubleshooting).
  • You can customize the AIDER_MODEL, logging level, and workspace location via environment variables in .env or at runtime with CLI overrides.
  • For production deployment, consider compiling to dist and using npm start to run the built server.

Related MCP Servers

Sponsor this space

Reach thousands of developers