The Model Context Protocol did exactly what it promised. In a year it went from a spec to the default way AI clients reach real systems. Claude, Cursor and ChatGPT can now read your pull requests, query your database and list your EC2 instances, and setting that up takes a few lines of JSON.
That ease is also the problem. Look at how MCP actually arrives in most companies: someone finds a server on GitHub, pastes an npx command and an API token into their client config, and it works. Then a colleague does the same. Six months later, nobody can answer three simple questions.
- Which tokens are sitting in which laptops, with what permissions?
- Who asked an AI to call which tool, with which arguments, and what came back?
- What code are those MCP servers actually running, and what can it reach?
I work in DevOps, and these are the questions I get asked after an incident, not before. So I built a gateway that can answer them up front.
The part nobody likes to say out loud
An MCP server started with npx or uvx is a package downloaded from a public registry and run with your user's full rights. It sits in the same home directory as ~/.ssh, ~/.aws/credentials, browser sessions and every .env file you have ever cloned.
One compromised package, one typo-squatted name, one malicious update, and everything that laptop can reach is gone.
This is not a hypothetical class of attack. It is the same supply-chain risk every package ecosystem has lived with for years, now multiplied by the number of people on your team who wanted their assistant to see Jira.
The tokens are the second half. A Jira or GitHub token pasted into a client config usually carries the owner's full permissions, including the destructive ones. Every user sees every tool the server offers, and when someone asks why a ticket was closed or a branch deleted, there is no log to look at.
Put one door in front of everything
Lian MCP Gateway is a single container that sits between AI clients and MCP servers. Clients get one URL. Behind it, the gateway does four things that are hard to do one laptop at a time.
- It knows who is calling. People sign in with your company identity provider over SAML. Groups come from there.
- It decides what each group can see. A rule grants a group a whole server or a single tool. Tools a group can't call never appear in its
tools/list, so the AI doesn't even know they exist. - It holds the credentials. Tokens are stored encrypted on the gateway and injected at call time. They never reach a laptop, a browser or the model.
- It records every call. Who, which tool, the arguments, allowed or denied, and the result.
A concrete case: AWS in the chat
AWS is where this stops being abstract. Amazon publishes its own MCP server, and the value is obvious: an engineer asks which EC2 instances are running in production and gets a live answer instead of opening the console.
Here is how that looks behind the gateway. You connect Amazon's server once, with one scoped credential that only the gateway holds. The Engineering group is granted the four tools it needs, such as describe_instances, list_buckets and get_cost_and_usage. terminate_instances and put_bucket_policy are simply not granted, so they never show up in that group's AI.
Now someone asks the assistant to delete the prod-backups bucket. Maybe it was a mistake, maybe it was a prompt injection hidden in a document the model just read. Either way, a data-loss prevention rule on requests to production buckets matches the call and blocks it at the gateway. AWS never receives the request. The model gets a clear tool error, and the security channel gets an alert within seconds.
The same rules run on the way back. If a tool result contains an AWS access key, a card number or a national ID, the gateway can alert, redact it to [REDACTED] or block the result entirely, and the agent keeps working with the rest.
I was worried this would slow every call down, so I measured it. On a 2-vCPU server:
- DLP off
- about 20 nanoseconds per call
- Typical arguments
- under 1 microsecond
- Clean 4 KB result
- about 15 microseconds
Tool calls themselves take hundreds of milliseconds. The scan is noise.
Running other people's code, safely
Many useful MCP servers are local processes, the npx and uvx kind. The gateway runs them too, but on the gateway, once, instead of on every laptop. Clients connect by URL and install nothing.
Each of those processes starts inside a Linux Landlock sandbox. It cannot open the gateway's encryption key file, cannot read the gateway's environment or memory, and never receives the gateway's own settings. If a server package turns out to be malicious, the secrets that protect every other server are out of its reach.
I want to be precise about what that means. The sandbox protects the gateway's secrets. It is not a network jail: a server that needs to call an external API can still do so. That trade-off is deliberate, and it is still a very different risk profile from the same package running in your home directory, next to your SSH keys.
Seeing what the model sees
Two smaller features turned out to matter more than I expected.
The first is a view of exactly what an AI client receives from each server, as any group: the tool names, descriptions and parameters, the tools that were hidden and why, and the instructions sent on connect, which you can edit. When someone says "the AI can't find the tool", you can see in seconds whether that is an access rule or a bad description.
The second is signed identity for remote servers. If an upstream MCP server has its own permissions, the gateway can send it a short-lived RS256 token naming the user and their groups. The server checks it against the gateway's public keys and applies its own rules, without trusting a shared secret.
Try it
The gateway is free and open source under the MIT license. It runs as one container next to a MySQL 8 database, behind your own TLS proxy.
docker pull avnersib/mcp-gateway
docker run -d --name mcp-gateway \
--env-file .env -p 8120:8120 \
-v mcpgw-data:/app/data \
avnersib/mcp-gateway
The set-up guide covers the database, the encryption key (environment, AWS Secrets Manager or a key file) and the first admin. If you only want one thing from this post, let it be the question it started with: do you know which MCP servers are running on your team's laptops right now?
If you try it, I would like to hear what breaks, what is missing, and what would stop you from putting it in front of your own tools.