What Kinds of Applications Can Integrate with the GitHub Copilot SDK?

Any application that can import the SDK's language packages—including CLI tools, IDE extensions, backend services, CI pipelines, and serverless functions—can integrate with the GitHub Copilot SDK to programmatically drive the Copilot CLI runtime.

The GitHub Copilot SDK is a language-agnostic toolkit available in the github/copilot-sdk repository that enables developers to embed AI agents into virtually any software architecture. By abstracting the Copilot CLI lifecycle through JSON-RPC connections, the SDK allows applications written in Node.js, Python, Go, .NET, Rust, or Java to execute autonomous tasks, expose custom tools, and coordinate multi-client sessions.

SDK Architecture and Connection Model

According to the github/copilot-sdk source code, the SDK operates as a thin client layer that spawns and communicates with the Copilot CLI binary. In nodejs/src/client.ts, the CopilotClient class manages the runtime lifecycle, handling process startup, connection factories (STDIO, TCP, or external URI), and authentication via GitHub tokens or environment variables.

The architecture follows a simple request-response pattern over JSON-RPC:


Your Application
   ↓  (SDK client)
JSON-RPC
   ↓
Copilot CLI (server mode)
   ↔  (runtime, tool execution, model inference)

A CopilotSession instance—defined in nodejs/src/session.ts—encapsulates individual conversations, managing prompt streaming, event routing, and persistent state. When applications need to define custom capabilities, the defineTool helper in nodejs/src/toolSet.ts constructs tool schemas that the LLM can invoke during agent execution.

Core Integration Capabilities

Applications integrating with the GitHub Copilot SDK gain access to seven primary capabilities that transform passive code completion into active agentic workflows.

Autonomous Agent Sessions

The SDK enables autonomous agent sessions where applications can send prompts to the Copilot runtime and receive streamed responses. According to nodejs/src/session.ts, the CopilotSession class exposes methods like send() and event listeners for assistant.message_delta, allowing real-time processing of LLM outputs while maintaining conversation context across multiple turns.

Custom Tool Exposure

Developers can expose custom tools by defining functions with Zod schemas (TypeScript) or Python callables that the LLM invokes to perform domain-specific work. The defineTool function in nodejs/src/toolSet.ts registers these capabilities with the CLI runtime, enabling agents to read files, call external APIs, or execute business logic within the host application.

Built-In Copilot Tools

Integrated applications automatically leverage built-in Copilot tools without additional implementation. The CLI runtime provides default file-editing, shell-command execution, and web-fetching capabilities that agents can invoke transparently during task execution.

Multi-Client Mission Control

The SDK supports Mission Control Protocol (MCP) coordination, allowing multiple processes to join the same session simultaneously. By configuring enableRemoteSessions: true in the client options, distributed microservices can share conversation state, UI elicitation prompts, and tool call permissions across process boundaries.

UI Elicitation Integration

Applications with user interfaces can integrate UI-elicitation dialogs by providing an onElicitationRequest handler. When the agent requires additional input—such as form data or user confirmation—the SDK surfaces these requests to the host application, which can render appropriate modals in TUIs, web interfaces, or IDE panels.

Slash Command Registration

The SDK allows applications to add slash-commands that users can invoke directly from the Copilot TUI (e.g., /deploy prod). These custom commands register as shortcuts that trigger specific agent workflows or tool sequences defined by the host application.

OpenTelemetry Instrumentation

For production observability, applications can instrument sessions with OpenTelemetry, enabling distributed tracing of every JSON-RPC message, tool invocation, and LLM response through the SDK's telemetry hooks.

Language-Specific Implementation Examples

The GitHub Copilot SDK provides idiomatic client libraries for six major programming languages. Each implementation follows the same core pattern: create a CopilotClient, start the runtime, create a session, and send messages.

Node.js and TypeScript

In nodejs/src/client.ts, the TypeScript SDK provides the CopilotClient class and approveAll permission helper:

import { CopilotClient, approveAll } from "@github/copilot-sdk";

async function run() {
  const client = new CopilotClient();          // spawns the CLI runtime
  await client.start();

  const session = await client.createSession({
    model: "gpt-5",
    onPermissionRequest: approveAll,           // auto-approve every tool
  });

  // Send a prompt and stream the response
  session.on("assistant.message_delta", e => process.stdout.write(e.data.deltaContent));
  await session.send({ prompt: "Summarize the repo's README." });
}
run();

Python

The Python SDK mirrors this API in python/copilot_sdk/client.py:

from copilot_sdk import CopilotClient, approve_all

client = CopilotClient()
client.start()

session = client.create_session(
    model="gpt-5",
    on_permission_request=approve_all,
)

# Send a message and wait for completion

response = session.send_and_wait({"prompt": "Explain async/await in Python."})
print(response["assistant"]["message"]["content"])

Go

The Go implementation in go/sdk/client.go uses context-aware patterns:

import (
    "context"
    copilot "github.com/github/copilot-sdk/go"
)

func main() {
    client, _ := copilot.NewClient()
    defer client.Stop(context.Background())

    sess, _ := client.CreateSession(copilot.SessionConfig{
        Model: "gpt-5",
        OnPermissionRequest: copilot.ApproveAll(),
    })

    sess.Send(context.Background(), copilot.Message{Prompt: "List the steps to build a Docker image."})
    // listen to events or use SendAndWait for a simple request
}

