How to Filter MCP Tools by User Role
To filter MCP tools by user role, apply two separate controls outside the model. First, filter the tool list so out-of-role tools are never advertised to the agent. Second, check every tool call against the user's role at execution time, with default deny for unknown tools. Hiding reduces what the model can choose. Denial ensures an attempted call still fails. Both depend on carrying the end user's identity and role to the point where policy is enforced.
Verify the filtering for each role
- Request the tool list as each role and compare it with the allowlist.
- Attempt a call to a hidden tool by name as each role and confirm it is denied.
- Add a new tool to a server and confirm no role can see or call it.
- Run the same role across every connected MCP server and confirm consistent results.
- Change a user's role and confirm the next request reflects it.
- Confirm that a read-only role cannot write even if a tool check is bypassed.
Why discovery filtering and invocation checks are separate controls
An agent plans by reading tool names, descriptions and schemas supplied by tool providers. The model decides which tools to invoke, when, and with what parameters. What is advertised therefore shapes what the model can choose, and a malicious tool description can steer the plan toward or away from specific tools. If a read-only role is shown write, delete or payment tools, the model can select them, and prompt injection or an ambiguous instruction can make that selection more likely.
Filtering the list shown to the model removes those options from planning. It is not authorization, though. A call can still arrive through a stale or cached tool list, a different client, or a tool name the model was induced to produce. Only a check at execution time, against the identity making the request, can refuse it.
The reverse also holds. Denying calls without filtering the list leaves the model proposing actions that will fail, exposes tool descriptions the role should not see, and keeps out-of-role tools inside the model's context. Neither control substitutes for the other, and neither should depend on a prompt telling the model to restrict itself. The model is not a reliable enforcement point.
Where to implement role-based tool filtering
A typical chain runs from the user to the MCP host, the MCP client, one or more MCP servers, and then tools, data and APIs. Filtering can sit at several points along it. Published guidance favors policy checks enforced at execution time and separate tool sets for different trust levels. It does not rank the locations, so the choice depends on how many servers and agents you run.
- In the MCP server: Closest to the tool, but each server implements roles differently. Server-side filtering alone does not remove confused-deputy risk if the server acts with its own broad privileges instead of the user's.
- In the agent application: Can shape exactly what the model sees. Logic is duplicated per application, and other clients or agents that reach the same servers are not covered.
- In an enforcement layer in the execution path: One place evaluates policy for every server and every call, so rules do not drift between servers. It adds a component that must receive identity reliably and stay available.
- At the resource: A read-only database role or API token holds even when a tool-level check fails. Use it as a backstop behind any tool filter, not as a replacement.
Design the role-to-tool policy and propagate identity
Start from a default-deny allowlist of approved servers and tools, scoped by role. Anything not listed is unavailable. That includes tools added to a server after the policy was written, so a new tool stays hidden and uncallable for every role until someone reviews and allows it. Give each role the minimum tools its task needs, and prefer granular tools over open-ended ones such as shell access or arbitrary URL fetch, which are hard to scope.
Identity is the input that makes the policy meaningful. Carry the end user's identity and role from the host to the enforcement point and on to downstream calls, so actions run in the user's context rather than under a shared high-privileged service identity. Resolve the role from your identity provider at request time instead of copying it into a static table. That reduces the risk of stale role mappings, which otherwise leave former or reassigned users with old access.
For destructive, financial or data-sharing operations, require explicit human approval. A bare confirmation flag is not enough. The approval should belong to the current actor and the exact tool call, remain valid, and be usable once.
- Role: Resolved from the identity provider for the current request.
- Server and tool: The exact pair being allowed, never a wildcard by default.
- Decision: Allow, redact, block, rate limit or escalate for approval.
- Parameter conditions: Limits on arguments, such as scope, volume or target.
- Approval requirement: Whether a human must approve, bound to actor and exact call.
- Owner and review date: A named owner and a date that forces periodic re-review.
Evidence to retain for auditors
An auditor needs to see that each role saw and could call only its permitted tools. For each request, retain the authenticated user and resolved role, the policy version in force, the tool list presented, each call attempted, and the decision taken with the rule that produced it. Retain denied and escalated calls as well as allowed ones, since denials show the control working.
For approvals, record the approving actor, the exact call approved, its validity window and whether it was consumed. Linking user identities to agent actions supports accountability for automated activity, so the identity-to-action link should be part of every record. Set retention and data residency to match your own regulatory obligations, and keep policy versions so a past decision can be explained against the rules that applied at that time.
How Trussed enforces policy across MCP servers and tool calls
Trussed enforces policy in the execution path across models, agents, tools and MCP servers. For tool calls, the decision is allow, redact, block, rate limit or escalate for human approval, enforced at runtime, not reviewed after the fact. Because one policy evaluates calls across servers, the rules do not vary from server to server. Scope is individual interactions and tool calls.
Enforcement generates audit-ready evidence continuously, mapped to HIPAA, NAIC, NYDFS, the EU AI Act and NIST, so a regulated enterprise can show what its AI was allowed to do and what it did. Trussed can be self-managed in the customer cloud, with configurable retention and data residency. The design decisions above, including the role model, identity source and default-deny allowlist, remain yours whichever layer enforces them.
Two controls, one policy
Discovery filter
The agent sees only the tools its user's role permits.
Invocation check
Every call is evaluated against role and policy at runtime.
Resource backstop
Read-only tokens and roles at the data source limit damage if a tool check fails.
Evidence
Per-role records of what was visible, what was called and what was decided.
See role-based tool enforcement in the execution path
Walk through how policy is enforced on MCP tool calls and how audit-ready evidence is produced for each decision.
Request a Demo