The Copilot SDK can integrate with MCP servers (Model Context Protocol) to extend the assistant's capabilities with external tools. MCP servers run as separate processes and expose tools (functions) that Copilot can invoke during conversations.
Note: This is an evolving feature. See issue #36 for ongoing discussion.
Model Context Protocol (MCP) is an open standard for connecting AI assistants to external tools and data sources. MCP servers can:
The SDK supports two types of MCP servers:
| Type | Description | Use Case |
|---|---|---|
| Local/Stdio | Runs as a subprocess, communicates via stdin/stdout | Local tools, file access, custom scripts |
| HTTP/SSE | Remote server accessed via HTTP | Shared services, cloud-hosted tools |
import { CopilotClient } from "copilot-sdk-supercharged";
const client = new CopilotClient();
const session = await client.createSession({
model: "gpt-5",
mcpServers: {
// Local MCP server (stdio)
"my-local-server": {
type: "local",
command: "node",
args: ["./mcp-server.js"],
env: { DEBUG: "true" },
cwd: "./servers",
tools: ["*"], // "*" = all tools, [] = none, or list specific tools
timeout: 30000,
},
// Remote MCP server (HTTP)
"github": {
type: "http",
url: "https://api.githubcopilot.com/mcp/",
headers: { "Authorization": "Bearer ${TOKEN}" },
tools: ["*"],
},
},
});
import asyncio
from copilot import CopilotClient
async def main():
client = CopilotClient()
await client.start()
session = await client.create_session({
"model": "gpt-5",
"mcp_servers": {
# Local MCP server (stdio)
"my-local-server": {
"type": "local",
"command": "python",
"args": ["./mcp_server.py"],
"env": {"DEBUG": "true"},
"cwd": "./servers",
"tools": ["*"],
"timeout": 30000,
},
# Remote MCP server (HTTP)
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {"Authorization": "Bearer ${TOKEN}"},
"tools": ["*"],
},
},
})
response = await session.send_and_wait({
"prompt": "List my recent GitHub notifications"
})
print(response.data.content)
await client.stop()
asyncio.run(main())
package main
import (
"context"
"log"
copilot "github.com/jeremiahjordanisaacson/copilot-sdk-supercharged/go"
)
func main() {
ctx := context.Background()
client := copilot.NewClient(nil)
if err := client.Start(ctx); err != nil {
log.Fatal(err)
}
defer client.Stop()
// MCPServerConfig is map[string]any for flexibility
session, err := client.CreateSession(ctx, &copilot.SessionConfig{
Model: "gpt-5",
MCPServers: map[string]copilot.MCPServerConfig{
"my-local-server": {
"type": "local",
"command": "node",
"args": []string{"./mcp-server.js"},
"tools": []string{"*"},
},
},
})
if err != nil {
log.Fatal(err)
}
defer session.Destroy()
// Use the session...
}
using GitHub.Copilot.SDK;
await using var client = new CopilotClient();
await using var session = await client.CreateSessionAsync(new SessionConfig
{
Model = "gpt-5",
McpServers = new Dictionary<string, object>
{
["my-local-server"] = new McpLocalServerConfig
{
Type = "local",
Command = "node",
Args = new List<string> { "./mcp-server.js" },
Tools = new List<string> { "*" },
},
},
});
Here's a complete working example using the official @modelcontextprotocol/server-filesystem MCP server:
import { CopilotClient } from "copilot-sdk-supercharged";
async function main() {
const client = new CopilotClient();
// Create session with filesystem MCP server
const session = await client.createSession({
mcpServers: {
filesystem: {
type: "local",
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
tools: ["*"],
},
},
});
console.log("Session created:", session.sessionId);
// The model can now use filesystem tools
const result = await session.sendAndWait({
prompt: "List the files in the allowed directory",
});
console.log("Response:", result?.data?.content);
await session.destroy();
await client.stop();
}
main();
Output:
Session created: 18b3482b-bcba-40ba-9f02-ad2ac949a59a
Response: The allowed directory is `/tmp`, which contains various files
and subdirectories including temporary system files, log files, and
directories for different applications.
Tip: You can use any MCP server from the MCP Servers Directory. Popular options include
@modelcontextprotocol/server-github,@modelcontextprotocol/server-sqlite, and@modelcontextprotocol/server-puppeteer.
| Property | Type | Required | Description |
|---|---|---|---|
type | "local" or "stdio" | No | Server type (defaults to local) |
command | string | Yes | Command to execute |
args | string[] | Yes | Command arguments |
env | object | No | Environment variables |
cwd | string | No | Working directory |
tools | string[] | No | Tools to enable (["*"] for all, [] for none) |
timeout | number | No | Timeout in milliseconds |
| Property | Type | Required | Description |
|---|---|---|---|
type | "http" or "sse" | Yes | Server type |
url | string | Yes | Server URL |
headers | object | No | HTTP headers (e.g., for auth) |
tools | string[] | No | Tools to enable |
timeout | number | No | Timeout in milliseconds |
Verify the MCP server starts correctly
Check tool configuration
tools is set to ["*"] or lists the specific tools you need[] means no tools are enabledVerify connectivity for remote servers
| Issue | Solution |
|---|---|
| "MCP server not found" | Verify the command path is correct and executable |
| "Connection refused" (HTTP) | Check the URL and ensure the server is running |
| "Timeout" errors | Increase the timeout value or check server performance |
| Tools work but aren't called | Ensure your prompt clearly requires the tool's functionality |
For detailed debugging guidance, see the MCP Debugging Guide.
Can you improve this documentation? These fine people already did:
Jeremiah Isaacson & Patrick NikoletichEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |