Helm7

Build an MCP server for your company data

To expose company data to AI agents safely, give them a small set of named tools instead of raw SQL. Each tool should read or write specific columns, and only the rows the caller is allowed to touch. Enforce that in the database itself, with column grants and row level security, so a clever prompt cannot talk its way past it.

Checked against current documentation on 16 November 2026.

Why not give the agent a SQL connection?

The quickest Postgres MCP server has one tool: run this SQL. It works in a demo. It is also a bad idea in production, for a plain reason. A model writes the SQL, and a model can be steered by anything it reads, including a customer's support message or a field in a record.

If the connection can read the whole database, so can the agent, and so can whoever manages to influence it. If the connection can write, a bad instruction becomes a bad update. Prompts are not a security boundary. The database is.

The MCP specification says as much about its own tools. In its security considerations, servers must validate all tool inputs, implement proper access controls, rate limit tool invocations and sanitise tool outputs. Clients should prompt for confirmation on sensitive operations and log tool use. Those duties land on you when you build a server. See the specification's tools page.

If MCP itself is new to you, start with what an MCP server is. The rest of this guide assumes you know that a server lists tools and a model calls them.

The layers that keep it safe

  1. 1Tools, not queriesEach tool does one named job, such as list_my_orders. The agent supplies a few arguments. It never supplies SQL. Anything you did not build as a tool cannot be done.
  2. 2A role of its ownConnect as a database role that is not your app's main role. Give it no login and grant it only what the tools need.
  3. 3Column-level grantsPostgres lets you grant SELECT, INSERT, UPDATE or REFERENCES on named columns. The manual's GRANT page documents the syntax. A column the role was never granted cannot be read, even by a query the tool did not intend.
  4. 4Row filters from the callerRestrict rows by who is asking. The caller's identity, such as the subject claim in their login token, decides which rows match.
  5. 5Row level securityThe PostgreSQL manual says that once row security is enabled on a table, all normal access must be allowed by a policy, and a table with no policy shows no rows. Policies stay in force whatever the application forgets.
  6. 6Read and write kept apartReads are cheap to reason about. Writes need tighter columns, a row filter that cannot be skipped, and often a human to confirm.
  7. 7Rate limitsA looping agent can send hundreds of calls a minute. Limit calls per caller and cap how much each call may return.

Two details deserve care. First, the manual says table owners and roles with BYPASSRLS skip row security, and superusers always do. So the role your tools run as must be neither. Second, a column grant and a policy do different jobs. Grants decide which columns a role may touch. Policies decide which rows.

-- A role with no login, used only by the MCP tools.
CREATE ROLE mcp_user NOLOGIN;
GRANT USAGE ON SCHEMA public TO mcp_user;

-- Column-level grants: cost_pence and supplier_email stay unreadable.
GRANT SELECT (id, name, category, price_pence) ON products TO mcp_user;
GRANT SELECT (id, customer_id, product_id, quantity, status, created_at)
  ON orders TO mcp_user;

-- Row level security: a signed-in caller sees only their own orders.
-- The claims arrive as JSON in a setting that the server sets for each request.
ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
CREATE POLICY own_orders ON orders
  FOR SELECT TO mcp_user
  USING (customer_id = (current_setting('request.jwt.claims', true)::json ->> 'sub'));
The database side of the layers, written by hand. Your server must set the role and the claims setting inside each request's transaction for this to work.

A worked example: products and orders

Take a small shop. A products table holds the catalogue and an orders table holds what customers bought. You want an agent that can tell anyone about products, and tell a signed-in customer about their own orders and place new ones. It must never see what you paid for stock.

CREATE TABLE products (
  id             bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
  name           text    NOT NULL,
  category       text    NOT NULL,
  price_pence    integer NOT NULL CHECK (price_pence >= 0),
  cost_pence     integer NOT NULL,   -- private
  supplier_email text                -- private
);

CREATE TABLE orders (
  id          bigint PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
  customer_id text    NOT NULL,
  product_id  bigint  NOT NULL REFERENCES products (id),
  quantity    integer NOT NULL CHECK (quantity > 0),
  status      text    NOT NULL DEFAULT 'placed',
  created_at  timestamptz NOT NULL DEFAULT now()
);

CREATE INDEX orders_customer_idx ON orders (customer_id);
CREATE INDEX orders_product_idx  ON orders (product_id);
Two tables. cost_pence and supplier_email are the columns no tool should ever name.

With Helm7 you describe the tools and it builds the server. Each tool has a name, a description the agent reads, a kind (get, list, search, traverse, insert or update), a table and the columns it may touch. Optional fields are filters, the columns a caller may match on, a row_filter, and auth, which is public or end_user.

database_mcp_create
{ "productId": "prd_...", "databaseId": "DATABASE_ID",
  "name": "Shop assistant",
  "tools": [
    { "name": "list_products",
      "description": "Browse products, optionally by category.",
      "kind": "list", "table": "products",
      "columns": ["id", "name", "category", "price_pence"],
      "filters": ["category"], "auth": "public" },

    { "name": "get_product",
      "description": "One product by id.",
      "kind": "get", "table": "products",
      "columns": ["id", "name", "category", "price_pence"],
      "auth": "public" },

    { "name": "list_my_orders",
      "description": "The signed-in customer's own orders.",
      "kind": "list", "table": "orders",
      "columns": ["id", "product_id", "quantity", "status", "created_at"],
      "filters": ["status"],
      "row_filter": "customer_id = $user.sub",
      "auth": "end_user" },

    { "name": "place_order",
      "description": "Order a product for the signed-in customer.",
      "kind": "insert", "table": "orders",
      "columns": ["product_id", "quantity"],
      "row_filter": "customer_id = $user.sub",
      "auth": "end_user" }
  ] }
One call, four tools. Add dry_run set to true to see the plan first. The $user.sub value comes from the caller's session token.

Look at what this does. The two public tools return four columns, so cost_pence and supplier_email are not just hidden by the tool, they are not granted to the role at all. list_my_orders can only match the customer's own rows, since the filter uses their token. place_order lets the agent choose a product and a quantity, and the customer_id is filled in from the token, not from anything the agent says.

Under the hood, Helm7 creates two database roles for each database, one for public tools and one for signed-in users. They are NOLOGIN roles holding column-level grants for exactly the columns the tools name. Each request runs in its own transaction with SET LOCAL ROLE and the caller's claims set, so any row level security you wrote also applies. Tools with auth set to end_user check the session token from your Product's managed auth first. The server's URL has the form https://www.helm7.com/api/app-mcp/ followed by its id, and speaks Streamable HTTP.

Some guard rails are built in. A public insert or update without a row filter is refused. An insert pins the row-filter columns from the claims, so a caller cannot write a row as someone else. Narrowing a tool later revokes the column grant in the same transaction. Deleting the server drops its roles straight away and its URL returns 404 within seconds.

Reads first, writes with care

Start with read tools only. They teach you how agents use your data and what they ask for, with little risk. Add a write tool when a real task needs one, and keep it narrow.

  • Name the exact columns a write may set. Leave out status, price and anything an agent should not decide.
  • Pin ownership from the login token, as place_order does. Never accept it as an argument.
  • Add database constraints that hold whatever the tool does: CHECK constraints, foreign keys, unique keys. The orders table above refuses a negative quantity whatever the agent sends.
  • Use a separate tool for each action, such as cancel_order, instead of one general update. A narrow tool is easier to audit and to describe to a model.
  • Keep a person in the loop for anything that spends money or cannot be undone. The specification says there should always be a human able to deny tool invocations.

Rate limits and result size

An agent in a loop is a fast, tireless caller. Limit it per caller, not per server, so one noisy user cannot starve the rest. Helm7 limits each caller to 120 calls a minute. Also cap rows per call, so a list tool cannot return a whole table.

Log every call with the tool, the caller and the arguments. That is what lets you answer a customer who asks what the assistant did on their account. The specification suggests clients log tool use as well, but you should keep your own record, since you cannot see theirs.

Writing your own server instead

You do not have to use Helm7 for any of this. The official MCP SDKs let you build a server in your own language. The project's SDK page lists TypeScript, Python, C#, Go, Rust and Ruby at its highest tier, with Java at the second and Swift, PHP and Kotlin at the third. See the MCP SDK list.

Two ways to expose a database to agents
AspectGenerated by Helm7Your own server with an official SDK
EffortDescribe tools in one callWrite, host, secure and update a service
Tool shapesget, list, search, traverse, insert, update on one tableAnything you can code, including joins, other APIs and business rules
DatabaseYour Helm7 PostgresAny database or API you can reach
Where the rules liveColumn grants, row filters, your own row level securityWherever you put them, so you must enforce them yourself
Best forStandard reads and narrow writes on your own tablesCustom logic, or data that is not in a Helm7 database

Choose your own server when a tool needs real logic: a refund that checks several systems, a search across a database and an outside API, or data that lives somewhere else. Whichever route you take, keep the same layers. The SDK gives you the protocol. It does not give you the grants, the policies or the limits.

If you want search by meaning in a tool, the search kind embeds the query for you; the mechanics are in semantic search on Postgres with pgvector. The databases page lists the switches this builds on, and the API reference documents database_mcp_create.

Common questions

  • Is it safe to let an AI agent run SQL?

    Not with a general connection. A model writes the SQL and can be steered by the data it reads. Use named tools, a role with column-level grants, and row level security, so the database enforces the limits whatever the agent tries.

  • How do I stop an agent reading private columns?

    Do not grant them. In Postgres you can grant SELECT on named columns only, so a role without a grant on a column cannot read it even through an unexpected query. Helm7 grants its MCP roles exactly the columns the tools name.

  • How do I show each user only their own rows?

    Take the user's identity from their login token and use it to filter rows. In Helm7 a row_filter such as customer_id = $user.sub does this, and any row level security you wrote applies as well.

  • Do I have to use Helm7 to build a Postgres MCP server?

    No. The official MCP SDKs let you write one yourself, in TypeScript, Python and several other languages. You then own hosting, authentication, grants, policies and rate limits.

  • What are the rate limits on a Helm7 MCP server?

    Each caller is limited to 120 calls a minute. You should still cap rows per call and log what each call did.

Run your entire app stack, end to end, from $12 a month.

App, Postgres, auth, storage, jobs and domains on one platform, planned and priced before anything changes.

More guides