.NET (C#)

The .NET SDK in dotnet/src/CopilotClient.cs provides async/await support:

using GitHub.Copilot.SDK;

var client = new CopilotClient();
await client.StartAsync();

var session = await client.CreateSessionAsync(new SessionConfig
{
    Model = "gpt-5",
    OnPermissionRequest = PermissionHandlers.ApproveAll
});

await session.SendAsync(new MessageOptions { Prompt = "What is nullable reference types?" });

Rust

The Rust SDK in rust/src/client.rs leverages Tokio for async runtime management:

use github_copilot_sdk::{CopilotClient, SessionConfig, PermissionDecision};

#[tokio::main]
async fn main() {
    let mut client = CopilotClient::new().await.unwrap();
    client.start().await.unwrap();

    let session = client.create_session(SessionConfig {
        model: "gpt-5".into(),
        on_permission_request: |_| PermissionDecision::ApproveAll,
        ..Default::default()
    }).await.unwrap();

    session.send(Message { prompt: "Explain Rust's ownership model." }).await.unwrap();
}

Java

The Java implementation in java/src/main/java/com/github/copilot/sdk/CopilotClient.java uses builder patterns:

CopilotClient client = new CopilotClient();
client.start();

CopilotSession session = client.createSession(new SessionConfig()
        .model("gpt-5")
        .onPermissionRequest(PermissionHandlers.approveAll()));

session.send(new MessageOptions().prompt("Describe the Java Stream API."));

Typical Integration Scenarios

The flexibility of the GitHub Copilot SDK architecture supports diverse application types:

  • CLI Tools: Command-line utilities use CopilotClient.start() to launch the CLI in the background, enabling AI-driven refactoring suggestions and code generation directly in terminal workflows.

  • VS Code and IDE Extensions: Extensions embed the SDK to provide inline completions and expose IDE-specific tools—such as "run tests" or "open file"—that the LLM can invoke through the defineTool mechanism.

  • Backend Services: Server processes maintain long-lived CLI connections, reusing CopilotSession instances across HTTP requests to automate PR creation, issue triage, or documentation generation.

  • CI Pipelines: Build scripts utilize short-lived SDK sessions to generate change proposals or security scan analyses, with sessionFs providers persisting checkpoints to disk for artifact collection.

  • Serverless Functions: Lambda and cloud functions configure custom OpenAI-compatible providers via the provider configuration option, enabling webhook handlers that return AI-crafted responses without local CLI dependencies.

  • Multi-Client Coordination: Microservices architectures benefit from Mission Control Protocol support, where each service instantiates a CopilotClient with remote sessions enabled, sharing conversation state and tool permissions across distributed components.

  • Custom Web UIs: React or Vue applications implement onElicitationRequest handlers to render modal dialogs when the agent requires user input, bridging the gap between conversational AI and complex form-based interactions.

Key Source Files for Implementation Reference

Developers exploring the github/copilot-sdk repository should examine these critical files:

Summary

The GitHub Copilot SDK enables virtually any application architecture to integrate with the Copilot CLI runtime:

  • Language Coverage: Native support for Node.js/TypeScript, Python, Go, .NET, Rust, and Java through idiomatic client libraries.
  • Core Capabilities: Autonomous agent sessions, custom tool exposure, built-in utilities, multi-client coordination, UI elicitation, slash commands, and OpenTelemetry instrumentation.
  • Implementation Pattern: Instantiate CopilotClient, manage the JSON-RPC connection to the CLI runtime, create CopilotSession instances, and handle events for streaming responses and tool permissions.
  • Use Cases: From terminal-based CLI tools and IDE extensions to backend microservices, CI automation, and serverless functions.

Frequently Asked Questions

Can a web application integrate with the GitHub Copilot SDK?

Yes, web applications can integrate by implementing the SDK on the server side or using custom providers. For browser-based clients, the SDK typically runs in a backend service that handles CopilotClient lifecycle management, while the frontend implements onElicitationRequest handlers to render forms and dialogs when the agent requires user input.

What authentication methods does the SDK support for integrated applications?

According to docs/auth/index.md, the SDK supports multiple authentication mechanisms including GitHub personal access tokens, environment variable injection, and Bring-Your-Own-Key (BYOK) configurations for custom OpenAI-compatible endpoints. The CopilotClient constructor accepts these credentials and manages token refresh automatically.

How do custom tools work in SDK-integrated applications?

Custom tools are defined using language-specific schemas—such as Zod in TypeScript or Python callables—and registered via defineTool in nodejs/src/toolSet.ts. When the LLM determines it needs to perform an action like reading a file or calling an API, it invokes the registered tool, which executes within the host application's process and returns results to the agent session.

Can multiple applications share the same Copilot session simultaneously?

Yes, through the Mission Control Protocol (MCP) feature. By enabling enableRemoteSessions: true in the client configuration, multiple processes can instantiate CopilotClient instances that connect to a shared CLI runtime, allowing distributed microservices to participate in the same conversation state and coordinate tool calls.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →