SberTech Generates Ready-Made MCP Tools from GraphQL Queries for AI Agents
To connect an AI agent to a company's API, teams use MCP, a standard that lets the agent discover tools and call them. At SberTech, the agent does not write GraphQL queries. Developers write operations in advance, such as "find clinics by city," and a generator turns each one into an MCP tool. The agent only picks a tool and fills in the city. This list is easier to review in pull requests and CI.
AI-processed from Habr: Сбер; edited by Hamidun News
Imagine your product has a GraphQL API, and now you need to give an AI agent access to it. GraphQL is a query language for APIs in which the client decides which data fields to return. MCP (Model Context Protocol) is a standard that lets an AI client discover external "tools," understand their parameters, and call them.
Connecting the two seems obvious: a GraphQL schema already describes types, arguments, and the shape of responses. But the schema does not answer the key question: which part of the API should be exposed to the model, and with how much freedom. The Platform V DataSpace team at SberTech, a low-code platform for business applications and data management, reviewed the options on Habr and explained its choice.
Four Ways to Open GraphQL to an Agent
The first option is the most flexible: a single MCP tool accepts the text of a GraphQL query and its variables. The Microsoft Fabric API, for example, works this way. The agent selects the fields, handles null values, and builds the entire query itself. For prototypes, local development, and getting to know an unfamiliar schema, this is convenient: a universal tool is quick to write. But the API surface stays wide, and the backend team reviews the queries only after they have already run.
The second option builds tools from the root fields of the schema. The agent immediately gets a set of tools with names and arguments that mirror the schema fields. This is simple and fast, but the schema is usually broader and more detailed than the application contract you want to show the model.
The third option relies on fixed operations. A developer writes a GraphQL operation in advance, and each MCP tool corresponds to one operation. The agent chooses a tool and fills in the variables. This is how Apollo MCP Server, WunderGraph Cosmo MCP Gateway, and the GraphQL Hive plugin work. Operations are stored in the repository, discussed in pull requests, validated against the schema, and act as an allowlist, meaning a list of what the agent is permitted to do.
The fourth option extends the third: operations remain the source of truth, and code is generated from them. Lab Digital implements a similar idea in its graphql-codegen-mcp-tools project, where operations are marked with MCP directives.
What DataSpace Chose and How It Works
SberTech took the fourth path: fixed operations plus code generation into TypeScript and Zod (a data validation library). The reasoning is clear: GraphQL developers keep describing the contract with familiar operations, and the agent sees a limited set of tools rather than the entire API.
The generator takes as input the predefined operations, tool descriptions and annotations, custom scalar settings, and TypeScript and Zod generation parameters. The output is a TypeScript module containing types, GraphQL documents, Zod schemas for input and output data, and MCP tool descriptions. A template server imports the module, registers the tools in McpServer, and the default handler calls the required operation in DataSpace and returns a structured response. Work with the schema and operations finishes before the server starts, so while running, the server knows the exact list of tools. Custom tools can be added alongside in the same code. TypeScript was chosen as a simple and convenient language for DataSpace users and the entire low-code platform.
In a demo built on a medical model (clinics, doctors, patients, schedules, appointments, addresses), the operation searchClinicByCity is shown. The agent passes a single parameter, the city name. The search condition by name prefix and the set of clinic fields are already fixed in the query. In @modelcontextprotocol/inspector, the operation looks like a regular MCP tool. For clients that do not support structured responses, the server also returns a text version. The authors openly acknowledge that few agents currently pass outputSchema into the model's context.
What Control Costs
The gain is that the agent does not write GraphQL. There are fewer chances to make a mistake in a field name or in null-handling rules, and field selection is predictable. In the generated code, you can see which tools were added or removed, which fields became required, and how enum values and the descriptions the model will see have changed. All of this can be checked locally and in CI before the agent makes its first call. This matters for enterprise APIs and sensitive data.
There is a cost too. The project gains an extra code generation step, and the generator configuration has to be maintained alongside the rest of the code. The agent's capabilities grow only when a developer writes a new operation.
A separate pitfall is the difference between "field not passed," "passed as null," and "default value used." At SberTech, the JSON Schema-based MCP contract serves as an early check of request shape, not as an exact copy of the GraphQL input-handling rules. The final source of truth remains the GraphQL API itself, while the Zod schemas merely reflect it for agents. This is a deliberate simplification.
The practical takeaway: for research and prototypes, one tool with arbitrary queries is enough. If the MCP server becomes part of a product, it is better to start with a small set of vetted operations. If you use Apollo, WunderGraph, or Hive, their gateways can build such tools themselves. And if you need types and diffs in CI, SberTech's code generation approach is worth considering.
- Dec 2, 2026Ai2 Releases MolmoWeb2 Web Agents: 27B Model Solves 75.3% of Tasks
- Dec 2, 2026T-Decision-1 9B scores 71.6 points and beats a model six times its size
- Dec 2, 2026JetBrains Releases Air App: Control AI Agents in Your IDE From a Smartphone
- Dec 2, 2026JetBrains Offers Voluntary Departures as IDE Search Raised Agent Task Costs by 6–7%
Key Questions Answered
What are the key details on Four Ways to Open GraphQL to an Agent?
The first option is the most flexible: a single MCP tool accepts the text of a GraphQL query and its variables. The Microsoft Fabric API, for example, works this way. The agent selects the fields, handles null values, and builds the entire query itself. For prototypes, local development, and getting to know an unfamiliar schema, this is convenient: a universal tool is quick to write. But the API surface stays wide, and the backend team reviews the queries only after they have already run.
What DataSpace Chose and How It Works?
SberTech took the fourth path: fixed operations plus code generation into TypeScript and Zod (a data validation library). The reasoning is clear: GraphQL developers keep describing the contract with familiar operations, and the agent sees a limited set of tools rather than the entire API. The generator takes as input the predefined operations, tool descriptions and annotations, custom scalar settings, and TypeScript and Zod generation parameters.
What Control Costs?
The gain is that the agent does not write GraphQL. There are fewer chances to make a mistake in a field name or in null-handling rules, and field selection is predictable. In the generated code, you can see which tools were added or removed, which fields became required, and how enum values and the descriptions the model will see have changed. All of this can be checked locally and in CI before the agent makes its first call. This matters for enterprise APIs and sensitive data. There is a cost too.
Free 2-Day Vibecoding & AI Agents Intensive
Day 1: the autonomous Hermes + DeepSeek AI agent — vibecoding and development on par with Claude Code / Codex / Gemini. Led by Jemal Hamidun, Head of AI at Alpina Digital and academic supervisor at MIPT. Right after you register with our bot Nika: the recording + 11 materials from the previous intensive.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
