Claude API vs Claude Code vs Agent SDK vs MCP vs Managed Agents

📚 Exam guide v1.1 (exams from 7 Dec 2026)🔄 Checked against official sources: 24 Nov 2026⏱️ 11 min read🎯 D1 Architecture and Runtime Selection · D8 Capability Mechanism Selection

👋 In plain words: Anthropic gives developers several ways to use Claude. Some only send a message and get a reply. Others run a whole agent for you, with files and tools. This lesson lays them side by side, then shows you how to pick the right one for a job, one decision at a time.

Advertisement

“Should we use the API, Claude Code or the Agent SDK?” is the first question on every Claude project, and the exam asks it in many forms. In this lesson you will meet the six building blocks of the Claude developer platform, run small Python examples of two of them, and follow a five-question decision path that picks the right one for any requirement.

📖 What You’ll Learn: You will be able to explain what the Messages API, Tool Runner, Claude Agent SDK, Managed Agents, Claude Code and MCP each do, who runs the agent loop in each, and which one fits a given requirement.

🔑 Key terms

  • Agent loop (harness): the code that sends a request, runs any tools Claude asks for, sends the results back and repeats until Claude is done.
  • Deployment: the machine or container where that loop and its tools run.
  • Surface: a place where you use Claude Code: the terminal (CLI), the desktop app, an IDE, the web or mobile.
  • MCP (Model Context Protocol): an open standard for connecting Claude to tools and data through MCP servers.
  • Skill: a folder of instructions, scripts and files that Claude loads only when a task needs it.

💡 Think of it like this

Think of renting transport. The Messages API is renting an engine: you build the car. The Tool Runner gives you the engine with a gearbox. The Agent SDK is a complete car you drive on your own roads. Managed Agents is a taxi service: Anthropic drives and owns the garage. Claude Code is the car with a driver who is very good at code. MCP is the standard fuel nozzle that fits every one of them.

🪜 Step 1: Meet the six building blocks

Building block What you write Who runs the agent loop Where tools run Typical use
Messages API (POST /v1/messages) Every request, and your own loop if you need one You Your code Classification, extraction, summaries, chat, workflows
Tool Runner (in the anthropic SDK, beta) Only the tool functions The SDK, inside your app Your code Agents over your own tools without writing the loop
Claude Agent SDK (claude-agent-sdk) A prompt and options The SDK: Claude Code’s harness as a library Your machine or server Coding and file agents with built-in Read, Write, Edit, Bash, Grep and Web tools
Claude Managed Agents (beta) An agent config and your tool results Anthropic A per-session container hosted by Anthropic Long-running or scheduled agents without hosting anything
Claude Code Prompts, CLAUDE.md, settings, Skills, hooks Claude Code Your machine, or a cloud environment for web sessions Writing, reviewing and fixing code; CI automation
MCP An MCP server (tools, resources, prompts) Not a runtime: a protocol The MCP server Sharing one integration (Jira, a DB, a test system) with every client

Two points from Anthropic’s own guidance are worth memorising:

  • Tool Runner is not the Agent SDK. The Tool Runner loops over tools you define and has no built-in file or shell tools. The Agent SDK is the full Claude Code harness, with built-in tools, hooks, subagents and permissions.
  • Both the Tool Runner and the Agent SDK are harness only: you still host them. Managed Agents is the option where Anthropic hosts both the loop and the sandbox.
Advertisement

🪜 Step 2: Call the Messages API (the foundation)

Everything else is built on one endpoint. You send a list of messages, Claude sends back content blocks. Here is the smallest useful call. Lesson 4 explains every line and sets up your API key.

📄 ask.py

import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY from the environment

response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "In one sentence, what is a flaky test?"}],
)
print(response.content[0].text)
print("stop_reason:", response.stop_reason)

⌨️ Terminal

python ask.py

🖥️ Output (sample run)

A flaky test is a test that sometimes passes and sometimes fails on the same code, usually because of timing, shared state or an unstable environment.
stop_reason: end_turn
  • The API is stateless: it remembers nothing between calls. If you want a conversation, you send the history every time.
  • There is no loop here. If Claude asked for a tool, your code would have to run it and call again. That is the work the higher-level options take off your hands.

🪜 Step 3: See MCP in action

MCP does not replace any of the options above. It is how you plug your systems into them. The script below builds a tiny MCP server with one QA tool and connects to it in-process, the way Claude Code or the Agent SDK would connect over stdio or HTTP.

📄 qa_mcp.py

import asyncio

from mcp import Client
from mcp.server.mcpserver import MCPServer

server = MCPServer("qa-tools")


