DEV Community

Cover image for AI agent data security: keep company data and passwords out of the agent's chat
Sergei Semenkov
Sergei Semenkov

Posted on Edited on Originally published at docs.emondrian.com

AI agent data security: keep company data and passwords out of the agent's chat

Is it safe to use AI with company data? Yes, when the AI agent works with the structure of your data and with synthetic data, and never with the real values. Everything an agent reads goes into its chat: to the model provider, into the chat history, sometimes into a shared workspace. That is why AI agent data security is the first question with sensitive or confidential data. eMondrian, an open-source semantic layer with an MCP server, lets you set the server up so that the agent does the setup work fast, building cubes, writing measures, checking queries and building Power BI reports, while not one real number, customer name, password or other secret reaches the chat. The agent works with the schema of your database and with a synthetic twin of your data: the same model, with synthetic data in place of the real values. People keep working on the real data in Excel and Power BI. The MCP audit log shows exactly what reached the agent.

What the agent sees, and what it doesn't

Set agentAccess=synthetic-only for the server, and every catalog splits in two for agents.

The structure of the real catalog, to build the model. The agent:

  • lists the tables, columns, types and keys of your database (describe_source), with no rows, row counts or statistics;
  • checks a SQL expression against the database without fetching a row (validate_source_sql);
  • reads, writes, validates and saves the schema: cubes, dimensions, hierarchies, measures, roles (get_schema, validate_schema, save_schema, add_time_measures).

The data of the synthetic twin, to check its work. Every tool that returns values or member names, such as MDX and DAX queries, cube descriptions, Power BI reports, dashboards and Excel PivotTables, refuses on the real catalog and points to its twin, <Catalog> (synthetic). The twin has the same cubes, dimensions, measures and roles over generated data, with members such as "Store City 017". The agent runs its queries there, sees that a measure adds up and a hierarchy drills down, and builds the report.

A query from the agent, and what comes back:

Sales (synthetic) · [Store].[City] × [Measures].[Store Sales]
Store City 017    2,675,629,826
Store City 042    1,903,114,507
Enter fullscreen mode Exit fullscreen mode

Generated names and generated numbers. Members that the model's own formulas name, such as a year in a role grant, keep their names, so the formulas keep working.

People get the real data. The setting applies to MCP agents only. Excel, Power BI and the web client query the real catalog under each user's roles, with the cubes and measures the agent built. To replace the dummy data with your actual data, a person opens the agent's report on the real catalog. Data privacy holds on both sides: the agent never sees a single real row, and each person sees only the rows their roles allow.

The agent cannot switch it off

  • No tool sets or removes agentAccess, and no tool changes the server's options.
  • save_catalog keeps the setting when it replaces a catalog, and refuses to register the same database or schema file under another name.
  • delete_catalog refuses a synthetic-only catalog, so the agent can't delete it and register it again without the setting.
  • Where a catalog and the server differ, the stricter value applies. A value the server doesn't recognise closes the catalog to agents.

An agent can only tighten the setting.

Passwords, secrets and credentials stay out of the chat too

  • Database passwords stay on the server. eMondrian connects to the database with credentials from its own configuration. Data-source passwords are masked in every MCP answer and error message.
  • The user's password stays in the browser. With OAuth, the user types the password on the login page, and the agent's client program, such as Claude Code, receives a token. The model sees only the tools' answers.
  • The audit log redacts secrets, such as passwords, tokens and keys, in every mode.

MCP security: check what reached the agent in the audit log

Every call the agent makes is written to logs/mcp-audit.log, one JSON line per message, in both directions:

  • the time and the signed-in user (principal);
  • the tool, catalog and cube;
  • the MDX or DAX query;
  • the status, the duration and the number of rows;
  • the client name and version, for example claude-code.

Switch on full mode (-Demondrian.mcp.audit=full), and the log also keeps the arguments and the result text of each call: exactly what reached the agent's chat. The format is JSON, so you can ship the log to your own Loki or ELK and alert on any call to a real catalog's data.

How to set it up

  1. Install eMondrian Community with Docker and switch sign-in on:
   ./auth/scripts/authentication.sh on       # Linux
   .\auth\scripts\authentication.ps1 on      # Windows
Enter fullscreen mode Exit fullscreen mode

Set PUBLIC_URL and turn on HTTPS, so MCP clients sign in with OAuth.

  1. Synthetic data for every catalog. Add to .env:
   JAVA_TOOL_OPTIONS=-Demondrian.mcp.agentAccess=synthetic-only -Demondrian.mcp.audit=full
Enter fullscreen mode Exit fullscreen mode

and recreate the container: docker compose up -d --force-recreate eMondrian. Catalogs registered later get the same setting.

  1. An account for the agent. Give the agent its own user in its own group, for example /agents, and give that group the rights to build the model in auth/security/security.properties:
   mondrian.security.schema.write=/emondrian-editors,/agents
   mondrian.security.database.read=/emondrian-admins,/agents
Enter fullscreen mode Exit fullscreen mode
  1. Close the real data to the agent's account. Give every real catalog a defaultRole with no access, and grant its data roles to people's groups only. This also covers XML/A and the REST API, so the agent's account gets no real rows over any protocol. On the twin, add a role for the agents' group:
   <Role name="Agents" schemaAccess="read">
     <SchemaGrant access="all"/>
     <RoleMember name="/agents"/>
   </Role>
Enter fullscreen mode Exit fullscreen mode
  1. Generate the twin. Ask the agent to run generate_synthetic_catalog for the catalog and follow it with synthetic_catalog_status. Generated data goes into separate syn_* databases, written and read by two database users that cannot read your real data.

  2. Connect the agent and sign in as the agent's user — see AI agents (MCP):

   claude mcp add --transport http emondrian https://bi.example.com/emondrian/mcp
Enter fullscreen mode Exit fullscreen mode

For agents that only analyse and never change the model, add -Demondrian.mcp.readOnly=true to JAVA_TOOL_OPTIONS: the MCP server then offers only tools that read.

Synthetic twins are built by the synthetic module of eMondrian Community, with a licence key that includes SYNTHETIC. The free 30-day evaluation key at emondrian.com/license includes it.

When the agent works on real data

You can also let an agent read real data, for a person who is allowed to see it. Then the agent acts on behalf of the user: it signs in as that person, through OAuth or a personal access token, and gets exactly that person's roles, with the same row-level and object-level security as in Excel and Power BI. The agent does not expand data access: a regional manager and the manager's agent see the same region. Rights are granted to groups from your identity provider, role-based access control (RBAC) with least privilege, and every call is written to the audit log with the user's name. Sign-in, groups, roles and the audit log are part of the free Community edition.

  • Users and groups come from Keycloak, Active Directory, LDAP, or an identity provider over OIDC or SAML, such as Microsoft Entra ID, Google, Okta or ADFS.
  • Actions that change something need a server right, granted to groups in security.properties: schema.write to save a schema, database.manage to register catalogs and install drivers, logs.read to read logs. The file is mounted read-only into the server, so only an administrator on the host changes it.
  • Per catalog, agentAccess can be real (data under the user's roles), synthetic-only (structure and the twin) or none (the catalog is hidden from agents).

Details: Security.

FAQ

Is it safe to use AI with company data?
Yes, when the agent works with the structure and synthetic data. Set up as above, the agent builds the model and reports without ever seeing your actual data, secrets stay on the server, and the audit log shows every call.

Does company data end up in the AI agent's chat?
Set up as above, the agent's chat, its history and its model provider get the structure of your model and generated numbers and names, and never a real value, password, token or database credential. You check it in the eMondrian MCP audit log: in full mode it keeps the result text of every call the agent received.

Does the AI model see my data?
The model sees what the tools return to the agent. With synthetic-only, that is the schema and synthetic data, never a real row.

Can an AI agent leak company data?
An agent can pass on only what reached its chat. Set up as above, the chat holds the structure and synthetic data, so there are no real values in it to leak, and no secrets.

What are the MCP security risks for company data?
Tool results go into the chat and to the model provider, and a tool that changes things acts on the server. With eMondrian, data tools answer from the synthetic twin, secrets are masked in every answer, rights decide what an agent may change, a read-only MCP server offers only tools that read, and the audit log records every call.

Can an AI agent build a semantic model without seeing the data?
Yes. On a synthetic-only catalog the agent reads the database's tables and columns, checks SQL without fetching rows, and writes and saves the schema. It tests its cubes and measures on the synthetic twin.

Can AI build a Power BI report without seeing our company's data?
Yes. The agent builds and checks the report on the synthetic twin, which has the same cubes, measures and roles as the real catalog. To replace the dummy data with your actual data, a person connects the report to the real catalog and gets the real numbers under their own roles.

What does the agent still see?
The structure: table and column names, and the model's catalog, cube, dimension and measure names and formulas. That is what it needs to build the model and write queries.

Can the agent turn the protection off?
No tool changes agentAccess or the server's options, and an agent can only tighten the setting.

Does the agent need its own database credentials?
The database credentials stay on the eMondrian server. The agent signs in as a person, with OAuth or a personal access token.

Can an AI agent see data the user is not allowed to see?
The agent sees only what its user may see, with the same row-level and object-level security as in Excel and Power BI.

Read more: AI agents (MCP) · Security · HTTPS · A semantic layer with an MCP server

Top comments (0)