Skip to content

Commit 6ff72f7

Browse files
softchriscinnamon-msftCopilotjamesmontemagnoChris
authored
Learn course 3 (#9927)
* Initial docs * New images and edits * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Fact-check and refine agent course tutorials - Re-indent nested MCP prompt code block to render inside the numbered step - Match exact tool sets command label (Chat: Configure Tool Sets > Create new tool sets file) - Correct Configure Tools guidance to documented behavior - Add Copilot Pro+ requirement for local Codex sessions * remove insiders requirement * adding course * fixed broken image links * copied all images to ensure this course don't break if images are moving around in the future * adding course, updating broken image links (#9915) * adding course * fixed broken image links * copied all images to ensure this course don't break if images are moving around in the future --------- Co-authored-by: Chris <chnoring@microsoft.com> * removing files that are now in /images for the course --------- Co-authored-by: Kayla Cinnamon <cinnamon@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: James Montemagno <james.montemagno@gmail.com> Co-authored-by: Chris <chnoring@microsoft.com>
1 parent 1fe8d5b commit 6ff72f7

19 files changed

Lines changed: 725 additions & 1 deletion
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
---
2+
ContentId: 5d7a2a1e-9f1c-4d2a-8c6a-1c2a8f7d4a01
3+
DateApproved: 05/21/2026
4+
MetaDescription: Practice choosing agent tools, tool sets, approvals, and sandboxing settings for focused AI workflows in VS Code.
5+
MetaSocialImage: ../images/shared/agent-first-development-social.png
6+
Keywords:
7+
- copilot
8+
- agents
9+
- tools
10+
- tool sets
11+
- approvals
12+
- sandboxing
13+
---
14+
15+
# Using tools with agents
16+
17+
Tools are how agents act on your request. They search your workspace, read files, edit code, run terminal commands, fetch web content, and call external services. In this guide, you will start with a small task, choose only the tools the task needs, and decide when to use a tool set, approvals, or sandboxing.
18+
19+
## Prerequisites
20+
21+
Before you start, install VS Code, enable AI features, and sign in to GitHub Copilot. You also need access to any extra tools you want to try, such as MCP servers or extensions that contribute tools.
22+
23+
* [Download VS Code](https://code.visualstudio.com/)
24+
* [Set up GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview#_step-1-set-up-copilot)
25+
26+
## Start with a task
27+
28+
Imagine you want the agent to explain how authentication works in a repository and then suggest one small test to add. That task needs repository context, but it probably does not need terminal access, web access, or external services at the start.
29+
30+
Use this prompt in an agent session:
31+
32+
```prompt
33+
Explain the authentication flow in this project. Find the main files involved, then suggest one focused test I should add next.
34+
```
35+
36+
Before you send it, decide which tools the agent should have. VS Code supports three kinds of tools:
37+
38+
* Built-in tools, such as read, edit, search, execute, and web.
39+
* MCP tools from installed Model Context Protocol servers.
40+
* Extension tools contributed by VS Code extensions.
41+
42+
The agent selects from the enabled tools based on your prompt and context. Your job is to give it enough capability to finish the task without giving it a noisy list of unrelated options.
43+
44+
## Choose tools for the first pass
45+
46+
1. Open the Chat view.
47+
48+
1. Select **Agent** from the agent picker.
49+
50+
1. Select **Configure Tools** in the chat input.
51+
52+
1. Keep repository search and file-reading tools enabled.
53+
54+
1. Leave terminal, web, and external service tools off for this first pass.
55+
56+
1. Send the prompt.
57+
58+
![Screenshot showing the Chat view with the Configure Tools button in the chat input.](../images/agents/agent-mode-select-tools.png)
59+
60+
Starting small helps the agent stay focused. It also reduces tool definitions in the model context window. VS Code can expose some groups as virtual tools to keep tool counts manageable, but a smaller active set still makes the task easier for the model to reason about.
61+
62+
> [!TIP]
63+
> If the agent says it needs to run tests or inspect generated output, add the terminal tool for the next request instead of restarting with every tool enabled.
64+
65+
## Add a specific tool when needed
66+
67+
Sometimes you know exactly which tool should ground the answer. Type `#` in the chat input to see available tools, context sources, and tool sets.
68+
69+
For example, revise the previous prompt like this:
70+
71+
```prompt
72+
Explain the authentication flow in this project. Focus on repository context. #codebase
73+
```
74+
75+
Use explicit tool references when the task has a clear source of truth:
76+
77+
* Use `#codebase` when the answer should come from your repository.
78+
* Use `#problems` when you want the agent to fix current diagnostics.
79+
* Use `#web` when the answer needs current external documentation.
80+
81+
![Screenshot showing the tool picker drop-down with built-in tools, MCP servers, and user-defined tool sets.](../images/agents/chat-tools-picker.png)
82+
83+
## Decide between individual tools and tool sets
84+
85+
Individual tools work well for one-off requests. Tool sets work better when you repeat the same setup.
86+
87+
| Use | Good fit | Example |
88+
| --- | --- | --- |
89+
| Individual tools | A short task with one clear source of context. | Explain a file with `#codebase` and no terminal access. |
90+
| Tool set | A repeated workflow that needs the same group of tools. | A Python maintenance workflow with search, edit, testing, and Python language tools. |
91+
| Custom agent tools | A role that should always run with the same boundaries. | A planning agent with search and web tools, but no edit or terminal tools. |
92+
93+
## Create a tool set for repeat work
94+
95+
In this step, create a reusable tool set for repository cleanup work.
96+
97+
1. Open the Command Palette.
98+
99+
1. Run **Chat: Configure Tool Sets** and select **Create new tool sets file**.
100+
101+
1. In the `.jsonc` file that opens, add the tools you use for the cleanup workflow, such as search, edit, and test tools, plus a `description` and `icon`.
102+
103+
1. Save the file.
104+
105+
1. Return to Chat and select the tool set from **Configure Tools**, or reference it in a prompt by typing `#` followed by the tool set name.
106+
107+
Now try a prompt that uses the saved setup:
108+
109+
```prompt
110+
Find one small cleanup opportunity in this repository, make the change, and run the focused validation for it.
111+
```
112+
113+
Tool sets solve the problem of repeatedly rebuilding the same tool selection. They also make reviews easier because the saved file shows which tools are expected for a workflow.
114+
115+
## Limit tools for a custom agent
116+
117+
When you build a [custom agent](https://code.visualstudio.com/docs/copilot/customization/custom-agents), you can list the tools and tool sets it has access to in the `tools` field of the agent's Markdown frontmatter:
118+
119+
```yaml
120+
---
121+
description: Python testing helper
122+
tools: ['search', 'edit', 'pylance', 'runTests']
123+
---
124+
```
125+
126+
You can also edit the `tools` field directly, or open the tools picker with the **Configure Tools** button in the Chat view and let VS Code update the agent's list for you.
127+
128+
Use a custom agent when the tool boundary is part of the role. For example, a planning agent should not edit files by accident, so give it search and web tools but leave out edit and terminal tools. An implementation agent needs a broader set because its job is to modify code and validate the change.
129+
130+
## Pick a permission level
131+
132+
Next, decide how much review you want before tools run. The permissions picker controls how much autonomy the agent has during a session.
133+
134+
* **Default Approvals** asks before sensitive actions.
135+
* **Bypass Approvals** auto-approves tool calls.
136+
* **Autopilot** (Preview) auto-approves tool calls and continues working until the task is done.
137+
138+
Use the mode that matches the risk of the task:
139+
140+
* Use **Default Approvals** while exploring unfamiliar code or when the agent can run commands you want to review.
141+
* Use **Bypass Approvals** for routine workflows in a trusted workspace after you know which tools will run.
142+
* Use **Autopilot** for contained tasks where the agent can keep iterating until it reaches a result you can review.
143+
144+
You can keep your preferred mode across sessions with `setting(chat.permissions.default)`. Autopilot is available when `setting(chat.autopilot.enabled)` is on.
145+
146+
> [!CAUTION]
147+
> Higher autonomy levels reduce the amount of review you do before tools run. Use them with care, especially when the agent can edit files or run terminal commands.
148+
149+
![Screenshot of approval options.](../images/agents/chat-approval-options.png)
150+
151+
## Add sandboxing for terminal work
152+
153+
Agent sandboxing adds OS-level isolation for terminal commands run by the agent. It limits file system and network access, and sandboxed commands are auto-approved because they already run in a controlled environment.
154+
155+
Enable it with `setting(chat.agent.sandbox.enabled)`. On macOS and Linux, you can choose full isolation or file system isolation with network access.
156+
157+
Sandboxing is a good fit when the agent needs terminal access but should not reach beyond the workspace or approved domains. For example, use sandboxing before asking the agent to run a generated script, start a local tool, or inspect a project with unfamiliar package scripts.
158+
159+
## Your turn
160+
161+
Try the same repository task three ways:
162+
163+
1. Run it with only repository search and file-reading tools.
164+
165+
1. Add the terminal tool and ask the agent to run one focused validation.
166+
167+
1. Save the tool selection as a tool set and reuse it in a new chat.
168+
169+
After each run, compare what changed. Notice whether the agent stayed focused, asked for missing permissions, or used tools you did not expect.
170+
171+
## Why this matters
172+
173+
The right tool mix keeps agents focused. Tool sets make good workflows repeatable. Custom agents make tool boundaries part of a role. Approvals and sandboxing help you stay in control when the agent can make changes or reach outside the workspace.
174+
175+
## What's next
176+
177+
Now that you know how to use tools, the next course shows how MCP servers add external data and actions to an agent session.
178+
179+
## Learn more
180+
181+
* [Use tools with agents](https://code.visualstudio.com/docs/copilot/agents/agent-tools)
182+
* [Tools concepts](https://code.visualstudio.com/docs/copilot/concepts/tools)
183+
* [Agent sandboxing](https://code.visualstudio.com/docs/copilot/concepts/trust-and-safety#agent-sandboxing)
184+
* [Agent approvals and permissions](https://code.visualstudio.com/docs/copilot/agents/agent-tools#permission-levels)
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
ContentId: 7a2e1d9c-4b8f-4a3d-8e0c-2f5d6b7c8a02
3+
DateApproved: 05/21/2026
4+
MetaDescription: Install, use, configure, and sandbox an MCP server to give VS Code agents focused external capabilities.
5+
MetaSocialImage: ../images/shared/agent-first-development-social.png
6+
Keywords:
7+
- mcp
8+
- model context protocol
9+
- agents
10+
- tools
11+
- api
12+
- customization
13+
---
14+
15+
# Extending agents with MCP servers
16+
17+
MCP servers connect agents to external tools and data sources. In this guide, you will install an MCP server, use one of its tools in chat, choose the right configuration scope, and decide when to sandbox the server.
18+
19+
## Prerequisites
20+
21+
Before you start, install VS Code, enable AI features, and sign in to GitHub Copilot. You also need access to an MCP server or the ability to add one from the marketplace.
22+
23+
* [Download VS Code](https://code.visualstudio.com/)
24+
* [Set up GitHub Copilot in VS Code](https://code.visualstudio.com/docs/copilot/overview#_step-1-set-up-copilot)
25+
26+
## Start with a concrete server
27+
28+
For this lesson, use the Playwright MCP server as the example. It gives the agent browser tools so it can open pages, interact with them, and capture screenshots.
29+
30+
1. Open the Extensions view.
31+
32+
1. Search for `@mcp playwright`.
33+
34+
1. Select **Install** to install the Playwright MCP server in your user profile.
35+
36+
1. When VS Code asks whether you trust the server, review the publisher and server details, then confirm if you trust it.
37+
38+
When the server starts, VS Code discovers its tools and makes them available in chat.
39+
40+
![Screenshot showing the MCP servers in the Extensions view.](../images/agents/extensions-view-mcp-servers.png)
41+
42+
## Use the server in chat
43+
44+
Now give the agent a task that actually needs browser access.
45+
46+
1. Open the Chat view.
47+
48+
1. Select **Agent**.
49+
50+
1. Select **Configure Tools**.
51+
52+
1. Enable the Playwright tools.
53+
54+
1. Send this prompt:
55+
56+
```prompt
57+
Go to code.visualstudio.com, decline the cookie banner if it appears, and describe the main navigation items on the homepage.
58+
```
59+
60+
The agent should call the Playwright MCP tools because the task requires browser interaction. If it asks for approval before a tool call, review the action and approve it when it matches the task.
61+
62+
![Screenshot showing an MCP tool invocation in chat with the input and output shown.](../images/agents/chat-agent-mode-tool-invocation.png)
63+
64+
## Decide where the configuration belongs
65+
66+
Installing a server writes configuration to an `mcp.json` file. Choose the scope based on who should use the server.
67+
68+
| Scope | Use it when | Example |
69+
| --- | --- | --- |
70+
| User profile | The server is useful across your own workspaces. | A browser automation server or documentation lookup server. |
71+
| Workspace | The server is part of how the project works. | A project-specific API server or database inspection tool. |
72+
| Remote user profile | The server must run on a remote machine. | A server that needs access to tools installed in a dev container or remote environment. |
73+
74+
Use **MCP: Open User Configuration** to inspect your user profile configuration. Use **MCP: Open Workspace Folder Configuration** when you want a `.vscode/mcp.json` file for the current project.
75+
76+
For servers that need credentials, do not hardcode secrets in a workspace file. Store sensitive values with input variables or environment files.
77+
78+
> [!TIP]
79+
> VS Code provides IntelliSense and inline actions for `mcp.json`, which makes it easier to start, stop, and inspect servers.
80+
81+
![MCP server configuration with lenses to manage server.](../images/agents/mcp-server-config-lenses.png)
82+
83+
## Learn what MCP can provide
84+
85+
MCP is built around a few capabilities. Each one solves a different problem.
86+
87+
* **Tools** let the agent take actions, such as opening a browser or querying an API.
88+
* **Resources** provide read-only context that you attach to a request, such as a database schema or document.
89+
* **Prompts** provide reusable templates from the server, such as a standard research prompt.
90+
* **MCP Apps** render interactive UI in chat when a server supports richer input or output.
91+
92+
Use tools when the agent needs to do something. Use resources when it needs to read something. Use prompts when your team wants a repeatable interaction pattern.
93+
94+
## Sandbox a local server
95+
96+
Treat local MCP servers as code that can run on your machine. Review the publisher and configuration before you install one.
97+
98+
By default, MCP tool calls prompt for approval before running, which keeps a human in the loop. For local stdio servers on macOS and Linux, you can enable sandboxing to restrict file system and network access.
99+
100+
Add sandboxing when a server needs useful powers but should stay inside clear boundaries. For example, with the Playwright MCP server, sandboxing lets the agent navigate pages and run browser tasks without prompting on every step because the work is isolated from your host.
101+
102+
To enable sandboxing for a local stdio server, set `sandboxEnabled` to `true` in the server configuration. If the server needs more access, update the sandbox rules for that server instead of widening access for the whole machine.
103+
104+
```json
105+
{
106+
"servers": {
107+
"playwright": {
108+
"command": "npx",
109+
"args": ["-y", "@microsoft/mcp-server-playwright"],
110+
"sandboxEnabled": true
111+
}
112+
}
113+
}
114+
```
115+
116+
![Screenshot showing the MCP server trust prompt.](../images/agents/mcp-server-trust-dialog.png)
117+
118+
## Practice with a second server
119+
120+
After you try Playwright, install a documentation or API-focused MCP server and compare the workflow.
121+
122+
1. Search for `@mcp` in the Extensions view.
123+
124+
1. Pick a server that connects to documentation, issue tracking, or another system you use.
125+
126+
1. Install it in your user profile if it is personal tooling, or in the workspace if the project should share it.
127+
128+
1. Enable its tools in Chat.
129+
130+
1. Ask a prompt that requires that external source.
131+
132+
For example, with a documentation MCP server enabled, ask a question that should be grounded in that documentation instead of the model's general knowledge.
133+
134+
## Manage MCP servers
135+
136+
You can manage servers from several places in VS Code:
137+
138+
* The Extensions view.
139+
* The `mcp.json` editor.
140+
* The Command Palette, including **MCP: List Servers**.
141+
* The Agent Customizations view from the cog in the Chat view.
142+
143+
Use these surfaces to start or stop a server, browse the marketplace, and install additional servers.
144+
145+
![Screenshot showing the actions for an MCP server in the Command Palette.](../images/agents/mcp-list-servers-actions.png)
146+
147+
To debug a server, select **Show Output** from the server's actions to see logs from every request the server handles.
148+
149+
![Screenshot showing the MCP server output panel with logs.](../images/agents/mcp-server-error-output.png)
150+
151+
## Why this matters
152+
153+
MCP gives agents a standard way to reach outside the model and work with the systems you already use. That means less ad hoc prompting and more repeatable workflows.
154+
155+
## What's next
156+
157+
Next, you will see how agent plugins package skills, agents, hooks, and MCP servers into a single installable bundle.
158+
159+
## Learn more
160+
161+
* [Add and manage MCP servers in VS Code](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)
162+
* [MCP configuration reference](https://code.visualstudio.com/docs/copilot/reference/mcp-configuration)
163+
* [MCP sandbox configuration](https://code.visualstudio.com/docs/copilot/reference/mcp-configuration#sandbox-configuration)
164+
* [Use tools with agents](https://code.visualstudio.com/docs/copilot/agents/agent-tools)

0 commit comments

Comments
 (0)