← Lab guides Microsoft Learn lab · overview
Lab overview

Build and extend an AI agent

Tailwind Traders has a language model, but it has never read the company’s own documents — so it answers fluently and gets it wrong. In this lab you turn that model into a real assistant: ground it in your documents, give it tools it can call, and put your own app in front of it. Two core tasks get you a working, tool-using agent in about 35 minutes; four optional tasks take it all the way to a hosted agent.

You write
Python on your machine
A chat window is provided — you write the logic behind it.
client.pyTask 3
Loads the agent and routes each tool call
Your own toolsTasks 4–5
Python functions, then your own MCP server
You build
One agent in Microsoft Foundry
Four pieces — each task adds or upgrades exactly one.
InstructionsTask 1
Who it is, and how it should answer
KnowledgeTask 1
Your uploaded documents, indexed for file search
ToolsTasks 2, 4, 5
Remote MCP, your functions, your own server
HostingTask 6
Your code moves into a Foundry-run container
It reads
Real sources, not guesses
Where every grounded answer actually comes from.
Your documents
Store_Policy.txt, weekly_sales.csv
Learn Docs MCP serverTask 2
Live documentation, fetched at question time
Knowledge makes it accurate Tools make it useful A client makes it real Hosting makes it yours to run
Lab overview

Build and extend an AI agent

Ask a plain language model about your own company and it will answer confidently, and wrongly. This lab closes that gap: you ground an agent in real documents, then give it tools it can call so it can reach past them. Two core tasks, about 35 minutes — and the same question gets a very different answer.

Before · a model on its own
“What’s your return policy for a tent?”
Tents can be returned within 90 days, no receipt required, for a full refund.
✗ Invented — nothing here came from Tailwind
The model is not broken. It has simply never read the store policy, so it fills the gap with something plausible.
After · a grounded, tool-using agent
“What’s your return policy for a tent?”
Camping equipment may be returned within 30 days with proof of purchase, provided it is unused and in its original packaging.
✓ Answered from your own document
Grounded in Store_Policy.txt — and for anything outside your files, it calls the Learn Docs MCP server live.
What you add to get there: Knowledge Task 1 Tools Task 2 Your own app Tasks 3–4 Hosting Tasks 5–6
Lab overview

Build and extend an AI agent

One assistant for Tailwind Traders, built in four layers — and every task in this lab adds exactly one of them. You start with a model that guesses and finish with an agent that reads your documents, calls your tools, and runs inside Microsoft Foundry. Stop after any layer and you still have something that works.

1
Instructions + knowledge
Tell it who it is, upload the store policy, turn on file search — all in the portal, no code
AccurateTask 1 · ~15 min
2
Tools it can call
A remote MCP server for live docs, then your own Python functions
UsefulTasks 2, 4, 5
3
A client app
Your own chat window, talking to the agent you just built
RealTask 3
4
Hosting
Your code moves into a Foundry-run container with its own endpoint
Yours to runTask 6
Layers 1–2 are the core path — about 35 minutes to a working, tool-using agent.
Lab overview

Build and extend an AI agent

Turn a model that guesses into an assistant that answers from Tailwind Traders’ own documents, calls tools, and runs in Microsoft Foundry. Every task stands alone and shares one starter folder, so you choose how far to go — and you have something working after the first 35 minutes.

Core
Task 1
Accurate
Answers from your uploaded documents instead of guessing. Portal only — no code.
~15 min
Core
Task 2
Useful
Calls a remote MCP server for live documentation, and asks you before it acts.
~20 min · stop here and you have a working agent
Optional
Tasks 3–4
Real
Your own chat app drives it, and your own Python functions become tools it can call.
~45 min
Optional
Tasks 5–6
Yours to run
Host your own MCP server, then promote the whole thing to a hosted agent running in Foundry.
~65 min
Lab overview · application architecture

Build and extend an AI agent

You write Python locally; the agent, its knowledge and its tool definitions live in a Microsoft Foundry project. Each badge marks the task that builds that component — Task 1 is portal-only, everything else is code you run yourself, until Task 6 moves your code into Foundry too.

Your machine
tailwind_ui.pyprovided
Web chat window — you never edit it
client.pyTask 3
You write respond() and route each tool call
functions.pyTask 4
Trip planner and rental pricing, in Python
server.pyTask 5
Your own MCP server, tools over stdio
Microsoft Foundry project
Model deploymentsetup
The model your agent runs on
Agent · instructionsTask 1
Who it is, and how it should answer
Knowledge · File searchTask 1
Your uploaded documents, indexed
Tool definitionsTasks 2, 4, 5
Remote MCP, your functions, your MCP server
Agent ServiceTask 6
Your code in a hosted container, own endpoint
Data & remote sources
Your documentsTask 1
Store_Policy.txt, weekly_sales.csv
Learn Docs MCP serverTask 2
learn.microsoft.com/api/mcp · approval required
Task 1 Accurate — grounded in your files Task 2 Useful — reaches live sources Tasks 3–4 Real — your app, your Python Tasks 5–6 Yours to run — your server, hosted
Lab overview · what each task builds

Build and extend an AI agent

Six tasks, one Tailwind Traders assistant — each row is the component you add and what it buys you. Tasks share one starter folder and one .env, so you can run just one, or work straight through.

Task Runs where Component you build Achievement
Task 1Core · ~15 min Foundry portal
Agent + instructions File search index Store_Policy.txt
Accurate
Task 2Core · ~20 min Foundry + local
Remote MCP tool Approval loop
Useful
Task 3Optional Your machine
client.py Responses API · agent_reference
Real
Task 4Optional Your machine
functions.py Function-calling loop
Extensible
Task 5Optional · capstone Your machine
server.py · your MCP server stdio · JSON-RPC
Your own tools
Task 6Optional Foundry
Agent Service container Own endpoint
Yours to run
Lab overview · one question, end to end

Build and extend an AI agent

This is a single question travelling through the assistant you build — every hop is a component, and every badge is the task that adds it. Build the first two hops and you already have a grounded, tool-using agent; the rest put your own code on both ends.

1
Your chat app sends the question and routes whatever comes back. Task 3
→ Responses API · agent_reference
2
Instructions decide how it answers, and which tool it needs. Task 1
→ file search, or a tool call
3
Looks the answer up in your uploaded documents, and cites them. Task 1
Store_Policy.txt · weekly_sales.csv
4
Not in your files? It calls the Learn Docs MCP server, or your own Python. Tasks 2, 4, 5
approval required before it acts
5
Finally the same code runs inside Foundry, behind its own endpoint. Task 6
callers change nothing
Hops 2–3 are the core path — about 35 minutes Hops 1, 4, 5 are optional, in any order Scenario: Tailwind Traders
Lab overview · component view

Build and extend an AI agent

Three subsystems, wired by interfaces you either provide or require — each part tagged with the task that builds it. Task 1 needs no code at all; Task 6 relocates your own parts into the Foundry subsystem.

«subsystem» Your machine internal structure :client.py respond() and tool routing Task 3 :functions.py trip planner, rental pricing Task 4 :server.py your MCP server, over stdio Task 5 «subsystem» Microsoft Foundry internal structure :Agent instructions — who it is Task 1 :Knowledge file search over your docs Task 1 :Tools tool definitions + approval Tasks 2,4,5 :AgentService hosted container, own endpoint Task 6 «subsystem» External :LearnDocsMCP learn.microsoft.com :Documents Store_Policy.txt ChatUI ResponsesAPI agent_reference FunctionTool MCP · stdio MCP · https approval required «indexed at upload» «deployed to · Task 6»
Lab overview · deployment view

Build and extend an AI agent

Where each artifact actually runs. Everything you write starts on your own machine and talks to a Foundry project over HTTPS — until Task 6 redeploys your code into Foundry, behind its own endpoint.

«device»
Your machine
tailwind_ui.py
provided chat window
given
client.py
calls the agent, routes tools
Task 3
functions.py
your Python tools
Task 4
server.py
your MCP server (stdio)
Task 5
«execution environment»
Microsoft Foundry project
Model deployment
the model the agent runs on
setup
Agent + knowledge
instructions, file search index
Task 1
Tool definitions
MCP, functions, approval
Tasks 2,4,5
Agent Service container
your code, moved here
Task 6
«external system»
Outside your tenant
Learn Docs MCP
called at question time
Task 2
Your documents
uploaded, then indexed
Task 1