Copilot Studio Data API builder MCP

Copilot Studio | The Grant Moves to the Server

From the archive. This post dates from the blog’s Dynamics GP and early Power Platform era. Products and screenshots may have changed since it was written, and some of its links (PartnerSource and CustomerSource pages, legacy Maximum Global Business downloads, and other retired sites among them) may have been archived or may no longer be available.
The grant moves to the server: eight CRONUS tools rebuilt on Data API builder, where tools/list is not filtered by role but tools/call returns PermissionDenied

Three weeks ago, in Scoped for the Agent, Open to the URL, I wrote that my eight-tool MCP server had a problem: the agents' tool grants were real and enforced entirely by Copilot Studio, while the server underneath checked nothing. I ended that post by saying that rebuilding the eight tools on Data API builder, where the grant would sit on the server, was the subject of another post.

This is that post. The rebuild works, the refusal is real, and two things about it are not what the documentation says.

What I built

The original is in cronus-order-management-agents: eight domain-specific tools in TypeScript over six tables of CRONUS demo data, with three Copilot Studio agents holding disjoint grants. The rebuild is in cronus-dab-rebuild.

Each handler became a stored procedure with the same name, parameters and computed output, so the agents' prompts do not change. Each procedure is then registered as a named MCP tool, with the role allowed to run it declared beside it:

"GetCreditProfile": {
  "source": { "object": "dbo.get_credit_profile", "type": "stored-procedure" },
  "permissions": [ { "role": "finance", "actions": [ { "action": "execute" } ] } ],
  "mcp": { "custom-tool": true }
}

Two lines carry the previous post's argument. custom-tool keeps the tool named instead of dissolving into a generic read_records call. The permissions block is the part Copilot Studio used to own, and it now lives in a file the orchestrator never sees.

The refusal is real

Asking for a tool the role was not granted returns this, verbatim:

{
  "toolName": "get_credit_profile",
  "status": "error",
  "error": {
    "type": "PermissionDenied",
    "message": "Permission denied for execute on entity 'GetCreditProfile'. You do not have permission to perform Execute operation for this entity."
  }
}

That is the sales role being refused a Finance tool, and it is what the rebuild was for. The hand-written server could not produce that response, because it had nothing to produce it from.

The other half of the claim also holds. The RBAC section says per-field rules apply automatically to every MCP tool, so I excluded UnitCost from the Products entity for sales, left it for finance, and then read the table with the generic tool rather than a named one:

Roleread_records on ProductsUnitCost
sales6 columnsabsent
finance7 columnspresent
inventorycall denied-

Same tool, same entity, three answers. The margin column is withheld by the server, not by the caller's good manners.

Every role sees every tool

Here is the first thing that is not as documented. The custom-tools article says that when a role lacks permission, the tool "doesn't appear in tools/list" and a direct call returns a permission error. The second half is true. The first is not.

Every role I tested gets 15 tools: all eight named tools, including the ones belonging to the other two roles, plus all seven generic DML tools. Anonymous gets 15 as well, and cannot call any of them.

Enforcement is intact, because the call is where it happens. What leaks is the shape of your business: an agent scoped to inventory can read the names get_credit_profile and calculate_credit_exposure and know those capabilities exist. Treat tool names as readable by anyone who can reach the endpoint, and do not encode anything in them you would not publish.

NOTE: a related line in the same article says inputSchema "currently returns empty properties". In 2.1.7 it does not. My custom tools advertise their parameters correctly, 1 for search_customer, 2 for get_customer_pricing, 3 for check_availability. That one has been fixed ahead of the page.

The validator disagrees with the engine

The second surprise cost me twenty minutes. Putting an mcp block on a table entity fails dab validate, with an error naming a property I had not set:

> Total schema validation errors: 1
custom-tool can only be enabled for entities with source type 'stored-procedure'.

The cause is in the published 2.1.7 schema. Its conditional requires only that mcp be present, then constrains custom-tool to true without requiring the property, and an absent property satisfies that constraint. So every entity carrying an mcp block matches, and anything that is not a stored procedure fails.

Which means the documented way to keep an entity away from agents, an mcp block turning dml-tools off, is a form you cannot write on a table. Nor is the schema's own boolean shorthand, "mcp": false. Adding a redundant "custom-tool": false makes it validate and changes nothing else.

Worth knowing: dab start runs the rejected configuration perfectly. I drove a full session against it and got the same 15 tools and the same per-field results. It is a validator defect rather than a broken feature, and it bites where dab validate belongs, in a pipeline gate.

What this does not fix

The local transport, dab start --mcp-stdio role:sales, authenticates with the Simulator provider. The role is asserted by the client and not proved. My probe says which role it wants and the server believes it.

That is the right tool for measuring whether the rules are applied, which is what I measured. It is not evidence that nobody can pick their own role. In production the role arrives as a validated claim and the Simulator is not configured at all. Moving the grant to the server makes the check enforceable. Making the role trustworthy is a separate authentication problem underneath it.

Why it matters

For makers, the rebuild is smaller than it looks. Eight tools became eight stored procedures and one configuration file, and the agents did not change, because the tool names and parameters did not change. If your tools are already queries wearing a function signature, this is mostly a move rather than a redesign.

For professional developers, what moved is where the check sits. Before, three agents held three different tool lists and the server answered anyone. After, the server refuses a call the configuration does not permit, whoever makes it. The Copilot Studio grant is still worth configuring, and it is now a convenience on top of a control rather than the control itself.

Steps to recreate

1) Create the demo database from sql/cronus-demo.sql in the first repo, then run sql/01-tools-as-procs.sql from the second against it.

2) Install the engine: dotnet tool install -g Microsoft.DataApiBuilder. It is self hosted and runs locally, so no Azure resource is involved.

3) Set CRONUS_CONNECTION_STRING, then run dab validate -c dab-config.json.

4) Drive it: python probe/probe_dab.py sales --call --fields, then the same for finance and inventory.

Step 4 produced every number above. The probe starts its own server, speaks MCP as one JSON object per line with no SDK in between, and attempts one tool belonging to another role so the refusal is on the record.

The demo concept

Run the probe as sales and as finance, side by side: both see 15 tools, one reads a credit profile and the other is refused, and the margin column appears in one column list and not the other. The refusals are the part worth showing, because they come from a configuration file rather than from an agent that was configured not to ask.

Final Notes

The question I left the last post on was: who enforces this when the caller is not your agent? For the rebuilt server the answer is the server, and I have the refusal to show for it.

What changed in my own thinking is narrower than I expected. I assumed moving the grant server-side would also make the catalog private, and it does not. Discovery and permission turn out to be separate switches, and only one of them moved.

What I learned from this exercise: the rebuild was eight stored procedures and a configuration file, and the two things that cost me real time were both places where the documentation and the shipped product disagreed.

Until next post!

MG.-
Mariano Gomez Bent
Former Microsoft BizApps MVP

Comments

Microsoft MVP Alumni