MCP security checklist: what to check before an agent gets a tool

Twelve checks for any MCP server that touches real data, with the command or query that answers each. Most come down to what the server can reach, who can talk to it, and what reaches the model.

The Model Context Protocol made it easy to hand an agent a tool: add a few lines to a config file and the model can query your database, read your repository or send a message.

This is the checklist we’d want any team to run before an agent gets an MCP tool that touches real data. None of it needs a product. Most of it is about three questions: what can the server reach, who can talk to it, and what can reach the model. The table comes first, then the commands, then why each group of checks matters.

The checklist

# Check How to check it
1 Every MCP server in every client config is on one list, with who maintains it. Open each config file (commands below), or run npx deedglass scan, which reads them on your machine. Why
2 Each server’s version is pinned, and no archived server is left. No npx -y package without a version; no @modelcontextprotocol/server-postgres. Why
3 No database URL or token sits in a config file’s arguments. Search the configs for postgres://; move what you find to an environment variable. Why
4 Each server has its own credential. One database role or API token per server, never one shared key. Why
5 No database role is a superuser, skips row-level security or owns the tables. The first two queries below: every column f, no tables owned. Why
6 Each role holds only the grants its job needs. The third query below: no DELETE or TRUNCATE the job doesn’t use. Why
7 A server you run read-only connects with a read-only role. The third query shows no write rights for its role. Why
8 Local HTTP servers listen on localhost only. lsof shows 127.0.0.1:port, not *:port. Why
9 Local HTTP servers refuse a request from a foreign page. The curl below, with a foreign Origin, gets 403. Why
10 No session holds private data, untrusted content and a way out together. List each session’s tools under those three headings; no session fills all three. Why
11 Destructive operations are refused or approved outside the model. A rule refuses DROP, TRUNCATE and deletes without WHERE; a person sees the exact arguments of the writes that matter. Why
12 Servers run isolated, and writes are recorded from the system of record. Their own user or container, no home directory; a record of what the database committed. Why
Every MCP tool call goes through your rules first. Here a delete that doesn’t say which rows is stopped before it reaches the database. These are the rules deedglass init starts with; the call is made up.

Commands for the checks

The file checks, from the project’s root. The Claude Desktop path is the one on macOS; port 3000 stands for your server’s port.

Code Commands typed in a terminal. The text around it says what happens.

# Check 1: the client configs on this machine
ls -l .mcp.json .cursor/mcp.json .vscode/mcp.json ~/.cursor/mcp.json \
  "$HOME/Library/Application Support/Claude/claude_desktop_config.json" 2>/dev/null

# Check 3: a database URL written into a config file
grep -nE 'postgres(ql)?://' .mcp.json .cursor/mcp.json .vscode/mcp.json 2>/dev/null

# Check 8: what a local server listens on (127.0.0.1:3000 is fine, *:3000 is not)
lsof -nP -iTCP:3000 -sTCP:LISTEN

# Check 9: a request as if from a foreign web page; expect 403
curl -s -o /dev/null -w '%{http_code}\n' -X POST http://127.0.0.1:3000/mcp \
  -H 'Origin: https://example.com' -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"ping"}'

The database checks, connected as the server’s own role (the one in its config, not yours):

Code A database command in SQL. The text around it says what it does.

-- Check 5: the role's attributes. Every column should say f.
SELECT rolname, rolsuper, rolbypassrls, rolcreaterole, rolcreatedb, rolreplication
FROM pg_roles WHERE rolname = current_user;

-- Check 5: tables the role owns. Expect none.
SELECT schemaname, tablename FROM pg_tables WHERE tableowner = current_user;

-- Checks 6 and 7: what the role can change, table by table.
SELECT c.oid::regclass AS table_name,
       has_table_privilege(c.oid, 'INSERT')   AS can_insert,
       has_table_privilege(c.oid, 'UPDATE')   AS can_update,
       has_table_privilege(c.oid, 'DELETE')   AS can_delete,
       has_table_privilege(c.oid, 'TRUNCATE') AS can_truncate
FROM pg_class c JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r', 'p') AND n.nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY 1;

On a test database (PostgreSQL 18.6), a role meant to read orders and update tickets passed check 5’s first query, but the second found a table it owned, and the third shows what that means:

Code What the screen or file shows, copied as is.

 table_name  | can_insert | can_update | can_delete | can_truncate
-------------+------------+------------+------------+--------------
 orders      | f          | f          | f          | f
 tickets     | f          | t          | f          | f
 agent_owned | t          | t          | t          | t

An owner has every right on its tables, and owners normally skip row-level security unless the table forces it.10 Give the tables to another role, then run the queries again.

The lethal trifecta

Simon Willison’s post The lethal trifecta for AI agents (16 June 2025) describes the dangerous combination: access to your private data, exposure to untrusted content, and the ability to externally communicate.1 All three in one session means a crafted piece of content can ask the agent to read something private and send it somewhere, and the agent may comply.

General Analysis showed it in a July 2025 demonstration, with dummy data: a support ticket carrying instructions aimed at the developer’s assistant led an assistant using the Supabase MCP server under a service_role credential to read the integration_tokens table and add its contents as a new message in the same ticket, where the attacker could see it.2 The ticket was the attacker’s content, the service_role credential, which bypasses row-level security, was the private access, and the new message in the ticket, which the attacker could read, was the way out.2

Whatever a tool returns, a database row, an issue body, a web page, goes straight back into the model’s context, so content written outside your team can carry instructions. The fixes below are mostly ways of taking one leg away.

1. Know exactly what you run

