Skip to content
AI agents

Turn a mainframe API into a governed MCP tool

Once a mainframe function sits behind an API, Tray can publish it as a governed MCP tool for AI agents. Five steps, with a read-only policy lookup as the example.

Paul Turner

VP of Product Marketing and Market Strategy, Tray.ai

To turn a mainframe into a tool an AI agent can use, put an API in front of the function you want, connect that API to Tray, and publish the operation through Agent Gateway as a governed MCP tool. The agent never touches the mainframe. It calls a named tool, and Tray makes the API call with credentials it holds, within limits you set, and logs the call.

This post walks through it with one example: an insurer’s policy lookup on CICS, turned into a read-only “look up policy” tool for a claims agent. It covers the five steps, when to allow writes, and the answers to the questions mainframe teams ask first.

The example: a claims agent that needs a policy

A claims adjuster asks an agent in Claude, “Is policy 4471-209 active, and what does it cover?” The answer lives in a CICS transaction that has run for decades. Nobody wants to rewrite it, and nobody wants an agent anywhere near the rest of the system.

So the job is narrow. Expose that one lookup as a tool called look_up_policy. It takes a policy number and returns status, coverage and effective dates. It cannot update, cancel or delete anything. The rest of this post builds that tool.

1. Find or expose the API

Agents speak MCP, and MCP tools call APIs. A mainframe function therefore needs an API first.

Many mainframe teams already have one. A common pattern is a REST layer in front of CICS or IMS transactions, and IBM z/OS Connect is one example of how teams expose that layer. SOAP services in front of CICS are just as common. Ask the mainframe team two questions: is there already a service for this transaction, and does it come with an OpenAPI or Swagger description?

If there is no API, that is the one piece of work to do on the mainframe side, and it is work the mainframe team already knows how to do. Expose the one transaction you need, not a catalog of them. A narrow API gives the tool a narrow reach.

2. Connect it to Tray

There are two routes, and both are ordinary Tray work.

  • HTTP connector. Point the HTTP connector at the REST service, add the authentication the service expects, and call the policy endpoint from a workflow. This is the quickest route for one or two operations. For a SOAP service, the same connector sends the request.
  • CDK. If the service has an OpenAPI or Swagger spec, the Tray CDK builds a connector from it. Every operation in the spec becomes an operation you can choose from, with typed inputs. This suits an API with many operations you will publish over time.

Tray also has connectors for IBM i, IBM Db2 and IBM MQ. If part of the job is reading a Db2 table or putting a message on a queue, you can use them in the same workflow.

If the API sits inside your network, Tray reaches it through on-premise connectivity. Tray runs as a managed cloud service, so nothing needs to be hosted for it, and the data stays inside your network until the tool returns the fields you chose.

3. Publish the operation as an MCP tool

Now the mainframe call becomes something an agent can find. In Agent Gateway for MCP, pick the policy lookup operation and publish it as a tool.

Three details decide whether the agent uses it well:

  • A plain name. look_up_policy, not CICSPOLQ01. The agent reads the name.
  • A description that says when to use it. “Look up one insurance policy by policy number. Returns status, coverage and effective dates. Read-only.”
  • A small input and a small output. One input, the policy number. Return the fields a claims agent needs, not the whole record.

Agents in Claude, ChatGPT, Cursor or Tray Helix connect to Agent Gateway over MCP and see the tool. Read what an MCP server is if the term is new, and MCP vs API for why the agent needs the tool and not the raw API.

4. Scope who can call what

Publishing a tool is not the same as letting everyone call it. Scope it.

  • Scoped operations. Only the operations you choose are published. The policy lookup is a tool. Everything else on the service is not.
  • Credentials held by Tray. The mainframe service account lives in Tray. The agent, the person’s laptop and the prompt never hold it.
  • Tool limits per team. Claims gets look_up_policy. A team that has no need for it does not see it. Set how often each team can call it.

This is the answer to the usual objection that an agent with mainframe access is too risky. The agent has no mainframe access. It has one tool, with one input, for one team.

5. Log every call and add approval where it matters

Every call to the tool is logged: which agent, for whom, what went in and what came back. When audit asks who looked up policy 4471-209 and why, the answer is in the log, not in anyone’s memory. See the governance page for how logs and access fit together.

Approval belongs on actions that change something. A read does not need it. A write does, and the next section covers that.

Read vs write: start with reads

The lookup is safe to hand to an agent because it only reads. Most mainframe work for agents starts here: policy status, account balance, order history, claim status. Reads answer the question and carry no risk of changing a record.

Writes are a separate decision. Because each operation is its own tool, adding one later is a deliberate step, not a side effect of the first.

Read tool Write tool
Example look_up_policy update_claim_status
Start here Yes No, add later
Scope One team, one input Smaller team, named inputs
Approval Not needed A person approves before the call runs
Log Every call Every call, with the approver

If you add a write, keep it narrow: one field, one value set, one team, and a person who approves the call before it reaches the mainframe.

Where this fits

This route is for mainframe functions that already have, or can get, an API. It does not replace modernizing the mainframe, and it does not need to wait for that. It gives agents a safe, logged way to use what the mainframe already knows today. For the wider pattern across older systems, see legacy system integration.

  • mcp
  • mainframe
  • how-to

Frequently asked questions

Can an AI agent call a mainframe?

Yes, once the mainframe function is exposed through an API. Tray connects to that REST or SOAP service, and Agent Gateway publishes chosen operations as MCP tools. The agent calls the tool, and Tray makes the call to the API with credentials the agent never sees.

Does the mainframe need to change?

Only if it has no API yet. Many mainframe teams already expose CICS or IMS transactions through a REST or SOAP layer, and IBM z/OS Connect is one common way to do that. If an API exists, the mainframe stays as it is and Tray works from the API.

How does Tray connect to a mainframe?

Through the mainframe's API. The HTTP connector calls a REST service, or the Tray CDK builds a connector from the API's OpenAPI or Swagger spec. Tray also connects to IBM i, IBM Db2 and IBM MQ.

Can the agent change mainframe data, or only read it?

Both are possible, but start with reads. Each operation is published as its own tool, so you can expose a policy lookup and leave every write off the list. A write tool can be added later with its own scope and an approval step.

What if the mainframe data cannot leave our network?

Tray runs as a managed cloud service and reaches on-premises systems through on-premise connectivity. The agent talks to Tray, Tray talks to the API inside your network, and only the fields the tool returns go back to the agent.

See your next integration running on Tray.

Tell us the systems you connect today and we'll show you the workflow on Tray iPaaS, or start free.

Great, a couple more details

This helps us connect you with the right person. Optional, and you can skip it.