AI Agents — Multi-Provider Developer Guide

Technology: ai-agents · Category: ai · Last reviewed: 2026-10-18

Source: https://tech-stack.codeamanilabs.org/guide/ai-agents

Insight:

An AI agent is an LLM running in a loop: perceive → reason → call a tool → observe the result → repeat until done. Every stack here (xAI Grok, Anthropic's Claude API / Agent SDK / Managed Agents, Microsoft Agent Framework, Google ADK, and the Vercel AI SDK) implements that same loop. What differs is who runs the loop, where tools execute, and how you attach them. The unifier is MCP (Model Context Protocol): build one MCP server and every agent can use it. For codeAmani: keep model and tool keys server-side, bound every loop with a step and cost cap, and require human approval before any action that moves money or writes to production.

 █████╗ ██╗     █████╗  ██████╗ ███████╗███╗   ██╗████████╗███████╗
██╔══██╗██║    ██╔══██╗██╔════╝ ██╔════╝████╗  ██║╚══██╔══╝██╔════╝
███████║██║    ███████║██║  ███╗█████╗  ██╔██╗ ██║   ██║   ███████╗
██╔══██║██║    ██╔══██║██║   ██║██╔══╝  ██║╚██╗██║   ██║   ╚════██║
██║  ██║██║    ██║  ██║╚██████╔╝███████╗██║ ╚████║   ██║   ███████║
╚═╝  ╚═╝╚═╝    ╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚═╝  ╚═══╝   ╚═╝   ╚══════╝

AI Agents — Multi-Provider Developer Guide

Focus: how to build AI agents on the stacks you'll actually reach for: Anthropic (Claude API Tool Runner, Claude Agent SDK, Claude Managed Agents), xAI Grok, Microsoft Agent Framework (+ VS Code agents), Google ADK, and the Vercel AI SDK. Covers their scope, how to wire tools, and the MCP connector that links them all. Grounded in each vendor's official docs and registries; reviewed 2026-10-18.

What an agent actually is

Strip away the hype: an agent is a language model put in a loop with tools. It reads the goal, decides whether it can answer directly or needs a tool, calls the tool, reads the result, and loops until it can give a final answer. Everything else (memory, multi-agent, hosting) is built on top.

flowchart LR
  U["User goal"] --> P["Perceive<br/>read context"]
  P --> R["Reason<br/>plan next step"]
  R --> D{"Need a tool?"}
  D -->|yes| T["Act<br/>call a tool"]
  T --> O["Observe<br/>read result"]
  O --> R
  D -->|no| A["Respond"]

The two non-negotiables: tools (what the agent can do: search, query a DB, send an SMS) and stop conditions (when to quit the loop). Get those right and the rest is plumbing.

Who runs the loop?

The first decision is not which model. It is who owns the loop and where tools execute:

You want… Reach for Loop runs Tools run
Full control of every message Raw SDK, manual loop Your code Your code
Your tools, no loop boilerplate Claude Tool Runner, AI SDK ToolLoopAgent, MS Agent Framework, Google ADK SDK in your process Your code
A ready-made coding/ops agent (files, bash, web) Claude Agent SDK SDK in your process Your machine / container
Anthropic to host the loop and a sandbox Claude Managed Agents (beta) Anthropic Per-session container
Search / code / MCP calls run by the provider xAI server-side tools xAI xAI
A loop that survives crashes and waits for approval AI SDK WorkflowAgent Durable workflow Your code

Official Documentation

Provider / spec URL
MCP specification (2026-07-28) https://modelcontextprotocol.io/specification/2026-07-28
MCP build a server / client https://modelcontextprotocol.io/docs/develop/build-server · https://modelcontextprotocol.io/docs/develop/build-client
Claude API tool use https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview
Claude Agent SDK https://code.claude.com/docs/en/agent-sdk/overview
Claude Agent SDK custom tools https://code.claude.com/docs/en/agent-sdk/custom-tools
Claude Managed Agents (beta) https://platform.claude.com/docs/en/managed-agents/overview
xAI function calling / server-side tools https://docs.x.ai/developers/tools/function-calling · https://docs.x.ai/developers/tools/overview
Microsoft Agent Framework https://learn.microsoft.com/agent-framework/overview/
Google Agent Development Kit https://adk.dev/
Vercel AI SDK agents https://ai-sdk.dev/docs/agents
VS Code agents + MCP servers https://code.visualstudio.com/docs/agents/overview · https://code.visualstudio.com/docs/agent-customization/mcp-servers

MCP — the universal connector

Before the providers, learn the thing that ties them together. MCP (Model Context Protocol) is an open standard: an MCP server exposes tools, resources, and prompts, and any MCP-capable agent (client) can consume them. Build your "check M-Pesa status" or "query Supabase" tool once as an MCP server, and every agent below can call it.

flowchart TB
  subgraph Agents["MCP clients (agents)"]
    G["Grok"]
    C["Claude Agent SDK /<br/>Managed Agents"]
    M["MS Agent Framework /<br/>VS Code"]
    A["Google ADK"]
  end
  subgraph Servers["Your MCP servers"]
    S1["mpesa-tools<br/>STK status · receipts"]
    S2["data-tools<br/>Supabase · BigQuery"]
  end
  G --> S1
  C --> S1
  M --> S2
  A --> S2
  C --> S2

What changed in the 2026-07-28 spec

The current revision is 2026-07-28 (the previous one was 2025-11-25). If you wrote MCP code a year ago, these are the changes that matter:

SDKs

Language Package Version (2026-10-18) Notes
TypeScript (v2, current) @modelcontextprotocol/server, @modelcontextprotocol/client 2.3.1 Split packages; implements the 2026-07-28 spec
TypeScript (v1) @modelcontextprotocol/sdk 1.32.1 Maintenance branch (v1.x): fixes for at least 6 months after the v2 release
Python mcp 2.3.0 from mcp.server import MCPServer (replaces FastMCP in the README)

A read-only tool server, built once and attachable to every agent below (TypeScript, v2 SDK, ESM):

// mpesa-tools/server.ts   npm i @modelcontextprotocol/server zod
import { McpServer } from "@modelcontextprotocol/server";
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
import { z } from "zod";

const server = new McpServer({ name: "mpesa-tools", version: "1.0.0" });

server.registerTool(
  "mpesa_status",
  {
    description: "Read the recorded status of an M-Pesa STK checkout. Read-only.",
    inputSchema: z.object({ checkout_request_id: z.string().min(10) }),
  },
  async ({ checkout_request_id }) => {
    const row = await lookupCheckout(checkout_request_id); // your DB read
    return row
      ? { content: [{ type: "text", text: JSON.stringify(row) }] }
      : { content: [{ type: "text", text: "not_found" }], isError: true };
  },
);

await server.connect(new StdioServerTransport());

Every provider in this guide speaks MCP. That's the bet: write tools once, reuse everywhere. See the github and supabase guides for first-party MCP servers you can attach today.


1. Anthropic — three ways to build on Claude

Anthropic offers three agent surfaces that differ in who hosts what. Pick the simplest one that does the job.

a) Claude API + Tool Runner (your tools, SDK runs the loop)

