GitHub Copilot CLI fully supports the Model Context Protocol (MCP), allowing you to extend its capabilities with custom tools and integrations. This guide covers setting up MCP servers, configuring the built-in GitHub MCP server, and managing server configurations for both personal and repository-level use.
Prerequisites
Before setting up MCP servers, ensure you have:
- GitHub Copilot CLI installed (installation guide)
- Active Copilot subscription (Individual, Business, or Enterprise)
- MCP enabled in your organization (Business/Enterprise users - see admin section below)
- Node.js installed if running Node-based MCP servers
Understanding MCP in Copilot
MCP (Model Context Protocol) is an open standard that allows AI assistants to connect with external data sources and tools. In Copilot CLI, MCP servers can provide:
- Database access (PostgreSQL, Neon, etc.)
- File system operations (read/write files, search directories)
- Cloud integrations (Azure, AWS, GitHub)
- Custom business logic (internal APIs, proprietary tools)
Built-in GitHub MCP Server
Copilot CLI includes a built-in GitHub MCP server that provides tools for interacting with GitHub.com:
- Search repositories, issues, and pull requests
- Read file contents from repositories
- Access GitHub API endpoints
- Query code search results
By default, only a subset of GitHub tools are enabled. You can enable all GitHub MCP tools using a CLI flag.
Adding MCP Servers
You can add MCP servers using the /mcp add slash command or by editing the configuration file directly.
Method 1: Using the /mcp Command (Recommended)
The easiest way to add an MCP server:
- Start Copilot CLI:
copilot
- Use the
/mcp addcommand:
/mcp add filesystem
-
Follow the interactive prompts to configure the server
-
View your current MCP configuration:
/mcp show
Method 2: Editing the Configuration File
For more control, edit the MCP configuration file directly.
Configuration file location:
- User-level:
~/.copilot/mcp-config.json - Repository-level:
.copilot/mcp-config.json(in your project root)
Create or edit the configuration file:
{
"mcpServers": {
"filesystem": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/directory"],
"env": {}
}
}
}
Configuration Format
Each MCP server entry requires:
| Field | Description | Required |
|---|---|---|
type | Server type, typically "stdio" for local servers | Yes |
command | The command to run the server | Yes |
args | Array of command-line arguments | Yes |
tools | Array of specific tools to enable (optional - enables all if omitted) | No |
env | Environment variables to pass to the server | No |
Configuration Examples
PostgreSQL Database Server
Connect Copilot to a PostgreSQL database for querying data:
{
"mcpServers": {
"postgres": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "postgresql://user:password@localhost:5432/mydb"
}
}
}
}
Filesystem Access
Allow Copilot to read and write files in specific directories:
{
"mcpServers": {
"filesystem": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/myuser/projects",
"/Users/myuser/documents"
],
"env": {}
}
}
}
Azure MCP Server
Connect to Azure services for cloud resource management:
{
"mcpServers": {
"azure": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@azure/mcp-server"],
"env": {
"AZURE_SUBSCRIPTION_ID": "your-subscription-id",
"AZURE_TENANT_ID": "your-tenant-id"
}
}
}
}
Neon Database Server
Connect to Neon serverless PostgreSQL:
{
"mcpServers": {
"neon": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@neondatabase/mcp-server-neon"],
"env": {
"NEON_API_KEY": "your-neon-api-key"
}
}
}
}
Multiple Servers Configuration
You can configure multiple MCP servers in a single configuration:
{
"mcpServers": {
"filesystem": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"],
"env": {}
},
"postgres": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "postgresql://localhost/mydb"
}
},
"github-extended": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "ghp_your_personal_access_token"
}
}
}
}
Built-in GitHub MCP Features
Copilot CLI includes a built-in GitHub MCP server with limited tools enabled by default. To enable all GitHub MCP tools:
Enable All GitHub Tools
Use the --enable-all-github-mcp-tools flag when starting Copilot:
copilot --enable-all-github-mcp-tools
This unlocks additional GitHub operations including:
- Creating and updating issues
- Managing pull requests
- Repository management
- Advanced search capabilities
Using Additional MCP Config at Startup
Load additional MCP servers from a specific config file:
copilot --additional-mcp-config /path/to/custom-mcp-config.json
This is useful for project-specific configurations or testing new MCP servers.
Repository-Level Configuration
Teams can share MCP configurations by including a .copilot/mcp-config.json file in their repository:
- Create the
.copilotdirectory in your repository root:
mkdir -p .copilot
- Create the MCP configuration file:
touch .copilot/mcp-config.json
- Add your shared MCP configuration:
{
"mcpServers": {
"project-db": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "${DATABASE_URL}"
}
}
}
}
- Commit the configuration to your repository:
git add .copilot/mcp-config.json
git commit -m "Add Copilot MCP configuration for project database"
Note: Use environment variable references (like ${DATABASE_URL}) for sensitive values instead of hardcoding credentials.
Configuration Precedence
When both user and repository configurations exist:
- Repository-level config (
.copilot/mcp-config.json) is loaded first - User-level config (
~/.copilot/mcp-config.json) can override or extend - CLI flags (
--additional-mcp-config) take highest precedence
Organization and Admin Settings
Enabling MCP for Your Organization
MCP is disabled by default in GitHub organizations. Administrators must enable it:
- Navigate to your organization's settings
- Go to Copilot > Policies
- Find the MCP (Model Context Protocol) section
- Enable MCP for your organization
- Optionally configure an allowlist of permitted MCP servers
MCP Server Allowlist
Organizations can restrict which MCP servers users can add:
- Allowlist enforcement is by name only (the server name in the configuration)
- Users cannot add servers not on the allowlist
- Built-in GitHub MCP server is always available when MCP is enabled
Example allowlist configuration (admin setting):
filesystempostgresazure
Users attempting to add a server not on the list will receive an error.
Compatible MCP Servers
These MCP servers are known to work with Copilot CLI:
| Server | Purpose | Package |
|---|---|---|
| GitHub (built-in) | GitHub.com integration | Included |
| Filesystem | File read/write operations | @modelcontextprotocol/server-filesystem |
| PostgreSQL | Database queries | @modelcontextprotocol/server-postgres |
| Azure MCP | Azure cloud services | @azure/mcp-server |
| Neon | Neon serverless Postgres | @neondatabase/mcp-server-neon |
| Serena | AI coding assistant enhancement | serena-mcp-server |
Known Limitations
Be aware of these current limitations:
- Tool limit: Maximum of 128 tools per request across all MCP servers
- No OAuth support: Remote MCP servers requiring OAuth authentication are not supported
- Local execution only: MCP servers run locally on your machine
- Default GitHub tools limited: Must use
--enable-all-github-mcp-toolsfor full GitHub access - Allowlist by name: Organization allowlists match server names only, not the actual package
Troubleshooting
MCP Server Not Loading
If your MCP server is not appearing:
- Verify the configuration file syntax is valid JSON
- Check that the
commandis available in your PATH - Ensure all required environment variables are set
- Try running the MCP server command manually to check for errors
"MCP is not enabled" Error
If you see this error in an organization:
- Contact your GitHub organization administrator
- Request that MCP be enabled in Copilot policies
- If using an allowlist, ensure your server name is permitted
Tools Not Available
If specific tools are not available:
- Check if you have exceeded the 128 tool limit
- Verify the MCP server provides the expected tools
- Try enabling tools explicitly in the
toolsarray
Server Crashes or Timeouts
If MCP servers are unstable:
- Check server logs for errors
- Ensure sufficient system resources
- Verify network connectivity for servers requiring external access
- Update the MCP server package to the latest version
Next Steps
- Learn about Copilot CLI agents for task automation
- Explore slash commands for efficient workflows
- Set up Copilot with GitHub Actions for CI/CD integration
- Compare with Claude Code MCP setup for another AI coding tool
Need help configuring Copilot for your team? Inventive HQ provides AI developer tool consulting, including Copilot deployment and MCP server integration. Contact us for a free consultation.