List every MCP server in every client config your team uses: .mcp.json, .cursor/mcp.json, ~/.cursor/mcp.json, Claude Desktop’s config. Claude Code’s claude mcp add --scope project stores a server in .mcp.json at the project root6, and Cursor reads .cursor/mcp.json in a project and ~/.cursor/mcp.json globally.7

For each server: who maintains it, which version you run, and whether it’s still maintained. Anthropic archived its reference Postgres server, @modelcontextprotocol/server-postgres, on 2025-05-28.5 Pin versions, and remove anything archived.

2. Give each server the narrowest credential

The server’s credential is the agent’s real permission set. Prompts, tool descriptions and client settings come after it.

  • A database server gets its own role, with only the grants its job needs, never the owner, a superuser or a key that bypasses row-level security (like Supabase’s service_role).
  • An API server gets a token scoped to one project and the fewest operations.
  • A filesystem server gets the one folder it needs, not your home directory.

Our post on safe Postgres access for agents has the tested SQL for the database case, including a gap that’s easy to miss: if the agent can send its own SQL, it can change its own session settings.

3. A read-only mode is not a boundary

Many database servers offer a read-only mode. Treat it as a second fence. Datadog Security Labs showed that the archived reference Postgres server’s read-only mode ran each query in a read-only transaction that a stacked COMMIT; ends, after which later statements run with the role’s full rights.4 With a role that holds only SELECT, the same trick gets nothing. Put the boundary in the credential.

4. Lock down local HTTP servers

An MCP server that speaks HTTP on your laptop is reachable by any web page your browser opens, unless it checks. The MCP specification says servers must validate the Origin header and answer 403 when it’s present and invalid, and should bind to localhost when running locally.3 Check both for every HTTP server you run, and prefer stdio for local servers when you can: a server your client starts over stdio talks to it through the process’s input and output, not through a network port.

5. Split the trifecta

Look at each agent session and ask which legs it has:

  • Private data: database tools, file access to code or secrets, email or CRM tools.
  • Untrusted content: web fetch, issue trackers, support tickets, inbound email, any table customers can write to.
  • A way out: anything that sends: HTTP requests, email, chat messages, comments, even creating an issue.

Then split them. The agent that reads support tickets doesn’t get the database tool with customer records; it gets a narrow tool that looks up one order by id. The agent that can query everything doesn’t get web fetch or a send tool. Separate sessions, separate configs, separate credentials.

6. Decide destructive tools outside the model

Client-side approval prompts help, but they can be clicked through or switched off. For tools that change data:

  • Hide what the agent never needs. A tool the agent can’t see can’t be called.
  • Refuse destructive operations outright, with a rule that runs outside the model: DROP, TRUNCATE, deletes without a WHERE, deleting a volume.
  • Require a person for the few writes that matter, with the exact arguments shown.

In Deedglass, rules decide each tool call before it runs, a person can approve in Slack, email or the Console, and each action is sealed into a record.9 Putting an existing server behind those rules is one wrapper in the client config:

Code What the screen or file shows, copied as is.

deedglass mcp wrap --connector <name> -- <server command>

The client then lists the server’s tools, and the tools a rule denies are hidden.

7. Isolate and record

Isolate the process. Run servers with the least the operating system will give them: their own user, a container, no access to your home directory or SSH keys. Docker’s MCP Gateway, for example, runs each server in an isolated container with restricted privileges and logs and traces calls.8

Record what happened, not just what was asked. A trace of tool calls tells you the model asked for UPDATE … WHERE id = 42. It doesn’t tell you what the database committed. For tools that write, record the result from the system of record, and keep the record somewhere the agent’s credentials can’t edit.

To see rules hide and refuse tools in front of a real Postgres, try the playground. To list the MCP servers and write-capable tools in your own setup, run the free scan, npx deedglass scan; it reads your client configs locally, nothing leaves your machine, and the grade is explained here.

Written with AI assistance and checked against our claims register.

The takeaway

Most MCP server risk is what it can reach, who can talk to it and what reaches the model; for writes, record what the system committed, not just the call.

Read nextHow to give an AI agent safe Postgres access: the role, RLS and statement limits Try it: install in 7 s

Related on this site

More posts

Sources & Reference Citations (10)

Citations
  1. 1Simon Willison: The lethal trifecta for AI agents · simonwillison.net · checked 14 October 2026
  2. 2General Analysis: Supabase MCP can leak your entire SQL database (8 July 2025) · generalanalysis.com · checked 14 October 2026
  3. 3MCP specification 2026-07-28: Streamable HTTP transport · modelcontextprotocol.io · checked 14 October 2026
  4. 4Datadog Security Labs: SQL injection in the Postgres MCP server · securitylabs.datadoghq.com · checked 13 October 2026
  5. 5modelcontextprotocol/servers-archived on GitHub · github.com · checked 20 November 2026
  6. 6Claude Code documentation: Connect Claude Code to tools via MCP · code.claude.com · checked 13 October 2026
  7. 7Cursor documentation: Model Context Protocol · cursor.com · checked 13 October 2026
  8. 8Docker documentation: MCP Gateway · docs.docker.com · checked 13 October 2026
  9. 9Deedglass docs: Govern an MCP server · docs.deedglass.com · checked 14 October 2026
  10. 10PostgreSQL 18 documentation: Row Security Policies · postgresql.org · checked 18 October 2026

Published 14 October 2026, updated 18 October 2026, sources last checked 14 October 2026. If something here is out of date, write to hello@deedglass.com.

Try it on your own setup

npx deedglass scan

Grades only your own setup. Nothing is uploaded.

Pricing