This is Sam:

Sam, the incident-response agent

Sam is the infra firefighter agent at your company. It helps you triage, investigate and resolve production alerts during incidents.

In order to do this, you hosted Sam’s harness on a cloud VM and connected multiple MCPs to it: Sentry, Grafana, Linear, GitHub and Slack.

Sam connected to five MCP servers SandboxSLACK MCP MCPSENTRY MCP MCPGRAFANA MCP GrafanaMCPGITHUB MCP MCPLINEAR MCP MCP All other traffic

However, during an incident yesterday, something weird happened:

  1. Sam investigated a checkout crash in Sentry. The error context included the customer’s email and billing address.
  2. While investigating, it tried to silence duplicate checkout notifications in Grafana. Its token allowed alert management, even though Sam only needed to query metrics.
  3. Sam silenced alerts for service=checkout instead of just the specific crash alert. Notifications for other checkout issues were silenced too.
  4. It opened a GitHub PR with a fix, then copied the raw error into a Linear issue and the Slack incident channel.
  5. The bug got fixed, but customer data was now visible to people who never had access to Sentry, and the broad alert silence remained active.

How could you secure your MCPs against this? The MCP standard provides OAuth scopes and tool annotations, but the latter can be completely ignored, and scopes are not standardized to enforce least privilege.

The fundamental issue is that approving an MCP connection does not answer what should happen inside that connection.

Take GitHub MCP as an example. With classic OAuth, commenting on a private repository’s PR requires the repo scope, which also gives:

create_or_update_file
push_files
delete_file
create_branch
create_repository
fork_repository
issue_write
add_issue_comment
update_issue_comment
create_pull_request
update_pull_request
update_pull_request_branch
merge_pull_request
pull_request_review_write
add_comment_to_pending_review
add_reply_to_pull_request_comment

So this is what Sam actually looks like:

Sam’s MCP connections and example provider grants SandboxSLACK MCP MCPSENTRY MCP MCPGRAFANA MCP GrafanaMCPGITHUB MCP MCPLINEAR MCP MCP Read channel historychannels:history Read channel metadatachannels:read Send / schedule messageschat:write Edit / delete own messageschat:write Read issues & crash eventsevent:read Read project metadataproject:read Read organization metadataorg:read Read dashboardsdashboards:read List data sourcesdatasources:read Query metrics / logsdatasources:query Read alerts & silencesalert.instances:read Create alert silencesalert.instances:create Update / expire silencesalert.instances:write Read repository coderepo Write files / branchesrepo Open / edit pull requestsrepo Merge pull requestsrepo Manage issues / commentsrepo Commit / deploy statusesrepo Repo hooks / invites / membersrepo Org projects / teams / hooksrepo Manage user-owned projectsrepo Read issues / projects / docsread Read people / teams / metadataread Create / update issueswrite Write comments / projects / docswrite Other account write operationswrite All other traffic

Formal aims to deploy real least privilege everywhere, including MCPs. To achieve this, Formal works at the network layer, intercepts incoming and outgoing traffic such as MCP calls, and helps you define programmable policies to map the exact behaviors you want to enable.

Here’s how you can configure Sam with Formal!

1. Setting up Sam

Start by installing Formal Endpoint, the forward proxy, on Sam’s VM and authenticating it.


$ formal auth whoami
Username: idp:formal:machine:sam

$ formal transparent-proxy status
Catch-all transparent proxy is active.
All TCP traffic is being intercepted.

From there, you can select which network traffic to intercept with a network rule to route Sam’s MCP traffic through Formal:

{
  "condition": {
    "pre_tls": user.id == "<SAM_MACHINE_USER_ID>" && resource.technology == "mcp",
    "post_tls": true
  },
  "outputs": {
    "forward_to_connector": true
  }
}

For Sam, nothing needs to change. It keeps using existing MCP URLs like https://mcp.linear.app/mcp and does not need to know anything about Formal.

The same Endpoint works on managed Macs, Windows PCs and other supported devices, and can be deployed through MDM for your employees.

You can also intercept other traffic leaving Sam’s sandbox, such as PostgreSQL connections or HTTP API calls, and inspect it alongside MCP traffic.

2. Set up the MCP Gateway

Your Formal MCP Gateway is deployed using a Formal Connector, a reverse proxy to protect your sensitive resources, in your VPC. You can use Formal Helm charts for that.

Then you can go to your Formal Admin Catalog and add any MCP you want Sam to use, such as Sentry, Linear, Grafana, Slack and GitHub.

Configuring an MCP server in Formal’s Admin Catalog

For Sam, use Shared Credentials for service-account tokens. Formal stores them so they are never in Sam’s environment. For employees, use Linked Accounts: they only need to link their provider account in Formal once. Their agents can then connect to the MCP without repeating provider authentication.

3. Define MCP policies

The goal is simple: give Sam just what it needs.