The default for a custom-tool agent. The TypeScript SDK's Tool Runner (beta in @anthropic-ai/sdk 0.135) runs the request → execute → loop cycle; you write tool functions. Full example: examples/agent-tool-runner.ts. The manual loop it automates is in examples/agent-loop.ts.

import Anthropic from "@anthropic-ai/sdk";
import { betaZodTool } from "@anthropic-ai/sdk/helpers/beta/zod";
import { z } from "zod";

const client = new Anthropic(); // ANTHROPIC_API_KEY, server-side

const mpesaStatus = betaZodTool({
  name: "mpesa_status",
  description: "Read the recorded status of an M-Pesa STK checkout.",
  inputSchema: z.object({ checkout_request_id: z.string() }),
  run: async ({ checkout_request_id }) => JSON.stringify(await lookupCheckout(checkout_request_id)),
});

const final = await client.beta.messages.toolRunner({
  model: "claude-opus-5-5",
  max_tokens: 16000,
  max_iterations: 10,          // the step cap. Always set it
  tools: [mpesaStatus],
  messages: [{ role: "user", content: "Is checkout ws_CO_123 paid?" }],
});

Three gotchas from the current API:

b) Claude Agent SDK (a ready-made agent harness)

from claude_agent_sdk import tool, create_sdk_mcp_server, ClaudeAgentOptions, query, ResultMessage

@tool("mpesa_status", "Check an M-Pesa STK payment status", {"checkout_id": str})
async def mpesa_status(args):
    status = await lookup(args["checkout_id"])  # your code
    return {"content": [{"type": "text", "text": status}]}

server = create_sdk_mcp_server(name="mpesa", version="1.0.0", tools=[mpesa_status])

options = ClaudeAgentOptions(
    mcp_servers={"mpesa": server},
    allowed_tools=["mcp__mpesa__mpesa_status"],  # auto-approve this one tool
    disallowed_tools=["Bash"],                    # remove a built-in entirely
    permission_mode="default",
    max_turns=10,
    max_budget_usd=0.50,                          # hard cost cap → result subtype "error_max_budget_usd"
)

async for msg in query(prompt="Is checkout ws_CO_123 paid?", options=options):
    if isinstance(msg, ResultMessage) and msg.subtype == "success":
        print(msg.result)

c) Claude Managed Agents (Anthropic hosts the loop and the sandbox)

Beta (managed-agents-2026-04-01, set automatically by the SDK on client.beta.*). You create a persisted, versioned Agent config once (model, system prompt, tools, MCP servers, skills), then start a Session per run. Each session gets its own container where bash, file, and code tools execute, and streams events back to you. Credentials for MCP servers and CLIs live in vaults and are substituted at egress, never visible in the sandbox. There are also scheduled deployments, rubric-graded outcomes, and multi-agent sessions.

See anthropic for models, prompt caching, and effort.


2. xAI — Grok agents

# pip install xai-sdk   (1.20.0, Python 3.10+)
import json
from pydantic import BaseModel, Field
from xai_sdk import Client
from xai_sdk.chat import system, user, tool, tool_result

client = Client()  # reads XAI_API_KEY

class WeatherReq(BaseModel):
    city: str = Field(description="City name")

def get_weather(city: str) -> str:
    return f"Sunny, 26°C in {city}"

chat = client.chat.create(
    model="grok-4.7",
    messages=[system("You are a helpful assistant.")],
    tools=[tool(name="get_weather", description="Current weather for a city.",
                parameters=WeatherReq.model_json_schema())],
)
chat.append(user("Weather in Nairobi?"))
resp = chat.sample()
chat.append(resp)
for tc in resp.tool_calls:                      # the model asked to call a tool
    args = json.loads(tc.function.arguments)
    chat.append(tool_result(get_weather(**args), tool_call_id=tc.id))  # tool_call_id optional
print(chat.sample().content)                     # final answer after the tool result
from xai_sdk.tools import web_search, code_execution, mcp
chat = client.chat.create(model="grok-4.7", tools=[
    web_search(), code_execution(),
    mcp(server_url="https://mcp.example.com", server_label="mpesa",
        allowed_tool_names=["mpesa_status"], authorization="Bearer TOKEN"),
])

3. Microsoft — Agent Framework + VS Code agents

a) Build agents in code — Microsoft Agent Framework

The direct successor to Semantic Kernel and AutoGen (same teams). It is GA in Python (agent-framework 1.22.0, Python ≥3.10) and .NET (Microsoft.Agents.AI 1.25.0). Go is public preview (github.com/microsoft/agent-framework-go v0.1.1). It covers agents, functional and graph-based workflows, session state, middleware and telemetry, MCP, and a newer Harness Agent (planning, context compaction, file and memory access, tool approval).

# pip install agent-framework
from typing import Annotated
from pydantic import Field
from agent_framework import Agent, tool
from agent_framework.openai import OpenAIChatClient   # or foundry.FoundryChatClient, anthropic.AnthropicClient

@tool(approval_mode="never_require")                 # read-only → no approval prompt
def get_weather(location: Annotated[str, Field(description="City name")]) -> str:
    """Get the weather for a location."""
    return f"Sunny, 26°C in {location}"

agent = Agent(
    client=OpenAIChatClient(),
    name="SupportAgent",
    instructions="You are codeAmani's Swahili-fluent support agent.",
    tools=[get_weather],
)
result = await agent.run("Habari ya hali ya hewa Nairobi?")
print(result.text)

b) Drive an agent in the IDE — VS Code

VS Code's docs now say agents rather than "agent mode": pick the Agent (or the Plan agent) in the chat session controls. Enable MCP tools with the Configure Tools button, reference tools with # (e.g. #fetch), and invoke MCP prompts as /<server>.<prompt>.

