Agent Mode, MCP Servers and Sub-Agents
30-second answer
Agent mode lets Copilot take a whole task: it plans, finds and edits files, runs terminal commands after you approve them, reads the output and iterates until the task is done. Copilot Edits (Edit mode) only changes the files you choose. MCP (Model Context Protocol) servers give the agent extra tools, such as the GitHub MCP server at https://api.githubcopilot.com/mcp/, configured in .vscode/mcp.json and allowed or blocked by an organization's MCP policy. Agent sessions keep separate pieces of work apart, and a sub-agent does a side task in its own context and returns only a summary, so the main conversation's context window stays focused.
Exam objective: 2.3.1 Use Agent Mode, Copilot Edits, and MCP for enhanced development and workflows; manage Agent Sessions and delegate tasks to Sub-Agents for optimized context usage. (Skills measured as of August 7, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Switch the chat to <strong>Agent</strong>. Describe the outcome, not the steps.
👆 Click the glowing item on screen to continue
Read the steps as text
- Switch the chat to Agent. Describe the outcome, not the steps.
- Agent mode plans, edits files and wants to run a command. It asks first; you can allow once, for the session, or skip.
- It reads the test output and iterates until the task passes. Keep or Undo the changes, and review the diffs either way.
- MCP servers add tools. In VS Code, list them in .vscode/mcp.json (shared with the repo) or your user settings. This one is the GitHub MCP server for issues, pull requests and Actions.
- The agent calls an MCP tool, after asking. For long tasks, separate sessions and sub-agents keep each piece of work in its own context, so the main conversation stays focused.
🧪 Simulation for learning. Screens are simplified versions of Visual Studio Code and github.com with GitHub Copilot; names, files and suggestions are examples. Not affiliated with GitHub or Microsoft, and nothing here touches your real account.
🖱️ Drag to rotate · scroll or pinch to zoom
MCP servers add tools
The Model Context Protocol (MCP) lets Copilot use external tools: the GitHub MCP server, a browser, a docs search or your own API. Configure servers in .vscode/mcp.json (VS Code) or with /mcp (CLI). Organizations can restrict which servers are allowed.
🤔 What happens if…
Read this tour as text
- Ask mode. Ask answers questions about code and concepts and can suggest code blocks. It doesn’t change your files by itself.
- Edit mode (Copilot Edits). Edit applies changes to the files you choose, across several files at once. You see each diff and Keep or Undo it.
- Agent mode. Agent works out which files to touch, edits them, runs commands and tests, reads errors and keeps going until the task is done. It asks before running terminal commands unless you’ve approved them.
- MCP servers add tools. The Model Context Protocol (MCP) lets Copilot use external tools: the GitHub MCP server, a browser, a docs search or your own API. Configure servers in
.vscode/mcp.json(VS Code) or with/mcp(CLI). Organizations can restrict which servers are allowed. - Sessions and sub-agents. Long tasks fill the context window. Agent sessions keep work separate, and a sub-agent can do a side task in its own context and hand back only a summary.
- Copilot coding agent. Assign an issue to Copilot on github.com (or
/delegatefrom the CLI). The coding agent works in a GitHub Actions environment on its own branch and opens a draft pull request with its changes. - Review stays human. You review the agent’s PR like any other. Copilot code review can comment and suggest changes, but its review doesn’t count as an approval. A person merges.
- Copilot CLI. The same agent in the terminal:
copilotfor a session with slash commands,copilot -p "…"for one prompt, and--allow-tool/--deny-toolto control what it may run.
Give Copilot more reach. Look at the built-in GitHub MCP server, add a docs server, let Copilot call a tool to read your issues, then hand a bigger task to Copilot coding agent so it opens a pull request.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
Copilot can’t see your issues, and big tasks fill up the context.
😊 THE SOLUTION
Give agent mode tools with MCP and split work with sessions and sub-agents.
- No access to issues or docs✓ An MCP server
- Context window fills up✓ Sub-agents with their own context
- Long task blocks your editor✓ Delegate to the coding agent
Start with a question
If you hire a contractor to redo your kitchen, do you want them to just give advice, or plan the job, fetch tools, ask before cutting into a wall, and keep going until it's done?
For a full kitchen, you want the second one. But you also want them to check with you before anything loud, and you don’t want them rifling through every room of the house to figure out where the fuse box is.
That’s agent mode. Copilot plans the job, edits files and asks before running commands. MCP servers are the extra tools in its van: a GitHub tool for issues, a browser, a docs search. And a sub-agent is the apprentice sent to find the fuse box, who comes back with one sentence (“it’s under the stairs”) instead of a tour of the house.
Explain it like I’m 10
Visual: agent mode in motion
Watch one request go through plan, edit, an approved test run, a failure, a fix, an MCP tool call and a sub-agent.
Read the video script
- Ask for the outcomeSwitch the chat to agent mode and ask for the result you want: a FREE code that gives a hundred percent off, totals that never go below zero, and tests.
- It plans and finds the filesFirst it plans. It searches the codebase for discount code and works out which files matter. You didn't have to list them, which is the big difference from edit mode.
- It edits, and you see each diffNext it edits. It changes discount dot js, creates a test file, and only reads cart dot js. Every change shows up as a diff you can review.
- It asks before it runs a commandNow it wants to run npm test. It asks first. You can allow it once, allow it for the rest of the session, or skip it. Here we allow it once, and one test fails.
- It reads the failure and iteratesThis is the loop. The agent reads the failing test, fixes the code, and runs the tests again. Now all five pass. Edit mode can't do this part: it never runs anything.
- MCP gives it new toolsTo check related bugs, it calls a tool from the GitHub MCP server, set up in dot vscode slash mcp dot json. Again it asks first. You allow it, and the open issues come back.
- A sub-agent keeps context leanOne more question: where else is the discount applied? A sub-agent goes off and reads the files in its own context. Its meter fills up, but the main one barely moves, because only a one-line summary comes back.
- You keep or undoFinally it reports back. You read the diffs, then keep or undo them. The agent did the legwork, but every command, every tool call and every change went past you.
The technical explanation
Agent mode vs Copilot Edits
Both live in the Chat view’s mode picker in VS Code.
| Edit mode (Copilot Edits) | Agent mode | |
|---|---|---|
| Which files | The ones you add to the working set | Finds them itself |
| Runs commands | No | Yes, after you approve |
| Reads errors and tests | No | Yes, and iterates |
| Uses tools / MCP | No | Yes |
| You review | Each diff: Keep or Undo | Each diff, each command, each tool call |
Ask agent mode for an outcome, not steps: “Add a FREE code that gives 100% off, make sure totals never go negative, and add tests.” It searches for discount, edits src/discount.js, creates tests/discount.test.js, then asks:
⌨️ Run in terminal: npm test
[Allow] [Allow for this session] [Skip]
If a test fails it reads the assertion, fixes the code and runs the tests again. When it’s done you get a summary and the diffs to Keep or Undo. “Allow for this session” saves clicks but means it won’t ask again for that command, so use it in repos you know.
MCP servers add tools
The Model Context Protocol is an open standard for connecting AI apps to tools and data. An MCP server exposes tools (functions the agent can call) and sometimes resources. In VS Code you list servers in .vscode/mcp.json, which you can commit so the whole team gets the same setup:
{
"servers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
}
}
}
That’s the GitHub MCP server: tools for issues, pull requests, Actions and more. Ask “Which open issues are labelled bug?” and the agent calls list_issues, after asking you. Other servers can run locally ("type": "stdio" with a command) for a browser, a database or your own API. In Copilot CLI, /mcp lists and adds servers and they’re saved in ~/.copilot/mcp-config.json; the GitHub MCP server is built in.
Two controls matter. You can switch individual tools on or off in the tools picker, and an organization with Copilot Business or Enterprise has an MCP servers in Copilot policy that allows or blocks MCP for its members. If the policy blocks it, no mcp.json file will bring it back.
-
1 Ask
You ask about open bugs.
-
2 Choose
The agent picks the github server's list_issues tool.
-
3 Approve
You allow the call (once or for the session).
-
4 Call
The MCP server queries GitHub and returns the issues.
-
5 Answer
The agent uses the result in its reply or next step.
Sessions and sub-agents: managing context
Every file the agent reads, every command output and every turn of chat goes into its context window. Long tasks fill it, and a crowded window means slower, vaguer answers.
- Agent sessions keep separate pieces of work apart. Start a new session for a new task instead of piling everything into one, and you can come back to an earlier session later. In the CLI that’s
/session,/resumeand--continue. - A sub-agent runs a side task in its own context: “find every place we log user emails” or “research how the report module is used”. It reads what it needs and returns a summary, and only that summary enters the main conversation.
- Delegating a whole task to Copilot coding agent (
/delegatein the CLI, or assigning an issue on github.com) moves the work off your machine entirely; it comes back as a draft pull request.
Architect level Custom agents, tools lists and trust
A custom agent (.github/agents/<name>.agent.md in a repo, or ~/.copilot/agents/ for your own CLI agents) is a named persona with its own instructions and a tools list. A “test-writer” agent that can only read and edit files, with no shell access, is a neat way to limit what an agent can do. MCP servers run with whatever access you give them, so treat third-party servers like any dependency: check who publishes them, prefer OAuth over tokens pasted into config, and keep secrets out of a committed mcp.json (VS Code supports input variables for that). Tool approvals stay on by default for a reason.
Real-world business scenario
Contoso (fictional)
- The problem
- Contoso's developers copied issue details from github.com into chat by hand, and long agent conversations that mixed research with coding kept running out of context and giving muddled answers.
- What they used
- A committed .vscode/mcp.json with the GitHub MCP server, the organization's MCP policy enabled for the shop team, agent mode for implementation with command approvals left on, and sub-agents for research tasks.
- Why that choice
- The agent reads issues itself through MCP, every tool call and command is approved by a person, and research stays out of the main context.
- The result
- Bug fixes started from the real issue text, and agent sessions stayed on task long enough to finish with passing tests.
When to use it and when not to
✓ Use it when…
- Agent mode for tasks that need searching, multi-file edits, running tests and a few rounds of fixing.
- Copilot Edits when you know the files and want no commands run.
- MCP servers when the agent needs data or actions outside your repo, such as issues or docs.
- Sub-agents or new sessions to keep research and side tasks out of the main context.
✕ Think twice when…
- Approving every command for the session in an unfamiliar repository.
- Adding MCP servers from unknown publishers, or committing tokens in mcp.json.
- Merging agent changes without reading the diffs and running the tests yourself.
↔ Alternatives to consider
- Copilot coding agent to work on an issue in the background and open a draft pull request.
- Copilot CLI for the same agent loop in the terminal, scriptable with copilot -p.
Test yourself with exercises
5 original practice questions in the GH-300 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What does agent mode do that Ask mode doesn't?
Model answer
Ask answers. Agent acts: it searches the codebase, edits files, asks to run commands like npm test, reads the results and keeps fixing until the task passes. I still review the diffs and decide what to keep.
Intermediate How do you give agent mode access to your GitHub issues?
Model answer
Add the GitHub MCP server. In VS Code that's a .vscode/mcp.json file with a servers entry pointing at https://api.githubcopilot.com/mcp/. Then the agent can call tools like list_issues, and it asks me before each tool call unless I've approved it.
Interviewer follows up
And if the tool never shows up?
You
Check that the server started, that my organization's MCP servers in Copilot policy allows MCP, and that the tool is enabled in the tools picker.
Experienced developer Why would you use a sub-agent rather than just asking the main agent?
Model answer
Context. If the main agent reads twenty files to research how logging works, all of that sits in its context window and crowds out the actual task. A sub-agent does the research in its own context and hands back a short summary, so the main thread stays lean and focused.
Architecture & design How would you let a team use MCP servers safely across many repositories?
Model answer
Set the organization's MCP policy deliberately, keep approved servers in a checked-in .vscode/mcp.json so everyone uses the same ones, prefer remote servers with OAuth over tokens pasted into config, and leave tool approvals on so a person sees each call. Anything that writes, like creating issues, deserves an extra look.
Quick revision
Key points
- Agent mode plans, edits files, runs terminal commands after approval and iterates until done.
- Copilot Edits (Edit mode) changes only the files you add and shows diffs to Keep or Undo.
- MCP servers add tools. VS Code reads .vscode/mcp.json with a "servers" object; the CLI uses /mcp and ~/.copilot/mcp-config.json.
- The GitHub MCP server's remote URL is https://api.githubcopilot.com/mcp/.
- Organizations control MCP with the "MCP servers in Copilot" policy.
- Agent sessions keep work separate; sub-agents run side tasks in their own context and return a summary.
- You can approve a command once or for the session; review every diff either way.
Important terminology
- Agent mode
- A Copilot Chat mode where Copilot plans a task, edits files, runs commands after approval and iterates on the results.
- Copilot Edits
- Edit mode, which applies changes to a working set of files you choose and lets you Keep or Undo each diff.
- Model Context Protocol (MCP)
- An open standard that lets AI apps connect to servers offering tools and data, such as GitHub, a browser or a docs search.
- GitHub MCP server
- GitHub's MCP server for issues, pull requests, Actions and more. Remote URL https://api.githubcopilot.com/mcp/.
- Agent session
- One piece of agent work with its own history and context, kept separate from other sessions.
- Sub-agent
- A helper agent that runs a side task in its own context window and returns a summary to the main agent.
Common mistakes
- Thinking Edit mode runs tests. Only Agent mode runs commands.
- Putting a personal access token in a shared mcp.json.
- Letting one agent conversation do research and implementation until the context window overflows.
Exam tips
- "Connect Copilot to an external tool or data source" = MCP server.
- "Multi-file change you review, no commands" = Copilot Edits.
- "Do a side task without filling the main context" = sub-agent.
Five quick revision questions
-
1.Which file configures MCP servers for a VS Code workspace?Show
.vscode/mcp.json
-
2.Which top-level key holds the servers in that file?Show
"servers"
-
3.What is the GitHub MCP server's remote URL?Show
https://api.githubcopilot.com/mcp/
-
4.Which chat mode can run npm test?Show
Agent mode
-
5.What does a sub-agent return to the main agent?Show
A summary of its result, not its whole context.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Custom Instructions and Prompt Files
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.