@server.tool()
def count_failures(log: str) -> int:
    """Count the lines in a pytest log that contain FAILED."""
    return sum("FAILED" in line for line in log.splitlines())


async def main():
    async with Client(server) as client:          # connect in-process (great for tests)
        listed = await client.list_tools()
        print("tools:", [t.name for t in listed.tools])
        result = await client.call_tool("count_failures", {"log": "test_a PASSED\ntest_b FAILED\ntest_c FAILED"})
        print("result:", result.structured_content)


asyncio.run(main())

⌨️ Terminal

python qa_mcp.py

🖥️ Output

tools: ['count_failures']
result: {'result': 2}
  • @server.tool() turns a normal Python function into an MCP tool. The type hints become the input schema and the docstring becomes the description Claude reads.
  • The same server could be used by Claude Code, Claude Desktop, the Agent SDK or your own API app, without changing it. That reuse is the main reason to choose MCP. Module 7 builds full servers.
Advertisement

🪜 Step 4: Know what the Agent SDK adds

The Agent SDK runs Claude Code’s agent loop inside your Python program. You give it a task and options. It reads files, runs commands and edits code with its built-in tools, under the permissions you allow.

📄 agent_sdk_preview.py

import asyncio

from claude_agent_sdk import ClaudeAgentOptions, query


async def main():
    options = ClaudeAgentOptions(
        allowed_tools=["Read", "Grep"],       # read-only: it can look, not change
        permission_mode="default",
    )
    async for message in query(prompt="Find every test marked @pytest.mark.skip in this repo", options=options):
        print(message)


asyncio.run(main())

We do not run this here: it is a preview. Lesson 33 builds and runs a full Agent SDK agent with custom tools and hooks. For now, notice the difference from Step 2: there is no messages.create, no loop and no tool code. The SDK owns all of it.

🪜 Step 5: Place Claude Code and Managed Agents

  • Claude Code is Anthropic’s agentic coding tool. You use it in the terminal, the desktop app, IDEs (VS Code and JetBrains), on the web and on mobile. Teams configure it with CLAUDE.md, settings.json, permission modes, Skills, plugins and hooks, and run it headless in CI. Module 9 covers it.
  • Claude Managed Agents stores an agent as a versioned object (model, system prompt, tools). Each session gets its own container where bash, file operations and code run. You stream events and send tool results back. It suits long-running, scheduled or file-heavy agents when you do not want to host the loop. It is in beta and bills session runtime on top of tokens.
⚠️ Watch out: Managed Agents is not available on every cloud platform. For agents on Amazon Bedrock, Google Vertex AI or Microsoft Foundry, use the Messages API with tool use or the Agent SDK instead. Always check platform availability before choosing.

🪜 Step 6: Pick the right option with five questions

Walk through these questions in order and stop at the first “yes”.

  1. Is it one request and one answer? (classify a bug report, summarise a log, extract fields) → Messages API. Add Message Batches if it is a large offline job.
  2. Do you need steps that your code controls? (generate test cases, then validate them, then file them) → Messages API + tool use as a workflow.
  3. Must Claude choose its own next step, over tools you own, inside your app? → Tool Runner or a manual loop on the Messages API.
  4. Does the agent need to read and edit files and run commands, on your infrastructure? → Claude Agent SDK, or Claude Code if a developer drives it interactively or CI runs it headless.
  5. Should Anthropic host the loop and a sandbox, possibly on a schedule? → Claude Managed Agents.

Across all five: if several clients must share the same integration, expose it as an MCP server. If the knowledge is a repeatable procedure rather than a live system, package it as a Skill.

🌍 Real-world example: Choosing for a QA team

Ravi’s team has four requests. (a) Tag 20,000 old bug reports by component: Message Batches, because it is one call per report and not urgent. (b) A Slack bot that answers “why did last night’s run fail?” from Jenkins logs: Messages API + tool use, with a get_build_log tool. (c) Fix broken Playwright locators across the repo: Claude Code, since a developer reviews every change. (d) Every night, triage new failures and open tickets: an Agent SDK job in CI, or Managed Agents with a scheduled deployment if they do not want to host it. Jira access goes into one MCP server shared by (b), (c) and (d).

🎯 Exam focus: Expect scenarios that list business requirements, error tolerance and audit needs, then ask for the architecture or runtime. Prefer the simplest option that meets the need. Choose an agent only when the task is open-ended, and add deterministic controls (hooks, approvals) when actions are risky or must be audited.
Advertisement

🧪 Practice Questions

Question 1. A team wants Claude to loop over three internal Python functions (search_tickets, get_ticket, add_comment) inside their existing web app, without writing the tool-call loop themselves. They host everything. What fits best?

  • A. Claude Managed Agents
  • B. The Tool Runner in the Anthropic Python SDK
  • C. Claude Code in headless mode
  • D. An MCP server with no client
Show answer

Answer: B. The Tool Runner drives the loop over tools you define, inside your own app. Managed Agents would move hosting to Anthropic, and Claude Code is aimed at coding tasks with built-in file tools.

Question 2. Which statement about the Claude Agent SDK is correct?

  • A. It is Claude Code’s harness packaged as a library, with built-in tools, hooks, subagents and permissions, and you host it.
  • B. It is another name for the Tool Runner.
  • C. Anthropic hosts its agent loop and sandbox for you.
  • D. It can only call tools exposed through MCP.
Show answer

Answer: A. The Agent SDK ships the Claude Code harness. The Tool Runner is a smaller helper in the regular SDK, and Managed Agents is the Anthropic-hosted option.

Question 3. Three internal tools (a test-results database, Jira and a feature-flag service) must be available to Claude Code users, a support chatbot built on the API, and a nightly Agent SDK job. Which two choices fit? (Choose 2.)

  • A. Expose each system once as an MCP server and connect every client to it.
  • B. Copy the tool code into each project so each client owns its own version.
  • C. Keep credentials in the MCP servers, not in prompts or client code.
  • D. Paste the API documentation of each system into every system prompt.
Show answer

Answer: A and C. MCP is built for one integration shared by many clients, and keeping credentials server-side limits who can see them. Copying code or pasting documentation into prompts multiplies maintenance and exposure.

Question 4. A request asks Claude to summarise each of 50,000 archived test reports. Results are needed by tomorrow, and cost matters most. What should you use?

  • A. Claude Code
  • B. An agent with subagents
  • C. The Message Batches API
  • D. Streaming requests in a loop
Show answer

Answer: C. Each report is one independent request and the job is not urgent, so batch processing fits and is billed at a discount. An agent adds cost without benefit.

📝 Assignment

  1. Task 1: Run qa_mcp.py and add a second tool, slowest_test(log: str) -> str, that returns the name of the slowest test from lines like test_x 2.31s.
    ✅ Done when: list_tools() shows both tools and calling the new one returns the right name.
  2. Task 2: Write down three Claude ideas from your own team and pick an option for each using the five questions in Step 6.
    ✅ Done when: each idea has one option and a one-line reason.
  3. Stretch: Rewrite the four QA requests from the real-world example for a different team (for example DevOps or support) and choose options for them.
    ✅ Done when: at least one uses MCP and one uses Batches.
Advertisement

❓ Frequently Asked Questions

🤔 What is the difference between the Claude API and Claude Code?

The Claude API (Messages API) is an HTTP endpoint you call from code. Claude Code is a ready-made agentic coding tool that uses Claude with built-in file, shell and search tools.

🤔 Is the Claude Agent SDK the same as Claude Code?

It is Claude Code’s agent harness packaged as a Python or TypeScript library, so you can run the same kind of agent from your own programs.

🤔 When should I use MCP instead of normal tool use?

Use normal tool use for tools that live inside one app. Use MCP when several clients should share one integration, or when you want to plug a system into Claude Code or Claude Desktop.

🤔 What are Claude Managed Agents?

A beta Anthropic service where your agent’s configuration is stored and versioned, and each session runs in an Anthropic-hosted container. You do not host the loop or the sandbox.

🏁 Summary

  • Everything is built on the Messages API; the other options decide who writes and hosts the agent loop.
  • The Tool Runner loops over your tools; the Agent SDK adds Claude Code’s built-in tools, hooks and subagents; both are hosted by you.
  • Managed Agents hosts the loop and a per-session sandbox for you, and is in beta.
  • MCP shares one integration with every client; Skills package repeatable procedures.
  • Pick the simplest option that meets the requirement, and only choose an agent when the task is open-ended.
📝 Test yourself: all CCDV-F mock tests (3 full 70-question exams and 8 domain practice tests, with explanations).

Next, continue with Anthropic Python SDK Setup: Your First Claude API Call Step by Step.

🎬 Prefer video? Watch QA, automation and AI testing tutorials on the SQA Tools YouTube channel.

Independent study material by SQA Tools. Not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic. Practice questions are original, not real exam content. Code outputs marked “sample run” come from running the exact code against a local stand-in for the Claude API, so real replies, IDs and token counts will differ. Exam facts checked against Anthropic’s official CCDV-F exam guide v1.1 on 24 Nov 2026.