# Building Agents (the hard parts!)

Rita Kozlov

AI Engineer World's Fair 2025

[Talk page](https://ai.engineer/talks/j_TKDweOsYE-building-agents-hard-parts) · [Video](https://www.youtube.com/watch?v=j_TKDweOsYE)

## Building Agents (the hard parts!)

A useful agent needs more than a model: it needs tools, persistent state and a workflow that can pause for approval without losing its place or repeating an action.

Familiarity with APIs, basic TypeScript and the idea of an LLM calling tools will help; no prior Cloudflare experience is required.

### From a first user to an automated workflow

[0:16](https://www.youtube.com/watch?v=j_TKDweOsYE&t=16s)

What does it take to bring an application from its first line of code to its first user, and then to millions more? Rita Kozlov introduces that problem from her role leading product for Cloudflare’s developer platform, including Workers and Durable Objects. She reports that about 20% of internet traffic passes through Cloudflare, using Uber and food ordering as everyday examples. Alongside CDN, DNS and DDoS services, the platform supplies developer functions, storage, compute and AI inference—the infrastructure between an idea and a running product.

AI adds another application-building shift to the sequence of cloud, mobile and social. The pace matters because developers are moving from experimenting with model responses to building applications around them.

![Timeline marking Cloud at 2000, Mobile at 2007, Social at 2010 and AI at 2022.](https://ai.engineer/api/talk-essay-media/cd2b784f76542db838088fc12d41e98d5b419b1fca29bfd7e6a035c086cfb2c9)

AI follows cloud, mobile and social in the application-building timeline.

Kozlov recalls a year-earlier developer adoption figure of roughly 44% and an attributed Gartner forecast that half of knowledge workers would use AI by 2030. She contrasts those with talk-time claims of more than 76% of developers and over 75% of knowledge workers using AI. The matching research needs a narrower reading: the [2024 Stack Overflow survey](https://survey.stackoverflow.co/2024/ai) counted 76% **using or planning to use** AI tools, with 62% currently using them versus 44% the previous year; it did not measure daily coding frequency. The [Microsoft and LinkedIn Work Trend Index](https://www.microsoft.com/en-us/worklab/work-trend-index/ai-at-work-is-here-now-comes-the-hard-part/) reported 75% usage among surveyed knowledge workers, based on February–March 2024 fieldwork. Those figures establish substantial adoption, but do not establish that the attributed Gartner forecast was surpassed on a comparable measure.

Kozlov suspects adoption has grown further since those reports. She also describes a change in the work developers are discussing: from training toward inference. **OpenAI o1** illustrates her emphasis on post-training and inference; DeepSeek’s training optimizations illustrate her expectation that more effort will move toward inference. These are her framing of the workload shift, rather than measured allocations of industry compute or energy.

### An email draft becomes a campaign

[3:42](https://www.youtube.com/watch?v=j_TKDweOsYE&t=222s)

Asking ChatGPT to draft an email is assistance. Asking an agent to run conference follow-up creates a process:

1. Collect the customers you spoke with that week.
2. Draft the campaign email.
3. Send the draft to you for approval before it goes to customers.
4. Notify you when customers respond.

**The agent must coordinate actions across time, including a point where it cannot proceed without a human.** The draft is only one intermediate result.

Kozlov reports some businesses seeing 20% revenue increases from sales automation agents, 90% faster support response times with AI agents, and roughly 50–75% time savings from agent use. The talk does not identify the studies, baselines or populations behind these figures, and the time-saving claim has no specified task. They motivate the opportunity; they are not capacity-planning assumptions for this campaign workflow.

### Follow the request through four components

[5:14](https://www.youtube.com/watch?v=j_TKDweOsYE&t=314s)

The campaign agent separates into four components. Keeping their responsibilities distinct makes it easier to see what a model call does—and what remains to be built around it.

| Component | Responsibility |
|---|---|
| Client | Let a human interact with the agent |
| AI | Reason about the request and choose what to do next |
| Workflows | Execute and coordinate the chosen actions |
| Tools | Provide access to external capabilities |

Workflows are the reasoning system’s executive branch: choosing an action does not itself execute it, and execution requires access to a tool.

For the CRM example, a voice request first travels over **WebRTC**, then through speech-to-text. A text interaction instead starts in a hosted chat UI. A gateway can provide caching and evaluations, helping track whether iterations improve the overall process, before the request reaches the LLM that produces the plan.

The workflow then records which actions have completed and which should happen next. Its tools might be a browser, an API, an internal service or a vector database containing additional knowledge. Selected actions also require human verification. The complete request path therefore includes both machine execution and the possibility of handing control back to a person.

![CRM agent diagram connecting a user through WebRTC or chat, speech-to-text, cache and evals, an LLM and workflows to a browser, APIs, internal services, a vector database and a human-in-the-loop.](https://ai.engineer/api/talk-essay-media/b4ae518c4eb64ee5e1d46a45126a4169fcfba94aeead7117170d148c67092149)

The CRM agent connects voice and chat inputs to reasoning, workflows and external tools.

### Expose tools through MCP

[7:35](https://www.youtube.com/watch?v=j_TKDweOsYE&t=455s)

Working backward from tools, **Model Context Protocol (MCP)** gives applications a common way to expose capabilities to LLM clients. Kozlov dates Anthropic’s introduction to the preceding November, but highlights another enabling change: models have become much better at tool calling. A standardized interface becomes more useful when the model can reliably choose and invoke the operations behind it. MCP preserves a client-server architecture, allowing conversations between a server and multiple clients.

![Slide titled What is MCP? “Spicy APIs” with three bullets about Anthropic's protocol, API interaction and tool calling, beside an MCP client-server diagram.](https://ai.engineer/api/talk-essay-media/b368dee09b72d041553333b794a993b9fbd1818b4fde563ae7803502652202d1)

MCP connects clients and servers through a transport layer.

The protocol separates several kinds of interaction:

- **Resources:** File contents, database records and other context the server can expose.
- **Prompts:** Reusable instructions that encode knowledge of how to interact with the system, including nuances its author understands best.
- **Tools:** Executable capabilities that connect a request to an action.
- **Sampling:** A server’s request for model generation through a supporting client.

Kozlov describes sampling informally as letting the LLM complete some thinking from shorthand, and says she had not seen it used in a production MCP server while preparing the talk. More precisely, the [sampling specification](https://modelcontextprotocol.io/specification/2025-03-26/client/sampling) defines `sampling/createMessage`: the client supplies model access and retains control over permissions.

The difficult implementation work remains transport, OAuth and memory. Kozlov mentions SSE and WebSockets together, but application WebSockets should be distinguished from standard MCP transport. The [March 2025 transport specification](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports) defines stdio and Streamable HTTP, with optional SSE; Streamable HTTP replaced the earlier HTTP+SSE transport. WebSockets can support the surrounding real-time application without being one of those standard MCP transports.

### Attach state to the agent

[10:14](https://www.youtube.com/watch?v=j_TKDweOsYE&t=614s)

Cloudflare’s [Agents SDK](https://blog.cloudflare.com/build-ai-agents-on-cloudflare/) packages much of that infrastructure. It is distinct from OpenAI’s identically named SDK; Kozlov says the two can work together. The walkthrough uses Cloudflare’s `McpAgent` class for remote MCP hosting. In the historical integration, `McpAgent` handles transport, while `workers-oauth-provider` supplies authorization support: extending the class alone does not configure OAuth.

The stateful foundation is **Durable Objects**, which Kozlov describes as serverless functions with state attached directly to them. Code can retain information without requiring the application developer to separately provision and connect a database. Around that foundation, the SDK provides real-time WebSocket communication, React integration hooks and basic AI chat capabilities. Those pieces connect persistent server behavior to a live client interface.

![Five-item Agents SDK slide listing McpAgent hosting with OAuth and HTTP streaming, Durable Objects state management, WebSocket communication, React hooks and basic AI chat capabilities.](https://ai.engineer/api/talk-essay-media/db326464ef73b1af2576bb601599ed4ab7e352508bc402124e205ee5d699b92d)

Cloudflare's Agents SDK combines remote MCP hosting, state management and chat integration.

### Remember book preferences across interactions

[11:57](https://www.youtube.com/watch?v=j_TKDweOsYE&t=717s)

The first walkthrough is a Goodreads-like recommendation server. Its class extends `McpAgent` and starts with empty state. An `addGenre` tool records a preference: Kozlov likes Patricia Highsmith, so her example adds thrillers. The important result is a persistent preference that later interactions can use.

A separate `getRecommendations` tool and a personalized MCP prompt can then use both preferred genres and previously read books. The following TypeScript captures that state transformation and prompt construction. Adding `thrillers` changes the preference list while preserving the read-book list:

```typescript
type ReadingState = {
  genres: string[];
  readBooks: string[];
};

function addGenre(state: ReadingState, genre: string): ReadingState {
  return {
    ...state,
    genres: [...new Set([...state.genres, genre])],
  };
}

function recommendationPrompt(state: ReadingState): string {
  return [
    `Recommend books for someone who likes: ${state.genres.join(", ") || "any genre"}.`,
    `Previously read books: ${state.readBooks.join(", ") || "none recorded"}.`,
    "Avoid recommending books already read.",
  ].join("\n");
}

const initialState: ReadingState = { genres: [], readBooks: [] };
const updatedState = addGenre(initialState, "thrillers");
const prompt = recommendationPrompt(updatedState);
```

The server must persist `updatedState`; returning a new JavaScript object alone does not make it durable. The prompt requests recommendations but does not itself execute a model call.

Add a genre without changing reading history
A later recommendation can use the saved preference while preserving the existing reading history.
Constructed example: The TypeScript field names, empty-array representation, deduplication behavior and exact prompt wording are teaching details. Thrillers, initially empty state, persisted preferences and use of reading history come from the talk.
Genre passed to addGenre — unchanged: thrillers
Operation: Add thrillers to the genre list, preserve readBooks, and construct the recommendation prompt from the resulting state.
- genres
  - Before: Initial state: []
  - After: Updated state to persist: ["thrillers"]
- readBooks
  - Before: Initial state: []
  - After: Updated state to persist: []
- prompt
  - Before: Initial state: Not present
  - After: Updated state to persist: Recommend books for someone who likes: thrillers.
Previously read books: none recorded.
Avoid recommending books already read.
A later recommendation can use the saved preference while preserving the existing reading history.

As preferences and reading history accumulate, Kozlov expects recommendations to become more personalized. Because memory lives in the standalone MCP server, changing clients need not erase it. That depends on clients reaching the same stored identity; persistence alone does not define how identities are shared across clients.

The infrastructure comparison is between separately assembling storage and using state attached to the agent:

| Separate storage setup | State through `McpAgent` |
|---|---|
| Provision a database | Use built-in persistent state |
| Manage database connections | Access state through the agent |
| Coordinate compute and storage scaling | Rely on the platform’s scaling |

Kozlov also presents reduced infrastructure management, avoiding added database access latency, and execution close to the AI agent as benefits. The walkthrough supplies no latency measurement or placement guarantee.

For deployment, Kozlov points to a blog with a **Deploy to Cloudflare** button. The [remote MCP deployment announcement](https://blog.cloudflare.com/remote-model-context-protocol-servers-mcp/) provides a related historical entry point. Kozlov says an initial MCP server can be running in less than a minute and names Atlassian, Asana, Stripe and Intercom as companies building servers this way. That timing is her reported onboarding estimate.

### Pause card issuance for human approval

[14:27](https://www.youtube.com/watch?v=j_TKDweOsYE&t=867s)

Remembering a genre solves state within a tool interaction. A workflow must preserve state across an entire chain of interactions. A reasoning model may take several minutes; a human may respond after minutes, hours, days or months. The application needs to resume when the delayed task completes, while also handling persistent state, retries, WebSocket connections and horizontal scaling.

The customer example comes from [Knock’s approval workflow](https://blog.cloudflare.com/building-agents-at-knock-agents-sdk/). A user requests a new credit card, and their boss must approve it through email, Slack or an in-app notification. The chat request starts the process; it is not authorization to issue the card.

The setup proceeds in three steps:

1. **Connect the chat.** Import `useAgent` from the Agents React library to connect the client to an agent instance.
2. **Gate the action.** Wrap `issueCard` with `requireHumanInput`, supplied by Knock Agent Toolkit in this historical example. Every invocation of the issuance tool must require human input.
3. **Request approval and defer execution.** Knock sends the approval notifications while the card-provisioning tool call remains paused.

**The approval gate belongs on the executable tool.** The workflow retains a pending call instead of issuing a card and asking a person afterward.

When the approval webhook returns, it must reach the same agent that owns the pending call. The walkthrough extracts the calling user’s ID from the tool call, looks up the agent by name using that ID, and routes the webhook to the existing agent’s Durable Object. Once an approved status arrives, the agent resumes the deferred tool execution, issues the card and tells the user it was approved.

The final part is duplicate prevention. Out-of-sync events must not approve or provision the same card twice. The agent records whether a request has already been processed and updates its approval status, so a later webhook can recognize completed work rather than repeat it. This persisted status is the walkthrough’s duplicate-handling mechanism; it does not by itself establish exactly-once behavior across an external card provider and every possible failure between issuance and recording the result.

### Put the agent where users already work

[18:56](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1136s)

With tools and workflows in place, the remaining choices are the reasoning model and the client. Kozlov leaves model selection and evaluations to other conference sessions, mentioning Logan’s talk about **Gemini**. This walkthrough therefore supplies the execution architecture, not a model-selection recipe.

MCP also creates a distribution option: build the server once and let users reach it through an existing client. Kozlov describes Cursor for developer users, followed by Claude and ChatGPT, as supporting remote MCP at the time of the talk. The architectural benefit is that an agent can become available inside a user’s existing workspace without first requiring a separately built UI; specific availability depends on the client’s support and access conditions.

A custom application remains useful when the workflow needs more control over both client and server. It need not be limited to text: Kozlov describes Cloudflare tooling that bridges WebRTC to WebSocket for voice interaction with an MCP client. Voice changes the input path, while the same server-side tools and coordination still carry out the work.

The finished system brings together a client, AI reasoning, workflows and tools. Kozlov recommends the Agents SDK as a starting point and says developers can get up and running in a few minutes. The campaign and card examples show what those pieces must accomplish together: accept a request, preserve its context, wait when approval is required, and resume the correct action when the response arrives.

## Resources

- [Cloudflare’s original Agents SDK introduction](https://blog.cloudflare.com/build-ai-agents-on-cloudflare/) — Rita Kozlov and colleagues introduce stateful agents, React connections, embedded storage and agent routing.
- [Deploying remote MCP servers on Cloudflare](https://blog.cloudflare.com/remote-model-context-protocol-servers-mcp/) — Historical introduction to Cloudflare’s remote MCP hosting and its transport and authorization components.
- [Knock’s human approval workflow with Cloudflare Agents](https://blog.cloudflare.com/building-agents-at-knock-agents-sdk/) — A virtual-card walkthrough that defers issuance for human approval using Knock notifications and a stateful Cloudflare agent.
- [Stack Overflow’s 2024 AI adoption results](https://survey.stackoverflow.co/2024/ai) — Survey results distinguish current AI tool use from planned adoption in development workflows.
- [Microsoft and LinkedIn’s 2024 Work Trend Index](https://www.microsoft.com/en-us/worklab/work-trend-index/ai-at-work-is-here-now-comes-the-hard-part/) — Research on workplace AI adoption, including the reported 75% usage rate among knowledge workers.
- [MCP transports: March 2025 specification](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports) — Historical specification for stdio, Streamable HTTP, SSE streaming and connection handling.
- [MCP sampling: March 2025 specification](https://modelcontextprotocol.io/specification/2025-03-26/client/sampling) — Explains how servers request model generation through clients while clients retain control over model access and permissions.

## Slides

### Innovation Partner and Platinum Sponsors

[0:10](https://www.youtube.com/watch?v=j_TKDweOsYE&t=10s) [AWS innovation partner logo above six platinum sponsor logos.](https://assets.ai.engineer/sites/aiecode2025/sha256/471fe2490581b1263fad49188870d18b7f1c7a9a0a11c691d55577d8ee1930fc.webp)

INNOVATION PARTNER
aws

PLATINUM SPONSORS
Graphite
Windsurf
MongoDB®
daily™
augment code
WorkOS

### Building Agents (the hard parts!)

Rita Kozlov introduces Cloudflare’s developer platform, including Workers and Durable Objects.

[0:27](https://www.youtube.com/watch?v=j_TKDweOsYE&t=27s) [Title slide introducing Rita Kozlov, Vice President of Product for Cloudflare Developer Platform.](https://assets.ai.engineer/sites/aiecode2025/sha256/2e7c1ddd6086d50b50e18d6bab6cf1d08cdf8ddff74c722699b032a008cb1a59.webp)

Building Agents (the hard parts!)

Rita Kozlov
Vice President of Product for Cloudflare Developer Platform

CLOUDFLARE
1

### Cloudflare’s vision for developers

Cloudflare aims to make development easier from the first line of code through production and millions of users, with building primitives, enterprise-scale solutions and support for AI workloads.

[1:00](https://www.youtube.com/watch?v=j_TKDweOsYE&t=60s) [Cloudflare’s developer vision highlights developer velocity, building primitives, enterprise scale and AI workloads.](https://assets.ai.engineer/sites/aiecode2025/sha256/e48d993078cabfccdb85e010e9f2c5f801fed8e59d27f819fad11e930c522969.webp)

CLOUDFLARE DEVELOPER PLATFORM
CLOUDFLARE

Cloudflare’s vision for developers

To help build a better Internet with a modern cloud platform that accelerates developer velocity and drives better end user experiences.

Remove friction & improve developer velocity
Provide primitives to build on
Enterprise grade solutions and scale
Enable new AI workloads

2

### AI as the next application paradigm shift

Cloudflare places AI in 2022 after cloud, mobile and social, presenting each as a shift in how applications are built.

[1:40](https://www.youtube.com/watch?v=j_TKDweOsYE&t=100s) [Timeline shows cloud in 2000, mobile in 2007, social in 2010 and AI in 2022.](https://assets.ai.engineer/sites/aiecode2025/sha256/a2a5bf7959e73c682cd22287eb6a368285e2d5729d6e099dc1dd085f149a2666.webp)

CLOUDFLARE DEVELOPER PLATFORM
CLOUDFLARE

AI is the next paradigm shift in the way applications are built

Timeline:
Cloud — 2000
Mobile — 2007
Social — 2010
AI — 2022

3

### AI workloads: training

A year earlier, AI workload discussions focused primarily on training. The diagram emphasizes Train with a large dark arrow, while Infer appears in gray.

[3:02](https://www.youtube.com/watch?v=j_TKDweOsYE&t=182s) [A diagram emphasizes training over inference as the earlier focus of AI workloads.](https://assets.ai.engineer/sites/aiecode2025/sha256/e7a311806d4a337b12219b525f935079a6961df3a4c4606e4671499f1966fe6e.webp)

Last year...

CLOUDFLARE

When we say “AI,” what are the workloads involved in making that happen?

Where the focus of AI has been...

Train
Infer

We stated that although the focus of AI had been on training...

CLOUDFLARE
8

### AI workloads: inference

Cloudflare predicted that AI workloads would shift from training toward inference. The speaker says that shift is now unfolding.

[3:16](https://www.youtube.com/watch?v=j_TKDweOsYE&t=196s) [A diagram emphasizes inference as the predicted next focus of AI workloads.](https://assets.ai.engineer/sites/aiecode2025/sha256/c3c795a6d0ec73d41330592f5771977a786e64cb2b508ad75f5db0ac5098a5f3.webp)

Last year...

CLOUDFLARE

When we say “AI,” what are the workloads involved in making that happen?

CLOUDFLARE

Where the focus of AI is going...

Train
Infer

...the focus of AI was going to shift to inference.

9

### From training and inference to automation

The speaker sees automation of end-to-end tasks as the next focus after training and inference, extending AI beyond augmenting people's work.

[3:41](https://www.youtube.com/watch?v=j_TKDweOsYE&t=221s) [Arrows progress from training to inference to automation, described as automating end-to-end tasks.](https://assets.ai.engineer/sites/aiecode2025/sha256/b2d9d04b1152700764953dde96846d861b06872cd570d4820ee4ce1e8ec1826e.webp)

Train → Infer → Automate

The next focus of AI is going to be on automating end-to-end tasks.

CLOUDFLARE
12

### Augmentation to automation

A generative AI assistant drafts one email; the agentic example follows up with a customer list, seeks sign-off before sending, and flags replies.

[4:08](https://www.youtube.com/watch?v=j_TKDweOsYE&t=248s) [Side-by-side examples compare drafting an email with an agentic customer follow-up campaign that includes review before sending.](https://assets.ai.engineer/sites/aiecode2025/sha256/20c3b7f471eeca71d8aaef882ed75f19e5d5c4539c3fd85fab58f69cfab6faaa.webp)

Augmentation → Automation

Augmentation (Generative AI)

Help me draft an email to a customer I met at a conference, reminding them of the benefits of Cloudflare

I'll help you draft a professional follow-up email.

Cloudflare Email
Click to open

Here’s a professional follow-up email that highlights Cloudflare's key benefits while maintaining a friendly tone. Would you like me to customize any specific parts based on your conversation at the conference?

Just let me know what you'd like to adjust!

Automation (Agentic AI)

Good Morning, Rita

Run a campaign following up with everyone I met at the conference last week:
get a list of customers
draft up an email
send to me for sign off
fire off
ping me when the customer responds

CLOUDFLARE
14

### What makes up an agent?

The slide combines clients, AI, workflows and tools: a manager coordinates specialist agents and external systems, while user feedback feeds an iterative improvement loop.

[5:12](https://www.youtube.com/watch?v=j_TKDweOsYE&t=312s) [Diagram presents clients, AI, workflows and tools, with multiple agents and a user feedback loop. A camera overlay obscures part of the bottom label.](https://assets.ai.engineer/sites/aiecode2025/sha256/d6e105bd64bf7e15981257060adcd82c024217321b23812e41070326a89b2948.webp)

What makes up an agent?

Agents = Clients + AI + Workflows + Tools

Manager Agent
Analyst Agent
Checker Agent
Planner Agent
External Systems

User Feedback
No
Yes
User Satisfaction

[illegible]ons
Interpretation & Reasoning
Workflow Generation
Workflow Execution
Iterative Improvement
Output/Outcome

CLOUDFLARE
17

### Example: CRM agent

A CRM agent accepts voice through WebRTC and speech-to-text, or a query through chat. Both paths pass through caching and evaluation before an LLM plans the work and workflows dispatch actions and maintain state.

[6:05](https://www.youtube.com/watch?v=j_TKDweOsYE&t=365s) [CRM agent flow connects a user through voice or chat to speech recognition, cache and evaluations, an LLM and workflows.](https://assets.ai.engineer/sites/aiecode2025/sha256/a25c4a67480424cdd83091ea8f784867bf4260830dd39230146d348bfafd5f7d.webp)

HOW DO AGENTIC AI SYSTEMS WORK?
CLOUDFLARE

Example: CRM agent

User
#1 connect to send query

WebRTC
#2 translate
Speech to text model
#3 cache and evaluate

Chat (UI)
#3 cache and evaluate
Cache & evals
#4 send query to LLM
LLM
#5 route
Workflows
#6 dispatch action & maintain state

21

### Example: CRM agent and tools

The CRM agent routes voice or chat through evaluation and an LLM to workflows. Workflows track actions, connect to tools, and can ask a human to confirm the next action.

[7:09](https://www.youtube.com/watch?v=j_TKDweOsYE&t=429s) [Expanded CRM agent diagram connects workflows to a browser, APIs, internal services, a vector database and a human reviewer.](https://assets.ai.engineer/sites/aiecode2025/sha256/2ee9c667cf5e1bfdd1e96c72edeca9aee2169ae2b01b6aee7daa99d51c3d18e3.webp)

HOW DO AGENTIC AI SYSTEMS WORK?
CLOUDFLARE

Example: CRM agent

User
#1 connect to send query

WebRTC
#2 translate
Speech to text model
#3 cache and evaluate

Chat (UI)
#3 cache and evaluate
Cache & evals
#4 send query to LLM
LLM
#5 route
Workflows
#6 dispatch action & maintain state

Client
AI
Tools

a. navigate to a website
Web browser
b. connect to API
APIs
c. access internal service
Internal services
d. query
Vector database
e. confirm next action
Human-in-the-loop

23

### Introducing the Model Context Protocol

Anthropic’s MCP announcement sparked discussion about exposing APIs to LLMs so people can interact with them in natural language.

[7:44](https://www.youtube.com/watch?v=j_TKDweOsYE&t=464s) [Slide displays an announcement titled Introducing the Model Context Protocol, dated November 25, 2024.](https://assets.ai.engineer/sites/aiecode2025/sha256/f9bdff42b1e6cdc54e282a3da8b40c3921120a2cee5dd95309dcb06cc8d86c37.webp)

Tools (MCP)

Announcements
Introducing the Model Context Protocol
Nov 25, 2024 • 3 min read

CLOUDFLARE
26

### What is MCP?

MCP connects clients to servers through a transport layer, giving AI a way to interact with APIs. The speaker calls improved LLM tool calling the missed headline.

[8:06](https://www.youtube.com/watch?v=j_TKDweOsYE&t=486s) [MCP connects AI to APIs; a diagram shows clients communicating with servers through a transport layer.](https://assets.ai.engineer/sites/aiecode2025/sha256/f99ef3c1bfa0a4d843f88d35b4eb2f10373d48e8414ea55edb8fa31e8d5e72e9.webp)

Tools (MCP)
CLOUDFLARE

What is MCP? “Spicy APIs” 🌶️

• Protocol release by Anthropic (there’s a whole track about this)
• Way of letting AI interact with your APIs
• Missed headline: LLMs are now really good tool calling

Diagram:
Host: MCP Client ↔ Transport Layer ↔ MCP Server (Server Process)
Host: MCP Client ↔ Transport Layer ↔ MCP Server (Server Process)

### MCP core concepts

MCP servers expose resources and reusable prompts, connect LLMs to tools, and request completions through sampling. The speaker had not seen sampling used in production on an MCP server.

[8:48](https://www.youtube.com/watch?v=j_TKDweOsYE&t=528s) [Table describing resources, prompts, tooling, and sampling, with examples.](https://assets.ai.engineer/sites/aiecode2025/sha256/13bd64d8818e9096d3b49b3cd76f14ff2864746f1e51aac2a2755bba83bf38b6.webp)

Tools (MCP)
CLOUDFLARE

Core concepts

Resources
Allow servers to expose data and content that can be read by clients and used as context for LLM interactions.
File contents, Database records, API responses, Live system data

Prompts
Prompts enable servers to define reusable prompt templates and workflows that clients can easily surface to users and LLMs.
“Analyze these system logs and the code file for any issues”

Tooling
Allow LLMs to interact with external systems, perform computations, and take actions in the real world
Browser, API, internal system

Sampling
Allows servers to request LLM completions through the client, enabling sophisticated agentic behaviors while maintaining security and privacy.
Agentic workflows, context management, error handling

### What are the hard parts?

The speaker identifies transport over SSE and WebSockets, OAuth, and memory as the trickiest parts of building MCP.

[9:48](https://www.youtube.com/watch?v=j_TKDweOsYE&t=588s) [The slide lists transport, OAuth, and memory as hard parts.](https://assets.ai.engineer/sites/aiecode2025/sha256/4e492a7941c18bfd2819164d6bd8a6013a50181ed9c381813cfccf87d99fc5d8.webp)

What are the hard parts?

1. Transport
2. OAuth
3. Memory

Tools (MCP)
CLOUDFLARE

### Cheat code

After naming transport, OAuth, and memory as MCP’s hard parts, the speaker teases a “cheat code” before revealing it.

[10:03](https://www.youtube.com/watch?v=j_TKDweOsYE&t=603s) [A slide says “Cheat code” beside a shushing face.](https://assets.ai.engineer/sites/aiecode2025/sha256/2b933a34b9e947520bea7f746599f9903129dc353eeecab17130fad55372a773.webp)

Cheat code 🤫

CLOUDFLARE

### Install Agents

Install Cloudflare’s Agents SDK with npm to get agent-building functionality out of the box.

[10:14](https://www.youtube.com/watch?v=j_TKDweOsYE&t=614s) [The slide displays the command npm i agents.](https://assets.ai.engineer/sites/aiecode2025/sha256/21fa85c2b074d5b4e2985e2ba9750406eab747c4fff5755f3bcd1a5fb08d306c.webp)

npm i agents

CLOUDFLARE

### Deploying MCP Servers on Cloudflare

A book-preference MCP server starts with empty state. Its addGenre tool appends a genre with setState, which the example says persists it for future interactions.

[11:49](https://www.youtube.com/watch?v=j_TKDweOsYE&t=709s) [Code example defines an MCP agent with book preferences and a tool that updates its state.](https://assets.ai.engineer/sites/aiecode2025/sha256/4d667484ca53d352e35408ae071bc2131e7cb9a0a8945a5469d65f852656c5e0.webp)

Deploying MCP Servers on Cloudflare
Tools (MCP)
CLOUDFLARE

export class MyMCP extends McpAgent<Env, BookPreferences, Props> {
  initialState = {
    favoriteGenres: [],
    booksRead: [],
    userName: ""
  };

  async init() {
    this.server.tool("addGenre", "Add a favorite genre", schema, async ({ genre }) => {
      // This automatically persists!
      this.setState({
        ...this.state,
        favoriteGenres: [...this.state.favoriteGenres, genre]
      });

      return { content: [{ type: "text", text: `Added ${genre}!` }] };
    });
  }
}

Interface text: AIE; aws; World's Fair

[12:28](https://www.youtube.com/watch?v=j_TKDweOsYE&t=748s) [Code defines an MCP agent with persistent book preferences and an addGenre tool.](https://assets.ai.engineer/sites/aiecode2025/sha256/a8d723ecb6f77e81ecdddfdeeb8c3ce2f79d06d9a7f4a5005bc397aa06cf89d8.webp)

Deploying MCP Servers on Cloudflare
Tools (MCP)
CLOUDFLARE

export class MyMCP extends McpAgent<Env, BookPreferences, Props> {
  initialState = {
    favoriteGenres: [],
    booksRead: [],
    userName: ""
  };

  async init() {
    this.server.tool("addGenre", "Add a favorite genre", schema, async ({ genre }) => {
      // This automatically persists!
      this.setState({
        ...this.state,
        favoriteGenres: [...this.state.favoriteGenres, genre]
      });

      return { content: [{ type: "text", text: `Added ${genre}!` }] };
    });
  }
}

## Full transcript

[0:00](https://www.youtube.com/watch?v=j_TKDweOsYE&t=0s) [on hold music] Hello, everyone.

[0:16](https://www.youtube.com/watch?v=j_TKDweOsYE&t=16s) Uh, I'm Rita. I'm the VP of Product for, um, Cloudflare's developer platform, so Workers and Durable Objects. Thank you for the shout-outs. Um, I always like to start by talking a little bit about, um, Cloudflare's mission, and especially our mission for developers.

[0:33](https://www.youtube.com/watch?v=j_TKDweOsYE&t=33s) And I saw a couple hands here in terms of number of people that used Cloudflare Workers before. Um, but actually, if you're sitting in this room, whether you've signed up for Cloudflare directly or not, um, you've a hundred percent used Cloudflare before because about twenty percent of internet traffic flows through Cloudflare.

[0:53](https://www.youtube.com/watch?v=j_TKDweOsYE&t=53s) Um, so if you've ordered an Uber recently, um, or, uh, or maybe even ordered some food, um, you've absolutely used Cloudflare. Um, but aside from Cloudflare's CDN, DNS, DDoS services, we do also offer, um, services to developers, including functions that you're able to run, storage, compute, AI inference, um, spanning many, many things.

[1:15](https://www.youtube.com/watch?v=j_TKDweOsYE&t=75s) And our, uh, our vision for developers is to make it as easy as possible for someone to bring their idea to life from the moment that they write their first line of code to deploying it to production, to making it live for the first user, to the millions that come after that.

[1:33](https://www.youtube.com/watch?v=j_TKDweOsYE&t=93s) Um, so that, that's what I do. It makes my job really exciting to wake up in the morning and see what developers are going to build.

[1:42](https://www.youtube.com/watch?v=j_TKDweOsYE&t=102s) Um, now, if, if you're in this room, I, I don't need to tell you that AI is as big a technological paradigm shift as, um, uh, as cloud, mobile, or social before it.

[1:54](https://www.youtube.com/watch?v=j_TKDweOsYE&t=114s) Um, I think everyone here is already convinced of that. But it is interesting to see just how quickly things are moving because I think that it's a good reflection of how quickly things are about to move next.

[2:06](https://www.youtube.com/watch?v=j_TKDweOsYE&t=126s) So, um, I realize that I gave a talk about a year ago, um, where I was pulling up some s- some stats and looking at where we were at.

[2:14](https://www.youtube.com/watch?v=j_TKDweOsYE&t=134s) And so a year ago, um, about forty-four percent of developers were using AI as a part of their day-to-day, um, to, to help them write code. Uh, and, um, Gartner was predicting that about, uh, by, by twenty-thirty, about fifty percent of knowledge workers would be using AI to augment their work.

[2:34](https://www.youtube.com/watch?v=j_TKDweOsYE&t=154s) Um, and the, these numbers seem ex- really, really low now, right? Like, um, today, um, over seventy-five percent of knowledge workers use AI to augment their work. Um, so this is already surpassing the twenty-thirty estimates that were given, and more than seventy-six percent of developers use AI as a part of their development process.

[2:55](https://www.youtube.com/watch?v=j_TKDweOsYE&t=175s) And, um, I, I, uh, I think that honestly, from the time that this report was pulled to now, that number has grown even more. Um, the other interesting thing was that about a year ago, when we were talking about, um, when we were talking about workloads, we were primarily talking about workloads in AI that involved training.

[3:15](https://www.youtube.com/watch?v=j_TKDweOsYE&t=195s) Um, and we predicted then that workloads were going to shift towards inference, and again, we've been seeing that unfold. So we, we saw that with OpenAI's o1 model, which is shifting more and more from training to post-training and inference.

[3:32](https://www.youtube.com/watch?v=j_TKDweOsYE&t=212s) We saw a similar thing actually with DeepSeek, who optimized training so much that more and more energy is spent on the inference part of it. But let's talk about what's next.

[3:42](https://www.youtube.com/watch?v=j_TKDweOsYE&t=222s) So, um, after training and inference comes, I think, actual automation, and, uh, I know there's been a lot of talk about agents the past couple days, but this is the reason that this is so exciting, is that we have the opportunity to not just, uh, to not just augment people's work, right?

[4:00](https://www.youtube.com/watch?v=j_TKDweOsYE&t=240s) You've been able for some time now to go somewhere like ChatGPT and ask it like, "Hey, help me draft up an email." But what's really, really powerful is to be able to go and say, "Hey, I have a campaign I want to run.

[4:13](https://www.youtube.com/watch?v=j_TKDweOsYE&t=253s) Grab me a full list of the customers that I talked to this week at the conference. Uh, then draft me up the email. Then actually, I do wanna review it before it goes to a customer, so do send it to me for approval, and then ping me when the customer responds."

[4:28](https://www.youtube.com/watch?v=j_TKDweOsYE&t=268s) Um, and, and so these are exactly the types of agentic workflows that I think we're going to see more and more that are really going to unlock that next level of productivity.

[4:39](https://www.youtube.com/watch?v=j_TKDweOsYE&t=279s) And we're already starting to see these agents out in the wild and really meaningfully impacting businesses. Um, so some businesses are seeing, uh, twenty percent revenue increases already as a part of starting to adopt agents as a part of sales automation.

[4:55](https://www.youtube.com/watch?v=j_TKDweOsYE&t=295s) Um, some businesses are seeing ninety percent faster response times to support when using AI agents. Um, and in general, uh, people are seeing about fifty to seventy-five percent time savings when using agents.

[5:06](https://www.youtube.com/watch?v=j_TKDweOsYE&t=306s) So agents are going to be even more meaningful, but are already reshaping the way that we work.

[5:14](https://www.youtube.com/watch?v=j_TKDweOsYE&t=314s) Um, okay, but, uh, you want to build an agent. Where do you start? What, what all goes into building an, an agent?

[5:22](https://www.youtube.com/watch?v=j_TKDweOsYE&t=322s) The way that I like to think about agents really comes down to these four components. So first, you have the client. You have the interface that the agent is going to be interacted through with a human, right?

[5:34](https://www.youtube.com/watch?v=j_TKDweOsYE&t=334s) Um, then you have the AI, the reasoning piece, the, the thinking part that's going to come up with the logic of, what are we about to execute? What are we gonna do next?

[5:44](https://www.youtube.com/watch?v=j_TKDweOsYE&t=344s) Now, the thinking part needs now its executive branch, right? It needs a way to go and execute on the actions that it decided that it was going to take.

[5:54](https://www.youtube.com/watch?v=j_TKDweOsYE&t=354s) And then, so that's the workflows, and then workflows also need access to tools. So it's not just enough to be like, "Okay, I'm gonna go and do this." They need access to the tools to actually take the actions.

[6:06](https://www.youtube.com/watch?v=j_TKDweOsYE&t=366s) So let's run through a quick example of what would it look like, that CRM agent that I was just showing, if I were to go and build something that helps me contact people that I talk to, what would that look like?

[6:19](https://www.youtube.com/watch?v=j_TKDweOsYE&t=379s) So the first part is if I wanted to have something that works over voice where I can be like, "Hey, do this for me," um, you need something that connects over WebRTC.

[6:27](https://www.youtube.com/watch?v=j_TKDweOsYE&t=387s) Um, you then need a speech-to-text model to translate what you said, um, back,

[6:34](https://www.youtube.com/watch?v=j_TKDweOsYE&t=394s) um, back into text. Um, alternatively, we're all familiar with chat UIs, right? So you need somewhere to host that. Um, then ideally, uh, you're using, um, some sort of gateway to do caching and to run your evals to make sure that as you're iterating on the overall process, that things are getting better and better.

[6:52](https://www.youtube.com/watch?v=j_TKDweOsYE&t=412s) Um, and then you need to send that response to an LLM that's going to do the thinking part and come up with the rest of the plan.

[7:00](https://www.youtube.com/watch?v=j_TKDweOsYE&t=420s) From there, you need a workflow agent. Um, so that's what's going to keep track of what actions have been executed and what actions need to take place next. And then, again, you need to connect to, uh, your tools.

[7:13](https://www.youtube.com/watch?v=j_TKDweOsYE&t=433s) It can be a web browser, it can be an API, it can be an internal service that you need to connect to, or it can be a vector database if you need to grab additional knowledge that, that, uh, that, that, um, agent needs, uh, access to.

[7:27](https://www.youtube.com/watch?v=j_TKDweOsYE&t=447s) Sometimes you're also going to need a human in the loop to verify some of these actions that you're taking.

[7:35](https://www.youtube.com/watch?v=j_TKDweOsYE&t=455s) So how do you build an agent? I'm actually going to go backwards here and start with the tools part. Um, and most recently, uh, there's been a lot of talk about MCP.

[7:47](https://www.youtube.com/watch?v=j_TKDweOsYE&t=467s) So the, the amazing thing is that Anthropic introduced this new standard back in November, and I think the, the really interesting thing about it is that it really got people thinking about, okay, how do we expose, uh, how do we expose APIs to LLMs in a way that allows us humans to talk to LLMs over natural language?

[8:09](https://www.youtube.com/watch?v=j_TKDweOsYE&t=489s) Um, but, but I think that the, uh, the real missed headlines of MCPs was actually that LLMs became really, really good at tool calling. This, this wasn't so much the case a few years ago if you tried to play around with tool calling, but, but now they are.

[8:24](https://www.youtube.com/watch?v=j_TKDweOsYE&t=504s) And so we have this new standard for how you can actually write out your code in a way that's going to be, um, incredibly easy to consume by any, uh, by any MCP client.

[8:37](https://www.youtube.com/watch?v=j_TKDweOsYE&t=517s) And so the, again, really cool thing about MCP is that it does respect a traditional client-server architecture where you're able to have that conversation back and forth, and importantly, have more than one client that connects to the MCP server.

[8:51](https://www.youtube.com/watch?v=j_TKDweOsYE&t=531s) Um, so these are some of the core concepts that go into MCP. MCP servers generally have, uh, resources, prompts, tooling, and sampling. Um, resources can be anything from file contents and database records.

[9:04](https://www.youtube.com/watch?v=j_TKDweOsYE&t=544s) Um, prompts actually help you define how you want someone else to interact with your agent, because you can actually prompt your agent probably better than anyone else can. If there are any nuances, um, a- about how your system works, you want to build that into it as much as possible.

[9:22](https://www.youtube.com/watch?v=j_TKDweOsYE&t=562s) Um, then you wanna give it access to the actual tooling, right, and connect those queries with the tools. Um, and then last but not least, sampling. Um, I actually think it...

[9:31](https://www.youtube.com/watch?v=j_TKDweOsYE&t=571s) I, I haven't seen anyone using sampling in production yet in an MCP server, was the interesting conclusion that I came to as I was preparing this talk. But, but the idea is to actually allow you to kind of use shorthand with your, uh, with your LLM and allow it to, um, kind of complete some of the thinking

[9:48](https://www.youtube.com/watch?v=j_TKDweOsYE&t=588s) behind it. Um, so, but, but building MCP does come with some tricky parts, and I, I think the trickiest parts of that is, first of all, the, the transport protocol, um, over SSE and WebSockets, the OAuth part, and the memory part.

[10:04](https://www.youtube.com/watch?v=j_TKDweOsYE&t=604s) Um, but I'm gonna share a cheat code with everyone here, um, so, um, get ready. Uh, I'm gonna, like, flash it real quick. Oh, you missed it. [laughs]

[10:14](https://www.youtube.com/watch?v=j_TKDweOsYE&t=614s) Um, uh, no, I'm just kidding. Uh, so Cloudflare has, uh, Cloudflare has, uh, an SDK called Agents that you can install that will actually give you a lot of this functionality out of the box.

[10:26](https://www.youtube.com/watch?v=j_TKDweOsYE&t=626s) Um, so we released Agents SDK a few months ago, and yes, it has the same name as the one that OpenAI, OpenAI just released a few days ago as well.

[10:35](https://www.youtube.com/watch?v=j_TKDweOsYE&t=635s) Um, but, uh, and the two actually work, uh, play with each other really, really well. But, um, I'll tell you a little bit about what it does, and, and you can, um...

[10:43](https://www.youtube.com/watch?v=j_TKDweOsYE&t=643s) So you can use, uh, Agents SDK, first of all, to ru- run MCP servers, and it comes with a class built in called McpAgent that allows you to host your remote MCP servers with OAuth, with, uh, transport, with HTTP streaming all built in.

[11:00](https://www.youtube.com/watch?v=j_TKDweOsYE&t=660s) Um, so if, uh, if you're one of those people that never wants to touch OAuth again, um, this allows you to do that. Um, the really cool thing is that it has state management built into it because Cloudflare has this primitive called Durable Objects.

[11:15](https://www.youtube.com/watch?v=j_TKDweOsYE&t=675s) And so, uh, Durable Objects, the idea is basically, it's kind of like a serverless function, but with state attached directly to it. So if you've ever wanted to, um, write some code, but then save the state of it without ever having to set up a database or anything like that, this is a really, really great way to

[11:32](https://www.youtube.com/watch?v=j_TKDweOsYE&t=692s) do it and makes it really easy to build these MCP servers. Um, it comes with real-time WebSocket communication, so that makes the whole chat interface thing really, really easy.

[11:42](https://www.youtube.com/watch?v=j_TKDweOsYE&t=702s) React integration hooks, so you can build, uh, you can integrate it into your front end really easily, and basic chat capabilities. So let's walk through what it would actually look like to deploy an MCP server on Cloudflare.

[11:57](https://www.youtube.com/watch?v=j_TKDweOsYE&t=717s) Um, so first, I can define my MCP class that extends McpAgent, which I was just talking about, and this MCP server is going to be kind of like a Goodreads, uh, server that's going to recommend different books to us.

[12:13](https://www.youtube.com/watch?v=j_TKDweOsYE&t=733s) So, uh, uh, we're going to set an initial state that's empty, but then I can add different... Uh, I can give it a tool, uh, that's called addGenre, so I can start to specify my preferences.

[12:26](https://www.youtube.com/watch?v=j_TKDweOsYE&t=746s) I'm a big Patricia Highsmith fan, so I can say, you know, I really like, uh, thrillers, and it's going to, it's going to save it and persist it for future interactions.

[12:37](https://www.youtube.com/watch?v=j_TKDweOsYE&t=757s) And so when I then ask it, um, for... I, I can then have a separate tool called getRecommendations that's going to get book recommendations, and, uh, you can have, uh, so we were talking about, uh, MCP prompts before.

[12:52](https://www.youtube.com/watch?v=j_TKDweOsYE&t=772s) You can have a personalized promp- prompt for recommending books to someone who likes the genres, right? Um, and has read the books that you've previously specified that you read.

[13:03](https://www.youtube.com/watch?v=j_TKDweOsYE&t=783s) And so it's a really good way to get these personalized recommendations, and every time that you inter- interact with this tool, it's going to persist the memory over every single time, so the recommendation are going to ke- keep getting better and better.

[13:16](https://www.youtube.com/watch?v=j_TKDweOsYE&t=796s) And because this MCP server is standalone and can be interacted with through various, uh, through various clients, the memory is actually going to persist regardless of the tool that you're using to call into it.

[13:30](https://www.youtube.com/watch?v=j_TKDweOsYE&t=810s) Um, now, why is this great? Um, it's amazing because traditionally you would have to separately set up a database, manage connections, handle scaling. There would be added latency in the setup, um, versus with McpAgent, because the memory part is built into it, um, you don't have to do any of that, and it's going to scale automatically.

[13:49](https://www.youtube.com/watch?v=j_TKDweOsYE&t=829s) It's going to run close to your AI agent, and you don't really need to think about infrastructure at all. You just get all of that out of the box.

[13:57](https://www.youtube.com/watch?v=j_TKDweOsYE&t=837s) Um, you can actually... So we have a blog post up. You can go and deploy your first MCP server today. It's really, really easy. There is literally a Deploy to Cloudflare button.

[14:07](https://www.youtube.com/watch?v=j_TKDweOsYE&t=847s) Takes, um, less than a minute to get your initial MCP server up and running. Uh, and what's been really cool is working with some of the brands that we respect so, so much and seeing companies like Atlassian, Asana, Stripe, Intercom building their own MCP servers in this exact way, so you're actually going down a really, really well-trodden

[14:27](https://www.youtube.com/watch?v=j_TKDweOsYE&t=867s) path here. Okay, so that was the tools part. Um, so let's, uh, keep working backwards from, from there. So we're, we're giving our agents access to tools, but now we need a coordination component, right?

[14:40](https://www.youtube.com/watch?v=j_TKDweOsYE&t=880s) Um, a workflow that's going to maintain a state not through just that one tool interaction but through the entire chain with perhaps a human in the loop.

[14:52](https://www.youtube.com/watch?v=j_TKDweOsYE&t=892s) Um, so human-in-the-loop workflows require long, uh, re- require you to have really, uh, long-running tasks that sometimes need to talk to an LLM. It might be a reasoning LLM that takes several minutes to come up with a response, um, and similarly, if you're talking to a human in the loop, a human could take minutes, hours, days, months

[15:13](https://www.youtube.com/watch?v=j_TKDweOsYE&t=913s) to respond, uh, and so you need something that's going to be able to come back and resume its flow after that task is completed. Um, you also still need to consider things like WebSocket servers, state persistence, retries, horizontal scaling.

[15:26](https://www.youtube.com/watch?v=j_TKDweOsYE&t=926s) These things can get quite tr- quite tricky. So again, let's walk through a real use case that, uh, we built out with a customer. Um, there's a company called Knock.

[15:35](https://www.youtube.com/watch?v=j_TKDweOsYE&t=935s) They do notification management, and they needed to provision, uh, an, an agent that would do, um, approval when, uh, you, you could request a new credit card, right? And then, you know, your boss needs to go and approve it through, you know, it can be, um, an email, Slack, um, in-app, uh, notification.

[15:56](https://www.youtube.com/watch?v=j_TKDweOsYE&t=956s) So what do we need to do in order to do that? Um, first we need to allow users to request a new card through a chat interface. Uh, so you can see that here we're importing useAgent from, um, the, from the Agents React library, and then we're gonna have, uh, we're, we're going to create a new instance

[16:16](https://www.youtube.com/watch?v=j_TKDweOsYE&t=976s) of chat that's going to have all of these things instantiated on our behalf, and this is all part of Agents SDK. Um, then we need to give it an ability to issue cards through this, um, issueCard action, um, but we need to wrap it in the requireHumanInput tool in order to delegate that piece to Knock.

[16:36](https://www.youtube.com/watch?v=j_TKDweOsYE&t=996s) So, um, we want to make sure that the issueCard tool is always, always requires the human input.

[16:44](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1004s) Um, then we need to invite Knock to send our approval notifications and defer the tool call to issue the card until there's approval, right? Um, so we have a tool call to get a new card provision, but we want to stall that on the actual approval.

[17:02](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1022s) Um, so you can see that in here, um, where we're going to route the messages to approve something.

[17:11](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1031s) Um, now, once, once something is approved, we need to then route it back to the appropriate agent, and this is going to automatically be handled by the Durable Object and in- instantly routed to the correct agent back.

[17:24](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1044s) Um, so you can see in here, um, that I'm going to find the user ID from the tool call for the calling user, um, and then I'm gonna be able to look it up, so I can get the agent by name by the user ID in here, and so then if it's an existing agent, we're gonna route

[17:42](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1062s) it to the correct Durable Object and make sure that we're handling it, um, with a correct, uh, webhook.

[17:49](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1069s) We then need to resom- resume the paused tool call, issue the card, and let the user know that the card was approved, right? Um, so in here, if we received an approved status, then we can move on with the deferred, uh, tool execution, uh, that, that we, uh, that we defined earlier.

[18:07](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1087s) And then last but not least, we need to make sure the duplicate actions don't occur, right? So if two things happen out of sync, we can't approve the card twice, uh, or we can't provision the card twice.

[18:19](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1099s) Um, and so this is where, again, that state management becomes really, really important. Um, and we're able to store all of this directly in the state here, um, so you can see if, um, you know, the, if the card has been request- requested or processed already, and then if it's been approved, we're gonna set the status, so

[18:39](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1119s) when a new webhook comes in, we can't reapprove the same exact one. Um, so we talked about, uh, we talked about tools, we talked about workflows. Um, next you need the, uh, the reasoning piece of this, and need to choose the dif- the right model to run this.

[18:56](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1136s) Um, I'm actually going to skip this part because there's an entire conference that's dedicated to this today, um, of people that are going to cover this way better than I will.

[19:06](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1146s) Um, actually, Logan's talk this morning about everything that's happening with Gemini was really, really good. There's a bunch of people talking about evals. Um, but then, uh, but then you need, you still need a client in order to connect to your server, right?

[19:19](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1159s) And, and again, this is the really beautiful thing about MCP, is that once you've built out your MCP server once, uh, you can have, uh, you can truly meet your users where they are.

[19:31](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1171s) Um, and realistically, the nice thing is you actually, you don't have to build a UI yourself at all. Um, if your, if your users are developers, most likely they're already using Cursor.

[19:43](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1183s) Uh, and so now that Cursor supports remote MCP servers, you just import your MCP server and have your clients be able to interact with it. Similarly, Claude and ChatGPT, they both support remote MCPs, so your users, again, can start using your agents instantly directly through there.

[20:03](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1203s) But you can also build your own app and your own MCP client, and I think this is where you can build really, really interesting agentic workflows when you do have more control over both the client and the server, uh, a- and connecting these two pieces together.

[20:19](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1219s) And not only that, but your app doesn't actually have to be limited to just being a user interface. It can also talk to your MCP a- uh, your MCP client over voice, um, especially with, um, some of the Cloudflare tools that we have built out, uh, that help translate WebRTC to WebSocket in a way that really, uh,

[20:39](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1239s) makes it easy to build out these applications, because the MCP client can easily understand those connections.

[20:47](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1247s) So yeah, how do you build an agent? Um, these are the four different pieces you need, your client, your AI, your workflows, your tools. Um, and if you wanna get started and don't know where to start, I really, really highly recommend the Agents SDK.

[21:01](https://www.youtube.com/watch?v=j_TKDweOsYE&t=1261s) You'll be able to get up and running in just a few minutes. Um, yeah, so thank you. [outro music]
