Sefism AI Agents and MCP Cheat Sheet
The revision companion to Sefism's AI agents and MCP roadmap: ten chapters on the agent loop, tool calling, structured output, memory, multi-agent patterns, frameworks, building MCP servers, evals, guardrails and shipping. It comes in Python and TypeScript editions with working snippets in each. It suits developers who already call model APIs and want to revise a concept quickly, copy a working shape or catch the classic mistake before users do.
10
Sefism · Oct 2026
74 per edition
Sefism · Oct 2026
2 (Python, TypeScript)
Sefism · Oct 2026
10
Sefism · Oct 2026
54 plus every concept
Sefism · Oct 2026
Cheat sheet
AI & Machine Learning
Sefism
Reference
Intermediate
Free
What this cheat sheet is
The AI agents and MCP cheat sheet is the revision companion to Sefism's AI agents and MCP roadmap. It is for developers who can already call a model API and want to build agents that hold up in real use, and it covers tool calling, structured output, memory, planning, frameworks, MCP servers, evals and guardrails in short entries.
Use it to revise an idea in a line or two, copy a working shape and spot the classic mistake before it reaches users. Every concept says what it is and why it matters, and many include a snippet or the pitfall people hit.
Two language editions
The sheet follows the roadmap's language choice:
- Python (the default): Pydantic validation, LangGraph, the OpenAI Agents SDK, the Claude Agent SDK and the MCP Python SDK. Every snippet is Python.
- TypeScript: Zod validation, LangGraph.js, the OpenAI Agents SDK, the Claude Agent SDK and the MCP TypeScript SDK. Every snippet is TypeScript.
Both editions have the same ten chapters and 74 concepts; only the validation entry and the code change.
Chapter by chapter
1. How agents work (6 concepts)
The agent loop (with a snippet), workflow versus agent, the augmented LLM, the ReAct pattern, ground truth from the environment and when not to use an agent.
2. Tool calling from scratch (8 concepts)
Tool definitions, the tool call and tool result messages, provider differences, tool choice, parallel tool calls, tool errors the model can act on, writing tool descriptions and keeping tool results small. Shown with one provider API and no framework.
3. Structured output and validation (7 concepts in each edition)
JSON Schema for model output, strict mode, Pydantic models or Zod schemas, validate-then-retry with the error, nullable fields instead of invented values, and enums, ranges and patterns.
4. Memory and state (7 concepts)
Short-term memory, context engineering, compaction and summarisation, long-term memory, memory stores, explicit agent state, and checkpoints and threads.
5. Planning and multi-agent patterns (8 concepts)
Prompt chaining, routing, parallelisation, orchestrator and workers, evaluator and optimiser, plan and execute, handoffs, and when multiple agents are worth the cost.
6. Agent frameworks (7 concepts)
Choosing a framework, the LangGraph StateGraph, interrupts for human approval, the OpenAI Agents SDK, the Claude Agent SDK, other frameworks, and keeping frameworks thin. The core API of each framework comes with a snippet.
7. Building and publishing MCP servers (8 concepts)
MCP hosts, clients and servers, tools, resources and prompts, stdio and Streamable HTTP, the stateless revision of the specification the sheet is written against, a server with the official SDK, the MCP Inspector, authorisation for remote servers and publishing to the MCP Registry.
8. Evals and testing agents (8 concepts)
Tasks, trials and eval sets, code, model and human graders, trajectory versus outcome evals, tool selection evals, pass@k and pass^k, LLM as judge, fake tools and sandboxes for tests, and evals in CI.
9. Guardrails, cost and safety (8 concepts)
Prompt injection, the lethal trifecta, least privilege for tools, human approval before risky actions, sandboxing code and commands, step, time and cost limits (with a snippet), the cost of an agent run, and input and output guardrails.
10. Observability and shipping (8 concepts)
Traces and spans for agents, the OpenTelemetry GenAI conventions, durable execution, retries and idempotent tools, streaming progress, model routing and fallbacks, deploying agents as background jobs, and turning production traces into evals.
Each chapter lists up to three library resources to go deeper with, such as Building Effective Agents, Writing Effective Tools for AI Agents, LangGraph Documentation, Model Context Protocol Documentation and promptfoo.
Rules of thumb and glossary
Ten rules of thumb end the sheet. Among them: write the agent loop by hand once before touching any framework; if a workflow can do the job, ship the workflow; when the agent picks the wrong tool, fix the tool's name and description before the prompt; validate every tool argument in code even with strict mode on; treat every web page, email, file and tool result as possibly hostile; turn every production failure into an eval case before you fix it; and check the date and version on any agent tutorial, because SDKs and the MCP specification change several times a year.
There is also a glossary of 54 short terms, and every concept joins it automatically.
How to use it with the roadmap
- After each stage, read the chapter and check you could build each concept from memory. The roadmap's topics link straight to the concepts that cover them.
- While building, keep chapters 2, 3 and 9 open. Most agent bugs come from vague tool descriptions, unvalidated arguments and missing limits.
- Before a technical conversation about agents, reread the patterns, evals and guardrails chapters. Being able to explain when not to use an agent, and how you know yours works, carries more weight than naming frameworks.
Where it sits next to the other AI sheets
Sefism has two standalone sheets that overlap with parts of this one. The LLM APIs cheat sheet is a compact reference to request shapes across providers. The Model Context Protocol cheat sheet covers protocol messages and host configuration. This sheet is about designing, building, testing and shipping agents, and uses those topics only where an agent needs them.
How it works on Sefism
Everything on Sefism is free to learn from. The public page shows all ten chapters with their introductions and opens the first two in full. Keeping the sheet uses credits and opens every chapter in the member area; new members get starting credits when they join. Adding the AI agents and MCP roadmap to your dashboard (your first roadmap is free) brings this sheet with it.
Related on Sefism
- Should I learn an agent framework or build agents from scratch?
- Which AI topics are worth learning: agents, RAG, MCP or LLMs?
- Prompt Injection Red-Team Harness for Tool-Using AI Agents, a project built from chapters 8 and 9.
- The AI engineering cheat sheet for prompting, retrieval and the ground underneath agents.
FAQ
What is the difference between an agent and a workflow? A workflow follows a path you wrote down; an agent decides its next step from what the environment returns. The sheet's first chapter covers both and when to prefer the simpler one.
Does it cover MCP? Yes, from the server side: roles, primitives, transports, the SDKs, the Inspector, authorisation and the registry.
Which frameworks does it cover? LangGraph, the OpenAI Agents SDK and the Claude Agent SDK in depth, with a short entry on others.
Is it up to date? It is written against the versions the roadmap uses as of 2026, and its own last rule is to check the date on anything agent-related.
Ready to start?
Opens on Sefism in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.