AI
GraphQL bridges the security gap for AI agents accessing business APIs through MCP
Model Context Protocol makes it easy for AI agents to call APIs, but organizations need fine-grained access control—and GraphQL offers a proven way to enforce it.
The New Stack
When operations staff ask an AI assistant to check inventory across warehouses and create transfer requests, the agent needs live access to internal APIs—not cached reports from yesterday. Model Context Protocol (MCP) makes that connection straightforward, but it raises an urgent security question: what data should the agent actually see?
The access control challenge#
An order management API might return a wealth of sensitive information—personal details, fraud scores, financial data—that should never leave a trusted network. Traditional web applications solve this by filtering responses based on user permissions at the backend. But with flexible AI agents calling APIs dynamically, that becomes complicated fast.
The dilemma is sharp: pass through everything from the upstream API, and you've created a security risk. Filter responses in the MCP tool itself, and you're forced to build dozens of overlapping, similar tools across different teams—each with its own version of the same filtering logic. Finance sees orders one way, support needs internal notes, inventory teams need another view entirely.
GraphQL as a field-level contract#
The solution is a deterministic contract that specifies exactly which fields and operations each agent can access, independent of what the upstream systems provide or what downstream agents need. GraphQL, designed with this principle in mind, offers a practical answer.
Since its creation, GraphQL has let API consumers request only the specific fields they need. A simple order status query can ask for just status and shipBy, and the response contains nothing else—regardless of what the backend system stores. Organizations like Shopify, Netflix, Airbnb, and Walmart have relied on this field-level precision for over a decade.
Applied to AI agents, the same approach works:
- Blocking sensitive fields: A GraphQL server can prevent access to fields like
internalFraudScoreorcustomerSSNentirely, enforcing rules at the field level across all operations - Controlling writes: Mutations (write operations) such as
requestInventoryTransferexpose specific business actions while the runtime validates permissions and the underlying service checks availability before accepting the request - Simplifying maintenance: Authorization rules belong to the field definition, so engineers don't have to remember to strip the same property from every different response

