Skip to main content
Glama

MCP File & Git Manager Server

by osamaloup
SETUP_GUIDE.md•9.25 kB
# Complete Setup Guide: n8n + MCP Server Integration ## šŸŽÆ Overview This guide will help you integrate the MCP File & Git Manager server with your n8n workflow using the AI Agent node with Claude API. **Architecture:** ``` Telegram Bot → n8n Workflow → AI Agent (Claude) → MCP Client Node → MCP Server ↓ Postgres Memory ``` --- ## šŸ“‹ Prerequisites - Docker and Docker Compose installed - Existing n8n instance running - Telegram Bot Token - Claude API Key - Your project folder path --- ## šŸš€ Part 1: Setup MCP Server ### Step 1: Navigate to MCP Server Directory ```bash cd /Users/lachaal/kjr/cursor/mcp-file-git-server ``` ### Step 2: Install Dependencies ```bash npm install ``` ### Step 3: Build the Server ```bash npm run build ``` ### Step 4: Test Locally (Optional) ```bash # Set project root export PROJECT_ROOT=/path/to/your/project # Start server npm start ``` Test the health endpoint: ```bash curl http://localhost:3001/health ``` --- ## 🐳 Part 2: Docker Setup ### Step 1: Build Docker Image ```bash cd /Users/lachaal/kjr/cursor/mcp-file-git-server docker build -t mcp-file-git-server . ``` ### Step 2: Add to Docker Compose Edit your main `docker-compose.yml` (in n8n-traefik directory): ```yaml services: # ... your existing services (traefik, postgres, mongodb, n8n) ... # Add this new service mcp-server: build: /Users/lachaal/kjr/cursor/mcp-file-git-server container_name: mcp-file-git-server environment: - PROJECT_ROOT=/workspace - PORT=3001 - NODE_ENV=production ports: - "3001:3001" volumes: # IMPORTANT: Change this to your actual project path - /Users/lachaal/kjr/cursor:/workspace:rw # Optional: Git credentials for private repos - ~/.gitconfig:/root/.gitconfig:ro - ~/.ssh:/root/.ssh:ro networks: - n8n-traefik_default restart: unless-stopped healthcheck: test: ["CMD", "wget", "-q", "--spider", "http://localhost:3001/health"] interval: 30s timeout: 10s retries: 3 ``` ### Step 3: Update n8n Service (Optional) To auto-install MCP nodes: ```yaml n8n: # ... existing config ... environment: # ... existing environment variables ... - N8N_CUSTOM_EXTENSIONS=n8n-nodes-mcp ``` ### Step 4: Build and Start Services ```bash # Navigate to your docker-compose directory cd /path/to/n8n-traefik # Build the MCP server docker-compose build mcp-server # Start all services docker-compose up -d # Check if MCP server is running docker ps | grep mcp-file-git-server # Check MCP server logs docker logs mcp-file-git-server # Test the health endpoint curl http://localhost:3001/health ``` You should see: ```json {"status":"healthy","timestamp":"2024-XX-XXTXX:XX:XX.XXXZ"} ``` --- ## šŸ”§ Part 3: Configure n8n ### Step 1: Verify n8n-nodes-mcp Installation ```bash # Access n8n container docker exec -it n8n-traefik-n8n-1 sh # Check if package is installed npm list -g n8n-nodes-mcp # If not installed, install it manually npm install -g n8n-nodes-mcp # Exit container exit # Restart n8n docker restart n8n-traefik-n8n-1 ``` Wait 30 seconds for n8n to restart, then access n8n at `http://localhost:5678` ### Step 2: Create Credentials #### A. Create Claude API Credential 1. Go to **Settings** → **Credentials** → **New** 2. Search for "Claude" or "Anthropic" 3. Enter your Anthropic API Key 4. Name it: `Claude API` 5. Save #### B. Create MCP Credential 1. Go to **Settings** → **Credentials** → **New** 2. Search for "MCP" or "MCP Client" 3. Configure: - **Name**: `File & Git Manager MCP` - **Transport**: `SSE` (Server-Sent Events) - **URL**: `http://mcp-file-git-server:3001/sse` - Leave other fields default 4. Click **Test** to verify connection 5. Save #### C. Verify Postgres Memory is Set Up Your Postgres is already running. Make sure you have the connection details: - Host: `postgres` (or `n8n-traefik-postgres-1`) - Port: `5432` - Database: `n8n` - User: `n8n` - Password: `n8n` --- ## šŸ”Ø Part 4: Build the n8n Workflow ### Step 1: Create New Workflow 1. Go to **Workflows** → **Create New Workflow** 2. Name it: "AI File & Git Assistant" ### Step 2: Add Telegram Trigger 1. Add **Telegram Trigger** node 2. Configure: - **Trigger On**: `message` - **Updates**: Select `message` 3. Connect your Telegram Bot credential 4. Save ### Step 3: Add Extract Message Node 1. Add **Code** node after Telegram Trigger 2. Name it: `Extract Message` 3. Add this code: ```javascript // Extract message and user context const telegram = $input.item.json; return [{ json: { message: telegram.message.text, chatId: telegram.message.chat.id, userId: telegram.message.from.id, username: telegram.message.from.username || telegram.message.from.first_name || 'User', timestamp: new Date().toISOString() } }]; ``` ### Step 4: Add MCP Client Node **IMPORTANT: This is the key integration point!** 1. Add **MCP Client** node (from n8n-nodes-mcp package) 2. Connect it after Extract Message 3. Configure: - **Credential**: Select `File & Git Manager MCP` - **Operation**: `List Tools` (to start) 4. Execute to verify it lists all 13 tools ### Step 5: Add AI Agent Node 1. Add **AI Agent** node 2. Configure: **Basic Settings:** - **Chat Model**: Anthropic Claude - Credential: `Claude API` - Model: `claude-sonnet-4-5-20250929` - **Input**: `={{ $json.message }}` **System Message:** ``` You are an expert AI assistant that helps users manage their project files and git repository. You have access to these powerful tools: šŸ“ File Operations: - read_file: Read file contents - write_file: Create or update files - list_files: Browse directories - delete_file: Remove files/directories - create_directory: Create new folders - search_in_files: Search for text in files šŸ”§ Git Operations: - git_status: Check repository status - git_add: Stage files for commit - git_commit: Create commits - git_push: Push to remote - git_pull: Pull from remote - git_log: View commit history - git_diff: See file changes Guidelines: 1. Always explain what you're going to do BEFORE using tools 2. For file operations, show relevant content or confirm changes 3. For git operations, check status before committing 4. Be cautious with destructive operations (delete, force push) 5. Format code in markdown blocks 6. Provide helpful context and suggestions Be conversational, helpful, and proactive in suggesting best practices! ``` **Tools Configuration:** Click **Add Tool** and select **MCP Tool** for each tool (read_file, write_file, etc.) **Memory Configuration:** - **Memory Type**: Postgres Chat Memory - **Session ID**: `={{ $('Extract Message').item.json.userId }}` - Configure Postgres connection ### Step 6: Add Response Formatter 1. Add **Code** node after AI Agent 2. Name it: `Format Response` 3. Add this code: ```javascript // Format AI response for Telegram const aiOutput = $input.item.json; const chatId = $('Extract Message').item.json.chatId; let message = ''; if (aiOutput.output) { message = aiOutput.output; } else if (aiOutput.text) { message = aiOutput.text; } else { message = 'āœ… Task completed successfully!'; } // Handle long messages (Telegram limit: 4096 chars) if (message.length > 4000) { message = message.substring(0, 3900) + '\n\n... (message truncated, see logs for full output)'; } return [{ json: { chatId: chatId, text: message, parse_mode: 'Markdown', disable_web_page_preview: true } }]; ``` ### Step 7: Add Send Response Node 1. Add **Telegram** node 2. Configure: - **Operation**: `Send Message` - **Chat ID**: `={{ $json.chatId }}` - **Text**: `={{ $json.text }}` - **Additional Fields**: - Parse Mode: `Markdown` - Disable Web Page Preview: `true` --- ## āœ… Part 5: Testing ### Test 1: List Files Send to Telegram: `List all files in my project` Expected: AI lists files using `list_files` tool ### Test 2: Read a File Send: `Show me the contents of package.json` Expected: AI reads and displays file contents ### Test 3: Git Status Send: `What's my git status?` Expected: AI shows git status ### Test 4: Create and Commit Send: `Create a file called test.md with "Hello World" and commit it` Expected: AI creates file, stages it, and commits --- ## šŸ› Troubleshooting ### MCP Server Not Reachable ```bash # Check if server is running docker ps | grep mcp-file-git-server # Check logs docker logs mcp-file-git-server # Test from n8n container docker exec -it n8n-traefik-n8n-1 sh wget -O- http://mcp-file-git-server:3001/health exit ``` ### Permission Denied Errors ```bash # Fix permissions on project folder sudo chown -R $(id -u):$(id -g) /Users/lachaal/kjr/cursor # Check in container docker exec -it mcp-file-git-server sh ls -la /workspace exit ``` --- ## šŸŽ‰ You're Done! Your setup is complete! You now have: - āœ… MCP Server running with 13 tools - āœ… n8n with MCP integration - āœ… AI Agent with Claude API - āœ… Postgres memory for conversations - āœ… Telegram bot interface Start chatting with your bot to manage your project files and git repository!

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/osamaloup/mcp-file-git-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server