MCP Servers
Prerequisites
- Completed Modules 1-5
- Understanding of JSON configuration
- Node.js and npm installed
Learning Objectives
- Understand the Model Context Protocol (MCP)
- Configure remote and local MCP servers
- Use the GitHub MCP server for repository operations
- Add custom MCP servers to extend Copilot's capabilities
- Manage MCP servers with slash commands
Concepts
What is MCP?
Model Context Protocol (MCP) is an open standard that extends AI capabilities:
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Copilot CLI │────▶│ MCP Server │────▶│ External │
│ │ │ │ │ Resources │
└─────────────┘ └─────────────┘ └─────────────┘
│
┌──────┴──────┐
│ Tools │
│ Prompts │
│ Resources │
└─────────────┘
Debugging MCP Servers
As of v0.0.410, MCP server errors now appear in the timeline view, making it easier to diagnose connection and configuration issues:
copilot
In the session, use /timeline to view the event history. MCP server errors will be displayed with details about:
- Server startup failures
- Connection errors
- Tool invocation errors
- Configuration issues
MCP error visibility in the timeline significantly improves the debugging experience when working with custom MCP servers, as errors are no longer silently ignored.
Server Types
| Type | Location | Use Case |
|---|---|---|
| Remote | Hosted externally | Team-wide tools, cloud services |
| Local | Runs on your machine | Local resources, custom tools |
| Built-in | Included with Copilot | GitHub integration |
Configuration Location
MCP servers are configured in:
- Default:
~/.copilot/mcp-config.json - Custom: Set via
XDG_CONFIG_HOME
Hands-On Exercises
Exercise 1: Explore the GitHub MCP Server
Goal: Use the built-in GitHub MCP server.
Steps:
-
Start Copilot:
copilot -
View current MCP configuration:
/mcp showAs of v0.0.415,
/mcp showgroups servers into User, Workspace, Plugins, and Built-in sections for easier navigation. -
The GitHub MCP server is pre-configured. Try using it:
What are the open issues in this repository? -
If you have a GitHub repository:
Show me the recent pull requests -
GitHub MCP provides tools for:
- Viewing issues and PRs
- Reading repository content
- Accessing organization info
- Interacting with GitHub resources
Expected Outcome: Copilot can access GitHub resources through the built-in MCP server.
Manually editing ~/.copilot/mcp-config.json is straightforward. The command structure for MCP config follows the standard MCP specification. Verify the JSON syntax is valid before restarting Copilot.
Exercise 2: Configure a Remote MCP Server
Goal: Add a remote MCP server with authentication.
Steps:
-
View current config file:
cat ~/.copilot/mcp-config.json -
Start Copilot and use the interactive MCP setup:
copilot/mcp add -
Use Tab to navigate between fields:
- Name:
github-api - Type: remote
- URL:
https://api.githubcopilot.com/mcp/ - Auth Header:
Authorization: Bearer YOUR_PAT_HERE
- Name:
-
Press
Ctrl+Sto save. -
Verify the configuration:
/mcp show -
Alternatively, edit the config file directly:
cat > ~/.copilot/mcp-config.json << 'EOF'
{
"servers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/",
"requestInit": {
"headers": {
"Authorization": "Bearer ${GITHUB_TOKEN}"
}
}
}
}
}
EOF
Expected Outcome: Remote MCP server configured and accessible.
Exercise 3: Add a Local MCP Server
Goal: Configure a locally-running MCP server.
Steps:
-
Install the MCP memory server:
npm install -g @modelcontextprotocol/server-memory -
Add it to your MCP config:
cat > ~/.copilot/mcp-config.json << 'EOF'
{
"servers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/"
},
"memory": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-memory"
]
}
}
}
EOF -
Restart Copilot to load the new server:
copilot -
Verify the server is loaded:
/mcp show -
Test the memory server:
Remember that my favorite programming language is Rust -
Later in the session:
What's my favorite programming language?
Expected Outcome: Local MCP server runs and provides additional capabilities.
Exercise 4: File System MCP Server
Goal: Add an MCP server for enhanced file operations.
Steps:
-
Install the filesystem MCP server:
npm install -g @modelcontextprotocol/server-filesystem -
Update MCP config with directory restrictions (using tilde expansion):
cat > ~/.copilot/mcp-config.json << 'EOF'
{
"servers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/"
},
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"~/projects"
],
"cwd": "~/projects"
}
}
}
EOFNote: You can use
~for home directory in both args andcwd(v0.0.410+). -
Restart Copilot (or use
/mcp reloadin v0.0.412+):copilot -
Check the timeline for any MCP server errors:
/timelineIf there are configuration issues, they'll appear here (v0.0.410+).
-
Test file operations through MCP:
Using the filesystem server, list all TypeScript files in my projects
Expected Outcome: MCP server provides structured file access with defined boundaries. Any startup errors are visible in the timeline.
Exercise 5: MCP Server Management Commands
Goal: Master MCP management through slash commands.
Steps:
-
Start Copilot:
copilot -
Show all servers:
/mcp show -
Add a new server interactively:
/mcp addFill in details and
Ctrl+Sto save. -
Edit an existing server:
/mcp edit memory -
Reload configuration without restarting (v0.0.412+):
/mcp reloadThis is useful when you've edited
~/.copilot/mcp-config.jsondirectly or want to pick up changes without exiting your current session. -
Disable a server temporarily:
/mcp disable memory -
Re-enable it:
/mcp enable memory -
Delete a server:
/mcp delete memory
Expected Outcome: You can manage MCP servers without editing config files, and reload configuration changes instantly.
Exercise 6: Using MCP Tools with Permissions
Goal: Control MCP tool access with allow/deny flags.
Steps:
-
Allow specific MCP server in programmatic mode:
copilot -p "Check my GitHub notifications" \
--allow-tool 'github' -
Allow all MCP tools:
copilot -p "Use memory to store my preferences" \
--allow-tool 'memory' -
Deny specific MCP server while allowing others:
copilot -p "Analyze the project" \
--allow-all-tools \
--deny-tool 'github' -
Combine with other tool permissions:
copilot -p "Review code and check GitHub issues" \
--allow-tool 'shell(cat)' \
--allow-tool 'github' \
--deny-tool 'write'
Expected Outcome: MCP server tools follow the same permission model as built-in tools.
Exercise 7: Temporary MCP Configuration
Goal: Use additional MCP servers for specific sessions.
Steps:
-
Create a temporary MCP config file:
cat > /tmp/temp-mcp.json << 'EOF'
{
"servers": {
"brave-search": {
"command": "npx",
"args": [
"-y",
"@anthropic/mcp-server-brave-search"
],
"env": {
"BRAVE_API_KEY": "${BRAVE_API_KEY}"
}
}
}
}
EOF -
Start Copilot with the additional config:
copilot --additional-mcp-config /tmp/temp-mcp.json -
The temporary servers are available for this session only.
-
Verify:
/mcp show -
The base config + temporary config are merged.
Expected Outcome: Additional MCP servers can be loaded per-session without modifying base config.
MCP Configuration Reference
Remote Server Schema
{
"servers": {
"server-name": {
"url": "https://example.com/mcp/",
"requestInit": {
"headers": {
"Authorization": "Bearer TOKEN"
}
}
}
}
}
Local Server Schema
{
"servers": {
"server-name": {
"command": "npx",
"args": ["-y", "@package/server-name"],
"env": {
"API_KEY": "${ENV_VAR}"
},
"cwd": "~/projects/my-server"
}
}
}
Common MCP Servers
| Server | Package | Purpose |
|---|---|---|
| Memory | @modelcontextprotocol/server-memory | Persistent memory |
| Filesystem | @modelcontextprotocol/server-filesystem | File operations |
| GitHub | Built-in | GitHub integration |
| PostgreSQL | @modelcontextprotocol/server-postgres | Database queries |
| Slack | @modelcontextprotocol/server-slack | Slack integration |
| Brave Search | @anthropic/mcp-server-brave-search | Web search |
Slash Commands
| Command | Description |
|---|---|
/mcp show | Display all MCP servers (grouped by source since v0.0.415) |
/mcp add | Add a new server interactively |
/mcp edit NAME | Edit an existing server |
/mcp delete NAME | Remove a server |
/mcp disable NAME | Temporarily disable |
/mcp enable NAME | Re-enable a disabled server |
/mcp reload | Reload MCP configuration without restarting (v0.0.412+) |
Summary
- ✅ MCP extends Copilot with custom tools and resources
- ✅ Built-in GitHub MCP server provides repository access
- ✅ Local servers run on your machine for local resources
- ✅ Remote servers connect to external services
- ✅
/mcpcommands manage servers without editing files - ✅
/mcp reloadreloads configuration without restarting (v0.0.412+) - ✅ Tilde (
~) expansion works incwdpaths (v0.0.410+) - ✅ MCP server errors appear in timeline for easier debugging (v0.0.410+)
- ✅ Giant single-line MCP tool results are now truncated correctly (v0.0.415)
- ✅
--additional-mcp-configloads temporary servers
Next Steps
→ Continue to Module 7: Agent Skills