Skip to content

Copilot SDK doesn't recognize the Environment variables from MCP server's configuration #430

@SangTruongTan

Description

@SangTruongTan

I'm developing a web app that use Copilot SDK as a backend AI engine. However, while configuring the MCP server. I'm facing an issue that the environment variables that aren't recognized and passed into the MCP process. It's weird because my MCP server is functioning properly with the native Copilot CLI. I traced the source code and found that Copilot SDK is just passing all the configuration to the Copilot CLI instance through JsonRPC. So, I think there should be either an interface mismatch or Copilot CLI issue.

    mcp_servers: dict[str, MCPLocalServerConfig] = {
        "gerrit-mcp": {
            "type": "local",
            "command": "python",
            "tools": ["*"],
            "args": [
                "<path_to_mcp>/mcp-gerrit/src/server.py",
                "--log-file",
                "./gerrit_mcp.log",
                "--log-level",
                "DEBUG",
            ],
            "env": {
                "GERRIT_URL": "<url>",
                "GERRIT_USERNAME": "<user>",
                "GERRIT_PASSWORD": "<password>",
            }
        }
    }

    client = CopilotClient()
    await client.start()

    session = await client.create_session(
        {"model": "gpt-4.1", "streaming": True, "mcp_servers": mcp_servers}
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions