UNPKG

sap-b1-mcp-server

Version:

SAP Business One Service Layer MCP Server

309 lines (235 loc) 7.57 kB
# 🚀 SAP B1 MCP Server - Deployment Guide ## 📦 Deploying to Another Machine ### 🎯 Quick Deployment Steps 1. **Copy Project Files** 2. **Install Dependencies** 3. **Configure SAP Credentials** 4. **Build & Setup Claude Desktop** 5. **Test Connection** --- ## 📋 Step-by-Step Deployment ### 1️⃣ **Copy Project to Target Machine** **Option A: Git Clone (Recommended)** ```bash # Clone the repository git clone <your-repo-url> sap_mcp cd sap_mcp # Or copy from existing machine scp -r /Users/alexchabanenko/Projects/sap_mcp user@target-machine:~/ ``` **Option B: Archive Transfer** ```bash # On source machine tar -czf sap_mcp_deploy.tar.gz /Users/alexchabanenko/Projects/sap_mcp # Transfer to target machine scp sap_mcp_deploy.tar.gz user@target-machine:~/ ssh user@target-machine "tar -xzf sap_mcp_deploy.tar.gz" ``` ### 2️⃣ **Install Prerequisites on Target Machine** **Install Bun Runtime** ```bash # Install Bun curl -fsSL https://bun.sh/install | bash # Add to PATH (add to ~/.bashrc or ~/.zshrc) export PATH="$HOME/.bun/bin:$PATH" source ~/.bashrc # or ~/.zshrc # Verify installation bun --version which bun # Note this path for Claude Desktop config ``` **Install Claude Desktop** - Download from [claude.ai](https://claude.ai/download) - Install the application ### 3️⃣ **Configure SAP B1 Credentials** Navigate to the project directory and configure your SAP credentials: ```bash cd sap_mcp # Copy environment template cp .env.example .env # Edit with your SAP B1 credentials nano .env # or vim .env ``` **Required `.env` Configuration:** ```env # SAP Business One Configuration SAP_B1_SERVER_URL=https://your-sap-server:50000 SAP_B1_DATABASE=YOUR_COMPANY_DATABASE SAP_B1_USERNAME=your_sap_username SAP_B1_PASSWORD=your_sap_password SAP_B1_SESSION_TIMEOUT=30 # MCP Server Configuration MCP_TRANSPORT=stdio # Logging Configuration LOG_LEVEL=INFO NODE_ENV=production ``` ### 4️⃣ **Build and Setup** **Install Dependencies & Build** ```bash # Install all dependencies bun install # Build the project bun run build:tsc # Verify build ls -la dist/ # Should see index.js and other compiled files ``` **Test MCP Server** ```bash # Test the server works bun start # Should show: "SAP B1 MCP Server connected via STDIO" # Press Ctrl+C to stop ``` **Setup Claude Desktop Integration** ```bash # Run the automated setup script chmod +x setup-claude-desktop.sh ./setup-claude-desktop.sh ``` ### 5️⃣ **Manual Claude Desktop Configuration (Alternative)** If the automated script doesn't work, manually configure: **Find Claude Desktop Config Location:** - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json` - **Windows**: `%APPDATA%/Claude/claude_desktop_config.json` - **Linux**: `~/.config/Claude/claude_desktop_config.json` **Configuration Template:** ```json { "mcpServers": { "sap-b1": { "command": "/full/path/to/bun", "args": ["/full/path/to/sap_mcp/dist/index.js"], "cwd": "/full/path/to/sap_mcp", "env": { "MCP_TRANSPORT": "stdio", "SAP_B1_SERVER_URL": "https://your-sap-server:50000", "SAP_B1_DATABASE": "YOUR_COMPANY_DATABASE", "SAP_B1_USERNAME": "your_sap_username", "SAP_B1_PASSWORD": "your_sap_password", "SAP_B1_SESSION_TIMEOUT": "30", "LOG_LEVEL": "INFO", "NODE_ENV": "production" } } } } ``` **⚠️ Important:** Replace these placeholders: - `/full/path/to/bun` - Get with: `which bun` - `/full/path/to/sap_mcp` - Your project directory - All SAP credentials with your actual values --- ## ✅ Testing Your Deployment ### 1. **Test MCP Server Directly** ```bash cd sap_mcp bun start # Should connect successfully without errors ``` ### 2. **Test Claude Desktop Integration** 1. **Restart Claude Desktop** completely (quit and reopen) 2. Start a **new conversation** 3. Look for 🔌 **MCP connection indicator** 4. Test with: *"What MCP tools do you have access to?"* 5. Expected: List of 26+ SAP B1 tools including stock and pricing tools ### 3. **Test SAP B1 Connection** In Claude Desktop, ask: - *"Check my SAP session status"* - *"Get the first 5 customers"* - *"Get stock levels for item 10001 in warehouse 01"* --- ## 🔧 Troubleshooting ### **Common Issues** **1. "spawn bun ENOENT"** - **Fix**: Use full path to bun in Claude Desktop config - **Get path**: `which bun` (usually `/home/user/.bun/bin/bun`) **2. "Missing required environment variables"** - **Fix**: Add all SAP_B1_* variables to Claude Desktop config `env` section - **Check**: .env file has all required credentials **3. "Module not found dist/index.js"** - **Fix**: Use absolute paths in Claude Desktop config - **Check**: `bun run build:tsc` completed successfully **4. SAP Connection Fails** - **Fix**: Verify SAP server URL, credentials, and network access - **Test**: `curl https://your-sap-server:50000/b1s/v1/$metadata` ### **Debug Commands** ```bash # Check bun installation bun --version which bun # Verify build ls -la dist/index.js # Test direct command bun dist/index.js # Check Claude Desktop logs (macOS) tail -f ~/Library/Logs/Claude/mcp-server-sap-b1.log ``` --- ## 🎁 Deployment Package ### **Create Deployment Archive** For easy deployment, create a complete package: ```bash # Create deployment archive (exclude sensitive files) tar -czf sap_mcp_deploy.tar.gz \ --exclude='.env' \ --exclude='node_modules' \ --exclude='.git' \ --exclude='*.log' \ sap_mcp/ # Archive includes: # ✅ Source code # ✅ Package files (package.json, etc.) # ✅ Setup scripts # ✅ Documentation # ❌ Sensitive credentials (.env) # ❌ Dependencies (node_modules) ``` ### **Deployment Checklist** - [ ] **Bun installed** and in PATH - [ ] **Claude Desktop** installed - [ ] **Project files** copied - [ ] **Dependencies** installed (`bun install`) - [ ] **Project built** (`bun run build:tsc`) - [ ] **SAP credentials** configured in `.env` - [ ] **Claude Desktop** configured - [ ] **MCP server** tested directly - [ ] **Claude Desktop** connection tested - [ ] **SAP B1 tools** tested --- ## 📊 Available Tools After Deployment Once deployed, you'll have access to **26+ SAP B1 tools** via Claude Desktop: ### 🔑 **Authentication & Session (3 tools)** - `sap_login`, `sap_logout`, `sap_session_status` ### 👥 **Master Data Operations (9 tools)** - `sap_get_business_partners`, `sap_create_business_partner` - `sap_get_items`, `sap_create_item` - `sap_get_warehouses`, `sap_get_pricelists` ### 📄 **Document Operations (6 tools)** - `sap_get_orders`, `sap_create_order` - `sap_get_invoices`, `sap_create_invoice` - `sap_get_purchase_orders`, `sap_create_purchase_order` ### 🔍 **Advanced Queries (2 tools)** - `sap_query`, `sap_cross_join` ### 📊 **Stock & Pricing Tools (4 tools)***NEW* - `sap_get_item_stock` - Get stock for item in specific warehouse - `sap_get_item_stock_all` - Get stock for item in all warehouses - `sap_get_item_price` - Get price for item in specific price list - `sap_get_item_prices_all` - Get prices for item in all price lists --- ## 🔄 Updates and Maintenance ### **Update Deployment** ```bash # Pull latest changes git pull origin main # Rebuild bun install bun run build:tsc # Restart Claude Desktop # No config changes needed if structure remains same ``` ### **Change SAP Credentials** 1. Update `.env` file OR 2. Update Claude Desktop config `env` section 3. Restart Claude Desktop --- **🎉 Your SAP B1 MCP Server is now ready for deployment across multiple machines!**