// .vscode/mcp.json  (top-level key is "servers"; .mcp.json files use "mcpServers")
{
  "inputs": [
    { "type": "promptString", "id": "mpesa-token", "description": "M-Pesa tools token", "password": true }
  ],
  "servers": {
    "mpesa": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "mpesa-mcp"],
      "env": { "MPESA_TOOLS_TOKEN": "${input:mpesa-token}" }
    },
    "github": { "type": "http", "url": "https://api.githubcopilot.com/mcp" }
  }
}

4. Google — Agent Development Kit (ADK)

# pip install google-adk
from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner

def get_weather(city: str) -> dict:
    """Current weather for a city.  (the docstring is the tool's description)"""
    return {"status": "success", "report": f"Sunny, 26°C in {city}"}

root_agent = Agent(
    name="weather_agent",
    model="gemini-flash-latest",   # the string the official quickstart uses
    description="Answers weather questions.",
    instruction="Use the get_weather tool to answer.",
    tools=[get_weather],           # plain Python functions; docstring + type hints = schema
)

runner = InMemoryRunner(agent=root_agent, app_name="weather")
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import (
    StdioConnectionParams, StreamableHTTPConnectionParams,
)
from mcp import StdioServerParameters

tools = [
    McpToolset(  # local server over stdio
        connection_params=StdioConnectionParams(
            server_params=StdioServerParameters(command="npx", args=["-y", "mpesa-mcp"]),
        ),
        tool_filter=["mpesa_status"],               # expose only what the agent needs
    ),
    McpToolset(  # remote server: prefer Streamable HTTP over SseConnectionParams
        connection_params=StreamableHTTPConnectionParams(
            url="https://mcp.example.com/mcp", headers={"Authorization": "Bearer TOKEN"},
        ),
    ),
]

5. Vercel AI SDK — agents in a Next.js app

For codeAmani's Next.js apps, AI SDK 7 (ai 7.x) gives you a provider-agnostic agent class, so you can swap Claude, Grok, or Gemini without rewriting the loop. Full example: examples/agent-loop-vercel.ts.

import { ToolLoopAgent, isStepCount } from "ai";
import { anthropic } from "@ai-sdk/anthropic";

export const supportAgent = new ToolLoopAgent({
  model: anthropic("claude-opus-5-5"),
  instructions: "Answer from tools; never guess payment status.",
  tools: { mpesaStatus },          // tool({ description, inputSchema, execute })
  stopWhen: isStepCount(10),
});

const { text } = await supportAgent.generate({ prompt: "Is ws_CO_123 paid?" });

Step limits differ by entry point, so always set stopWhen explicitly:

Entry point Default stop Consequence if you forget
generateText / streamText isStepCount(1) Stops after the first tool call and returns an empty answer
ToolLoopAgent isStepCount(20) Logs a warning when it hits the cap
WorkflowAgent (@ai-sdk/workflow) none Runs until the model stops calling tools

WorkflowAgent is the durable variant. Each tool call is a workflow step with retries, the run survives a crash, and needsApproval tools suspend for a human and resume later. That is the right shape for an agent that must wait for an approval before an M-Pesa payout.


Choosing a stack

Claude (Tool Runner / Agent SDK / Managed) xAI Grok MS Agent Framework Google ADK Vercel AI SDK
Language TS / Python (+ more SDKs) Python / REST Python / .NET / Go (preview) Python / TS / Go / Java / Kotlin TypeScript
Tools functions, MCP, built-ins client + server-side functions + MCP functions + MCP functions (+ MCP adapter)
MCP mcp_servers / Managed vaults mcp() tool MCPStdioTool / MCPStreamableHTTPTool McpToolset via MCP client
Hosting your infra, or Anthropic (Managed) xAI API Azure / your infra Agent Runtime / your infra Vercel / your infra
Multi-agent subagents, multi-agent sessions DIY graph + functional workflows agent hierarchies, A2A subagents, workflows
Best for coding/ops agents, guardrails, hosted sandboxes live web/X research .NET/Azure shops Gemini + GCP-native Next.js apps, provider swaps

Rule of thumb for codeAmani: Claude for anything agentic with real consequences (Tool Runner in apps, Agent SDK for ops, Managed Agents when you want Anthropic to host the sandbox); the AI SDK ToolLoopAgent in Next.js when provider portability matters; Grok for live web/X research; ADK when you're already on GCP/Gemini; Microsoft when the stack is .NET/Azure.


Capabilities & scope (what to expect)


codeAmani notes

Official docs: