Skip to main content

Security gateway for Model Context Protocol (MCP) to protect AI tool interactions

Project description

LangProtect MCP Gateway

๐Ÿ›ก๏ธ Security gateway for Model Context Protocol (MCP) - Protect your AI tool interactions from security threats.

PyPI version

Features

โœ… Automatic Threat Detection - Scans all MCP requests for security risks
โœ… Access Control - Whitelist/blacklist MCP servers and tools
โœ… Full Audit Trail - Logs all AI interactions for compliance
โœ… IDE Support - Works with VS Code, Cursor, and all MCP-compatible IDEs
โœ… Easy Setup - 30-second installation โœ… Fail-Open Design - Won't block your workflow if backend is unavailable

Quick Start

Installation

The gateway runs as a global CLI tool. Choose your platform:

Linux (Debian/Ubuntu) - Recommended: pipx

# Install pipx (one time)
sudo apt install pipx -y
pipx ensurepath

# Install the gateway
pipx install langprotect-mcp-gateway

macOS - Recommended: pipx

# Install pipx via Homebrew
brew install pipx
pipx ensurepath

# Install the gateway
pipx install langprotect-mcp-gateway

Windows

# Option 1: pipx (recommended)
pip install pipx
pipx install langprotect-mcp-gateway

# Option 2: User install
pip install --user langprotect-mcp-gateway

Verify Installation

which langprotect-gateway   # Should show: ~/.local/bin/langprotect-gateway
langprotect-gateway --help  # Should show usage info

VS Code Setup (Recommended - No Wrapper Script!)

Step 1: Add this to your .vscode/mcp.json:

{
  "servers": {
    "langprotect-gateway": {
      "type": "stdio",
      "command": "langprotect-gateway",
      "args": ["--mcp-json-path", "${workspaceFolder}/.vscode/mcp.json"],
      "env": {
        "LANGPROTECT_URL": "http://localhost:8000",
        "LANGPROTECT_EMAIL": "your.email@company.com",
        "LANGPROTECT_PASSWORD": "your-password"
      },
      "servers": {
        "filesystem": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
        }
      }
    }
  }
}

Step 2 (Optional): Enable auto-start in .vscode/settings.json:

{
  "chat.mcp.autostart": "newAndOutdated"
}

This makes VS Code automatically start the gateway when you open the workspace!

That's it! VS Code will:

  1. Start the gateway with your credentials (automatically if autostart is enabled)
  2. Gateway reads the servers section and proxies those MCP servers
  3. All tool calls get logged to LangProtect

Alternative: Wrapper Script Setup

If you prefer using a wrapper script (useful for shared configs):

  1. Create a wrapper script (e.g., langprotect-wrapper.sh):
#!/bin/bash
export LANGPROTECT_URL="http://localhost:8000"  # Your LangProtect backend
export LANGPROTECT_EMAIL="your.email@company.com"
export LANGPROTECT_PASSWORD="your-password"
export MCP_SERVER_COMMAND="npx"
export MCP_SERVER_ARGS="-y,@modelcontextprotocol/server-filesystem,/path/to/allowed/dir"

exec langprotect-gateway "$@"
  1. Make it executable: chmod +x langprotect-wrapper.sh

  2. Create .vscode/mcp.json:

{
  "servers": {
    "langprotect-filesystem": {
      "type": "stdio",
      "command": "/path/to/langprotect-wrapper.sh",
      "args": []
    }
  }
}
  1. Reload VS Code: Ctrl+Shift+P โ†’ "Developer: Reload Window"

  2. Start the server: Ctrl+Shift+P โ†’ "MCP: List Servers" โ†’ Click "Start"

Cursor Setup

{
  "mcpServers": {
    "langprotect-gateway": {
      "command": "langprotect-gateway",
      "args": ["--mcp-json-path", "~/.cursor/mcp.json"],
      "env": {
        "LANGPROTECT_URL": "http://localhost:8000",
        "LANGPROTECT_EMAIL": "your.email@company.com",
        "LANGPROTECT_PASSWORD": "your-password"
      },
      "servers": {
        "filesystem": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
        }
      }
    }
  }
}

Claude Desktop Setup

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "langprotect-gateway": {
      "command": "langprotect-gateway",
      "args": ["--mcp-json-path", "~/Library/Application Support/Claude/claude_desktop_config.json"],
      "env": {
        "LANGPROTECT_URL": "http://localhost:8000",
        "LANGPROTECT_EMAIL": "your.email@company.com",
        "LANGPROTECT_PASSWORD": "your-password"
      },
      "servers": {
        "filesystem": {
          "command": "npx",
          "args": ["-y", "@modelcontextprotocol/server-filesystem", "."]
        }
      }
    }
  }
}

How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   VS Code   โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚ LangProtect Gatewayโ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  Filesystem MCP  โ”‚
โ”‚  (Copilot)  โ”‚     โ”‚   (Security Scan)  โ”‚     โ”‚    Server        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚ LangProtect Backendโ”‚
                    โ”‚  (Policy Check)    โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  1. Intercepts all MCP tool calls from your AI assistant
  2. Sends each request to LangProtect backend for security scanning
  3. Blocks requests that violate your security policies
  4. Forwards allowed requests to the actual MCP server
  5. Logs everything for audit trail โ†“ LangProtect Gateway (this package) โ†“ [Security Scan] โ†“ MCP Servers (filesystem, github, etc.)

Every request is:
1. Intercepted by the gateway
2. Scanned for security threats
3. Logged to LangProtect backend
4. Forwarded to actual MCP server (if safe)
5. Response returned to AI

## Dashboard

Monitor all activity at your LangProtect dashboard:
- View all AI interactions
- See security threats blocked
- Track IDE usage
- Generate compliance reports

## Security

The gateway protects against:
- ๐Ÿšซ Sensitive file access (`.env`, SSH keys, etc.)
- ๐Ÿšซ Dangerous commands (`rm -rf`, data exfiltration)
- ๐Ÿšซ SQL injection patterns
- ๐Ÿšซ Hardcoded credentials in suggestions
- ๐Ÿšซ Prompt injection attacks

## Troubleshooting

**"externally-managed-environment" error on Linux:**
- Modern Linux systems protect system Python. Use `pipx` instead:
  ```bash
  sudo apt install pipx -y
  pipx install langprotect-mcp-gateway

Authentication failed:

  • Check LANGPROTECT_URL, LANGPROTECT_EMAIL, LANGPROTECT_PASSWORD are correct
  • Ensure LangProtect backend is accessible

Gateway not starting:

  • Check Python version: python3 --version (need 3.8+)
  • Check package installed: pipx list | grep langprotect
  • Verify path: which langprotect-gateway

Tools not working:

  • Check MCP servers are configured under "servers" section
  • Restart IDE completely

Command not found after install:

  • Run pipx ensurepath and restart your terminal
  • Or add ~/.local/bin to your PATH manually

For Team Leads

Quick Team Rollout:

  1. Share credentials with each team member:

    Email: user@company.com
    Password: secure-password
    Server: http://langprotect.company.com:8000
    
  2. Team members install:

    # Linux/macOS
    sudo apt install pipx -y  # or: brew install pipx
    pipx install langprotect-mcp-gateway
    
    # Configure mcp.json with credentials
    # Restart IDE
    
  3. Monitor dashboard: See all team activity in real-time

Updates

# Upgrade with pipx
pipx upgrade langprotect-mcp-gateway

# Or reinstall specific version
pipx install langprotect-mcp-gateway==1.1.0 --force

Support

License

MIT License - see LICENSE file for details

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langprotect_mcp_gateway-1.2.2.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langprotect_mcp_gateway-1.2.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file langprotect_mcp_gateway-1.2.2.tar.gz.

File metadata

  • Download URL: langprotect_mcp_gateway-1.2.2.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for langprotect_mcp_gateway-1.2.2.tar.gz
Algorithm Hash digest
SHA256 2a3eeed32e615940ddc0ac7b8e359e17ebccf2d816321679afdd5293884e70c4
MD5 59d8f447d798e9a0a2bd11d5bd03a980
BLAKE2b-256 a17ea1226628de636358484ef47c5550fdee088df0a2627d3cd5ac4a48a93cbf

See more details on using hashes here.

File details

Details for the file langprotect_mcp_gateway-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for langprotect_mcp_gateway-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 db9ccb7623b420eaf3a7692f2a77ecc7c9908c1283f651eee8120c7288d1c752
MD5 0af5d09b5d10e66d14d8aebf24d37233
BLAKE2b-256 26ea449642ed2ef92161c263c8de2eb0c7f0f26adc413ea230cad4cb3a9ded04

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page