-
Notifications
You must be signed in to change notification settings - Fork 347
docs: Add GitHub Copilot SDK Configuration section with code snippets #1577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add new 'GitHub Copilot SDK Configuration' section to README - Include collapsible 'GitHub Copilot SDK snippets' with examples for: - Python (github-copilot-sdk) - Node.js/TypeScript (@anthropic-ai/github-copilot-sdk) - Go (github.com/github/copilot-sdk-go) - .NET (GitHub.Copilot.SDK) - Document MCP server session configuration for Azure MCP integration - Add prerequisites and key configuration insights
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive documentation for integrating Azure MCP Server with the GitHub Copilot SDK across four programming languages (Python, Node.js/TypeScript, Go, and .NET). The documentation follows a similar pattern to the existing "GitHub Copilot CLI Configuration" section but focuses on programmatic SDK integration rather than CLI usage.
Changes:
- Added new "GitHub Copilot SDK Configuration" section with collapsible code examples
- Provided installation instructions and configuration snippets for Python, Node.js/TypeScript, Go, and .NET
- Documented MCP server session configuration patterns across all supported languages
Comments suppressed due to low confidence (10)
servers/Azure.Mcp.Server/README.md:403
- Same terminology inconsistency - should use "Copilot SDK" instead of "Copilot CLI SDK" to accurately describe the programmatic SDK being configured.
Azure MCP provides a set of tools that enable AI assistants to interact with Azure resources directly. When integrated with the Copilot CLI SDK, you can build applications that leverage natural language to manage Azure subscriptions, resource groups, storage accounts, and more.
servers/Azure.Mcp.Server/README.md:548
- The model name "gpt-4.1" does not exist. This is the same issue as in the Python example - use a valid model name like "gpt-4", "gpt-4-turbo", or "gpt-4o".
model: 'gpt-4.1', // Default model; BYOK can override
servers/Azure.Mcp.Server/README.md:703
- The model name "gpt-4.1" does not exist. Use a valid model name like "gpt-4", "gpt-4-turbo", or "gpt-4o".
Model = "gpt-4.1", // Default model; BYOK can override
servers/Azure.Mcp.Server/README.md:397
- Markdown headers (starting with #) should not be used inside collapsible details sections. The heading "Using GitHub Copilot CLI SDK with Azure MCP" appears after the details tag opens, which will not render properly as a heading in collapsed state and creates structural inconsistency. Consider removing the heading or restructuring the content.
# Using GitHub Copilot CLI SDK with Azure MCP
servers/Azure.Mcp.Server/README.md:407
- The prerequisite lists "GitHub Copilot CLI" which is confusing in the context of SDK configuration. The SDK doesn't require the CLI to be installed - it's a programmatic library. This should clarify what's actually needed (e.g., "GitHub Copilot SDK installation" or remove this as a prerequisite since it's covered in the installation sections below).
1. **GitHub Copilot CLI** - Install from [GitHub Copilot CLI](https://docs.github.com/en/copilot/github-copilot-in-the-cli)
servers/Azure.Mcp.Server/README.md:630
- The model name "gpt-4.1" does not exist. Use a valid model name like "gpt-4", "gpt-4-turbo", or "gpt-4o".
Model: "gpt-4.1", // Default model; BYOK can override
servers/Azure.Mcp.Server/README.md:392
- The text refers to "GitHub Copilot CLI SDK" but the link points to "github.com/github/copilot-sdk" which is the GitHub Copilot SDK (not CLI SDK). The terminology should be consistent - either use "GitHub Copilot SDK" throughout or clarify the distinction. The SDK is for programmatic integration, not CLI usage.
The [GitHub Copilot CLI SDK](https://github.com/github/copilot-sdk) enables programmatic integration of Azure MCP tools into your applications across multiple languages.
servers/Azure.Mcp.Server/README.md:532
- These Node.js/TypeScript examples configure the Copilot client with
--allow-all-toolsand--allow-all-paths, which drop the usual safeguards around which tools can be invoked and what parts of the filesystem can be accessed. In any server-side or multi-user integration, this opens a path for remote users (via prompts) to influence the model into running unexpected commands or accessing arbitrary local files, leading to potential code execution or data exfiltration. It would be safer to recommend a minimal set of allowed tools and paths for Azure MCP scenarios and to clearly warn that these broad flags are only appropriate in tightly controlled environments.
async function main() {
// Initialize the Copilot client
const client = new CopilotClient({
cliArgs: [
'--allow-all-tools',
'--allow-all-paths',
]
});
servers/Azure.Mcp.Server/README.md:607
- The Go sample initializes the Copilot client with
CLIArgscontaining--allow-all-toolsand--allow-all-paths, which disables important safety constraints around tool invocation and filesystem access. If this configuration is used in a long-running service or with untrusted prompts, an attacker could coerce the model into invoking arbitrary local tools or reading sensitive files, effectively turning the Copilot SDK into a powerful remote automation primitive. Consider demonstrating a configuration that only enables the specific tools and paths required for Azure MCP and explicitly documenting the risks of these "allow all" flags.
client, err := copilot.NewClient(copilot.ClientOptions{
CLIArgs: []string{
"--allow-all-tools",
"--allow-all-paths",
},
servers/Azure.Mcp.Server/README.md:684
- The .NET example uses
CliArgs = new[] { "--allow-all-tools", "--allow-all-paths" }, which broadly authorizes the model to call any tool and traverse the full filesystem. In real applications, especially services handling untrusted input, this configuration can be exploited by prompting the model to execute dangerous commands or access and exfiltrate sensitive local data. It would be safer for the documentation to illustrate a constrained configuration (only the tools and directories needed for Azure MCP) and to warn that these permissive flags should not be used in production without strong isolation and additional controls.
var client = new CopilotClient(new CopilotClientOptions
{
CliArgs = new[] { "--allow-all-tools", "--allow-all-paths" }
});
servers/Azure.Mcp.Server/README.md
Outdated
| # Using GitHub Copilot CLI SDK with Azure MCP | ||
|
|
||
| This guide explains how to configure the [GitHub Copilot CLI SDK](https://github.com/github/copilot-sdk) to use Azure MCP (Model Context Protocol) tools for interacting with Azure resources. | ||
|
|
||
| ## Overview | ||
|
|
||
| Azure MCP provides a set of tools that enable AI assistants to interact with Azure resources directly. When integrated with the Copilot CLI SDK, you can build applications that leverage natural language to manage Azure subscriptions, resource groups, storage accounts, and more. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 1. **GitHub Copilot CLI** - Install from [GitHub Copilot CLI](https://docs.github.com/en/copilot/github-copilot-in-the-cli) | ||
| 2. **Azure MCP Server** - Available via npm: `@azure/mcp` | ||
| 3. **Azure CLI** - Authenticated via `az login` | ||
| 4. **Valid GitHub Copilot subscription** | ||
|
|
||
| ### Install Azure MCP Server | ||
|
|
||
| ```bash | ||
| # Option 1: Use npx (downloads on demand) | ||
| npx -y @azure/mcp@latest server start | ||
|
|
||
| # Option 2: Install globally (faster startup) | ||
| npm install -g @azure/mcp@latest | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Key Configuration Insight | ||
|
|
||
| > **Important:** MCP servers must be configured in the **session config** (not CLI arguments) for tools to be available. The critical configuration is: | ||
| ```json | ||
| { | ||
| "mcp_servers": { | ||
| "azure-mcp": { | ||
| "type": "local", | ||
| "command": "npx", | ||
| "args": ["-y", "@azure/mcp@latest", "server", "start"], | ||
| "tools": ["*"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| The `tools: ["*"]` parameter is essential - it enables all tools from the MCP server for the session. | ||
|
|
||
| --- | ||
|
|
||
| ## Python | ||
|
|
||
| ### Installation | ||
|
|
||
| ```bash | ||
| pip install github-copilot-sdk | ||
| ``` | ||
|
|
||
| ### Configuration | ||
|
|
||
| ```python | ||
| import asyncio | ||
| from copilot import CopilotClient | ||
| from copilot.generated.session_events import SessionEventType | ||
|
|
||
| async def main(): | ||
| # Initialize the Copilot client | ||
| client = CopilotClient({ | ||
| "cli_args": [ | ||
| "--allow-all-tools", | ||
| "--allow-all-paths", | ||
| ] | ||
| }) | ||
|
|
||
| await client.start() | ||
|
|
||
| # Configure Azure MCP server in session config | ||
| azure_mcp_config = { | ||
| "azure-mcp": { | ||
| "type": "local", | ||
| "command": "npx", | ||
| "args": ["-y", "@azure/mcp@latest", "server", "start"], | ||
| "tools": ["*"], # Enable all Azure MCP tools | ||
| } | ||
| } | ||
|
|
||
| # Create session with MCP servers | ||
| session = await client.create_session({ | ||
| "model": "gpt-4.1", # Default model; BYOK can override | ||
| "streaming": True, | ||
| "mcp_servers": azure_mcp_config, | ||
| }) | ||
|
|
||
| # Handle events | ||
| def handle_event(event): | ||
| if event.type == SessionEventType.ASSISTANT_MESSAGE_DELTA: | ||
| if hasattr(event.data, 'delta_content') and event.data.delta_content: | ||
| print(event.data.delta_content, end="", flush=True) | ||
| elif event.type == SessionEventType.TOOL_EXECUTION_START: | ||
| tool_name = getattr(event.data, 'tool_name', 'unknown') | ||
| print(f"\n[TOOL: {tool_name}]") | ||
|
|
||
| session.on(handle_event) | ||
|
|
||
| # Send prompt | ||
| await session.send_and_wait({ | ||
| "prompt": "List all resource groups in my Azure subscription" | ||
| }) | ||
|
|
||
| await client.stop() | ||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Node.js / TypeScript | ||
|
|
||
| ### Installation | ||
|
|
||
| ```bash | ||
| npm install @anthropic-ai/github-copilot-sdk | ||
| ``` | ||
|
|
||
| ### Configuration (TypeScript) | ||
|
|
||
| ```typescript | ||
| import { CopilotClient, SessionEventType } from '@anthropic-ai/github-copilot-sdk'; | ||
|
|
||
| async function main() { | ||
| // Initialize the Copilot client | ||
| const client = new CopilotClient({ | ||
| cliArgs: [ | ||
| '--allow-all-tools', | ||
| '--allow-all-paths', | ||
| ] | ||
| }); | ||
|
|
||
| await client.start(); | ||
|
|
||
| // Configure Azure MCP server in session config | ||
| const azureMcpConfig = { | ||
| 'azure-mcp': { | ||
| type: 'local' as const, | ||
| command: 'npx', | ||
| args: ['-y', '@azure/mcp@latest', 'server', 'start'], | ||
| tools: ['*'], // Enable all Azure MCP tools | ||
| } | ||
| }; | ||
|
|
||
| // Create session with MCP servers | ||
| const session = await client.createSession({ | ||
| model: 'gpt-4.1', // Default model; BYOK can override | ||
| streaming: true, | ||
| mcpServers: azureMcpConfig, | ||
| }); | ||
|
|
||
| // Handle events | ||
| session.on((event) => { | ||
| if (event.type === SessionEventType.ASSISTANT_MESSAGE_DELTA) { | ||
| if (event.data?.deltaContent) { | ||
| process.stdout.write(event.data.deltaContent); | ||
| } | ||
| } else if (event.type === SessionEventType.TOOL_EXECUTION_START) { | ||
| const toolName = event.data?.toolName || 'unknown'; | ||
| console.log(`\n[TOOL: ${toolName}]`); | ||
| } | ||
| }); | ||
|
|
||
| // Send prompt | ||
| await session.sendAndWait({ | ||
| prompt: 'List all resource groups in my Azure subscription' | ||
| }); | ||
|
|
||
| await client.stop(); | ||
| } | ||
|
|
||
| main().catch(console.error); | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Go | ||
|
|
||
| ### Installation | ||
|
|
||
| ```bash | ||
| go get github.com/github/copilot-sdk-go | ||
| ``` | ||
|
|
||
| ### Configuration | ||
|
|
||
| ```go | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "log" | ||
|
|
||
| copilot "github.com/github/copilot-sdk-go" | ||
| ) | ||
|
|
||
| func main() { | ||
| ctx := context.Background() | ||
|
|
||
| // Initialize the Copilot client | ||
| client, err := copilot.NewClient(copilot.ClientOptions{ | ||
| CLIArgs: []string{ | ||
| "--allow-all-tools", | ||
| "--allow-all-paths", | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| if err := client.Start(ctx); err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| defer client.Stop(ctx) | ||
|
|
||
| // Configure Azure MCP server in session config | ||
| azureMcpConfig := map[string]copilot.MCPServerConfig{ | ||
| "azure-mcp": { | ||
| Type: "local", | ||
| Command: "npx", | ||
| Args: []string{"-y", "@azure/mcp@latest", "server", "start"}, | ||
| Tools: []string{"*"}, // Enable all Azure MCP tools | ||
| }, | ||
| } | ||
|
|
||
| // Create session with MCP servers | ||
| session, err := client.CreateSession(ctx, copilot.SessionConfig{ | ||
| Model: "gpt-4.1", // Default model; BYOK can override | ||
| Streaming: true, | ||
| MCPServers: azureMcpConfig, | ||
| }) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| // Handle events | ||
| session.OnEvent(func(event copilot.SessionEvent) { | ||
| switch event.Type { | ||
| case copilot.AssistantMessageDelta: | ||
| if event.Data.DeltaContent != "" { | ||
| fmt.Print(event.Data.DeltaContent) | ||
| } | ||
| case copilot.ToolExecutionStart: | ||
| fmt.Printf("\n[TOOL: %s]\n", event.Data.ToolName) | ||
| } | ||
| }) | ||
|
|
||
| // Send prompt | ||
| err = session.SendAndWait(ctx, copilot.Message{ | ||
| Prompt: "List all resource groups in my Azure subscription", | ||
| }) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## .NET |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent use of heading markers. The document starts with "# Using GitHub Copilot CLI SDK with Azure MCP" (line 397) followed by "## Overview" (line 401), "## Prerequisites" (line 405), etc., then switches to "## Python" (line 445), "## Node.js / TypeScript" (line 512), etc. This creates a confusing hierarchy where language-specific sections appear at the same level as overview/prerequisites. Consider restructuring the headings for better hierarchy, or flatten the structure by removing the top-level heading on line 397.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(not sure why I can't create a new comment...)
@kvenkatrajan
It would be great to add this to the table of contents at the top.
Otherwise, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should create a separate PR for this. There is a bunch of items missing from the table of contents
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Made suggestions based on the copilot cli sdk https://github.com/github/copilot-sdk?tab=readme-ov-file#available-sdks |
|
@kvenkatrajan I've opened a new pull request, #1581, to work on those changes. Once the pull request is ready, I'll request review from you. |
Summary
This PR adds a new GitHub Copilot SDK Configuration section to the Azure MCP Server README, providing developers with code snippets for integrating Azure MCP tools programmatically.
Changes
Why
Developers building applications with the GitHub Copilot CLI SDK need guidance on how to configure Azure MCP tools within their sessions. This documentation enables programmatic integration across multiple languages.
Testing