Skip to content

๐Ÿ”ง Setting Up & Configuring MCP Servers

You know how MCP works under the hood. Now let's get practical โ€” how do you actually add, configure, and manage MCP servers in Copilot CLI?


The Control Centre: mcp-config.json

Every MCP server you use is defined in one file:

C:\Users\<your-username>\.copilot\mcp-config.json

This is the control centre โ€” it tells Copilot which servers to start, how to start them, and what credentials to use.

โ˜• The Cafรฉ Staff Rota Analogy

Think of mcp-config.json as the staff rota pinned on the cafรฉ wall:

Staff Rota mcp-config.json
Staff member's name Server name (e.g., "azure")
Their role (barista, chef, cleaner) Server type (e.g., "stdio")
How to reach them (phone number, walkie-talkie channel) Command to run (e.g., "node server.js")
Access credentials (keys, passwords) Environment variables (API keys, secrets)

Anatomy of the Config File

Here's your actual config, annotated:

{
  "mcpServers": {                          // ๐Ÿ‘ˆ All servers live here
    "m365-admin-graph": {                  // ๐Ÿ‘ˆ Server name (you choose this)
      "type": "stdio",                     // ๐Ÿ‘ˆ Transport: local process
      "command": "node",                   // ๐Ÿ‘ˆ What program to run
      "args": [                            // ๐Ÿ‘ˆ Arguments passed to the program
        "C:\\...\\server.js"
      ],
      "env": {                             // ๐Ÿ‘ˆ Environment variables (secrets!)
        "M365_TENANT_ID": "...",
        "M365_CLIENT_ID": "...",
        "M365_CLIENT_SECRET": "..."
      }
    },
    "azure": {
      "type": "stdio",
      "command": "npx",                    // ๐Ÿ‘ˆ Downloads fresh each time
      "args": ["-y", "@azure/mcp@latest", "server", "start"]
    },
    "youtube-channel-mcp": {
      "type": "stdio",
      "command": "node",
      "args": ["C:\\...\\server.js"]       // ๐Ÿ‘ˆ No env โ€” uses stored OAuth tokens
    }
  }
}

Every Server Entry Has These Fields

Field Required? What It Does Example
type โœ… Yes How Copilot talks to the server "stdio" (local) or "http" (remote)
command โœ… Yes (stdio) The program to run "node", "npx", "python"
args โœ… Yes (stdio) Arguments for the command ["server.js"] or ["-y", "@azure/mcp@latest"]
url โœ… Yes (http) URL of the remote server "https://mcp.example.com"
env โŒ Optional Environment variables (secrets, config) {"API_KEY": "abc123"}
headers โŒ Optional (http) HTTP headers for authentication {"Authorization": "Bearer ..."}

This file contains secrets!

Your mcp-config.json may contain API keys, client secrets, and tenant IDs. Never share it publicly or commit it to GitHub. Your daily backup to OneDrive keeps it safe.


Two Ways to Install MCP Servers

There are two main approaches, and your config uses both:

1. npm install โ€” Permanent Local Copy ๐Ÿ“ฆ

This downloads the server code permanently to your machine. It's there forever (until you delete it).

# Install the server globally
npm install -g youtube-channel-mcp

# Or install to a specific folder
cd ~/.copilot/mcp-servers
npm install m365-admin-graph-mcp

Config points to the local file:

{
  "command": "node",
  "args": ["C:\\Users\\...\\server.js"]
}

Pros Cons
โšก Fast startup (already on disk) ๐Ÿ“ฆ Takes disk space
๐Ÿ”’ Specific version (won't surprise you) ๐Ÿ”„ Must manually update
๐ŸŒ Works offline (after first install)

Your servers using this: m365-admin-graph, youtube-channel-mcp

2. npx โ€” Download Fresh Each Time ๐Ÿ”„

This downloads the latest version every time Copilot starts the server. Nothing stored permanently.

# npx downloads and runs in one command
npx -y @azure/mcp@latest server start

Config uses npx directly:

{
  "command": "npx",
  "args": ["-y", "@azure/mcp@latest", "server", "start"]
}

Pros Cons
๐Ÿ”„ Always latest version ๐ŸŒ Slower startup (downloads first)
๐Ÿ’พ No permanent disk space ๐ŸŒ Needs internet every time
๐Ÿงน No cleanup needed โŒ Won't work offline

Your server using this: azure

โ˜• Cafรฉ Analogy

Method Cafรฉ Version
npm install Hiring a permanent staff member โ€” they live nearby, show up instantly, but you need to send them on training courses (updates) yourself
npx Hiring from a temp agency โ€” fresh person every day with the latest training, but they need time to commute (download) and won't show up if the agency is closed (no internet)

Which should you use?

  • npm install when you want reliability and speed (servers you use daily)
  • npx when you want automatic updates and don't mind the startup delay (Azure MCP works great this way)

Three Ways to Add an MCP Server

Method 1: /mcp Command (Easiest) โญ

The /mcp command inside Copilot CLI gives you an interactive menu:

/mcp

This shows you: - All configured servers and their status (running/stopped/error) - Options to add, remove, and configure servers

Best for beginners

/mcp is the safest way to add servers โ€” it validates the config and won't let you break things. Use this first!

Method 2: Ask Copilot in Plain English

Just tell Copilot what you want:

"Add the GitHub MCP server to my config"

"Set up a Playwright browser automation MCP server"

Copilot will edit the config file for you and restart the server.

Method 3: Edit mcp-config.json Manually

Open the file directly:

notepad "$HOME\.copilot\mcp-config.json"

Add a new entry inside "mcpServers":

{
  "mcpServers": {
    "existing-server": { ... },
    "new-server": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "some-mcp-package@latest"]
    }
  }
}

