Skip to main content
You can mount a GitHub repository to your session sandbox and connect to the GitHub MCP for making pull requests. GitHub repositories are cached, so future sessions that use the same repository start faster.
Managed Agents API requests require the managed-agents-2026-04-01 beta header, except memory store endpoints, which use agent-memory-2026-07-22 instead. The SDK sets the correct beta header automatically. See Beta headers.

GitHub MCP and session resources

First, create an agent that declares the GitHub MCP server. The agent definition holds the server URL but no authentication token:
Then create a session that mounts the GitHub repository:
The resources[].authorization_token authenticates the repository clone operation and is not echoed in API responses. Mounting a repository also loads any skills stored in its root .claude/skills directory. Skills are discovered once per session, from the repository state checked out at session start. See Load skills from a GitHub repository.

Token permissions

When providing a GitHub token, use the minimum required permissions:
Use fine-grained personal access tokens with minimum required permissions. Avoid using tokens with broad access to your GitHub account.

Multiple repositories

Mount multiple repositories by adding entries to the resources array:

Managing repositories on a running session

After a session is created, you can list its repository resources and rotate their authorization tokens. Each resource has an id returned at session creation time (or through resources.list) that you use for updates. Repositories are attached for the lifetime of the session; to change which repositories are mounted, create a new session.

Creating pull requests

With the GitHub MCP server, the agent can create branches, commit changes, and push them:

Next steps

Session event stream

Stream events and steer the agent while it opens the pull request

MCP connector

Connect more MCP servers to give the agent additional tools

Adding files

Mount files in the sandbox alongside your repositories