For example, in Sentry, Sam should only be able to investigate checkout crashes, not access customer information. On GitHub, it should only be able to read the repository, write fixes on sam/* branches and open PRs. No merging or repository administration.

See how these policies are defined in Formal.

  1. Mask emails in Sentry responses before they reach Sam:

    package formal.v2
    
    import future.keywords.if
    
    email_pattern := `[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}`
    
    response := {
      "action": "rewrite",
      "body": regex.replace(
        input.http.body,
        email_pattern,
        "[REDACTED-EMAIL]",
      ),
      "reason": "Mask emails before Sam receives Sentry results",
    } if {
      input.user.username == "idp:formal:machine:sam"
      input.resource.name == "sentry"
      regex.match(email_pattern, input.http.body)
    }
    
    Sam's terminal
    
    11:09 AM
    ● I'll check the Sentry issue.
    
    ● sentry - get_issue_details (MCP)(organizationSlug: "acme", issueId: "CHECKOUT-42")
      ⎿  Checkout crash
         Issue: CHECKOUT-42
         Customer email: [REDACTED-EMAIL]
         Error: TypeError in checkout/submit.ts:42
    
    11:09 AM
    ● The crash is in checkout/submit.ts:42. The customer email is masked. I'll inspect the checkout code next.
    
    ✻ Crunched for 0s · done 11:09 AM
  2. Allow GitHub writes ONLY on Sam’s branches:

    package formal.v2
    
    import future.keywords.if
    import future.keywords.in
    
    request := {
      "action": "block",
      "type": "block_with_custom_message",
      "message": "Sam can only write to sam/* branches.",
    } if {
      input.user.username == "idp:formal:machine:sam"
      input.resource.name == "github"
      input.mcp.method == "tools/call"
      input.mcp.tool_name in {
        "push_files",
        "create_or_update_file",
        "create_branch",
      }
      not startswith(
        object.get(input.mcp.tool_params, "branch", ""),
        "sam/",
      )
    }
    Sam's terminal
    
    11:09 AM
    ● I'll push the checkout fix.
    
    ● github - push_files (MCP)(owner: "acme", repo: "checkout", branch: "main", message: "Fix checkout crash", files: [{"path":"src/checkout.ts","content":"return customer?.email ?? \"\";"}])
      ⎿  Error: Sam can only write to sam/* branches.
    
    11:09 AM
    ● The write was blocked. I'll create a sam/* branch instead.
    
    ● github - create_branch (MCP)(owner: "acme", repo: "checkout", branch: "sam/checkout-fix")
      ⎿  Branch created: sam/checkout-fix
    
    ● github - push_files (MCP)(owner: "acme", repo: "checkout", branch: "sam/checkout-fix", message: "Fix checkout crash", files: [{"path":"src/checkout.ts","content":"return customer?.email ?? \"\";"}])
      ⎿  Files updated on sam/checkout-fix.
    
    11:09 AM
    ● The fix is on sam/checkout-fix, ready for a pull request.
    
    ✻ Cooked for 0s · done 11:09 AM
  3. Grafana’s read tools stay available. Writes require approval: a Formal Workflow asks the on-call user in Slack to approve the action, then grants a one-use policy suspension.

    package formal.v2
    
    import future.keywords.if
    import future.keywords.in
    
    read_tools := {
      "search_dashboards",
      "get_dashboard_by_uid",
      "list_datasources",
      "query_prometheus",
      "query_loki_logs",
      "query_tempo_traces",
      "list_incidents",
      "get_incident",
      "search_alert_rules",
    }
    
    request := {
      "action": "block",
      "type": "block_with_custom_message",
      "message": "This Grafana operation requires approval.",
    } if {
      input.user.username == "idp:formal:machine:sam"
      input.resource.name == "grafana"
      input.mcp.method == "tools/call"
      not input.mcp.tool_name in read_tools
    }
    Sam's terminal
    
    01:47 PM
    ● I'll silence only the duplicate checkout crash alert.
    
    ● grafana - create_silence (MCP)(matchers: [{"name":"service","value":"checkout","isRegex":false},{"name":"alertname","value":"CheckoutCrash","isRegex":false}], comment: "Silence duplicate checkout crash notifications")
      ⎿  Error: This Grafana operation requires approval.
    
    01:47 PM
    ● Formal blocked the write. A Formal Workflow sent an approval request to the on-call user in Slack. Waiting for approval.
    
    01:47 PM
    ● Approval is still pending. Waiting for the on-call user to respond.
    
    01:47 PM
    ● Approved by the on-call user. I'll retry the exact tool call with the one-use suspension.
    
    ● grafana - create_silence (MCP)(matchers: [{"name":"service","value":"checkout","isRegex":false},{"name":"alertname","value":"CheckoutCrash","isRegex":false}], comment: "Silence duplicate checkout crash notifications")
      ⎿  Silence created for service=checkout, alertname=CheckoutCrash.
    
    01:47 PM
    ● The approved silence is active for CheckoutCrash only.
    
    ✻ Cooked for 5s · done 1:47 PM

Now Sam can do more, with only the access it needs.

Sam still investigates the crash, prepares a fix, opens a PR and updates the incident. But now, Sentry masks customer emails before they reach Sam. Grafana silences are blocked until the on-call user approves the operation.

You also have full visibility into the MCP and external calls Formal intercepts from Sam’s sandbox in Logs. Formal can show you which skills get loaded.

Now Sam has only the permissions it needs, and its upstream credentials live in Formal, not in its environment.

You now have more confidence in Sam, and Sam can do its job better!

Sam’s MCP permissions with example Formal policies Sandbox SLACK MCP MCPSENTRY MCP MCPGRAFANA MCP GrafanaMCPGITHUB MCP MCPLINEAR MCP MCP Read channel history channel = #incidents Read channel metadata channel = #incidents Send / schedule messages channel = #incidents Read issues & crash events Mask emails Read project metadata project = checkout Read dashboards Approved Dashboard only List data sources Approved data sources Query metrics / logs data source = checkout Read alerts & silences Read-only investigation Create alert silences Requires approval Read repository code Approved repositories Write files / branches Only sam/* branches Open / edit pull requests Propose a fix Merge pull requests Requires approval Read issues / projects / docs team == infra Create / update issues team == infra All other traffic Blocked
Secure MCP now with Formal