DEV Community

Cover image for Enterprise MCP Gateway with Built-In Security: OAuth 2.0, RBAC, and Tool Access Control

Enterprise MCP Gateway with Built-In Security: OAuth 2.0, RBAC, and Tool Access Control

Anthony Max on August 05, 2026

TL;DR MCP servers are powerful, but they can provide access to production systems if anyone on the team can connect and run tools withou...
Collapse
 
kikashy profile image
Brian Jin

The distinction between runtime tool access and administrative RBAC is especially useful. Deny-by-default controls whether an agent can invoke a tool, but there is still another question before execution: whether the proposed action is justified by the available evidence, applicable rules, exceptions, and approval conditions.

For example, a production payment tool may be correctly allow-listed, yet the agent may still lack the required evidence or human authorization for this particular transaction. Have you considered a policy or decision-evaluation step between tool suggestion and /v1/mcp/tool/execute, with explicit outcomes such as approve, deny, unresolved, or escalate?

Collapse
 
anthonymax profile image
Anthony Max

That's a useful distinction. Bifrost determines what an agent is allowed to access, while the application decides whether a particular request satisfies the organization's policies.

Collapse
 
kikashy profile image
Brian Jin

Exactly. The scaling challenge I see is that when this decision remains entirely application-specific, every team ends up inventing its own representation for required evidence, exceptions, missing information, approvals, escalation, and audit reasons.

That is the boundary I’m exploring with the open-source Judgment Pack Specification (JPS): a portable, testable decision contract between tool suggestion and execution.

JPS would not replace Bifrost’s access controls, credentials, or execution layer. A JPS evaluator could review the proposed action and its context, then return an explicit disposition such as approve, deny, unresolved, or escalate, with the supporting evidence and rules, before Bifrost executes the tool.

Would a pluggable pre-execution decision-evaluator hook fit Bifrost’s architecture?

Something like: proposed tool call + context > external judgment evaluator > disposition > /v1/mcp/tool/execute

Collapse
 
valentin_monteiro profile image
Valentin Monteiro

Per-request narrowing looks like it cancels itself out as written: the note under the example says a virtual key with mcp_configs auto-generates x-bf-mcp-include-tools and overrides anything sent manually, and deny-by-default means a key without mcp_configs has zero tools to narrow in the first place. That leaves the manual header with no obvious window. Is it meant for callers who authenticate through SSO or x-bf-mcp-session-id rather than a virtual key, or does the manual header actually intersect with the key's allowlist instead of being replaced?

Collapse
 
anthonymax profile image
Anthony Max

Good observation.

Collapse
 
mudassirworks profile image
Mudassir Khan

the deny by default virtual key design is the right call. the more common pattern we see is allowlist based keys where you have to explicitly block tools — any new MCP server added surfaces all its tools to all clients until someone remembers to update every key. deny by default flips that to safe.

the per_user_oauth auth type is what makes enterprise rollout actually viable. shared OAuth tokens mean any team member rotating credentials blocks everyone. per user lazy auth means you can onboard without coordinating a shared secret.

curious how you're handling token refresh for per_user_oauth when the upstream provider (Notion, Sentry) expires tokens mid session. retry transparent to the agent, or surface the 401 upward?

Collapse
 
lee_rodgers_05 profile image
Lee Rodgers

I didn't realize the difference between RBAC and runtime tool access before reading this.

Collapse
 
anthonymax profile image
Anthony Max

Do you use MCP servers in your work?

Collapse
 
leee_rodgers1 profile image
Lee Rodgers1 • Edited

Yes.

Collapse
 
polterguy profile image
Thomas Hansen

Interesting little project. We've been working on something similar. Also open sauce, and 100% free of charge! ^_^

  1. RBAC
  2. Hallucination resistant LLM (yes, really!)
  3. Runtime restricts capabilities based upon RBAC

Etc, etc, etc ...

Collapse
 
kikashy profile image
Brian Jin

Thanks for sharing Thomas. I took a closer look at the repo. The hallucination-resistant part is interesting: Hyperlambda generates a constrained AST, rejects functions that do not exist, and uses RBAC to restrict which functions can execute. I also appreciate that the README clearly distinguishes this from logical correctness - the generated workflow can still make the wrong decision.

That seems highly complementary to what I’m exploring with JPS. Hyperlambda can guarantee that an operation exists and is permitted, while a Judgment Pack can evaluate whether that operation is justified by the available evidence, rules, exceptions, and approval conditions.

I’d be interested to know whether Magic supports a pluggable decision-evaluation step before executing the generated AST.

Collapse
 
polterguy profile image
Thomas Hansen

I’d be interested to know whether Magic supports a pluggable decision-evaluation step before executing the generated AST

Of course, it's just an MCP server, so you can plug anything into both pre and post processing, and execution. Exactly what did you have in mind?

Collapse
 
ozereray profile image
Eray Özer

This is a fantastic breakdown of RBAC and tool access control! 🚀

One massive bottleneck we noticed when building enterprise gateways for AI agents is the latency overhead. Traditional middleware often chokes the agent's reasoning loop. We ended up building a zero-latency runtime proxy (Aegisora) specifically to enforce these kinds of least-privilege policies without slowing down the agent. Curious to know what your average latency overhead looks like with this setup?