Skip to content

Question: How to configure MCP servers for programmatic CopilotClient sessions? #380

@brettbergin

Description

@brettbergin

Context

I'm building a tool that uses copilot-sdk to create programmatic sessions. The tool runs as a subprocess invoked via the Copilot CLI.

Question

When I create a CopilotClient session programmatically, it does not have access to MCP tools that are available in the parent Copilot CLI. Specifically, github-mcp-server tools return "Tool does not exist" errors.

I've tried passing MCP server configurations via create_session():

session_config = {
    "model": "claude-sonnet-4",
    "mcp_servers": {
        "github-mcp-server": {
            "type": "sse",
            "url": "https://api.githubcopilot.com/mcp/",
            "headers": {"Authorization": f"Bearer {token}"},
            "tools": ["*"]
        }
    }
}
session = await client.create_session(session_config)

However, the github-mcp-server still isn't accessible. I suspect this is because it requires internal Copilot authentication rather than a PAT.

What works:

  • Local stdio MCP servers from ~/.copilot/mcp-config.json load and function correctly
  • The mcp_servers parameter in SessionConfig is being passed through

What doesn't work:

  • Remote MCP servers (the SSE endpoint returns protocol errors with PAT auth)
  • The built-in github-mcp-server from the parent CLI

Questions

  1. Is there a supported way to access github-mcp-server from programmatic SDK sessions?
  2. Is there an API to inherit MCP configuration from the parent Copilot CLI process?
  3. Are there plans to expose a helper like load_default_mcp_config() for common use cases?

Current Workaround

The agent falls back to using gh CLI commands for GitHub data access, which works but loses the benefits of structured MCP tool responses.

Environment

  • copilot-sdk version: 0.1.19 (via github-copilot-sdk package)
  • Python: 3.14
  • Platform: macOS

Thank you for any guidance you can provide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationquestionFurther information is requestedsdk/python

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions