fix: Docker stdio communication for Claude Desktop compatibility

Fixed the initialization timeout issue with minimal changes:

1. Added stdout flush after server connection to combat Docker buffering
2. Fixed docker-entrypoint.sh to not output to stdout in stdio mode
3. Added process.stdin.resume() to keep server alive
4. Added IS_DOCKER environment variable for future use
5. Updated README to prioritize Docker with correct -i flag configuration

The core issue was Docker's block buffering preventing immediate JSON-RPC
responses. The -i flag maintains stdin connection, and explicit flushing
ensures responses reach Claude Desktop immediately.

Also fixed "Shutting down..." message that was breaking JSON-RPC protocol
by redirecting it to stderr in stdio mode.

Docker is now the recommended installation method as originally intended.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-06-17 00:30:54 +02:00
parent b769ff24ee
commit 75952f94ca
6 changed files with 474 additions and 21 deletions

View File

@@ -35,7 +35,45 @@ When Claude, Anthropic's AI assistant, tested n8n-MCP, the results were transfor
Get n8n-MCP running in 5 minutes:
### Option 1: Local Installation (Recommended)
### Option 1: Docker (Easiest)
**Prerequisites:** [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed on your system
```bash
# Pull the Docker image
docker pull ghcr.io/czlonkowski/n8n-mcp:latest
```
Add to Claude Desktop config:
```json
{
"mcpServers": {
"n8n-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e", "MCP_MODE=stdio",
"-e", "LOG_LEVEL=error",
"-e", "DISABLE_CONSOLE_OUTPUT=true",
"ghcr.io/czlonkowski/n8n-mcp:latest"
]
}
}
}
```
**Important:** The `-i` flag is required for MCP stdio communication.
**Configuration file locations:**
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
**Restart Claude Desktop after updating configuration** - That's it! 🎉
### Option 2: Local Installation
**Prerequisites:** [Node.js](https://nodejs.org/) installed on your system
@@ -63,25 +101,6 @@ Add to Claude Desktop config:
}
```
### Option 2: Docker (Experimental)
⚠️ **Known Issue**: Docker support has a timeout issue with MCP initialization. The server doesn't respond to Claude's initialize request within 60 seconds, causing connection failures. Use local installation until this is resolved.
For brave souls who want to help debug:
```bash
docker pull ghcr.io/czlonkowski/n8n-mcp:latest
```
See [Issue #X](https://github.com/czlonkowski/n8n-mcp/issues) for updates.
### Configuration File Locations
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
**Remember to restart Claude Desktop after updating configuration!** 🎉
## Features