GitHub Copilot CLI
Table of Contents
GitHub Copilot CLI is a powerful command-line tool that brings AI-powered assistance directly to your terminal. This guide walks through installation and configuration, including integration with Microsoft Learn documentation.
Overview
GitHub Copilot CLI provides an interactive terminal assistant that helps with software engineering tasks. It can answer questions, execute commands, search codebases, and integrate with external tools through the Model Context Protocol (MCP). The CLI offers context-aware assistance while you work, making it easier to navigate complex tasks without leaving your terminal.
I am often working with the newer technologies as part of my day job working with partner and I need to make sure that my references are fully up to date. After installing GitHub Copilot I will integrate with the Microsoft Learn MCP server to make sure that is the case, rather than relying on potentially stale training data.
Prerequisites
It is assumed that you have
- curl
- jq
- gh
It is also assumed that you are authenticated to GitHub. (Check with gh auth status.)
Install
Node.js and nvm
First, ensure you have Node.js installed using nvm (Node Version Manager).
This guide is based on installing nvm and Node.js into WLS2, but you can also find guides for Windows and other OS.
-
Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bashThis command adds to your ~/.bashrc. Restart the session.
-
Install a supported Node.js version (22 or later)
nvm install 22 -
Set it as default
nvm alias default 22 nvm use default -
Show the installed versions and the currently set version.
nvm ls
GitHub CLI
-
Install GitHub Copilot CLI
npm install -g @github/copilot@latest -
Verify the installation
copilot --versionExample output:GitHub Copilot CLI 0.0.412. Run 'copilot update' to check for updates. -
Start GitHub Copilot at the CLI
copilotIf you are already using the GitHub CLI (
gh) and you are authenticated (gh auth status) then the GitHub Copilot CLI should use the same credentials.
Adding the Microsoft Learn MCP Server
The GitHub Copilot CLI is already set up with the GitHub MCP Server with a subset of tools suitable for CLI use. (You can override this with a switch to use the full set of tools.) GitHub Copilot will use the same set of stored credentials tha the GitHub CLI uses when connecting to the integrated GitHub MCP server.
In this section we will look at the process to add MCP servers. Here we’ll add the Microsoft Learn MCP server to provide access to official Microsoft documentation directly within Copilot CLI.
-
Start GitHub Copilot at the CLI
copilot -
Run the MCP server configuration command
/mcp add -
Enter the server name
MicrosoftLearn -
Select HTTP for the transport
-
Enter the URL
https://learn.microsoft.com/api/mcp -
Save the configuration with
ctrl+s -
Use
escto close the wizard -
Show the config
You can press
enterimmediately after adding an MCP server into Copilot, or use:/mcp show MicrosoftLearnExample output:● Configured MCP servers: MicrosoftLearn ● MCP configuration saved successfully! Changes will take effect immediately. MCP Server: MicrosoftLearn Type: http URL: https://learn.microsoft.com/api/mcp Status: ✓ Connected Tools (3/3 enabled): ✓ microsoft_code_sample_search: Search for code snippets and examples in official Microsoft ... ✓ microsoft_docs_fetch: Fetch and convert a Microsoft Learn documentation webpage to... ✓ microsoft_docs_search: Search official Microsoft/Azure documentation to find the mo...
-
View the MCP config file
The steps above will create a ~/.copilot/mcp-config.json file. View it using the command below:
jq . ~/.copilot/mcp-config.jsonExample output:```json { "mcpServers": { "MicrosoftLearn": { "type": "http", "url": "https://learn.microsoft.com/api/mcp", "headers": {}, "tools": [ "*" ] } } } ```
! for a single shell command, or switch modes using shift+tab.
Creating Copilot instructions
Create a custom instructions file to enhance Copilot’s behavior:
mkdir -p $HOME/.copilot
cat > $HOME/.copilot/copilot-instructions.md << 'EOF'
# Copilot Instructions
## Microsoft Documentation
When answering questions about Microsoft technologies (Azure, .NET, C#, F#, ASP.NET Core, Microsoft.Extensions, NuGet, Entity Framework, PowerShell, Azure CLI, etc.), always use the `microsoft_docs_search`, `microsoft_docs_fetch`, or `microsoft_code_sample_search` MCP tools to verify information against official Microsoft Learn documentation.
These tools provide access to the latest official documentation and may contain more detailed or newer information than the training data.
EOF
This configuration ensures that Copilot always references official Microsoft documentation when answering questions about Microsoft technologies.
Restarting
After making configuration changes, restart your terminal session or reload your shell configuration:
-
Restart by sourcing your config
source ~/.bashrcUse
source ~/.zshrcfor zsh.
You’re now ready to use GitHub Copilot CLI with full Microsoft Learn integration!