agentic ai & mcp · tool & agent builders

Agentic AI & MCP

Build AI agents that plan, use tools, remember context, and collaborate. Covers LangGraph, CrewAI, MCP protocol, OpenAI Assistants, multi-agent patterns, and safety. Mapped to mcp-learning-guide and crewai-course-materials repos.

AGENTICAgentic AI & MCP
All Courses
fundamentals

What is an AI Agent?

An agent is an LLM with the ability to plan actions, use tools, and remember context across steps. It solves complex tasks by breaking them into sub-tasks and choosing the right tool at each step.

Agent Core Loop

User Goal
LLM Planner
Select Tool
Execute Tool
Observe Result
Final Answer

Loop continues until goal is reached or max steps exceeded

Key Agent Components

ComponentRole
Planner (LLM)Reasons about which tool to use next given the goal and history
ToolsPython functions, APIs, databases, web browsers, code interpreters
MemoryShort-term (conversation), long-term (vector DB), episodic (past runs)
ExecutorRuns the chosen tool and captures the output
ScratchpadStores intermediate reasoning and tool outputs

Interactive Notebook

Notebook: What is an Agent
Simple agent loop, ReAct pattern, tool calling concepts
First load ~30-60s · Saves automatically
Open Notebook

Quiz

Test your understanding of What is an Agent -- 10 questions, 70% to pass.

Take Quiz
langchain-learning-guide

LangGraph

Build stateful, multi-step agent workflows as directed graphs. LangGraph gives you control flow, branching, state management, and checkpointing — solving the reliability problems of simple chain-based agents.

Core Concepts

ConceptMeaning
NodeA Python function that processes the graph state and returns updates
EdgeConnection between nodes — can be conditional or unconditional
StateTyped dictionary shared across all nodes in the graph
Conditional EdgeRoutes to different nodes based on the current state value
CheckpointingSave graph state so you can pause, resume, or rollback

Code Example

langgraph_agent.py
from langgraph.graph import StateGraph, END
from typing import TypedDict

class AgentState(TypedDict):
    question: str
    answer:   str
    tool_output: str

def call_llm(state):
    # call LLM with state["question"]
    return {"answer": llm.invoke(state["question"])}

def should_continue(state):
    return "tools" if needs_tool(state) else "end"

graph = StateGraph(AgentState)
graph.add_node("llm", call_llm)
graph.add_conditional_edges("llm", should_continue, {
    "tools": "tool_node", "end": END
})
app = graph.compile()

Interactive Notebook

Notebook: LangGraph
State graph, nodes, conditional edges, checkpointing
First load ~30-60s · Saves automatically
Open Notebook

Quiz

Test your understanding of LangGraph -- 10 questions, 70% to pass.

Take Quiz
crewai-course-materials

CrewAI

Build multi-agent systems where specialized agents collaborate on a shared mission. Each agent has a role, goal, backstory, and set of tools — like a team of people with different expertise.

CrewAI Components

ComponentDescription
AgentHas a role (e.g., "Researcher"), goal, backstory, and optional LLM override
TaskA specific piece of work with a description, expected output, and assigned agent
CrewA group of agents and tasks with a defined process (sequential or hierarchical)
ToolA Python function or external API the agent can call

Code Example

crew_agents.py
from crewai import Agent, Task, Crew

researcher = Agent(
    role="Research Analyst",
    goal="Find the latest AI papers on RAG",
    backstory="Expert in LLM research and arxiv papers",
    tools=[search_tool]
)

writer = Agent(
    role="Technical Writer",
    goal="Summarize findings into a clear report",
    backstory="Clear communicator for technical audiences"
)

crew = Crew(agents=[researcher, writer], process="sequential")
result = crew.kickoff()

Interactive Notebook

Notebook: CrewAI
Multi-agent roles, tasks, sequential and hierarchical processes
First load ~30-60s · Saves automatically
Open Notebook

Quiz

Test your understanding of CrewAI -- 10 questions, 70% to pass.

Take Quiz
mcp-learning-guide

Model Context Protocol (MCP)

MCP is an open standard for connecting AI models to external tools and data sources. It defines a standard way for LLM applications to call tools, access resources, and receive prompts from MCP servers.

MCP Architecture

ComponentRole
MCP HostThe AI application (Claude Desktop, Claude Code, etc.)
MCP ClientManages the connection between host and servers
MCP ServerExposes tools, resources, and prompts to the host
ToolsFunctions the LLM can invoke via MCP
ResourcesFiles, databases, APIs the LLM can read
PromptsReusable prompt templates exposed by the server

Creating an MCP Server (Python SDK)

mcp_server.py
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("My Project Server")

@mcp.tool()
def search_docs(query: str) -> str:
    """Search project documentation"""
    results = vector_db.search(query, top_k=3)
    return "\n".join(r.content for r in results)

@mcp.resource("docs://{filename}")
def get_doc(filename: str) -> str:
    return open(f"docs/{filename}").read()

if __name__ == "__main__":
    mcp.run()

Interactive Notebook

Notebook: MCP
Model Context Protocol, tool registration, client-server
First load ~30-60s · Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
openai assistants api

OpenAI Assistants API

Build persistent AI assistants with managed threads, file search, code interpreter, and function calling — without managing conversation state yourself.

Key Objects

ObjectWhat it is
AssistantA configured AI with tools, instructions, and a model
ThreadA conversation session — stores message history automatically
MessageA single turn in the conversation (user or assistant)
RunAn invocation of the Assistant on a Thread
File SearchBuilt-in RAG over uploaded files
Code InterpreterExecutes Python code in a sandboxed environment

Interactive Notebook

Notebook: Assistants API
Persistent threads, tool calling, Code Interpreter
First load ~30-60s · Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
multi-agent patterns

Multi-Agent Systems

When a single agent isn't enough, multiple specialized agents collaborate — passing tasks between each other through defined handoff patterns.

Common Patterns

PatternDescriptionBest for
SequentialAgent A → Agent B → Agent C (output feeds next)Research → write → review pipelines
SupervisorManager agent routes tasks to specialist agentsComplex tasks with routing logic
ParallelMultiple agents work on the same task independentlyEnsemble / redundancy for critical tasks
HierarchicalSupervisor agents manage sub-supervisor agentsVery large, deeply nested workflows

Interactive Notebook

Notebook: Multi-Agent
Supervisor pattern, parallel execution, handoff
First load ~30-60s · Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz
evaluation & safety

Agent Evaluation & Safety

Agentic systems can fail in subtle ways — infinite loops, unexpected tool use, prompt injection. These patterns help you build reliable, safe agents.

Safety Patterns

RiskMitigation
Infinite loopsSet max_iterations, detect repeated states, add step counter
Prompt injectionSanitize tool outputs before injecting into prompts
Tool misuseValidate tool arguments, require human approval for destructive actions
Hallucinated tool callsStrict JSON schema validation on tool call arguments
Cost runawayBudget caps on tokens and tool executions per run

Interactive Notebook

Notebook: Safety
Loop detection, budget limits, HITL, logging
First load ~30-60s · Saves automatically
Open Notebook

Quiz

Test your understanding -- 10 questions, 70% to pass.

Take Quiz