MSBA-379 · Lesson 4 of 12 · 25 min
Domain review: tool use and environments
▶ Video coming soon A video version of this lesson is on the way.
Implement tool use and environment interaction is the heaviest domain on GH-600, at 20 to 25 percent, and it was Malik's weakest on the baseline: 3 of 7. Priya split the review over two sessions and invited Seraphine Kowalik-Duarte to join the second by video, because three of Malik's four misses involved controls that only an enterprise uses. "Tidewater is one organization on GitHub Team," Priya said. "Skerry has an enterprise, an internal MCP registry and a security team that reads the audit log. The exam assumes you know both worlds."
The domain has four skill groups: select and configure agent tools; configure MCP servers; integrate agents within development environments; and operate agents with safe execution paths and robust error handling. This lesson takes them in that order. The common thread is a question Malik learned to ask of every scenario: where does this setting live, and which agent does it reach?
| Skill group | Key bullets | First taught in |
|---|---|---|
| Select and configure agent tools | Identify required tools; configure tools; configure tool permissions | Tool use and function calling; Custom agents and instructions |
| Configure MCP servers | Add an MCP server to an agent; configure the GitHub remote MCP server; configure registries; configure allow lists | Model Context Protocol |
| Integrate agents within development environments | Execution context; repository scope; CI invocation; branch scope; branches and pull requests; environment constraints | Interacting with repositories and environments; The GitHub Copilot cloud agent |
| Safe execution paths and error handling | Error handling, retries, rollbacks, escalation, traceability | Sandboxes and permissions; Operating agents in production |
Selecting and configuring tools
A tool is a capability the model can call: read a file, search the codebase, edit a file, run a shell command, open a pull request, query an issue tracker. Identifying required tools starts from the task, not from what is available. A reviewer agent needs to read and search; it does not need to edit. A test-writing agent needs to read, edit test files and run the test command. A triage agent needs to read issues and apply labels. Every extra tool is both a chance for the model to choose wrongly and an extra capability an attacker could steer through prompt injection.
Tools are configured in different places depending on the surface. A custom agent, defined in a Markdown file in the repository's .github/agents folder, lists its tools in the file's frontmatter. Tidewater's reviewer agent for trail-units had read and search tools only, so it could not change code even if told to. The cloud agent gets its built-in tools from GitHub and additional tools from the MCP servers configured for the repository, each of which can be limited to named tools. Copilot CLI asks the user to approve tool use interactively and accepts command-line options that allow specific tools in advance, which is how it runs unattended in a workflow. Agent mode in an editor asks for approval of terminal commands and other sensitive actions, with settings that can relax this for particular commands.
---
name: reviewer
description: Reviews pull requests in trail-units for correctness and missing tests. Never edits files.
tools: ["read", "search"]
---
You review changes to the trail-units action.
Report problems as a numbered list with file and line.
If a change needs a fix, describe it; do not make it.Configuring tool permissions is least privilege applied to tools. The tool list decides which tools exist for the agent; permissions decide what each tool can reach. A shell tool limited to the test command is narrower than an unrestricted shell. A GitHub token limited to one repository is narrower than one that reaches the organization. An MCP server configured with only two of its twelve tools is narrower than the whole server. When an exam option offers "give the agent all tools so it never gets stuck", it is the anti-pattern, not the answer.
Configuring MCP servers
The Model Context Protocol is the open standard through which agents discover and call tools provided by servers. The study guide's four MCP bullets map to four different actions, and the exam can tell them apart.
Adding an MCP server as a tool to an agent. For the cloud agent, a repository administrator adds an MCP configuration, in JSON, in the repository's Copilot settings on GitHub. Each server entry gives its type, how to reach or start it, any secrets it needs and the list of tools the agent may use. Secrets referenced by the configuration are stored in the repository's Copilot environment with names that begin with COPILOT_MCP_, which keeps them away from the rest of the repository's automation. In an editor, servers are configured in the editor's MCP settings for the workspace or the user. A custom agent can also name the MCP servers and tools it uses.
{
"mcpServers": {
"trail-data": {
"type": "local",
"command": "npx",
"args": ["-y", "@tidewater/trail-data-mcp@1.2.0"],
"env": { "TRAIL_DATA_TOKEN": "COPILOT_MCP_TRAIL_DATA_TOKEN" },
"tools": ["list_stale_trails", "get_trail"]
}
}
}Configuring the GitHub remote MCP server. GitHub hosts an MCP server that exposes GitHub itself as tools: issues, pull requests, code search, Actions runs, security alerts and more. The remote server runs on GitHub's infrastructure, so there is nothing to install, and it authenticates with OAuth or a token. Its tools are grouped into toolsets, and a configuration can enable only the toolsets a task needs and can run the server in read-only mode, which removes every tool that writes. The cloud agent has the GitHub MCP server available by default, scoped to the repository it works in. An exam question about giving an agent the ability to read issues across an organization, but never change them, is a toolsets and read-only question.
Configuring MCP registries. A registry is a catalogue of servers with names, descriptions and connection details. GitHub runs the public GitHub MCP Registry. An enterprise can also run a private registry, for example in Azure API Center, listing only servers its security team has reviewed, and point Copilot at it through the MCP Registry URL policy. The registry makes approved servers easy to find in supported editors.
Configuring MCP allow lists. An allow list decides which servers may run at all. In November 2026 there were two mechanisms, and the difference matters. The older one is the policy Restrict MCP access to registry servers, with the options Allow all and Registry only; with Registry only, only servers from the configured registry may run. GitHub's documentation still described this as public preview and not the recommended method. The recommended method, generally available since August 2026, is enterprise managed settings: a file, copilot/managed-settings.json, in the .github-private repository of the enterprise's source organization, with allowedMcpServers and deniedMcpServers lists. Entries can match a remote server's URL, with wildcards, or a local server's exact command and arguments; matching on the server's name is a convenience only, because users can rename servers. The policies fail closed, so a malformed file blocks rather than allows, and a server must pass every layer of policy. GitHub listed the Copilot app, Copilot CLI and Visual Studio Code as the clients that enforce it.
{
"allowedMcpServers": [
{ "serverUrl": "https://api.githubcopilot.com/mcp/*" },
{ "serverUrl": "https://mcp.skerry.example/*" }
],
"deniedMcpServers": [
{ "serverCommand": "npx -y unvetted-db-mcp" }
]
}Above both sits the switch that decides whether MCP is available at all: the MCP servers in Copilot policy, which an enterprise must enable everywhere, and an organization must enable, before members with Copilot Business or Enterprise can use MCP servers. Seraphine summarized Skerry's layers in one sentence: "The policy turns MCP on, managed settings decide which servers can run, the registry helps people find the good ones, and each repository's configuration decides which tools the cloud agent actually gets."
Worked problem
Permit or provide?
Skerry's security team approves a new internal MCP server for inventory data. Developers can use it in Visual Studio Code, but the cloud agent in the stores repositories still cannot. What is missing?
Show solution
- Managed settings permit the server; they do not configure it for any agent.
- The cloud agent receives MCP servers from the repository's MCP configuration.
- Any secret the server needs must be in the Copilot environment with the COPILOT_MCP_ prefix.
Answer: The repository's cloud agent MCP configuration, with the server, its allowed tools and its secret in the Copilot environment. The allow list was necessary but not sufficient.
Integrating agents within development environments
This group has six bullets, and each corresponds to a decision you can make about where and how an agent runs.
Evaluating the execution context. An agent's execution context is where it runs and what it can reach. Agent mode in an editor runs on the developer's machine, with the developer's files, credentials and network. Copilot CLI runs in a terminal, locally or on a runner. The cloud agent runs in a fresh, temporary environment powered by GitHub Actions, with a clone of one repository, a token limited to that repository and outbound network access controlled by a firewall. An agentic workflow runs as a GitHub Actions job inside a sandboxed container behind the Agent Workflow Firewall. Evaluating the context means asking what the agent could damage or leak there, and whether that is acceptable for the task. An agent that needs no secrets is safer in the cloud agent than on a laptop full of credentials.
Scoping an agent to a specific repository. The cloud agent works in the repository where the task was assigned, and its token reaches only that repository. Custom agents defined in a repository's .github/agents folder are available in that repository; organization or enterprise agents defined centrally are available more widely. A question that asks how to make an agent available in only one repository usually wants the repository-level definition, not an organization-wide one.
Configuring an agent to be invoked in a CI workflow. There are two routes. The first is to run Copilot CLI in a GitHub Actions job: install the CLI, authenticate, and run it non-interactively with a prompt and an explicit list of allowed tools. GitHub's documentation shows the CLI installed with npm, run with the -p option for a prompt, with --allow-tool options for each permitted tool and --no-ask-user so it never waits for input, authenticated either with the workflow's GITHUB_TOKEN where the organization permits it or with a fine-grained token that has the Copilot Requests permission, passed in the COPILOT_GITHUB_TOKEN variable. The second route, which the same documentation recommends, is GitHub Agentic Workflows: a workflow written in Markdown with YAML frontmatter, compiled into a standard Actions workflow lock file, where the agent runs with read-only permissions and proposes changes as safe outputs that separate jobs apply after a threat detection job has scanned them.
name: Nightly link report
on:
schedule:
- cron: '15 6 * * 1-5'
permissions:
contents: read
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v7
- run: npm install -g @github/copilot
- name: Summarize broken links
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_CLI_TOKEN }}
run: |
copilot -p "Read linkcheck.json and summarize broken links by guidebook chapter in report.md" --allow-tool=write --no-ask-user
cat report.md >> "$GITHUB_STEP_SUMMARY"Configuring branch-based scope. The cloud agent creates its own branch, prefixed copilot/, and can push only to branches it created. It cannot push to the default branch. Rulesets on protected branches, required reviews and required checks then decide what happens when its pull request asks to merge. Branch-based scope is also how you isolate parallel agent work, which lesson 7 develops.
Enabling autonomous actions, including creating branches and pull requests. For the cloud agent, an administrator enables the agent through Copilot policies (on Business and Enterprise plans the policy starts off) and in the repositories where it may work; after that, assigning an issue to Copilot or asking it in a pull request starts a session that creates a branch and a pull request. In an agentic workflow, creating a pull request is a declared safe output: the agent asks for it, and a permission-controlled job creates it. In both cases the autonomy is real but bounded: the agent opens the pull request; people and rulesets decide whether it merges.
Handling environment-specific constraints. The cloud agent's environment is prepared by a workflow file, .github/workflows/copilot-setup-steps.yml, with a single job named copilot-setup-steps that installs dependencies before the agent starts. Variables and secrets the agent needs go in the repository's copilot environment. The firewall limits outbound traffic to a recommended allow list plus any entries the repository adds. Tidewater's trail-report validator taught the lesson the hard way: the agent's runs failed because the setup steps lacked a native date library that the CI workflow installed, and the fix was to make the setup steps match CI.
name: Copilot setup steps
on:
workflow_dispatch:
push:
paths: [.github/workflows/copilot-setup-steps.yml]
jobs:
copilot-setup-steps:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v7
with:
node-version: 24
- run: npm ciSafe execution paths and error handling
The last group is about what happens when things go wrong, and it has five bullets: error handling, retries, rollbacks, escalation paths, and traceability and accountability. These are general engineering ideas applied to agents.
| Bullet | What it looks like for agents |
|---|---|
| Error handling | Tools return clear errors; the agent reads them, does not pretend success, and stops when a failure is outside its task |
| Retries | A limited number of retries with waits for transient failures such as a network timeout; no retries for permanent errors; retried actions are safe to repeat |
| Rollbacks | Agent work lands on a branch or pull request that can be closed or reverted; settings changed outside the repository are recorded with their previous values |
| Escalation paths | A defined way to stop and ask: a comment, a label, an assigned person, a failed check, with instructions on when to use it |
| Traceability and accountability | Session logs, signed commits, pull request history, workflow logs, hooks that log tool use, and audit log entries naming the agent and the person it acted for |
Two details are easy to miss. First, retries need idempotent actions. Retrying a test run is harmless; retrying "create a pull request" may create two. Second, escalation must be designed, not hoped for. Tidewater's AGENTS.md has a section on stopping conditions: stop and comment when a change needs files outside the listed area, when a test seems wrong, or when setup fails twice. That gives the agent a defined path other than guessing.
Hooks strengthen both traceability and control. GitHub supports hooks for the cloud agent and for Copilot CLI: JSON files in the repository's .github/hooks folder that run commands at points such as session start, before and after a tool is used, and when the agent stops or an error occurs. A preToolUse hook receives the details of a tool call and can approve or deny it, which makes it a deterministic guardrail, and a postToolUse hook can log each call to a place the team keeps.
Seraphine finished her part of the session with Skerry's numbers: eleven MCP servers approved in the first month, three only in read-only mode, every one listed in managed settings with an owner and a review date. "The exam asks how," she said. "Your security team will ask who decided and when. Write both down."
Common mistakes
MistakeTreating an allow list as if it gives a server to an agent.
InsteadAllow lists permit; a repository or agent configuration provides the server and its tools.
MistakeChoosing the registry-only policy as the recommended allow list method.
InsteadManaged settings with allowed and denied servers are the generally available, recommended method; registry only was still in preview.
MistakeMatching allowed servers by name.
InsteadMatch by URL or exact command; names can be changed by users.
MistakeFixing a cloud agent setup failure by changing the CI workflow.
InsteadFix copilot-setup-steps.yml so the agent's environment matches CI.
MistakeRetrying every failed action.
InsteadRetry transient failures a limited number of times, and only actions that are safe to repeat.
Summary and key terms
- Domain 2 is the heaviest at 20 to 25 percent: tools, MCP, environments and safe execution.
- Choose tools from the task; limit each agent to the tools and permissions it needs.
- MCP layers: the MCP policy turns it on, managed settings allow or deny servers, registries aid discovery, and repository configuration gives tools to an agent.
- Agents run in different contexts: editor, CLI, cloud agent in an Actions-powered environment, or an agentic workflow job; copilot-setup-steps, the copilot environment and the firewall shape the cloud agent.
- Safe execution means clear errors, limited idempotent retries, reversible changes, designed escalation, and traceability through logs, hooks and audit entries.
- MCP allow list
- A control that decides which MCP servers may run, set in enterprise managed settings or through a registry-only policy.
- Managed settings
- An enterprise file, copilot/managed-settings.json in the .github-private repository, that sets Copilot policies such as allowed and denied MCP servers.
- Toolset
- A group of related tools in the GitHub MCP server that can be enabled or left out together.
- copilot-setup-steps
- The workflow job that prepares the cloud agent's environment before a session starts.
- Hook
- A command that runs at a defined point in an agent session, such as before a tool call, and can log or deny the action.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Where are secrets for cloud agent MCP servers stored, and how are they named?
Show answer
In the repository's copilot environment, with names beginning COPILOT_MCP_.
Which two keys hold MCP allow and deny lists in managed settings?
Show answer
allowedMcpServers and deniedMcpServers.
What does read-only mode do for the GitHub MCP server?
Show answer
It removes every tool that writes.
Which options run Copilot CLI non-interactively with specific tools?
Show answer
A prompt with -p, --allow-tool for each permitted tool, and --no-ask-user.
Which hook can deny a tool call?
Show answer
preToolUse.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.