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.
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
Automatic Setup (Recommended)
Run the setup command to automatically configure VS Code:
langprotect-gateway-setup
This will:
- โ Create a global wrapper script
- โ Configure VS Code to use LangProtect in ALL workspaces
- โ Enable auto-start
Then edit the wrapper script to add your credentials:
# Linux/macOS
nano ~/.local/bin/langprotect-mcp-wrapper.sh
# Update these lines:
export LANGPROTECT_URL="http://localhost:8000"
export LANGPROTECT_EMAIL="your.email@company.com"
export LANGPROTECT_PASSWORD="your-password"
Reload VS Code and you're done! LangProtect will protect all your workspaces.
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:
- Start the gateway with your credentials (automatically if autostart is enabled)
- Gateway reads the
serverssection and proxies those MCP servers - All tool calls get logged to LangProtect
Alternative: Wrapper Script Setup
If you prefer using a wrapper script (useful for shared configs):
- 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 "$@"
-
Make it executable:
chmod +x langprotect-wrapper.sh -
Create
.vscode/mcp.json:
{
"servers": {
"langprotect-filesystem": {
"type": "stdio",
"command": "/path/to/langprotect-wrapper.sh",
"args": []
}
}
}
-
Reload VS Code:
Ctrl+Shift+Pโ "Developer: Reload Window" -
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) โ
โโโโโโโโโโโโโโโโโโโโโโ
- Intercepts all MCP tool calls from your AI assistant
- Sends each request to LangProtect backend for security scanning
- Blocks requests that violate your security policies
- Forwards allowed requests to the actual MCP server
- 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_PASSWORDare 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 ensurepathand restart your terminal - Or add
~/.local/binto your PATH manually
For Team Leads
Quick Team Rollout:
-
Share credentials with each team member:
Email: user@company.com Password: secure-password Server: http://langprotect.company.com:8000 -
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
-
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
- Documentation: https://www.langprotect.com/docs
- Issues: https://github.com/langprotect/mcp-gateway/issues
- Security: security@langprotect.com
License
MIT License - see LICENSE file for details
Links
- Homepage: https://www.langprotect.com/
- GitHub: https://github.com/langprotect/mcp-gateway
- Documentation: https://www.langprotect.com/docs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langprotect_mcp_gateway-1.2.4.tar.gz.
File metadata
- Download URL: langprotect_mcp_gateway-1.2.4.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54fa2eacd6125047bdfdb06352d307ed844433fbed7c1b10cbfdb8c0ad76b756
|
|
| MD5 |
b0a42d0b67cbdb6dc0cc7e771de0a133
|
|
| BLAKE2b-256 |
56703cedbccded5baef5b600740951f8b17773d178799660e6627662f1f8dd15
|
File details
Details for the file langprotect_mcp_gateway-1.2.4-py3-none-any.whl.
File metadata
- Download URL: langprotect_mcp_gateway-1.2.4-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e729ac6d18781c9b2b227a564252c710f0fb409dcad5d65c548a68ff3e1d4c9c
|
|
| MD5 |
5417ec6db1675b14ca01d4eb30678d57
|
|
| BLAKE2b-256 |
704d0af5f236dda994e7a697a7ee827adda1b0d90413c4549b32ef5551e367cc
|