← Back to Learn
mcpsecuritytools

MCP server security basics

Authensor

The Model Context Protocol (MCP) is a standard for connecting AI agents to tools and data sources. An MCP server exposes capabilities like file access, database queries, API calls, and shell execution. An MCP client (usually an AI agent) connects to the server and calls these tools.

The problem: MCP servers have no built-in authorization. Any connected client can call any tool with any arguments. There is no policy layer, no approval workflow, and no audit trail.

Why MCP servers need security

Research has found that 32% of MCP servers have critical vulnerabilities. Common issues include:

  • No access control - Any connected agent can call any tool
  • No input validation - Tool arguments are passed through without checks
  • No audit logging - There is no record of what tools were called or by whom
  • Privilege escalation - Agents can chain tool calls to gain capabilities they should not have
  • Data exfiltration - Tools that read files or databases can be used to extract sensitive data

These are not theoretical risks. When you connect Claude Desktop, Cursor, or any other MCP client to a filesystem server, that agent can read any file the server has access to. If a prompt injection attack succeeds, the agent will use those tools on behalf of the attacker.

The MCP Gateway approach

An MCP Gateway is a transparent proxy that sits between the MCP client and the MCP server. Every tool call passes through the gateway, which evaluates it against a policy before forwarding it to the server.

Agent (MCP Client) -> MCP Gateway -> MCP Server -> Real World

The gateway intercepts every tools/call request, wraps it in an authorization envelope, evaluates it against your policy, and either forwards it or blocks it. From the agent's perspective, it is talking to a normal MCP server. From the real MCP server's perspective, it is receiving normal tool calls. The gateway is invisible to both sides.

Setting up an MCP Gateway

With Authensor, you configure the gateway in your MCP client config:

{
  "mcpServers": {
    "authensor-gateway": {
      "command": "npx",
      "args": [
        "@authensor/mcp-server",
        "--gateway",
        "--upstream", "npx @modelcontextprotocol/server-filesystem /tmp"
      ]
    }
  }
}

This wraps the filesystem MCP server with the Authensor gateway. Every file operation now goes through policy evaluation.

Writing policies for MCP tools

Policies define what tools can be called and under what conditions:

version: "1"
default: deny
rules:
  - tool: "read_file"
    action: allow
    constraints:
      allowedPaths: ["/tmp/", "/home/user/projects/"]

  - tool: "write_file"
    action: escalate
    reason: "File writes require approval"

  - tool: "execute_command"
    action: deny
    reason: "Shell execution is not permitted"

This policy allows file reads within specific directories, requires human approval for file writes, and blocks shell execution entirely. The default: deny means any tool not explicitly mentioned is blocked.

The SEP authorization protocol

Authensor's MCP Gateway implements the MCP SEP (Safety Extension Protocol) with three message types:

  1. authorization/propose - The gateway proposes an action to the policy engine
  2. authorization/decide - The policy engine returns allow, deny, or escalate
  3. authorization/receipt - A hash-chained audit receipt is created for the decision

Every decision is logged with a SHA-256 hash chain, creating a tamper-evident record of all tool usage.

Key security practices

Default deny - Start with everything blocked and explicitly allow what is needed. This is the opposite of most MCP server configurations, which allow everything by default.

Least privilege - Give agents access to only the tools they need for their specific task. A summarization agent does not need shell access.

Constrain arguments - Do not just allow or deny tools. Constrain their arguments. Allow read_file but only for specific directories. Allow http_request but only for specific domains.

Require approval for writes - Any tool that modifies state (writes files, sends emails, makes API calls) should require human approval until you have high confidence in the agent's behavior.

Monitor patterns - Use behavioral monitoring to detect unusual tool usage. A sudden spike in file reads or a tool being called that has never been called before could indicate an attack.

Further reading

Keep learning

Explore more guides on AI agent safety, prompt injection, and building secure systems.

View All Guides