Sponsored by Deepsite.site

MCP Gateway

Created By
lasso-security8 months ago
A plugin-based gateway that orchestrates other MCPs and allows developers to build upon it enterprise-grade agents.
Content

MCP Gateway

Hugging Face Token Masking Example

MCP Gateway is an advanced intermediary solution for Model Context Protocol (MCP) servers that centralizes and enhances your AI infrastructure.

How It Works

Your agent interacts directly with our MCP Gateway, which functions as a central router and management system. Each underlying MCP is individually wrapped and managed.

Key Features

Agnostic Guardrails

  • Applies configurable security filters to both requests and responses.
  • Prevents sensitive data exposure before information reaches your agent.
  • Works consistently across all connected MCPs regardless of their native capabilities.

Unified Visibility

  • Provides comprehensive dashboard for all your MCPs in a single interface.
  • Includes intelligent risk assessment with MCP risk scoring.
  • Delivers real-time status monitoring and performance metrics.

Advanced Tracking

  • Maintains detailed logs of all requests and responses for each guardrail.
  • Offers cost evaluation tools for MCPs requiring paid tokens.
  • Provides usage analytics and pattern identification for optimization.
  • Sanitizes sensitive information before forwarding requests to other MCPs.

Overview

MCP Gateway acts as an intermediary between LLMs and other MCP servers. It:

  1. Reads server configurations from a mcp.json file located in your root directory.
  2. Manages the lifecycle of configured MCP servers.
  3. Intercepts requests and responses to sanitize sensitive information.
  4. Provides a unified interface for discovering and interacting with all proxied MCPs.

Installation

Install the mcp-gateway package:

pip install mcp-gateway

Install the mcp-gateway package with presidio guardrail:

pip install mcp-gateway[presidio]

Run

This is an example of how to add to your mcp.json in cursor:

{
  "mcpServers": {
      "mcp-gateway": {
          "command": "mcp-gateway",
          "args": [
              "--mcp-json-path",
              "~/.cursor/mcp.json",
              "--enable-guardrails",
              "basic",
              "--enable-guardrails",
              "presidio"
          ],
          "servers": {
              "filesystem": {
                  "command": "npx",
                  "args": [
                      "-y",
                      "@modelcontextprotocol/server-filesystem",
                      "."
                  ]
              }
          }
      }
  }
}

This example gives you the basic and presidio guardrails for token and PII masking for filesystem MCP. You can add more MCPs that will be under the Gateway by putting the MCP server configuration under the "servers" key.

Usage

Start the MCP Gateway server with python_env config on this repository root:

mcp-gateway --enable-guardrails basic --enable-guardrails presidio

You can also debug the server using:

LOGLEVEL=DEBUG mcp-gateway --mcp-json-path ~/.cursor/mcp.json --enable-guardrails basic --enable-guardrails presidio

Features

  • Tool: get_metadata - Provides information about all available proxied MCPs to help LLMs choose appropriate tools and resources
  • Tool: run_tool - Executes capabilities from any proxied MCP after sanitizing the request and response

Available Plugins

Guardrails

MCP Gateway supports various plugins to enhance security and functionality. Here's a summary of the built-in guardrail plugins:

Plugin NameDescriptionActivation ArgumentPII MaskingToken/Secret MaskingCustom PolicyJailbreak PreventionHarmful Content
basicMasks common secrets (API Keys: AWS, GCP, Azure; Tokens: GitHub, HF, JWT, Slack, etc.) using regex.--enable-guardrails basic✅ (API Keys, Various Tokens)
presidioMasks PII (Credit Card, IP, Email, Phone, SSN, etc.) using the Presidio library.--enable-guardrails presidio✅ (Credit Card, IP, Email, Phone, SSN, etc.) See Presidio for details.
lassoComprehensive security via Lasso Security API. See Lasso Security for details.--enable-guardrails lasso

Note: To use the presidio plugin, you need to install it separately: pip install mcp-gateway[presidio].

For more details on how the plugin system works, how to create your own plugins, or how to contribute, please see the Plugin System Documentation.

Use Cases

Masking Sensitive Information

MCP Gateway can mask sensitive information like tokens and credentials:

  1. Create a file with sensitive information:

    echo 'HF_TOKEN = "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"' > tokens.txt
    
  2. When an agent requests to read this file through MCP Gateway:

    Use your mcp-gateway tools to read the ${pwd}/tokens.txt and return the HF_TOKEN
    

    “Recommend with sonnet”

  3. MCP Gateway will automatically mask the sensitive token in the response, preventing exposure of credentials while still providing the needed functionality.

Example of Masked Sensitive Information

The image below shows how MCP Gateway automatically masks a Hugging Face token in the response:

Hugging Face Token Masking Example

Using Lasso Guardrails

To use Lasso Security's advanced AI safety guardrails, update your mcp.json configuration as follows:

  1. Replace the existing guardrails with the "lasso" guardrail.
  2. Add the LASSO_API_KEY environment variable in the "env" section.

Here's how to configure it:

{
  "mcpServers": {
      "mcp-gateway": {
          "command": "mcp-gateway",
          "args": [
              "--mcp-json-path",
              "~/.cursor/mcp.json",
              "--enable-guardrails",
              "lasso"
          ],
          "env": {
              "LASSO_API_KEY": "<lasso_token>"
          },
          "servers": {
              "filesystem": {
                  "command": "npx",
                  "args": [
                      "-y",
                      "@modelcontextprotocol/server-filesystem",
                      "."
                  ]
              }
          }
      }
  }
}

You will need to:

  1. Obtain a Lasso API key by signing up at Lasso Security.
  2. Replace <lasso_token> with your actual Lasso API key.

When running with Lasso guardrails, you can also use:

mcp-gateway --enable-guardrails lasso

With Lasso you get:

🔍 Full visibility into MCP interactions with an Always-on monitoring.

🛡️ Mitigate GenAI-specific threats like prompt injection and sensitive data leakage in real-time with built-in protection that prioritizes security from deployment.

✨ Use flexible, natural language to craft security policies tailored to your business's unique needs.

⚡ Fast and easy installation for any deployment style. Monitor data flow to and from MCP in minutes with an intuitive, user-friendly dashboard.

The Lasso guardrail checks content through Lasso's API for security violations before processing requests and responses.

Read more on our website 👉 Lasso Security.

License

MIT

Server Config

{
  "mcpServers": {
    "mcp-gateway": {
      "command": "mcp-gateway",
      "args": [
        "--mcp-json-path",
        "~/.cursor/mcp.json",
        "--enable-guardrails",
        "basic",
        "--enable-guardrails",
        "presidio"
      ],
      "servers": {}
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
DeepChatYour AI Partner on Desktop
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
CursorThe AI Code Editor
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Amap Maps高德地图官方 MCP Server
ChatWiseThe second fastest AI chatbot™
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Tavily Mcp
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
WindsurfThe new purpose-built IDE to harness magic
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Serper MCP ServerA Serper MCP Server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Playwright McpPlaywright MCP server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"