GitHub Copilot SDK
Use the Copilot SDK with explicit permissions, lifecycle management, and completion handling.
When to invoke
- Embed Copilot in a TypeScript, Python, Go, or .NET application.
- Create or resume Copilot SDK sessions.
- Stream responses and tool events.
- Register custom tools or MCP servers.
Prerequisites and context
- GitHub Copilot CLI is installed, authenticated, and available to the runtime.
- Select a supported language runtime and repository package-management convention.
- Define the permission policy before enabling tools or filesystem/process access.
Procedure
- Verify CLI availability and authentication.
- Install the language SDK using the repository's package manager.
- Create a client with an explicit permission handler.
- Start the client and create or resume a session before sending a prompt.
- Register only the required tools and MCP servers with typed schemas.
- For streaming, handle content deltas, tool events, errors, and the session-idle completion signal.
- Stop/dispose the session and client on success, error, cancellation, and process shutdown.
- Validate permission denial, tool failure, cancellation, and normal completion paths.
Installation
| Language |
Package command |
| TypeScript |
npm install @github/copilot-sdk |
| Python |
pip install github-copilot-sdk |
| Go |
go get github.com/github/copilot-sdk/go |
| .NET |
dotnet add package GitHub.Copilot.SDK |
Minimal TypeScript shape:
const client = new CopilotClient({ permissionHandler: approveRequired });
await client.start();
const session = await client.createSession();
const response = await session.sendAndWait({ prompt: "Summarize this repository" });
console.log(response?.data.content);
await client.stop();
For streaming, process assistant.message_delta and treat session.idle as completion; do not
assume the first text event is the final response.
Output template
## GitHub Copilot SDK result
**Status:** IMPLEMENTED | BLOCKED
**Language:** <TypeScript | Python | Go | .NET>
### Integration
- Client lifecycle: <start/stop behavior>
- Session: <create/resume behavior>
- Permissions: <handler and denied path>
- Tools or MCP: <registered surface or none>
- Streaming: <events and completion signal>
### Validation
- <test/command and result>
Limits
- Do not approve every tool by default in production.
- Do not leave clients, sessions, processes, or streams undisposed.
- Do not expose secrets in prompts, tool schemas, logs, or MCP configuration.
- Verify SDK APIs against current official documentation before version-sensitive implementation.
Progressive disclosure and bundled resources
- Extended SDK guide: tools, MCP, session management, events, and language-specific examples.
Related primitives
| Name |
Type |
Use it when |
mcp-cli |
skill |
MCP server discovery or testing is required. |
mcp-ecosystem |
skill |
The Open Horizons MCP ecosystem is the target. |
github-cli |
skill |
GitHub authentication or repository API work is separate from SDK use. |
Quality gate
References
1---2name: github-copilot-sdk3description: Builds applications with the GitHub Copilot SDK using explicit client lifecycle, sessions, permissions, streaming, tools, and MCP integration. Use when embedding Copilot in an application, creating sessions, handling events, registering tools, or troubleshooting SDK behavior.4---56<!-- Generated from harness/github-copilot/plugins/open-horizons-platform/skills/github-copilot-sdk/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# GitHub Copilot SDK910Use the Copilot SDK with explicit permissions, lifecycle management, and completion handling.1112## When to invoke1314- Embed Copilot in a TypeScript, Python, Go, or .NET application.15- Create or resume Copilot SDK sessions.16- Stream responses and tool events.17- Register custom tools or MCP servers.1819## Prerequisites and context2021- GitHub Copilot CLI is installed, authenticated, and available to the runtime.22- Select a supported language runtime and repository package-management convention.23- Define the permission policy before enabling tools or filesystem/process access.2425## Procedure26271. Verify CLI availability and authentication.282. Install the language SDK using the repository's package manager.293. Create a client with an explicit permission handler.304. Start the client and create or resume a session before sending a prompt.315. Register only the required tools and MCP servers with typed schemas.326. For streaming, handle content deltas, tool events, errors, and the session-idle completion signal.337. Stop/dispose the session and client on success, error, cancellation, and process shutdown.348. Validate permission denial, tool failure, cancellation, and normal completion paths.3536## Installation3738| Language | Package command |39| --- | --- |40| TypeScript | `npm install @github/copilot-sdk` |41| Python | `pip install github-copilot-sdk` |42| Go | `go get github.com/github/copilot-sdk/go` |43| .NET | `dotnet add package GitHub.Copilot.SDK` |4445Minimal TypeScript shape:4647```typescript48const client = new CopilotClient({ permissionHandler: approveRequired });49await client.start();50const session = await client.createSession();51const response = await session.sendAndWait({ prompt: "Summarize this repository" });52console.log(response?.data.content);53await client.stop();54```5556For streaming, process `assistant.message_delta` and treat `session.idle` as completion; do not57assume the first text event is the final response.5859## Output template6061```markdown62## GitHub Copilot SDK result6364**Status:** IMPLEMENTED | BLOCKED65**Language:** <TypeScript | Python | Go | .NET>6667### Integration68- Client lifecycle: <start/stop behavior>69- Session: <create/resume behavior>70- Permissions: <handler and denied path>71- Tools or MCP: <registered surface or none>72- Streaming: <events and completion signal>7374### Validation75- <test/command and result>76```7778## Limits7980- Do not approve every tool by default in production.81- Do not leave clients, sessions, processes, or streams undisposed.82- Do not expose secrets in prompts, tool schemas, logs, or MCP configuration.83- Verify SDK APIs against current official documentation before version-sensitive implementation.8485## Progressive disclosure and bundled resources8687- [Extended SDK guide](references/extended-guide.md): tools, MCP, session management, events, and language-specific examples.8889## Related primitives9091| Name | Type | Use it when |92| --- | --- | --- |93| `mcp-cli` | `skill` | MCP server discovery or testing is required. |94| `mcp-ecosystem` | `skill` | The Open Horizons MCP ecosystem is the target. |95| `github-cli` | `skill` | GitHub authentication or repository API work is separate from SDK use. |9697## Quality gate9899- [ ] CLI availability and authentication are checked.100- [ ] Permission handling is explicit and tested.101- [ ] A session exists before messages are sent.102- [ ] Streaming handles deltas, errors, and idle completion.103- [ ] Client and session resources are disposed on every exit path.104105## References106107- [GitHub Copilot SDK](https://github.com/github/copilot-sdk)