Copilotintermediate

How to Set Up MCP Servers with GitHub Copilot CLI

Configure Model Context Protocol (MCP) servers in GitHub Copilot CLI to extend functionality with custom tools, databases, and external services. Complete setup guide with examples.

12 min readUpdated January 2025

Want us to handle this for you?

Get expert help →

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.

The easiest way to add an MCP server:

  1. Start Copilot CLI:
copilot
  1. Use the /mcp add command:
/mcp add filesystem
  1. Follow the interactive prompts to configure the server

  2. 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:

FieldDescriptionRequired
typeServer type, typically "stdio" for local serversYes
commandThe command to run the serverYes
argsArray of command-line argumentsYes
toolsArray of specific tools to enable (optional - enables all if omitted)No
envEnvironment variables to pass to the serverNo

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:

  1. Create the .copilot directory in your repository root:
mkdir -p .copilot
  1. Create the MCP configuration file:
touch .copilot/mcp-config.json
  1. Add your shared MCP configuration:
{
  "mcpServers": {
    "project-db": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": {
        "POSTGRES_CONNECTION_STRING": "${DATABASE_URL}"
      }
    }
  }
}
  1. 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:

  1. Repository-level config (.copilot/mcp-config.json) is loaded first
  2. User-level config (~/.copilot/mcp-config.json) can override or extend
  3. 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:

  1. Navigate to your organization's settings
  2. Go to Copilot > Policies
  3. Find the MCP (Model Context Protocol) section
  4. Enable MCP for your organization
  5. 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):

  • filesystem
  • postgres
  • azure

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:

ServerPurposePackage
GitHub (built-in)GitHub.com integrationIncluded
FilesystemFile read/write operations@modelcontextprotocol/server-filesystem
PostgreSQLDatabase queries@modelcontextprotocol/server-postgres
Azure MCPAzure cloud services@azure/mcp-server
NeonNeon serverless Postgres@neondatabase/mcp-server-neon
SerenaAI coding assistant enhancementserena-mcp-server

Known Limitations

Be aware of these current limitations:

  1. Tool limit: Maximum of 128 tools per request across all MCP servers
  2. No OAuth support: Remote MCP servers requiring OAuth authentication are not supported
  3. Local execution only: MCP servers run locally on your machine
  4. Default GitHub tools limited: Must use --enable-all-github-mcp-tools for full GitHub access
  5. 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:

  1. Verify the configuration file syntax is valid JSON
  2. Check that the command is available in your PATH
  3. Ensure all required environment variables are set
  4. Try running the MCP server command manually to check for errors

"MCP is not enabled" Error

If you see this error in an organization:

  1. Contact your GitHub organization administrator
  2. Request that MCP be enabled in Copilot policies
  3. If using an allowlist, ensure your server name is permitted

Tools Not Available

If specific tools are not available:

  1. Check if you have exceeded the 128 tool limit
  2. Verify the MCP server provides the expected tools
  3. Try enabling tools explicitly in the tools array

Server Crashes or Timeouts

If MCP servers are unstable:

  1. Check server logs for errors
  2. Ensure sufficient system resources
  3. Verify network connectivity for servers requiring external access
  4. Update the MCP server package to the latest version

Next Steps


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.

Frequently Asked Questions

Find answers to common questions

MCP (Model Context Protocol) servers extend Copilot's capabilities by providing additional tools and context. For example, you can add database access, file system operations, cloud service integrations, or custom business logic that Copilot can use during conversations.

Need Professional IT & Security Help?

Our team of experts is ready to help protect and optimize your technology infrastructure.