Примечание.
Второй пилот SDK is currently in Technical Preview. Functionality and availability are subject to change.
The Второй пилот 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.
What is MCP?
Model Context Protocol (MCP) is an open standard for connecting AI assistants to external tools and data sources. MCP servers can execute code or scripts, query databases, access file systems, call external APIs, and more.
Server types
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 |
Configuration
import { CopilotClient } from "@github/copilot-sdk";
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: ["*"],
},
},
});
For examples in Python, Go, and .NET, see the github/copilot-sdk repository.
Quick start: filesystem MCP server
Here's a complete working example using the official @modelcontextprotocol/server-filesystem MCP server:
import { CopilotClient } from "@github/copilot-sdk";
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.disconnect();
await client.stop();
}
main();
Совет
You can use any MCP server from the MCP Servers Directory. Popular options include @modelcontextprotocol/server-github, @modelcontextprotocol/server-sqlite, and @modelcontextprotocol/server-puppeteer.
Configuration options
Local/Stdio server
| 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 |
Remote server (HTTP/SSE)
| Property | Type | Required | Description |
|---|---|---|---|
type | "http" or "sse" | Yes | Server type |
url | string | Yes | Server URL |
headers | object | No | HTTP headers (for example, for auth) |
tools | string[] | No | Tools to enable |
timeout | number | No | Timeout in milliseconds |
Troubleshooting
Tools not showing up or not being invoked
- Verify the MCP server starts correctly—Check that the command and arguments are correct, and ensure the server process doesn't crash on startup. Look for error output in stderr.
- Check tool configuration—Make sure
toolsis set to["*"]or lists the specific tools you need. An empty array[]means no tools are enabled. - Verify connectivity for remote servers—Ensure the URL is accessible and check that authentication headers are correct.
Common issues
| 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 |
Further reading
- Model Context Protocol specification
- MCP Servers Directory—community MCP servers
- GitHub MCP Server—official GitHub MCP server