AI Agents — Multi-Provider Developer Guide

Technology: ai-agents · Category: ai · Last reviewed: 2026-08-23

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 provider here — xAI Grok, Anthropic's Claude Agent SDK, Microsoft's Agent Framework, and Google's ADK — implements that same loop; what differs is the SDK, the hosting, and how you attach tools. The unifier is MCP (Model Context Protocol): build one MCP server and every agent can use it. For codeAmani, keep the model + tool keys server-side, allowlist tools, and require human approval before any agent action that moves money or writes to production.

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

AI Agents — Multi-Provider Developer Guide

Focus: How to build AI agents across the four stacks you'll actually reach for — xAI Grok, Anthropic (Claude Agent SDK), Microsoft (Agent Framework + Copilot agent mode), and Google (ADK + Agent Engine) — their scope and capabilities, how to wire tools, and the MCP connector that links them all. Grounded in each vendor's official docs; reviewed 2026-08-23.

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. That's it. 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.

Official Documentation

Provider / spec URL
xAI (Grok) API https://docs.x.ai/docs
Claude Agent SDK (Python) https://github.com/anthropics/claude-agent-sdk-python
Google Agent Development Kit https://adk.dev/
Microsoft Agent Framework https://learn.microsoft.com/agent-framework/
Model Context Protocol (MCP) https://modelcontextprotocol.io/
Copilot agent mode (VS Code) https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode

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; any MCP-capable agent (client) can consume them over stdio (local subprocess) or HTTP. Build your "send M-Pesa receipt" 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"]
    M["MS Agent Framework / Copilot"]
    A["Google ADK"]
  end
  subgraph Servers["Your MCP servers"]
    S1["mpesa-tools<br/>STK push · receipts"]
    S2["data-tools<br/>Supabase · BigQuery"]
  end
  G --> S1
  C --> S1
  M --> S2
  A --> S2
  C --> S2

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. xAI — Grok agents

# pip install xai-sdk   (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.6",  # current flagship (grok-4 is retired); check docs.x.ai/developers/models
    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))
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.6", tools=[
    web_search(), code_execution(),
    mcp(server_url="https://mcp.example.com", authorization="Bearer TOKEN"),
])

2. Anthropic — Claude Agent SDK

# pip install claude-agent-sdk   (also: npm i @anthropic-ai/claude-agent-sdk)
from claude_agent_sdk import tool, create_sdk_mcp_server, ClaudeAgentOptions, query

@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"],   # pre-approve → no permission prompt
)

async for msg in query(prompt="Is checkout ws_CO_123 paid?", options=options):
    print(msg)

3. Microsoft — Agent Framework + Copilot agent mode

Two complementary surfaces.

a) Build agents in code — Microsoft Agent Framework

The unified successor to Semantic Kernel + AutoGen (same teams), now GA (1.x) with SDKs for .NET, Python, and Go (Go still public preview) — session state, middleware/telemetry, graph-based multi-agent workflows, MCP support, and first-class model providers including Anthropic, Microsoft Foundry, Azure OpenAI, OpenAI, and Ollama.

# pip install agent-framework   (GA, 1.x)
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient   # or FoundryChatClient, Anthropic, etc.

agent = Agent(
    client=OpenAIChatClient(),                 # any IChatClient-style provider
    instructions="You are codeAmani's Swahili-fluent support agent.",
    tools=[get_weather],                       # plain functions become tools
)
result = await agent.run("Habari ya hali ya hewa Nairobi?")
print(result)

In .NET the base type is AIAgent and a single ChatClientAgent wraps any IChatClient provider. The framework also ships CopilotStudioAgent and an A2AAgent (agent-to-agent).

b) Drive an agent in the IDE — Copilot agent mode

In VS Code / Visual Studio, open Chat → switch to Agent mode → the tools icon lists available tools, including any MCP servers you've added. Reference a tool inline with #tool_name. This is how you wire MCP servers (Microsoft Learn, Azure, your own) into the editor agent.

// .vscode/mcp.json — add an MCP server to Copilot agent mode
{ "servers": { "mpesa": { "command": "npx", "args": ["-y", "mpesa-mcp"] } } }

4. Google — Agent Development Kit (ADK)

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

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}"}

agent = Agent(
    name="weather_agent",
    model="gemini-flash-latest",
    instruction="Use the tools to answer.",
    tools=[get_weather],          # plain Python functions; docstring matters
)

runner = InMemoryRunner(agent=agent, app_name="weather")
# runner.run_async(user_id=..., session_id=..., new_message=types.Content(...))

Choosing a provider

xAI Grok Claude Agent SDK MS Agent Framework Google ADK
Language Python / REST Python / TS C# / Python / Go Python / Java / Go
Tools client + server-side MCP + built-ins functions + MCP functions + MCP
MCP mcp() tool mcp_servers VS Code + framework McpToolset
Hosting xAI API your infra / Claude Code Azure / your infra Vertex Agent Engine
Multi-agent DIY subagents workflows (graph) agent hierarchies
Best for research + live web/X coding/ops agents w/ guardrails .NET shops, IDE agents Gemini + GCP-native

Rule of thumb for codeAmani: Claude Agent SDK for ops/coding agents with strong guardrails; Google ADK when you're already on GCP/Gemini and want managed Agent Engine memory; Grok for live-web/X research; Microsoft when the stack is .NET/Azure or you want the in-IDE Copilot agent.


Capabilities & scope (what to expect)


codeAmani notes

Official docs: