Skip to content

Expose the session id to MCP servers in _meta of tools/call #5652

Not planned

Description

@Bajmein

Hooks receive sessionId on stdin, but an MCP server has no per-request way to know which Copilot CLI session is calling it.

Today (1.0.119) the only source is the environment variable COPILOT_AGENT_SESSION_ID of the stdio server process. It works because Copilot restarts stdio servers on /new, but it ties identity to the process: it cannot work for HTTP/SSE servers, and it would break if a server process were ever shared or kept across sessions (e.g. /resume).

_meta of tools/call already carries com.github.copilot/toolCallId and com.github.copilot/turnId. Could it also carry com.github.copilot/sessionId, equal to the sessionId hooks receive?

Use case: an MCP server that keeps per-session state (e.g. message delivery between agent sessions) and must match a tool call to the session its hooks report. Other clients already do this (Antigravity CLI sends antigravity.google/root_conversation_id in _meta).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions