Dev.to Security ๐Ÿ” Cybersecurity ๐Ÿ‘ 0 ๐Ÿ“– 9 min read

Keep company data and passwords out of your AI agent's chat

An AI agent that connects to eMondrian acts on behalf of the user who signed in, with exactly that user's permissions. eMondrian is an open-source semantic layer with an MCP server. The agent signs in as a person, throug

An AI agent that connects to eMondrian acts on behalf of the user who signed in, with exactly that user's permissions. eMondrian is an open-source semantic layer with an MCP server. The agent signs in as a person, through OAuth or a personal access token, and gets that person's roles: the same row-level and object-level security as in Excel and Power BI. The agent does not expand data access, it needs no database credentials of its own, and every call is written to an audit log with the user's name. You can also set the server up so that neither real data nor secrets reach the agent's chat: it works on a synthetic twin of your data, and the MCP audit log lets you check every call.

All of this is part of the free, open-source Community edition.

What data can the agent see?

The same data as its user.

  • The agent signs in as a person. An MCP client signs in with OAuth (the client opens the login page in the browser) or with the user's personal access token. 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.
  • One set of roles for every client. Roles in the semantic model decide which cubes, measures and members a user sees, and which rows. Excel, Power BI Desktop, the REST API and the MCP server apply the same roles. A regional manager and the manager's agent see the same region.
  • Delegated authorization. The gateway passes the user name and groups to the eMondrian server; the server never receives the password.
  • The database stays behind the server. The server connects to the database with credentials from its own configuration. The agent never receives them, and data-source passwords are masked in every MCP answer.

A role in the model:

<Role name="Sales EMEA">
  <SchemaGrant access="none">
    <CubeGrant cube="Sales" access="all"/>
  </SchemaGrant>
  <RoleMember name="/Sales/EMEA"/>
</Role>

Members of the group /Sales/EMEA see the Sales cube, and so do their agents.

What can the agent change?

What its user may change. Querying data needs no server right. Every action that changes something, or reads more than data, needs a server right, the same for MCP, XML/A and the REST API:

Right What it allows MCP tools, for example
schema.read Read a schema's XML and measure formulas get_schema, formulas in describe_cube
schema.write Save a schema or a role save_schema, save_role
database.read See data-source details (with schema.read on the catalog) describe_source
database.manage Register or delete catalogs, install drivers save_catalog, delete_catalog, install_driver
logs.read Read server logs read_logs
dashboard.manage Administer all dashboards dashboard tools

Rights are granted to groups or users in auth/security/security.properties:

mondrian.security.schema.write=/emondrian-editors,/emondrian-admins
mondrian.security.database.manage=/emondrian-admins
mondrian.security.logs.read=/emondrian-admins

The file lives on the server host and is mounted read-only into the server, so rights are changed only by an administrator on the host, never by a client or an agent. A change applies from the next request, with no restart. A higher right includes the lower one: schema.write includes schema.read, and database.manage includes database.read. schema.read and schema.write can also be granted per catalog. Tools that manage users, groups and tokens also check the caller's Keycloak administrator role on every call.

Least privilege for agents. Give analysts and their agents data roles only, and keep schema.write and database.manage for the groups that build the model. The server validates every schema before it saves it. Schemas are files: keep them in Git and review each change as a diff.

Can I limit what agents do on top of the user's rights?

Yes, with two settings that apply to agents only. Excel and Power BI keep working as before.

  • A read-only MCP server. Start the server with -Demondrian.mcp.readOnly=true, and the MCP server offers agents only tools that read: list catalogs, describe cubes, run queries, build Excel PivotTables. The public demo runs this way.
  • Agent access per catalog. In datasources.xml, set agentAccess on a catalog:
    • real: agents work with the catalog's data, under the user's roles;
    • synthetic-only: agents see a generated twin of the catalog, with the same model and synthetic numbers (with the Synthetic data module);
    • none: the catalog is for Excel, Power BI and the REST API.

Can I keep both data and passwords away from the agent?

Yes. eMondrian can be set up so that the agent builds and explains the model, while no password and no real number reaches it or its model provider.

Passwords.

  • Database passwords stay on the server. The server connects to the database itself, 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 receives a token. The token is held by the client program, such as Claude Code; the model sees only the tools' answers.
  • The audit log redacts secrets โ€” passwords, tokens and keys โ€” in every mode.

Data. Set three things together:

JAVA_TOOL_OPTIONS=-Demondrian.mcp.agentAccess=synthetic-only -Demondrian.mcp.readOnly=true
  1. Synthetic data for every catalog. With agentAccess=synthetic-only set for the whole server, every tool that returns data answers from a generated twin of the catalog: the same cubes, dimensions, measures and roles, with generated values and generated members such as "Store City 017". This covers MDX and DAX queries, cube descriptions, Power BI reports, dashboards and Excel PivotTables. Catalogs registered later get the same setting, and where a catalog and the server differ, the stricter value applies. Members that the model's own formulas name, such as a year in a role grant, keep their names, so the formulas keep working. (With the Synthetic data module.)
  2. A read-only MCP server. With mcp.readOnly=true, agents get only the tools that read.
  3. A separate account for the agent, and closed real catalogs. Give the agent its own user in its own group, for example /agents. Give every real catalog a defaultRole with no access, and grant its data roles to people's groups only. On the synthetic twin, add a role for the agents' group:
   <Role name="Agents" schemaAccess="read">
     <SchemaGrant access="all"/>
     <RoleMember name="/agents"/>
   </Role>

The agent's account then gets generated data from the twin, over MCP, XML/A and the REST API alike, and nothing from the real catalogs. schemaAccess="read" lets the agent build Power BI reports on the twin.

A read-only database user for eMondrian adds one more layer: grant it SELECT on the tables the cubes are built on.

The agent still sees the structure on the twin: catalog, cube, dimension and measure names, and measure formulas. That is what it needs to write queries, explain the model and build reports. The schema files and data-source details of the real catalogs stay with the groups that have schema.read and database.read. Excel and Power BI users keep working on the real data under their own roles.

Check it in the MCP audit log. Every call the agent makes is in logs/mcp-audit.log: the user, the tool, the catalog, the query and the number of rows. In full mode the log also keeps the result text of each call, so you see exactly what reached the agent's chat.

Who controls access, and where is it recorded?

  • Your identity provider. Groups come from Keycloak, Active Directory, LDAP, OIDC or SAML, named by their full path, for example /Sales/Analysts. Move a person to another group, and the person's agent moves with them.
  • The audit log. Every MCP call is written to logs/mcp-audit.log, one JSON line per message, in both directions. Each line has:
    • the time and the signed-in user (principal);
    • the tool, catalog and cube;
    • the MDX or DAX query;
    • the status, any error, the duration and the number of rows;
    • the session, the client name and version (for example claude-code), and the client IP.

Passwords, tokens and keys are always redacted. The format is JSON, so you can ship the log to your own Loki or ELK. In full mode, the log also keeps the arguments and the result text of each call.

  • Checking what a user sees. An administrator can run a read tool as_user to see the data as another user sees it. The call is logged under the administrator's name.
  • Personal access tokens. Each user creates a token at PUBLIC_URL/account/tokens and can revoke it there; an administrator can revoke any token. Issuing a new token revokes the old one. A revoked token, or a disabled user, is refused within about 30 seconds.

How to switch it on

  1. Install eMondrian Community with Docker.
  2. Switch sign-in on with one command:
   ./auth/scripts/authentication.sh on       # Linux
   .\auth\scripts\authentication.ps1 on      # Windows
  1. Set PUBLIC_URL and turn on HTTPS. MCP clients on other machines sign in with OAuth over HTTPS.
  2. Connect your identity provider and grant rights to its groups โ€” see Security.
  3. Give every schema a restrictive defaultRole, and add roles for your groups.
  4. Connect the agent and sign in โ€” see AI agents (MCP):
   claude mcp add --transport http emondrian https://bi.example.com/emondrian/mcp

Is it safe to use AI with company data?

It depends on what the AI can reach. With eMondrian:

  • the data stays in your database, and the semantic layer runs on your own server;
  • the agent gets only what its user may see;
  • every call is logged with the user's name;
  • for sensitive catalogs, agents can work on a synthetic twin, with the same model and generated numbers.

Query results go to the agent and to the model provider the agent uses, so choose that provider under your company's data policy.

FAQ

Can an AI agent see data the user is not allowed to see?
The agent sees only what its user may see. It signs in as the user and gets that user's roles: the same row-level and object-level security as in Excel and Power BI.

How do I set up role-based access control for AI agents?
Define data roles in the semantic model and grant server rights in security.properties, both to groups from your identity provider. An agent gets the roles and rights of the user it signs in as.

Does an MCP server support row-level security?
The eMondrian MCP server applies the row-level and object-level security of the semantic model to every query the agent runs.

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.

Does company data end up in the AI agent's chat?
Set up as in Can I keep both data and passwords away from the agent?, the agent's chat, its history and its model provider get only generated numbers and names, and never a password, token or database credential. You control this in the eMondrian MCP audit log: every agent call is recorded with the user, tool, catalog and query, and in full mode with the result text the agent received. Passwords, tokens and keys are redacted in every mode.

Is it safe to use AI with company data?
With eMondrian the data stays in your database, the agent sees only what its user may see, and every call is logged with the user's name.

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

๐Ÿ“ฐ Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.