Skip to content
Back to search

mcp-gateway

A plugin-based gateway that orchestrates other MCPs and allows developers to build upon it enterprise-grade agents.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/lasso-security--mcp-gateway/badge.svg)](/listings/lasso-security--mcp-gateway)

HTML

<a href="/listings/lasso-security--mcp-gateway"><img src="/api/listings/lasso-security--mcp-gateway/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Python (recommended)

Install the mcp-gateway package:

pip install mcp-gateway

> `--mcp-json-path` - must lead to your [mcp.json](https://docs.cursor.com/context/model-context-protocol#configuration-locations) or [claude_desktop_config.json](https://modelcontextprotocol.io/quickstart/server#testing-your-server-with-claude-for-desktop) > `--plugin` or `-p` - Specify the plugins to enable (can be used multiple times)

Usage

This example enables the basic guardrail for token masking and xetrack tracing plugin for filesystem MCP:

mcp-gateway --mcp-json-path ~/.cursor/mcp.json -p basic -p xetrack

You can add more MCPs that will be under the Gateway by putting the MCP server configuration under the "servers" key.

<details> <summary>Cursor example:</summary>

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

</details>

<details> <summary>Claude example:</summary>

Get `<PYTHON_PATH>`

which python
{
  "mcpServers": {
      "mcp-gateway": {
          "command": "<python path>",
          "args": [
            "-m",
            "mcp_gateway.server",
            "--mcp-json-path",
            "<path to claude_desktop_config>",
            "--plugin",
            "basic"
          ],
          "servers": {
              "filesystem": {
                  "command": "npx",
                  "args": [
                      "-y",
                      "@modelcontextprotocol/server-filesystem",
                      "."
                  ]
              }
          }
      }
  }
}

</details>

<details> <summary>Docker</summary>

Build the image after clone this repo

docker build -t mcp/gateway .
{
  "mcpServers": {
      "mcp-gateway": {
          "command": "docker",
          "args": [
            "run",
            "--rm",
            "--mount", "type=bind,source=/Users/oro/Projects/playground/mcp-gateway,target=/app",
            "-i",
            "-v", "/Users/oro/.cursor/mcp.json:/config/mcp.json:ro",
            "-e", "LASSO_API_KEY=<LASSO_API_KEY>",
            "-v", "mcp-gateway-logs:/logs",
            "mcp/gateway:latest",
            "--mcp-json-path", "/config/mcp.json",
            "--plugin", "basic",
            "--plugin", "lasso"
          ],
          "servers": {
              "filesystem": {
                  "command": "npx",
                  "args": [
                      "-y",
                      "@modelcontextprotocol/server-filesystem",
                      "."
                  ]
              }
          }
      }
  }
}

In this example we use lasso and basic guardrail to show how we can pass enviroment varabile and arguments to the docker and how we can mount storage for the filesystem MCP. The Docker image can be built with optional dependencies required by certain plugins (e.g., `presidio`). Use the `INSTALL_EXTRAS` build argument during the `docker build` command. Provide a comma-separated string of the desired extras: `"presidio,xetrack"`

</details>

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 521 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. <div align="center">
  2. <a href="https://pypi.org/project/mcp-gateway/">
  3. <img src="https://img.shields.io/pypi/v/mcp-gateway.svg?color=blue" alt="PyPI version">
  4. </a>
  5. <a href="https://pypi.org/project/mcp-gateway/">
  6. <img src="https://img.shields.io/pypi/pyversions/mcp-gateway.svg" alt="Python Versions">
  7. </a>
  8. <a href="./LICENSE">
  9. <img src="https://img.shields.io/github/license/lasso-security/mcp-gateway" alt="License">
  10. </a>
  11. # MCP Gateway
  12. </div>
  13. # Overview
  14. ![](docs/MCP_Flow.png)
  15. MCP Gateway is an advanced intermediary solution for Model Context Protocol (MCP) servers that centralizes and enhances your AI infrastructure.
  16. MCP Gateway acts as an intermediary between LLMs and other MCP servers. It:
  17. 1. 📄 Reads server configurations from a `mcp.json` file located in your root directory.
  18. 2. ⚙️ Manages the lifecycle of configured MCP servers.
  19. 3. 🛡️ Intercepts requests and responses to sanitize sensitive information.
  20. 4. 🔗 Provides a unified interface for discovering and interacting with all proxied MCPs.
  21. 5. 🔒 **Security Scanner** - Analyzes server reputation and security risks before loading MCP servers.
  22. ## Installation
  23. ### Python (recommended)
  24. Install the mcp-gateway package:
  25. ```bash
  26. pip install mcp-gateway
  27. ```
  28. > `--mcp-json-path` - must lead to your [mcp.json](https://docs.cursor.com/context/model-context-protocol#configuration-locations) or [claude_desktop_config.json](https://modelcontextprotocol.io/quickstart/server#testing-your-server-with-claude-for-desktop)
  29. > `--plugin` or `-p` - Specify the plugins to enable (can be used multiple times)
  30. ### Usage
  31. This example enables the basic guardrail for token masking and xetrack tracing plugin for filesystem MCP:
  32. ```bash
  33. mcp-gateway --mcp-json-path ~/.cursor/mcp.json -p basic -p xetrack
  34. ```
  35. You can add more MCPs that will be under the Gateway by putting the MCP server configuration under the "servers" key.
  36. <details>
  37. <summary>Cursor example:</summary>
  38. ```json
  39. {
  40. "mcpServers": {
  41. "mcp-gateway": {
  42. "command": "mcp-gateway",
  43. "args": [
  44. "--mcp-json-path",
  45. "~/.cursor/mcp.json",
  46. "--plugin",
  47. "basic",
  48. "--plugin",
  49. "xetrack"
  50. ],
  51. "servers": {
  52. "filesystem": {
  53. "command": "npx",
  54. "args": [
  55. "-y",
  56. "@modelcontextprotocol/server-filesystem",
  57. "."
  58. ]
  59. }
  60. }
  61. }
  62. }
  63. }
  64. ```
  65. </details>
  66. <details>
  67. <summary>Claude example:</summary>
  68. Get `<PYTHON_PATH>`
  69. ```bash
  70. which python
  71. ```
  72. ```json
  73. {
  74. "mcpServers": {
  75. "mcp-gateway": {
  76. "command": "<python path>",
  77. "args": [
  78. "-m",
  79. "mcp_gateway.server",
  80. "--mcp-json-path",
  81. "<path to claude_desktop_config>",
  82. "--plugin",
  83. "basic"
  84. ],
  85. "servers": {
  86. "filesystem": {
  87. "command": "npx",
  88. "args": [
  89. "-y",
  90. "@modelcontextprotocol/server-filesystem",
  91. "."
  92. ]
  93. }
  94. }
  95. }
  96. }
  97. }
  98. ```
  99. </details>
  100. <details>
  101. <summary>Docker</summary>
  102. Build the image after clone this repo
  103. ```bash
  104. docker build -t mcp/gateway .
  105. ```
  106. ```json
  107. {
  108. "mcpServers": {
  109. "mcp-gateway": {
  110. "command": "docker",
  111. "args": [
  112. "run",
  113. "--rm",
  114. "--mount", "type=bind,source=/Users/oro/Projects/playground/mcp-gateway,target=/app",
  115. "-i",
  116. "-v", "/Users/oro/.cursor/mcp.json:/config/mcp.json:ro",
  117. "-e", "LASSO_API_KEY=<LASSO_API_KEY>",
  118. "-v", "mcp-gateway-logs:/logs",
  119. "mcp/gateway:latest",
  120. "--mcp-json-path", "/config/mcp.json",
  121. "--plugin", "basic",
  122. "--plugin", "lasso"
  123. ],
  124. "servers": {
  125. "filesystem": {
  126. "command": "npx",
  127. "args": [
  128. "-y",
  129. "@modelcontextprotocol/server-filesystem",
  130. "."
  131. ]
  132. }
  133. }
  134. }
  135. }
  136. }
  137. ```
  138. In this example we use lasso and basic guardrail to show how we can pass enviroment varabile and arguments to the docker and how we can mount storage for the filesystem MCP.
  139. The Docker image can be built with optional dependencies required by certain plugins (e.g., `presidio`).
  140. Use the `INSTALL_EXTRAS` build argument during the `docker build` command. Provide a comma-separated string of the desired extras: `"presidio,xetrack"`
  141. </details>
  142. ## Quickstart
  143. ### Masking Sensitive Information
  144. MCP Gateway will automatically mask the sensitive token in the response, preventing exposure of credentials while still providing the needed functionality.
  145. 1. Create a file with sensitive information:
  146. ```bash
  147. echo 'HF_TOKEN = "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"' > tokens.txt
  148. ```
  149. 2. When an agent requests to read this file through MCP Gateway:
  150. - Recommend to test with sonnet 3.7
  151. ```
  152. Use your mcp-gateway tools to read the ${pwd}/tokens.txt and return the HF_TOKEN
  153. ```
  154. **Output:**
  155. ![Hugging Face Token Masking Example](docs/hf_example.png)
  156. ## Usage
  157. Start the MCP Gateway server with python_env config on this repository root:
  158. ```bash
  159. mcp-gateway -p basic -p presidio
  160. ```
  161. You can also debug the server using:
  162. ```bash
  163. LOGLEVEL=DEBUG mcp-gateway --mcp-json-path ~/.cursor/mcp.json -p basic -p presidio
  164. ```
  165. ## Tools
  166. Here are the tools the MCP is using to create a proxy to the other MCP servers
  167. - **`get_metadata`** - Provides information about all available proxied MCPs to help LLMs choose appropriate tools and resources
  168. - **`run_tool`** - Executes capabilities from any proxied MCP after sanitizing the request and response
  169. # Plugins
  170. ## Contribute
  171. 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](./mcp_gateway/plugins/README.md).
  172. ## Guardrails
  173. MCP Gateway supports various plugins to enhance security and functionality. Here's a summary of the built-in guardrail plugins:
  174. | Name | PII Masking | Token/Secret Masking | Custom Policy | Prompt Injection | Harmful Content |
  175. | :---------- | :----------------------------------------------------------------------- | :----------------------------------------------------------------------------------- | :-----------: | :------------------: | :-------------: |
  176. | `basic` | ❌ | ✅ | ❌ | ❌ | ❌ |
  177. | `presidio` | ✅ | ❌ | ❌ | ❌ | ❌ |
  178. | `lasso` | ✅ | ✅ | ✅ | ✅ | ✅ |
  179. **Note:** To use the `presidio` plugin, you need to install it separately: `pip install mcp-gateway[presidio]`.
  180. ### Basic
  181. ```bash
  182. mcp-gateway -p basic
  183. ```
  184. Masking basic secerts
  185. - azure client secret
  186. - github tokens
  187. - github oauth
  188. - gcp api key
  189. - aws access token
  190. - jwt token
  191. - gitlab session cookie
  192. - huggingface access token
  193. - microsoft teams webhook
  194. - slack app token
  195. ### Presidio
  196. ```bash
  197. mcp-gateway -p presidio
  198. ```
  199. [Presidio](https://microsoft.github.io/presidio/) is identification and anonymization package
  200. - Credit Card
  201. - IP
  202. - Email
  203. - Phone
  204. - SSN
  205. - [Etc](https://microsoft.github.io/presidio/supported_entities/)
  206. ### Lasso
  207. ```bash
  208. mcp-gateway -p lasso
  209. ```
  210. #### Prerequisites
  211. - **Obtain a Lasso API key** by signing up at [Lasso Security](https://www.lasso.security/).
  212. To use Lasso Security's advanced AI safety guardrails, update your `mcp.json` configuration as follows:
  213. 1. Add the `LASSO_API_KEY=<YOUR-API-KEY>` to your environment variable or in the "env" section.
  214. 2. Insert other MCP servers configuration under key `servers`
  215. Example:
  216. ```json
  217. {
  218. "mcpServers": {
  219. "mcp-gateway": {
  220. "command": "mcp-gateway",
  221. "args": [
  222. "--mcp-json-path",
  223. "~/.cursor/mcp.json",
  224. "-p",
  225. "lasso"
  226. ],
  227. "env": {
  228. "LASSO_API_KEY": "<lasso_token>"
  229. },
  230. "servers": {
  231. "filesystem": {
  232. "command": "npx",
  233. "args": [
  234. "-y",
  235. "@modelcontextprotocol/server-filesystem",
  236. "."
  237. ]
  238. }
  239. }
  240. }
  241. }
  242. }
  243. ```
  244. #### Features
  245. 🔍 Full visibility into MCP interactions with an Always-on monitoring.
  246. 🛡️ Mitigate GenAI-specific threats like prompt injection and sensitive data leakage in real-time with built-in protection that prioritizes security from deployment.
  247. ✨ Use flexible, natural language to craft security policies tailored to your business's unique needs.
  248. ⚡ Fast and easy installation for any deployment style. Monitor data flow to and from MCP in minutes with an intuitive, user-friendly dashboard.
  249. The Lasso guardrail checks content through Lasso's API for security violations before processing requests and responses.
  250. Read more on our website 👉 [Lasso Security](https://www.lasso.security/).
  251. ## Tracing
  252. ### Xetrack
  253. [xetrack](https://github.com/xdssio/xetrack) is a lightweight package to track ml experiments, benchmarks, and monitor stractured data.
  254. We can use it to debug and monitor **tool calls** with logs ([loguru](https://github.com/Delgan/loguru)) or [duckdb](https://duckdb.org) and [sqlite](https://sqlite.org). .
  255. ```bash
  256. mcp-gateway -p xetrack
  257. ```
  258. #### Prerequisites
  259. `pip install xetrack`
  260. #### Params
  261. * `XETRACK_DB_PATH` - The sqlite db location.
  262. * All logs register in the *events* table.
  263. * If fancy objects return from the MCPs response, read about xetrack [assets](https://github.com/xdssio/xetrack?tab=readme-ov-file#track-assets-oriented-for-ml-models) to retrive it.
  264. * `XETRACK_LOGS_PATH` - The logs location
  265. * `FLATTEN_ARGUMENTS` - Flatten the arguments, default `true`
  266. * `FLATTEN_RESPONSE` - Flatten the response, default `true`
  267. * It is recommend to to gitignore the logs location
  268. * It is recommended to use [DVC](http://dvc.org) to manage the db file
  269. #### Quickstart
  270. ```json
  271. {
  272. "mcpServers": {
  273. "mcp-gateway": {
  274. "command": "mcp-gateway",
  275. "args": [
  276. "--mcp-json-path",
  277. "~/.cursor/mcp.json",
  278. "-p",
  279. "xetrack"
  280. ],
  281. "env": {
  282. "XETRACK_DB_PATH": "tracing.db",
  283. "XETRACK_LOGS_PATH": "logs/"
  284. },
  285. "servers": {
  286. "filesystem": {
  287. "command": "npx",
  288. "args": [
  289. "-y",
  290. "@modelcontextprotocol/server-filesystem",
  291. "."
  292. ]
  293. }
  294. }
  295. }
  296. }
  297. }
  298. ```
  299. Let's say you use the filesystem *list_directory* tool on path *"."*, you can find the call parameters under `logs/<date>.log`.
  300. You can expolre using [xetrack cli](https://github.com/xdssio/xetrack?tab=readme-ov-file#cli) to query the db:
  301. ```bash
  302. $ xt tail tracing.db --json --n=1
  303. [
  304. {
  305. "timestamp": "2025-04-17 17:12:48.233126",
  306. "track_id": "mottled-stingray-0411",
  307. "meta": "f3be31e09667745f",
  308. "paths": null,
  309. "call_id": "deab617e-0a45-4950-9de9-3fb549810cf2",
  310. "capability_name": "list_directory",
  311. "content_type": "text",
  312. "content_annotations": "f3be31e09667745f",
  313. "response_type": "CallToolResult",
  314. "server_name": "filesystem",
  315. "capability_type": "tool",
  316. "isError": 0,
  317. "content_text": "[DIR] .cursor\n[DIR] .git\n[FILE] .gitignore\n[DIR] .pytest_cache\n[DIR] .venv\n[FILE] LICENSE\n[FILE] MANIFEST.in\n[FILE] README.md\n[DIR] docs\n[DIR] logs\n[DIR] mcp_gateway\n[FILE] pyproject.toml\n[FILE] requirements.txt\n[DIR] tests\n[DIR] tmp",
  318. "path": ".",
  319. "prompt": null
  320. }
  321. ]
  322. ```
  323. With python
  324. ```python
  325. from xetrack import Reader
  326. df = Reader("tracing.db").to_df()
  327. ```
  328. With duckdb cli and ui
  329. ```bash
  330. $ duckdb --ui
  331. D INSTALL sqlite; LOAD sqlite; ATTACH 'tracing.db' (TYPE sqlite);
  332. D SELECT server_name,capability_name,path,content_text FROM db.events LIMIT 1;
  333. ┌─────────────┬─────────────────┬─────────┬────────────────────────────────────┐
  334. │ server_name │ capability_name │ path │ content_text │
  335. │ varchar │ varchar │ varchar │ varchar │
  336. ├─────────────┼─────────────────┼─────────┼────────────────────────────────────┤
  337. │ filesystem │ list_directory │ . │ [DIR] .cursor\n[DIR] .git\n[FILE… │
  338. └─────────────┴─────────────────┴─────────┴────────────────────────────────────┘
  339. ```
  340. Of course you can use another MCP server to query the sqlite database 😊
  341. # Scanner
  342. The Security Scanner analyzes MCP servers for potential security risks before loading, providing an additional layer of protection through reputation analysis and tool description scanning.
  343. ```bash
  344. mcp-gateway --scan -p basic
  345. ```
  346. **Features:**
  347. - 🔍 **Reputation Analysis** - Evaluates server reputation using marketplace (Smithery, NPM) and GitHub data
  348. - 🛡️ **Tool Description Scanning** - Detects hidden instructions, sensitive file patterns, and malicious actions
  349. - ⚡ **Automatic Blocking** - Blocks risky MCPs based on reputation scores (threshold: 30) and security analysis
  350. - 📝 **Configuration Updates** - Automatically updates your MCP configuration file with scan results
  351. ## Quickstart
  352. Initial configuration:
  353. ```json
  354. {
  355. "mcpServers": {
  356. "mcp-gateway": {
  357. "command": "mcp-gateway",
  358. "args": [
  359. "--mcp-json-path",
  360. "~/.cursor/mcp.json",
  361. "--scan"
  362. ],
  363. "servers": {
  364. "filesystem": {
  365. "command": "npx",
  366. "args": [
  367. "-y",
  368. "@modelcontextprotocol/server-filesystem",
  369. "."
  370. ]
  371. }
  372. }
  373. }
  374. }
  375. }
  376. ```
  377. After the first run, the scanner will analyze all configured MCP servers and add a `blocked` status to your configuration:
  378. ```json
  379. {
  380. "mcpServers": {
  381. "mcp-gateway": {
  382. "command": "mcp-gateway",
  383. "args": [
  384. "--mcp-json-path",
  385. "~/.cursor/mcp.json",
  386. "--scan"
  387. ],
  388. "servers": {
  389. "filesystem": {
  390. "command": "npx",
  391. "args": [
  392. "-y",
  393. "@modelcontextprotocol/server-filesystem",
  394. "."
  395. ],
  396. "blocked": "passed"
  397. }
  398. }
  399. }
  400. }
  401. }
  402. ```
  403. **Status Values:**
  404. - `"passed"` - Server passed all security checks and is safe to use
  405. - `"blocked"` - Server failed security checks and will be blocked from loading
  406. - `"skipped"` - Server scanning was skipped (manual override)
  407. - `null` - Server not yet scanned or previously blocked server now considered safe
  408. > **Note:** You can manually change a blocked server to `"skipped"` if you're confident it's safe.
  409. ## How It Works
  410. 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.
  411. Key Features
  412. **Agnostic Guardrails**
  413. * Applies configurable security filters to both requests and responses.
  414. * Prevents sensitive data exposure before information reaches your agent.
  415. * Works consistently across all connected MCPs regardless of their native capabilities.
  416. **Unified Visibility**
  417. * Provides comprehensive dashboard for all your MCPs in a single interface.
  418. * Includes intelligent risk assessment with MCP risk scoring.
  419. * Delivers real-time status monitoring and performance metrics.
  420. **Security Scanner**
  421. * Analyzes MCP server reputation and tool descriptions for security risks before loading.
  422. **Advanced Tracking**
  423. * Maintains detailed logs of all requests and responses for each guardrail.
  424. * Offers cost evaluation tools for MCPs requiring paid tokens.
  425. * Provides usage analytics and pattern identification for optimization.
  426. * Sanitizes sensitive information before forwarding requests to other MCPs.
  427. ## License
  428. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.