the previous a number of months, I’ve had the chance to immerse myself within the job of adapting APIs and backend programs for consumption by LLMs, particularly brokers utilizing the MCP protocol. Initially, I anticipated the expertise to be no completely different than some other comparable improvement tasks I’ve finished previously. I used to be fascinated to find, nonetheless, that these autonomous shoppers are a brand new kind of creature. Consequently, evolving APIs to yield probably the most worth from agent interplay required greater than merely making them accessible.
This publish is a results of my experimentations and area testing, hopefully it may be helpful to different practitioners.
The facility and curse of autonomy
We builders are used to Third-party instruments and automation processes interacting with the applying APIs. Our interfaces have subsequently advanced round greatest practices that greatest assist these use instances. Transactional, versioned, contract-driven APIs, minded to implement ahead/backward compatibility and constructed for effectivity. These are all necessary considerations which are secondary in precedence and infrequently merely irrelevant when contemplating the autonomous consumer.
With brokers as shoppers, there isn’t any want to fret about backward/ahead compatibility as every session is stateless and distinctive. The mannequin will examine tips on how to use instruments every time it discovers them, arriving on the proper mixture of API calls to realize its goal. As enthusiastic as this agent could also be, nonetheless, it can additionally surrender after a couple of failed makes an attempt until given correct incentive and pointers.
Extra importantly, with out such clues it may succeed within the API name however fail to satisfy its aims. In contrast to scripted automations or skilled builders, it solely has the API documentation and responses to go on in planning out tips on how to meet its objectives. The dynamic nature of its response is each a blessing and a curse as these two sources are additionally the sum of information it might probably draw upon to be efficient.
Dialog-Pushed APIs
I had first realized that the agent would require a unique kind of design whereas troubleshooting some instances wherein the agent was not in a position to get to the specified outcomes. I offered MCP software entry to an API that gives utilization info for any code perform primarily based on tracing knowledge. Typically it appeared the agent was merely not utilizing it appropriately. Wanting extra carefully on the interplay, it appeared that the mannequin was appropriately calling the software and for numerous causes obtained an empty array as a response. This habits can be 100% appropriate for any comparable operation in our API.
The agent, nonetheless, had bother comprehending why this was taking place. After making an attempt a couple of easy variations, it gave up and determined to maneuver on to different avenues of exploration. To me, that interplay spelled out a missed alternative. Nobody was at fault; transactionally, the habits was appropriate. All the related assessments would cross, however in measuring the effectiveness of utilizing this API, we discovered the ‘success price’ was ridiculously low.
The answer turned out to be a easy one, as a substitute of returning an empty response, I made a decision to offer a extra detailed set of directions and concepts:
var emptyResult = new NoDataFoundResponse()
{
Message = @"There was no information discovered primarily based on the factors despatched.
This might imply that the code just isn't known as, or that it isn't manually instrumented
utilizing OTEL annotations.",
SuggestedNextSteps = @"Recommended steps:
1. Seek for endpoints (http, shoppers, jobs and so on.) that use this perform.
Endpoints are normally mechanically instrumented with OTEL spans by the
libraries utilizing them.
2. Strive calling this software utilizing the tactic and sophistication of the endpoint
itself or use the GetTraceForEndpoint software with the endpoint route.
3. Counsel handbook instrumentation for the precise methodology relying on the language used within the challenge
and the present model of instrumentation used (annotations, code and so on.)"
};
As an alternative of simply returning the outcomes to the agent, I used to be making an attempt to do one thing brokers will typically try as nicely — maintain the dialog going. My perceptions of API responses, subsequently, modified. When being consumed by LLMs, past serving purposeful functions, they’re, in essence, a reverse immediate. An ended interplay is a lifeless finish, nonetheless, any knowledge we return again to the agent offers it an opportunity to drag on one other thread in its investigative course of.
HATEOAS, the ‘select your individual journey’ APIs

Serious about the philosophy of this strategy, I spotted that there was one thing vaguely acquainted about it. A very long time in the past, after I was taking my first steps crafting trendy REST APIs, I used to be launched to the idea of hypermedia APIs and HATEOAS: Hypertext As Engine of the Software State. The idea was outlined by Fielding in his seminal 2008 weblog publish REST APIs have to be hypertext-driven. One sentence in that publish utterly blew my thoughts on the time:
“Software state transitions have to be pushed by consumer collection of server-provided decisions which are current within the obtained representations”
In different phrases, the server can train the consumer what to do subsequent as a substitute of merely sending again the requested knowledge. The canonical instance is an easy GET request for a selected useful resource, whereby the response offers info on actions the consumer can take subsequent on that useful resource. A self-documenting API the place the consumer was not required to know something about it forward of time besides a single entry level from which a department of decisions emerges. Right here is an effective instance from the Wikipedia web page:
HTTP/1.1 200 OK
{
"account": {
"account_number": 12345,
"steadiness": {
"foreign money": "usd",
"worth": 100.00
},
"hyperlinks": {
"deposits": "/accounts/12345/deposits",
"withdrawals": "/accounts/12345/withdrawals",
"transfers": "/accounts/12345/transfers",
"close-requests": "/accounts/12345/close-requests"
}
}
}
On the time, I used to be fascinated by this idea, which jogged my memory of what’s generally known as ‘select your individual journey’ books or ‘gamebooks’. This style of books, an inseparable a part of my childhood, didn’t merely relay a narrative (or present an API response by this metaphor), but additionally gave the reader a key as to what are the following set set of choices accessible to it. Hypermedia REST APIs have been self-documenting and provided customers a technique to perceive the state of the applying and the operations accessible for every entity or course of useful resource with out having to learn by means of in depth documentation.
Hypermedia on steroids
A technique to have a look at Hypermedia APIs is that they supply extra context to the consumer as part of the response. Context, to brokers, is all the things, and it definitely doesn’t must cease with accessible choices or operation. An API is an interplay level wherein context might be relayed and offered in a kind that might encourage additional interplay. Let’s check out one other instance!
One other software I used to be engaged on, permits the mannequin to retrieve runtime points discovered within the deployment setting, once more primarily based on observability knowledge. The precise outcome I used to be testing immediate response for, was an anomaly discovered within the efficiency of a selected endpoint. Evidently at occasions responses have been EXTREMELY gradual, ~70X slower than the median. Offering that info piece to the LLM was useful, however in the end didn’t accomplish greater than easy repeats of the info offered.
For reference, right here is the response offered, in addition to the agent output:
{
"Identify": "Efficiency Anomaly",
"Class": "Efficiency",
"P50":
{
"Worth": 12.33,
"Unit": "ms",
"Uncooked": 12331700.0
},
"P95":
{
"Worth": 909.62,
"Unit": "ms",
"Uncooked": 909625000.0
},
"SlowerByPercentage": 7376.314701136097,
"SpanInfo":
{
....
},
#extra knowledge
....
}

There’s nothing functionally fallacious with the API response or the way in which the data was mediated to the consumer by the agent. The one downside is that there’s a lot of context and concepts lacking from it that might leverage the agent’s potential to take that dialog ahead. In different phrases, it is a conventional API request/response interplay, however brokers by means of reasoning are able to a lot extra. Let’s see what occurs if we modify our API to inject further state and recommendations to attempt to carry the dialog ahead:
{
"_recommendation":
"This asset's P95 (slowest 5%) length is disproportionally gradual
in comparison with the median to an extreme diploma
Listed below are some steered investigative subsequent steps to get to the
root trigger or appropriate the problem:
1. The difficulty consists of instance traces for each the P95 and median
length, get each traces and examine them discover out which asset
or property are those which are abnormally gradual typically
2. Test the efficiency graphs for this asset P95 and see if there
has been a change just lately, if that's the case test for pull requests
merged round that point that could be relevan tot his space
3. Test for fruther clues within the gradual traces, for instance perhaps
ALL spans of the identical kind are gradual at the moment interval indicating
a scientific subject"
"Identify": "Efficiency Anomaly",
"Class": "Efficiency",
"P50":
{
...
},
#extra knowledge
All we’ve finished is give the AI mannequin slightly extra to go on. As an alternative of merely returning the outcome, we are able to feed the mannequin with concepts on tips on how to use the data offered to it. Absolutely sufficient, these recommendations are instantly put to make use of. This time, the agent continues to analyze the issue by calling different instruments to examine the habits, examine the traces and perceive the issue lineage:

With the brand new info in place, the agent is comfortable to proceed the exploration, look at the timeline and synthesize the outcomes from the varied instruments till it comes up with new knowledge, that was under no circumstances a part of the unique response scope:

Wait… Shouldn’t all APIs be designed like that?
Completely! I undoubtedly consider that this strategy may benefit customers, automation builders, and everybody else — even when they use brains for reasoning somewhat than LLM fashions. In essence, a conversation-driven API can broaden the context past the realm of information and into the realm of potentialities. Opening up extra branches of exploration for brokers and customers alike and bettering the effectiveness of APIs in fixing the underlying use case.
There’s undoubtedly extra room for evolution. For instance, the hints and concepts offered to the consumer by the API in our instance have been static, what in the event that they have been AI-generated as nicely? There are various completely different A2A fashions on the market, however in some unspecified time in the future, it may simply be a backend system and a consumer brainstorming about what the info means and what could possibly be finished to know it higher. As for the consumer? Neglect about him, discuss to his agent.