Free · Daily brief + weekly playbookDaily 60-sec AI Voice Brief + Weekly Production AI Agent PlaybookGet the brief →
ReleaseAPI / Product · ActionableHabr: Сбер→ original

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
SberTech Generates Ready-Made MCP Tools from GraphQL Queries for AI Agents
Source: Habr: Сбер. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr: Сбер ↗
Editor-in-Chief
Key metric #1GraphQL is a query language for APIs where the client chooses the response fields
Key metric #2Operations live in the repository and act as an allowlist: the agent sees only them
Downsidean extra code generation step and generator config in the project

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.

Story

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.

ZK
Zhemal Khamidun — Head of AI at Alpina Digital · MIPT (academic supervisor of the Tech Entrepreneurship department). Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Free · Waitlist · Hermes + DeepSeek

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.

Join the waitlist →Nomad AI Workspace
Jemal Hamidun

Editor-in-chief · Cite this analysis

Jemal Hamidun

Head of AI at Alpina Digital · Academic Supervisor of the Tech Entrepreneurship Department at MIPT

Head of AI & CPO of AlpinaGPT at Alpina Digital, Academic Lead of Tech Entrepreneurship at MIPT. Founder of Hamidun News and Vibe Academy.

Ready-to-paste citation for journalists, blogs and Telegram channels

Source: Hamidun News — SberTech Generates Ready-Made MCP Tools from GraphQL Queries for AI Agents https://news.hamidun.com/en/news/16714/sbertech-generates-ready-made-mcp-tools-from-graphql-queries

What do you think?
Loading comments…