<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sam Chinellato on Medium]]></title>
        <description><![CDATA[Stories by Sam Chinellato on Medium]]></description>
        <link>https://medium.com/@samchine?source=rss-ebd87bcc47f2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VFdkLQDVhCoSJgk6.jpg</url>
            <title>Stories by Sam Chinellato on Medium</title>
            <link>https://medium.com/@samchine?source=rss-ebd87bcc47f2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:29:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samchine/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Load Testing OpenShift AI: What Platform Engineering Has to Relearn for AI]]></title>
            <link>https://medium.com/@samchine/load-testing-openshift-ai-what-platform-engineering-has-to-relearn-for-ai-e5fbe1011e38?source=rss-ebd87bcc47f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5fbe1011e38</guid>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Sam Chinellato]]></dc:creator>
            <pubDate>Wed, 14 Oct 2026 21:57:28 GMT</pubDate>
            <atom:updated>2026-10-14T21:57:28.605Z</atom:updated>
            <content:encoded><![CDATA[<p>Most platform teams already know how to load test an API. You point k6 or JMeter at an endpoint, ramp up requests per second, watch p95 latency and error rate, and find the knee in the curve. Then the organisation stands up an internal AI inferencing platform: shared GPU-backed inference endpoints behind an OpenAI-compatible gateway, with keys, quotas and chargeback. The same playbook stops working.</p><p>The reason is simple. On an LLM endpoint, <strong>a request is not a unit of work. A token is.</strong> Two calls to /v1/chat/completions can share a method, a path and an API key, and still differ by a hundred times in the GPU time they use. A classification prompt might cost 300 tokens. A RAG call with a long context, or an agent on its eighth tool-calling turn, can cost 30,000. If your load test, rate limits and SLOs count requests, they measure the wrong thing.</p><p>This article shows how we use <a href="https://github.com/SamChinellato/agent-testing-harness">agent-testing-harness</a> to load test AI inferencing endpoints the way they are actually consumed, and what that work taught us about adapting platform engineering to AI workloads.</p><h3>Why AI traffic breaks old assumptions</h3><p>Three properties of LLM serving matter most to a platform team.</p><p><strong>1. Latency has two phases, and users notice both.</strong> Inference splits into <em>prefill</em>, which processes the prompt, and <em>decode</em>, which generates output one token at a time. The first shows up as <strong>time to first token (TTFT)</strong>. The second shows up as <strong>inter-token latency (ITL)</strong>, also called time per output token. The two phases compete for the same GPUs, and that interference is why the DistServe work at OSDI ’24 separated them onto different hardware (<a href="https://www.usenix.org/conference/osdi24/presentation/zhong-yinmin">Zhong et al., 2024</a>). One “latency” number hides which phase is hurting.</p><p><strong>2. Throughput without SLOs is meaningless.</strong> A server can post impressive tokens per second while every user waits eight seconds for the first word. The useful measure is <strong>goodput</strong>: the request rate you can serve <em>while still meeting</em> your TTFT and ITL targets. This idea comes from DistServe and now appears in NVIDIA, Anyscale and vLLM benchmarking guidance (<a href="https://docs.nvidia.com/nim/benchmarking/llm/2.0.0/overview.html">NVIDIA NIM benchmarking</a>, <a href="https://docs.anyscale.com/llm/serving/benchmarking/benchmarking-guide">Anyscale</a>).</p><p><strong>3. Agents are the noisy neighbours.</strong> Chat users pause to read. Agents don’t. An agent loop fires sequential calls as fast as each one returns, its context grows every turn, and if it’s written badly it retries a 429 straight away. One runaway agent can use up a shared team quota and push everyone else into throttling.</p><h3>What the harness does</h3><p>agent-testing-harness runs real LangGraph agents, not synthetic prompts, against any OpenAI-compatible endpoint. Each agent is its own process with an identity, a team and a behaviour. The included agents have different token profiles:</p><p>AgentPatternToken profiletriageclassify → extract → summariseInput-heavy (~700–800 prompt tokens), short outputsresearchplan → sequential workers → synthesiseBursts of 6–8 calls per cycleassistantmulti-turn streaming chatCost grows each turn as history accumulates</p><p>This matters because synthetic benchmarks with fixed input and output lengths miss the shapes that cause trouble in production: bursty fan-out, growing contexts and retry storms.</p><p>Each agent runs in one of three <strong>modes</strong>:</p><ul><li><strong>paced</strong> follows its budget. It uses a client-side token bucket set to 90% of its tokens-per-minute (TPM) limit, honours Retry-After, and backs off exponentially with jitter.</li><li><strong>naive</strong> has no bucket. It retries a 429 three times with a 100 ms pause.</li><li><strong>runaway</strong> loops every 50 ms, ignores the limit and never backs off. It plays the misbehaving tenant.</li></ul><p><strong>Budgets</strong> apply at global, team or worker scope, can cap TPM, RPM and concurrency, and update live from the dashboard within a second. Set a budget’s enforcement to shadow and the harness records how long the client <em>would have</em> waited without slowing it down. That lets you size a quota before you enforce it.</p><h3>Load testing an AI Inference Endpoint</h3><h3>1. Characterise the endpoint</h3><p>Run uv run probe first. It sends requests for 90 seconds and records every status code, rate-limit header and token count. In a few minutes you learn the real TPM limit, whether limits are per user or shared by a team, whether the window is fixed or sliding, and which headers your gateway actually returns. Gateways often differ from their documentation.</p><h3>2. Find the goodput ceiling with a sweep</h3><p>The sweep executor follows the method popularised by vLLM&#39;s <a href="https://github.com/vllm-project/guidellm">GuideLLM</a>:</p><ol><li>Run at a <strong>synchronous</strong> rate (one request at a time) to get a latency baseline with no queuing.</li><li>Double the rate until the endpoint saturates.</li><li>Benchmark several constant rates between the baseline and that ceiling.</li></ol><p>The output is a latency/throughput curve for <em>your</em> agent’s traffic, not a vendor’s best case.</p><h3>3. Use open-model load for realistic traffic</h3><p>The harness’s executors mirror k6’s: constant_vus and ramping_vus, plus constant_arrival_rate, ramping_arrival_rate and poisson_arrival_rate. The arrival-rate executors use an <strong>open model</strong>, so new work arrives on schedule whether or not the server keeps up. This avoids <em>coordinated omission</em>. A closed-loop test slows down when the server slows down, which quietly flatters your p99. Poisson arrivals are the honest default for many independent users.</p><h3>4. Test fairness</h3><p>This is where an AI inferencing platform succeeds or fails, and generic load tools don’t cover it. The bundled scenario puts a paced and a runaway agent on one shared team budget:</p><pre>run: steady-vs-runaway<br>budgets:<br>  - budget_id: team-shared<br>    scope: team<br>    scope_ref: banking-ops<br>    tokens_per_minute: 3000<br>    enforcement: client_bucket<br>scenarios:<br>  well-behaved:<br>    agent: triage<br>    mode: paced<br>    executor: { kind: constant_arrival_rate, rate: 30, duration: 5m, max_vus: 5 }<br>    budget: team-shared<br>  runaway:<br>    agent: research<br>    mode: runaway<br>    executor:<br>      kind: ramping_arrival_rate<br>      stages: [{ target: 10, duration: 1m }, { target: 60, duration: 4m }]<br>      max_vus: 20<br>    budget: team-shared<br>thresholds:<br>  - &quot;rate(status_429) &lt; 0.05&quot;</pre><p>Run it with uv run harness run scenarios/steady-vs-runaway.yaml and watch the bench. Each worker&#39;s TPM is plotted against dashed team and worker limit lines, and throttled calls are marked. Then ask the questions that matter: does the gateway isolate tenants, or does the well-behaved agent&#39;s TTFT degrade too? Do 429s come with a usable Retry-After? Does per-key limiting hold when one team runs many keys?</p><h3>5. Keep the evidence</h3><p>Each run writes scenario.json (the resolved config), requests.jsonl (one telemetry record per call) and summary.json (p50/p90/p95/p99 for total latency and TTFT, mean ITL, tokens in and out, status counts and throttle rate) under runs/, tagged with the git SHA. /metrics exposes the same aggregates to Prometheus, and a starter Grafana dashboard is included. Because the live view and the artifact share one aggregation, the dashboard and the report agree. The CLI exits non-zero when iterations are dropped, so a scenario can gate a CI pipeline. Threshold expressions are already parsed and validated, which is the natural place to grow full SLO gating.</p><h3>How platform engineering practices need to adapt</h3><p><strong>Make tokens the unit of everything.</strong> Quotas, chargeback, capacity plans and dashboards should count tokens per minute, split into input and output tokens, with concurrency as a second limit. Request counts belong in the appendix. Most AI gateways now support TPM limits (<a href="https://aigateway.envoyproxy.io/blog/envoy-ai-gateway-reference-architecture/">Envoy AI Gateway</a>, <a href="https://api7.ai/blog/ai-gateway-rate-limiting">API7</a>). Load testing is how you check that those limits do what you think.</p><p><strong>Write SLOs in phase-aware terms.</strong> “p95 latency &lt; 2 s” doesn’t fit a streaming endpoint. Something like “p95 TTFT &lt; 500 ms and mean ITL &lt; 50 ms at 40 req/min of the triage profile” does. Define a goodput SLO per workload class, because a batch summariser and an interactive copilot shouldn’t share one.</p><p><strong>Treat client behaviour as part of the platform.</strong> In classic platform engineering, server-side protection is enough. With agents, a well-behaved client is cheaper than any amount of throttling. Publish a paved-road SDK or harness wrapper with token-bucket pacing, Retry-After handling and jittered backoff, and test it against a runaway agent before tenants find the problem for you.</p><p><strong>Load test continuously, not once.</strong> Model versions, quantisation, vLLM releases, LoRA adapters and routing changes all move the curve. Inference-aware routing such as the <a href="https://github.com/kubernetes-sigs/gateway-api-inference-extension">Gateway API Inference Extension</a> and <a href="https://llm-d.ai/blog/intelligent-inference-scheduling-with-llm-d">llm-d</a>, which route on KV-cache state and queue depth, changes behaviour under load in ways only a realistic, repeatable scenario will catch. Version scenario files next to platform config and run them on every model or gateway change.</p><p><strong>Test with your real workload shapes.</strong> Fixed 512-in/128-out benchmarks are fine for comparing hardware. They are a poor guide to capacity planning. Model the long-context RAG call, the eight-step agent burst and the growing chat history, because those drive KV-cache pressure and tail latency.</p><p><strong>Size quotas in shadow mode first.</strong> Run a budget in shadow enforcement against real traffic, read the would-have-waited numbers, then turn enforcement on. This is the AI version of a dark launch.</p><h3>Closing thought</h3><p>Platform engineering for AI isn’t a new discipline. It is the old one with a new unit of work. Golden paths, SLOs, multi-tenancy and continuous verification still apply, but measured in tokens, split by inference phase, and tested against clients that can loop faster than any human. A harness that runs real agents, in both their best and worst behaviour, against your actual endpoint is the cheapest way to learn where your platform breaks before your tenants do.</p><h3>Further reading</h3><ul><li>Zhong et al., <a href="https://arxiv.org/abs/2401.09670">DistServe: Disaggregating Prefill and Decoding for Goodput-optimized LLM Serving</a>, OSDI 2024</li><li><a href="https://arxiv.org/pdf/2508.10251">Meta-Metrics and Best Practices for System-Level Inference Performance Benchmarking</a></li><li><a href="https://github.com/vllm-project/guidellm">GuideLLM</a>, vLLM project</li><li><a href="https://docs.nvidia.com/nim/benchmarking/llm/2.0.0/overview.html">NVIDIA NIM LLM benchmarking guide</a></li><li><a href="https://docs.anyscale.com/llm/serving/benchmarking/benchmarking-guide">Anyscale LLM serving benchmarking guide</a></li><li><a href="https://grafana.com/docs/k6/latest/using-k6/scenarios/concepts/open-vs-closed/">k6: Open and closed models</a></li><li><a href="https://aigateway.envoyproxy.io/blog/envoy-ai-gateway-reference-architecture/">Envoy AI Gateway reference architecture</a></li><li><a href="https://api7.ai/blog/ai-gateway-rate-limiting">API7: AI gateway rate limiting</a></li><li><a href="https://llm-d.ai/blog/intelligent-inference-scheduling-with-llm-d">llm-d: Intelligent inference scheduling</a></li><li><a href="https://developers.redhat.com/articles/2025/10/07/master-kv-cache-aware-routing-llm-d-efficient-ai-inference">Red Hat Developer: KV-cache-aware routing with llm-d</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5fbe1011e38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Design Better MCP Tools with GraphQL and Why it Matters]]></title>
            <link>https://medium.com/@samchine/how-to-design-better-mcp-tools-with-graphql-and-why-it-matters-87ad381cfa47?source=rss-ebd87bcc47f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/87ad381cfa47</guid>
            <dc:creator><![CDATA[Sam Chinellato]]></dc:creator>
            <pubDate>Thu, 20 Nov 2025 00:05:33 GMT</pubDate>
            <atom:updated>2025-11-20T00:05:33.552Z</atom:updated>
            <content:encoded><![CDATA[<p>Anthropic’s Model Context Protocol (MCP) has quickly emerged as the most popular way for AI Agents to interact with external systems — also called <em>Tools</em> in MCP speak — such as APIs, Databases, and much more. MCP is a hotly discussed topic, and for good reason — <a href="https://www.gartner.com/en/newsroom/press-releases/2025-06-25-gartner-predicts-over-40-percent-of-agentic-ai-projects-will-be-canceled-by-end-of-2027">Gartner recently predicted that 40% of Agentic AI projects will be cancelled by 2027, with the technical complexity of integrating AI Agents into legacy systems being one of the biggest blockers to achieving business value</a>. It is tempting to assume that MCP alone will reduce the complexity of integrating AI Agents into enterprise environments, however MCP’s capabilities are often overestimated: while MCP provides standardisation over how AI Agents interact with external systems, it does not help to design integrations that are consistent and performant.</p><p>This article will cover what integration challenges MCP solves, what challenges it doesn’t solve, <strong>and how to design better MCP Tools for your Agents using GraphQL</strong>.</p><h3><strong>What integration challenges does MCP solve?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*xx89GCkdADRpgufUeqhACw.png" /><figcaption>Reference: <a href="https://modelcontextprotocol.io/docs/learn/architecture">https://modelcontextprotocol.io/docs/learn/architecture</a></figcaption></figure><p>MCP enables AI Agents to interact with external systems through the JSON RPC 2.0 protocol, which allows them to remotely execute functions on other machines. It defines several helpful primitives on top of JSON RPC 2.0, the most important of which is a <strong>Tool</strong>. Within MCP, a Tool is a function that an AI Agent can actively call and decide when to use based on the prompt provided. An AI Agent is responsible for selecting the right Tool and building the appropriate request object when calling it.</p><p>To select a Tool, the AI Agent needs to have a list of available Tools in its context window. Tool discovery is handled by leveraging MCP’s <strong>tools/list</strong> method for tool discovery:</p><h4>Request</h4><pre>{ <br><br>  &quot;jsonrpc&quot;: &quot;2.0&quot;, <br>  &quot;id&quot;: 2, <br>  &quot;method&quot;: &quot;tools/list&quot; <br><br>} </pre><h4>Response</h4><pre>{ <br>  &quot;jsonrpc&quot;: &quot;2.0&quot;, <br>  &quot;id&quot;: 2, <br>  &quot;result&quot;: { <br>    &quot;tools&quot;: [ <br>      { <br>        &quot;name&quot;: &quot;get_weather&quot;, <br>        &quot;title&quot;: &quot;Get Weather&quot;, <br>        &quot;description&quot;: &quot;Returns the current weather conditions for a specified location&quot;, <br>        &quot;inputSchema&quot;: { <br>          &quot;type&quot;: &quot;object&quot;, <br>          &quot;properties&quot;: { <br>            &quot;location&quot;: { <br>              &quot;type&quot;: &quot;string&quot;, <br>              &quot;description&quot;: &quot;The city or location to get weather for&quot; <br>            } <br>          }, <br>          &quot;required&quot;: [&quot;location&quot;] <br>        } <br>      }, <br>      { <br>        &quot;name&quot;: &quot;get_calendar&quot;, <br>        &quot;title&quot;: &quot;Get Calendar&quot;, <br>        &quot;description&quot;: &quot;Retrieves calendar events for a specified date range&quot;, <br>        &quot;inputSchema&quot;: { <br>          &quot;type&quot;: &quot;object&quot;, <br>          &quot;properties&quot;: { <br>            &quot;start_date&quot;: { <br>              &quot;type&quot;: &quot;string&quot;, <br>              &quot;description&quot;: &quot;The start date in YYYY-MM-DD format&quot; <br>            }, <br>            &quot;end_date&quot;: { <br>              &quot;type&quot;: &quot;string&quot;, <br>              &quot;description&quot;: &quot;The end date in YYYY-MM-DD format&quot; <br>            } <br>          }, <br>          &quot;required&quot;: [&quot;start_date&quot;, &quot;end_date&quot;] <br>        } <br>      } <br>    ] <br>  } <br>}</pre><p>Via MCP, an AI Agent has access to a list of Tools available. Each Tool comes with a name and description — that the AI Agent uses to evaluate whether a Tool call is required to answer a given user query — and an input schema — that the AI Agent needs to successfully pass parameters when calling a Tool. MCP provides a <strong>tools/call</strong> method for an AI Agent to call a Tool:</p><h4>Request</h4><pre>{ <br>  &quot;jsonrpc&quot;: &quot;2.0&quot;, <br>  &quot;id&quot;: 3, <br>  &quot;method&quot;: &quot;tools/call&quot;, <br>  &quot;params&quot;: { <br>    &quot;name&quot;: &quot;get_weather&quot;, <br>    &quot;arguments&quot;: { <br>      &quot;location&quot;: &quot;Melbourne&quot; <br>    } <br>  } <br>} </pre><h4>Response</h4><pre>{ <br>  &quot;jsonrpc&quot;: &quot;2.0&quot;, <br>  &quot;id&quot;: 5, <br>  &quot;result&quot;: { <br>    &quot;content&quot;: [ <br>      { <br>        &quot;type&quot;: &quot;text&quot;, <br>        &quot;text&quot;: &quot;Location: Melbourne, Temperature: 22°C, Conditions: Partly Cloudy&quot; <br>      } <br>    ] <br>  } <br>} </pre><h3><strong>MCP Tool Design Matters</strong></h3><p>Tool design is where we can have the most impact on cost, performance and scalability of AI Agents. Firstly, it’s important to understand that available Tools, Tool calls, and Tool results are all stored in an AI Agent’s context window, and that each Tool call adds to the amount of tokens generated by it: this can have a significant impact on the cost and performance of AI Agents. The more Tools an AI Agent needs to use to answer a user query, the longer it will take to answer it, as the AI Agent will need to call each tool and evaluate the response. Furthermore, this process increases the context length an AI Agent is required to hold in memory, resulting in a <a href="https://arxiv.org/html/2410.18745v1">well documented impact on performance</a>. If MCP Tools are not designed to maximise result efficiency and minimise the number of Tool calls required, AI Agents currently cannot scale — producing poor and expensive answers to user queries.</p><p>To meet enterprise requirements, AI Agents need to be well connected, cost effective and performant. MCP helps standardise how AI Agents can connect to external systems, it is up to Tool design to ensure the rest.</p><h3><strong>Why Can’t REST APIs Become Tools?</strong></h3><p>Many of the early naive implementations to designing Agentic systems were based on existing REST APIs. Tools such as <a href="https://gofastmcp.com/getting-started/welcome">FastMCP</a> make it very quick and easy to create an MCP proxy for Agents to interface with REST APIs like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*laqX3ZVZP7_NiF__dEjULQ.png" /></figure><p>Using this approach, REST API methods are mapped directly to Tools, and an MCP proxy is responsible for routing tool calls to the relevant API and returning API responses to the AI Agent(s).</p><p>While this might be sufficient for a simple Proof of Concept, it is not a scalable approach. To explain this, here is an example of what answering a relatively simple user query would entail:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-9ZB_3Q2iKANxTTeAOLDhg.png" /></figure><p>The above diagram shows a simplified example of how an AI Agent interacts with Tools mapped to REST APIs (in reality, this flow would be more complex, involving authentication, authorisation and further API calls. To simplify the example, these have been omitted).</p><p>To answer <strong>‘What’s the weather like for my meeting tomorrow?’ </strong>an AI Agent needs to call 3 separate Tools:</p><ul><li><strong>get_next_meeting</strong> to fetch meeting date and location out of the Calendar API</li><li><strong>get_location_coordinates</strong> to convert the location to a set of coordinates</li><li><strong>get_weather_forecast</strong> to fetch the weather information for the meeting</li></ul><p>Long established API design principles state that ‘<a href="https://research.google.com/pubs/archive/32713.pdf"><strong>APIs should do one thing and do it well</strong></a>’, meaning that a well-designed API has functionality that is simple to understand and should implement no more than its requirements. AI Agents, however, need to be able to interact with many systems in a single workflow, and do so well. In practice, this means that mapping REST APIs into Tools will translate into <strong>a lot</strong> of Tools for AI Agents to leverage. Each Tool call drives up inference costs and delays the answer to a user’s query. As queries and AI Agents get more complex, this effect compounds as more Tool calls are required, filling up the AI Agent’s context window and degrading performance.</p><p>AI Agents are different from traditional software applications; they solve problems dynamically and non-deterministically. They therefore require different interfaces: while a REST API may be the right choice for an application to interact with another system, it is not a suitable choice for an AI Agent.</p><h3><strong>Static Orchestration as Tools</strong></h3><p>Another approach to MCP Tool design is to compose existing APIs into higher-level, coarse-grained interfaces better suited to Agentic use cases:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ANUn-MfJFwn24U5mB_VrXg.png" /></figure><p>Using this approach, a service/workflow orchestrator (e.g. App Connect Enterprise, IBM webMethods, a Java app) is responsible for chaining API calls together and exposing a higher-level Tool to AI Agents via MCP. In doing so, the AI Agent can answer ‘<strong>What’s the weather like for my meeting tomorrow?</strong>’ a lot more easily (although with specific limitations):</p><ul><li>The AI Agent uses a single <strong>get_meeting_weather </strong>tool</li><li>Execution is handled remotely by an orchestrator</li><li>A combined result is returned to the AI Agent</li></ul><p>This approach to MCP Tool design comes with clear advantages:</p><ul><li>The service orchestrator is <strong>deterministic</strong>, meaning that the same input will always produce the same result.</li><li>Service orchestrators are inherently more performant than AI Agents, and will compose APIs more quickly and cheaply, caching API requests and any other data where possible.</li></ul><p>However, leveraging static automation for orchestration comes with its own set of problems:</p><ul><li>Generative AI should help reduce workload on Platform or Development teams, not increase it. Adding a static orchestration layer introduces an additional burden to development teams that are already stretched thin.</li><li>Static orchestration cannot handle unforeseen queries. To answer a question via static automation, an appropriate tool to answer the question needs to exist <strong>before</strong> the question is asked.</li><li>AI Agents shine at <strong>dynamically</strong> reacting to prompts/user queries. If these flows are entirely predefined, AI Agents become responsible for little more than detecting user intent and routing it to the appropriate predefined orchestration. This is a very expensive chatbot.</li></ul><p>MCP Tools should maximise efficiency and performance, however this should not come at the cost of restraining the dynamic capabilities of an AI Agent.</p><h3><strong>Dynamic Agency: GraphQL for Agents</strong></h3><p>So far, this article has discussed how an MCP Tool needs to provide an AI Agent a balance of <strong>efficiency</strong> — allowing it to query multiple data sources in a simple, standardised way — and <strong>flexibility </strong>— allowing an AI Agent to dynamically query and mutate the state of the external system to answer a myriad of different possible user questions. These problems are not new, and existing technologies, such as <strong>GraphQL, </strong>can be leveraged to engineer MCP Tools that achieve both of these outcomes.</p><p>GraphQL is an open-source query language originally created by Meta, designed to provide an efficient and flexible alternative to REST APIs. Named after its graph-based data model, it enables more efficient queries with fewer API calls than REST. GraphQL provides a single endpoint for retrieving data from multiple data sources via a consistent schema regardless of the backend. Through a Federated architecture, it allows for autonomous components (e.g. APIs) to work together, behind a single schema, while maintaining independence. This is achieved through a federated router that acts as the central coordinator, composing these separate components into a unified schema that clients can query.</p><h3><strong>Graph Federation over Orchestration</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Xon45iFc-SJ1D32THGl5w.png" /></figure><p>GraphQL is greatly advantageous when designing Tools, as atomic Tool definitions are no longer needed to fetch the data required to answer a user’s question. In the example above the AI Agent can fetch meeting, location and weather data from <strong>a single endpoint</strong> by leveraging a federated schema of the Weather, Calendar and Maps APIs. Thanks to GraphQL’s graph data model, the AI Agent can efficiently fetch the data <strong>in a single Tool call, </strong>and a GraphQL router is then responsible for resolving schema fields to the appropriate backend API.</p><p>However, unlike in static orchestration, the router is not responsible for orchestrating data sources to answer the user’s query. Orchestration remains the AI Agent’s indirect responsibility when building a query, removing the burden of orchestrating existing systems from developers, and making the most of the AI Agent’s dynamic capabilities.</p><p>Defining Tools with GraphQL allows an AI Agent to benefit from GraphQL’s flexibility. GraphQL allows a client to specify the data it needs to fetch from a backend down to the field level. By having access to a GraphQL schema as a Tool, an AI Agent can select the data it requires from backend systems dynamically to answer the user’s question — this makes for a flexible yet efficient approach. An AI Agent can request the appropriate fields based on their name and description and receive only that data back, reducing burden on the context window. This flexibility has benefits beyond dynamism and efficiency. Authorisation is a complex problem when it comes to Agentic systems and beyond the scope of this article, however, GraphQL offers granularity for authorisation, making it easy to control what an AI Agent can access through field-level authorisation.</p><h4><strong>An Example</strong></h4><p>In practical terms, defining a GraphQL Tool might look something like this:</p><pre>{ <br>  &quot;tools&quot;: [ <br>    { <br>      &quot;name&quot;: &quot;next-meeting-weather-lookup-tool&quot;, <br>      &quot;description&quot;: &quot;Use this tool to fetch information for a user&#39;s weather and calendar. This a graphQL based tool that takes no variables or parameters. Only pass a query to the tool to select the desired information&quot;, <br>      &quot;inputSchema&quot;: { <br>        &quot;type&quot;: &quot;object&quot;, <br>        &quot;properties&quot;: { <br>          &quot;operationName&quot;: { <br>            &quot;description&quot;: &quot;The operation to select from the executable document.&quot;, <br>            &quot;type&quot;: &quot;string&quot; <br>          }, <br>          &quot;query&quot;: { <br>           &quot;description&quot;: &quot;The GraphQL executable document. Use the following GraphQL schema to determine when to use this tool. If you need a capability that this schema does not support, this tool cannot help with the request. Schema: type Location {\n  id: Int!\n  city: String\n  latitude: Float\n  longitude: Float\n  timezone: String\n}\n\ntype Weather {\n  id: Int!\n  locationId: Int\n  timestamp: DateTime\n  temperature: Float\n  condition: String\n  humidity: Int\n  windSpeed: Float\n  windspeed: Float\n}\n\ntype User {\n  id: Int!\n  name: String\n  email: String\n  timezone: String\n  events: [Event]\n}\n\ntype Event {\n  id: Int!\n  userId: Int\n  title: String\n  description: String\n  startTime: DateTime\n  starttime: DateTime\n  endTime: DateTime\n  endtime: DateTime\n  location: String\n  attendees: String\n}\n\n\&quot;DateTime scalar type represents a date and time\&quot;\nscalar DateTime\n\ntype Query {\n  users: [User]\n  weather(locationId: Int!): Weather\n  events(userId: Int!): [Event]\n}&quot;, <br>            &quot;type&quot;: &quot;string&quot; <br>          }, <br>          &quot;variables&quot;: { <br>            &quot;description&quot;: &quot;The variables to be replaced in the GraphQL operation in the executable document.&quot;, <br>            &quot;nullable&quot;: true, <br>            &quot;type&quot;: &quot;object&quot; <br>          } <br>        }, <br>        &quot;required&quot;: [ <br>          &quot;query&quot; <br>        ], <br>        &quot;additionalProperties&quot;: false <br>      } <br>    } <br>  ] <br>} </pre><p>This GraphQL-based Tool gives an AI Agent access to calendar and weather data by exposing the Calendar and Weather fields in the schema, while the schema itself is described to the AI Agent in the query parameter description (line 15). The Tool requires an AI Agent to pass in a valid GraphQL query that is then executed on the MCP server. Using this tool, an AI Agent can dynamically build a query or mutation using a consistent syntax, regardless of the backends that implement the Weather or Calendar APIs.</p><p>The same properties that make GraphQL a good choice for a development team, make it a good choice for an AI Agent: it provides an efficient graph interface to query a variety of backends via a consistent schema. GraphQL federation reduces the number of Tools that AI Agents need to be aware of, while maintaining the dynamic nature of Agentic systems by allowing them to indirectly orchestrate different data sources together.</p><h3><strong>Conclusion</strong></h3><p>MCP tool design is a nascent field, and MCP Tool design best practices are still emerging, but it is already clear that Agentic platforms depend on good MCP Tool design to successfully integrate with enterprise systems in an efficient, cost effective, and performant way. This article has aimed to outline some guidelines to design better MCP Tools:</p><ol><li>Tools fill up an AI Agent’s context window: the more efficient they are in retrieving or mutating external data, the more performant the AI Agent will be.</li><li>When an AI Agent needs to choose from too many Tools, it is more likely to make a mistake. Therefore, Tools should be flexible, adapting to different use cases.</li><li>AI Agents are most valuable when solving dynamic, unforeseen, queries. Tools should preserve agency, leveraging technologies such as GraphQL to do so.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87ad381cfa47" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>