Agent frameworks and MCP
The frameworks for building AI agents that plan, use tools and work in steps: LangGraph, CrewAI, the Microsoft Agent Framework, the OpenAI Agents SDK, the Claude Agent SDK and Google's Agent Development Kit, plus the Model Context Protocol (MCP) for connecting tools. What each is best at, with simple examples.
🎯 By the end of this lesson you will be able to:
- Explain what agent frameworks add beyond a simple model call
- Compare the main agent frameworks and when to use each
- Build a simple MCP tool server conceptually and know why MCP matters
In this lesson
What do agent frameworks add?
An agent (Lesson 10) is a model that works in a loop: decide, use a tool, look at the result, decide again. Writing that loop yourself is possible, but agent frameworks add the parts that are hard to get right:
- Tool calling: describing tools to the model and running the ones it chooses.
- State and memory: keeping track of what has happened across many steps.
- Control: limits on steps, retries, branching and timeouts.
- Human approval: pausing before risky actions until a person agrees.
- Multi-agent: several specialised agents handing work to each other.
- Tracing: a record of every step, so you can debug and evaluate (Lesson 23).
LangGraph: controlled workflows
LangGraph (from the LangChain team) builds agents as a graph: boxes for steps and arrows for what happens next, with a shared state. It is popular for production because you decide exactly which steps can happen, can save progress, and can pause for human approval.
A support workflow as a graph
from typing import TypedDict
from langgraph.graph import StateGraph, START, END
class State(TypedDict):
ticket: str
category: str
reply: str
def classify(state: State):
return {"category": "refund"} # call a model here to classify the ticket
def draft(state: State):
return {"reply": "Draft reply ..."} # call a model here to draft the reply
graph = StateGraph(State)
graph.add_node("classify", classify)
graph.add_node("draft", draft)
graph.add_edge(START, "classify")
graph.add_edge("classify", "draft")
graph.add_edge("draft", END)
app = graph.compile()
print(app.invoke({"ticket": "My parcel never arrived"}))Best for: business workflows that must be predictable, auditable and able to pause for approval.
CrewAI: teams of role-based agents
CrewAI lets you describe a crew of agents with roles, goals and tasks, like a small team. It is quick to learn and good for research, content and analysis tasks split between specialists.
A researcher and a writer working together
from crewai import Agent, Task, Crew
researcher = Agent(role="Researcher", goal="Find reliable facts about the topic", backstory="A careful analyst")
writer = Agent(role="Writer", goal="Write a clear one-page brief", backstory="A plain-English writer")
research = Task(description="Research {topic}", expected_output="Key facts with sources", agent=researcher)
brief = Task(description="Write a one-page brief from the research", expected_output="A one-page brief", agent=writer)
crew = Crew(agents=[researcher, writer], tasks=[research, brief])
print(crew.kickoff(inputs={"topic": "home solar batteries"}))Best for: quick multi-agent prototypes and tasks that split naturally into roles.
Agent SDKs from the big providers
- OpenAI Agents SDK (Python and TypeScript): a lightweight way to build agents with tools, handoffs between agents, guardrails and built-in tracing.
- Claude Agent SDK (Python and TypeScript, from Anthropic): gives you the same agent loop that powers Claude Code, including tools for files, search and commands, so you can build agents that do real work on a computer or codebase.
- Google Agent Development Kit (ADK): Google's open-source framework for single and multi-agent systems, designed for Gemini but able to use other models, with deployment to Google Cloud.
- Microsoft Agent Framework: Microsoft's framework for .NET and Python (version 1.0 released in 2026). It is the direct successor to AutoGen (multi-agent conversations) and Semantic Kernel (enterprise integration), combining both with graph-based workflows.
A tool-using agent with the OpenAI Agents SDK
from agents import Agent, Runner, function_tool
@function_tool
def order_status(order_id: str) -> str:
"""Look up the delivery status of an order."""
return "Shipped on 2 November" # look this up in your real system
agent = Agent(name="Support", instructions="Help customers with their orders.", tools=[order_status])
result = Runner.run_sync(agent, "Where is order 4471?")
print(result.final_output)The model reads the tool description, decides to call order_status with "4471", and uses the result in its answer.
MCP: one standard way to connect tools
The Model Context Protocol (MCP), introduced by Anthropic and now widely supported, is an open standard for connecting AI applications to tools and data (Lesson 16). Write a tool once as an MCP server, and any MCP-compatible app or agent framework can use it, much like a USB-C port for AI.
A tiny MCP server in Python
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("orders")
@mcp.tool()
def order_status(order_id: str) -> str:
"""Return the delivery status of an order."""
return "Shipped on 2 November" # look this up in your real system
if __name__ == "__main__":
mcp.run()Now Claude, ChatGPT, IDE assistants and agent frameworks that support MCP can all use the same order-status tool.
Which agent framework should you choose?
| Situation | Good choice |
|---|---|
| Predictable business workflow with approvals and audit | LangGraph |
| Quick multi-agent prototype with clear roles | CrewAI |
| Mostly using OpenAI models, want simple agents with handoffs | OpenAI Agents SDK |
| Agents that work with files, code and commands | Claude Agent SDK |
| Built on Google Cloud and Gemini | Google ADK |
| Enterprise .NET or Azure environment | Microsoft Agent Framework |
| Tools that many apps and agents should share | Expose them as MCP servers |
What this means for your role
Developer
Prototype the agent loop by hand once, then pick a framework. Put tools behind MCP servers so they're reusable and testable on their own.
Tester / QA
Test agents on trajectories, not just final answers: right tools, right order, safe failure, approval before risky actions.
Business Analyst / PO
Describe workflows as clear steps with decision points and approval needs; that maps directly onto graph-style frameworks.
Tech Lead / Architect
Standardise one agent framework and MCP for tools; enforce least-privilege credentials and step limits in the platform.
Project / Delivery Manager
Agents need more evaluation and safety work than simple features; plan for it and start with narrow scopes.
Scrum Master / Agile
Encourage small, observable agent experiments with clear success metrics before the team commits to a bigger multi-agent design.
Try it: design before you code
- Pick a task an agent could do at work, such as answering order questions.
- Draw it as boxes and arrows: steps, tools, decision points and where a human approves.
- Decide: is this a fixed workflow (LangGraph-style) or a flexible agent? Which tools would you expose through MCP?
Key takeaways
- Agent frameworks add tool calling, state, control, human approval, multi-agent handoffs and tracing.
- LangGraph suits controlled production workflows; CrewAI suits quick role-based teams.
- The OpenAI Agents SDK, Claude Agent SDK, Google ADK and Microsoft Agent Framework each fit their ecosystems.
- MCP is the open standard for connecting tools once and using them from many apps and agents.
Key terms
- Agent framework
- Code that runs the agent loop and adds tools, state, control and tracing.
- Handoff
- One agent passing a task to another, more specialised agent.
- MCP server
- A program that exposes tools or data to AI apps using the Model Context Protocol.
- Trajectory
- The sequence of steps and tool calls an agent took to reach its answer.
Check your understanding
Answer all 5 questions. Score 3 or more to complete the lesson.
1. You need a refund workflow with fixed steps and a human approval before money is sent. Which framework fits best?
2. What is MCP?
3. What does CrewAI organise agents around?
4. Which Microsoft framework brings together ideas from AutoGen and Semantic Kernel?
5. Before building a multi-agent system, what should you check first?