← Back to list

Setting a classic PAT for my GitHub MCP Server

Opencode, Personal Access Tokens

Rizky Ramadhani · 2026-06-04 07:34 · 0 claps · 3.0 min read
#github #mcp-server #open-code #cli #devops
Open on Medium ↗
Wiki topics: AGT · AI Agents ☁️ · DevOps & Cloud 🔓 · Open Source

Setting a classic PAT for my GitHub MCP Server

Opencode, Personal Access Tokens

https://www.istockphoto.com/id/foto-foto/token

https://www.istockphoto.com/id/foto-foto/token

Specs:

  • macOS Tahoe 26.5
  • GitHub personal account
  • Separate GitHub agent account
  • Opencode CLI installed in Tart macOS VM

Why?

I wanted to limit what my agent has access to through its own GitHub account, so that the blast radius is decreased in case of hijacking, breach or the agent managing to find holes in my security settings.

Initially, I want to limit my agent to only maintain my project board (that I invited it to from my personal account). This requires the agent to also have access to my repo to assign issues to, list branches, commits etc. I’ll also need to limit the toolsets the GitHub MCP server has access to in my .opencode/config.jsonc to reduce token usage.

Eventually when I feel comfortable knowing the agent is confined by the permissions I set, I’ll want it to create branches, automate PRs/workflows and so on.

I’ve previously created a ruleset before inviting my agent account as an external collaborator, to tighten up possible security holes.

How?

  • I created a classic personal access token (PAT; Settings > Developer Settings > Personal access tokens > Tokens (classic)) by hand in my agent’s GitHub account with the following settings:

Note: Opencode

Expiration: 30 days

Select scopes: repo, project.

GitHub’s documentation here is a bit tricky to navigate, and GitHub MCP server doesn’t yet support OAuth login (i.e. via the opencode mcp auth githubcommand. In the Tools section of GitHub’s README, you can find the required PAT scope for the tools you require. Even though it says ‘Required OAuth Scopes’ the scopes also work with classic PATs.

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["superpowers@git+https://github.com/obra/superpowers.git"],
  "mcp": {
    "github": {
      "type": "remote",
      "url": "https://api.githubcopilot.com/mcp/",
      "enabled": true,
      "oauth": false,
      "headers": {
        "Authorization": "Bearer {env:GITHUB_PERSONAL_ACCESS_TOKEN}",
        "X-MCP-Readonly": "true",
        "X-MCP-Lockdown": "true",
        "X-MCP-Toolsets": "projects,issues"
        // "X-MCP-Tools": "projects_get,projects_list,projects_write,add_issue_comment,get_label,issue_read,issue_write,list_issues,search_issues,sub_issue_write"
      }
    }
  }
}

oauth: false to disable OpenCode’s auto OAuth discovery

”Authorization”: “Bearer {env:GITHUB_PERSONAL_ACCESS_TOKEN} to use the classic PAT I generated above by typing inexport GITHUB_PERSONAL_ACCESS_TOKEN={access_token} to authenticate the session in my terminal before running opencode .

“X-MCP-Readonly” : ensures the server won’t allow operations that modify issues (yet). Read only mode will disable any tool that isn’t read-only. I plan to switch this off once I’m better at prompting the agent as I don’t always get the same output consistently.

“X-MCP-Lockdown”: Limiting by ensuring the server only shows content in public repos from users with push access (in this case: agent).

“X-MCP-Toolsets”: Enabling specific toolsets only necessary for the above tasks

“X-MCP-Tools”: Currently commented out — in future I will use to minimise the amount of tokens used as necessary. The list of tools to be referenced can be found here.

  • To verify the config worked, I ran:
export GITHUB_PERSONAL_ACCESS_TOKEN={access_token}

followed by:

opencode mcp list

which gave me the following output:

┌  MCP Servers
│
●  ✓ github connected
│      https://api.githubcopilot.com/mcp/
│
└  1 server(s)

Notes:

  • opencode.jsonc draft written by Gemini + Claude with official GitHub MCP Server README.md as reference. Corrected by hand and may change in future

References

[embed]github-mcp-server/README.md at main · github/github-mcp-server GitHub's official MCP Server. Contribute to github/github-mcp-server development by creating an account on GitHub.github.com

[embed]github-mcp-server/docs/scope-filtering.md at main · github/github-mcp-server GitHub's official MCP Server. Contribute to github/github-mcp-server development by creating an account on GitHub.github.com

[embed]github-mcp-server/docs/server-configuration.md at main · github/github-mcp-server GitHub's official MCP Server. Contribute to github/github-mcp-server development by creating an account on GitHub.github.com

[embed]The GitHub MCP Server adds support for tool-specific configuration, and more - GitHub Changelog The GitHub MCP Server now comes with support for tool-specific configuration, allowing you to customize the server to…github.blog

[embed]github-mcp-server/docs/installation-guides/install-opencode.md at main · github/github-mcp-server GitHub's official MCP Server. Contribute to github/github-mcp-server development by creating an account on GitHub.github.com

[embed]github-mcp-server/docs/remote-server.md at main · github/github-mcp-server Remote MCP Toolsets from the Remote GitHub MCP Server docs.github.com

[embed]A practical guide on how to use the GitHub MCP server Upgrade from a local MCP Docker image to GitHub's hosted server and automate pull requests, continuous integration, and…github.blog


메타데이터
post_id
8974e3cf2af8
slug
setting-a-classic-pat-for-my-github-mcp-server-8974e3cf2af8
url
https://medium.com/@walkable-llc/setting-a-classic-pat-for-my-github-mcp-server-8974e3cf2af8
canonical_url
https://medium.com/@walkable-llc/setting-a-classic-pat-for-my-github-mcp-server-8974e3cf2af8
author_url
https://medium.com/@walkable-llc
status
ok
fetched_at
2026-06-09 15:37:30