JSON is Picky

If you edit manually, watch for:

  • Commas between entries โ€” every server needs a comma after it, EXCEPT the last one
  • Matching braces โ€” every { needs a }
  • No trailing commas โ€” "value",} will break the whole file

If you mess up, Copilot won't be able to read the config and ALL MCP servers will stop working. When in doubt, use Method 1 or 2!


Authentication โ€” How Servers Prove Who You Are

Different MCP servers use different ways to authenticate:

Your Three Servers, Three Auth Methods

Server Auth Method How It Works Cafรฉ Analogy
m365-admin-graph Client Secret (env vars) App has its own ID + password, passed as environment variables A staff member with their own set of keys to the building
azure Azure CLI login Uses YOUR personal az login session Staff member uses your master key โ€” they act as you
youtube-channel-mcp OAuth2 tokens (stored) One-time browser login, tokens saved to disk Staff member logged in once, gets a reusable pass card

Environment Variables (env)

The env field passes secrets to the server process as environment variables โ€” values that exist only while the server is running:

"env": {
  "M365_TENANT_ID": "00b98149-...",
  "M365_CLIENT_ID": "41458c1c-...",
  "M365_CLIENT_SECRET": "AKm8Q~~..."
}

Why environment variables?

Environment variables are the standard way to pass secrets to applications. They're:

  • Not visible to other programs on your machine
  • Not saved in log files or command history
  • Temporary โ€” they only exist while the server process is running

It's like whispering the password to the staff member instead of writing it on the whiteboard.

Azure CLI Login

The Azure MCP server doesn't need env vars โ€” it reuses your existing Azure CLI session:

# You log in once (this opens a browser)
az login

# The Azure MCP server then uses this session automatically
# No secrets in the config file!

This is the simplest auth method but means the server acts as you โ€” it has whatever permissions your Azure account has.

OAuth2 Tokens

The YouTube MCP server uses OAuth2 โ€” you log in through a browser once, and it saves tokens locally:

~\.copilot\mcp-servers\youtube-channel-mcp\tokens.json  (stored after first login)

These tokens expire and need refreshing. The server handles this automatically, but if it stops working, delete the tokens file and log in again.


Verifying Your MCP Servers

After setting up a server, here's how to check it's working:

1. Check Status with /mcp

/mcp

Look for: - ๐ŸŸข Running โ€” server is healthy - ๐Ÿ”ด Error โ€” something is wrong (check the error message) - โšช Stopped โ€” server isn't running

2. Ask a Simple Question

The fastest test is asking Copilot something that requires that server:

Server Test Question
m365-admin-graph "How many users are in my lab?"
azure "List my Azure resource groups"
youtube-channel-mcp "Show my YouTube channel stats"

If you get an answer, the server is working. If you get an error, check the error message โ€” it usually tells you exactly what's wrong.

3. Check Logs (Advanced)

If a server is misbehaving, Copilot shows MCP errors in its output. Common errors:

Error Message What It Means Fix
"Failed to start MCP server" Command in config is wrong Check command and args โ€” is the path correct?
"ENOENT: no such file" The server file doesn't exist Reinstall with npm, or check the file path
"Authentication failed" Credentials are wrong or expired Re-authenticate or update env vars
"Connection refused" Server started but crashed immediately Check if all required env vars are set

Common Recipes

Add an npm Server (Permanent)

# 1. Install the package
npm install -g some-mcp-server

# 2. Find where it was installed
npm root -g
# โ†’ C:\Users\ssutheesh\AppData\Roaming\npm\node_modules

# 3. Add to mcp-config.json (or ask Copilot to do it)

Add an npx Server (Always Latest)

Just add this to your config:

"server-name": {
  "type": "stdio",
  "command": "npx",
  "args": ["-y", "package-name@latest"]
}

Add a Remote HTTP Server

"remote-server": {
  "type": "http",
  "url": "https://mcp.example.com/api",
  "headers": {
    "Authorization": "Bearer your-api-key-here"
  }
}

Quick Summary

Topic Key Takeaway
Config file ~/.copilot/mcp-config.json โ€” the single source of truth for all MCP servers
npm vs npx npm = permanent & fast; npx = always latest but slower startup
Adding servers Use /mcp (safest), ask Copilot (easiest), or edit JSON manually (most control)
Authentication Env vars (secrets), Azure CLI login (your identity), or OAuth2 tokens (stored)
Verification /mcp for status, ask a test question, or check error messages

What you can now do

  • โœ… Read and understand your mcp-config.json
  • โœ… Know the difference between npm install and npx
  • โœ… Add a new MCP server using three different methods
  • โœ… Understand how authentication works for different server types
  • โœ… Troubleshoot when an MCP server isn't working

๐Ÿ’ก Next up: Managing MCP Servers โ€” day-to-day operations with the /mcp command, restarting servers, and handling updates.