github-org-mcp

github-org-mcp

A stateless HTTP MCP service that exposes GitHub organization member management tools (list, view, add, update role, remove members, and manage invitations) as MCP tools consumable by Claude and other MCP clients.

Category
访问服务器

README

github-org-mcp

A stateless HTTP MCP service that exposes GitHub organization member management (list / view / add / update role / remove members, and manage invitations) as Model Context Protocol (MCP) tools consumable by Claude and other MCP clients.

The OAuth flow is handled upstream — this service does not perform OAuth. The caller passes a GitHub OAuth access token and the org slug on each request via HTTP headers; the service maps the token to Authorization: Bearer <token> when calling the GitHub REST API.

Architecture

  • Stateless — no user state, no credential storage, no session data persisted between requests.
  • Concurrent-safe — per-request credential isolation via Python contextvars; concurrent requests never bleed token/org.
  • Dual auth modes — per-request credentials via HTTP headers (gateway mode, default, SOP-compliant) or single shared credentials (env mode, local dev only).
  • Two transports — HTTP server (MCP_TRANSPORT=http) for production, stdio (MCP_TRANSPORT=stdio) for local development.

Endpoints

Method Path Description
POST /mcp MCP protocol entry point
GET /health Health check

Default port: 8080 (configurable via MCP_HTTP_PORT).

Authentication — HEADER Parameters

In gateway mode (default), every POST /mcp request must carry both headers below. Requests missing either header receive 401. Credentials are never stored globally or persisted; each request's token and org live only in a contextvars.ContextVar and are reset when the request completes.

Client → this service this service → GitHub upstream
X-GitHub-Token: <oauth_access_token> Authorization: Bearer <oauth_access_token>
X-GitHub-Org: <org_slug> URL path segment .../orgs/<org_slug>/...
Header 类型 (Type) 是否必填 (Required) 默认值 (Default) 枚举值 (Enum) 字段描述 (Description) Example
X-GitHub-Token string 必填 (Yes) 无 (none) 无 (none) GitHub OAuth access token; mapped to Authorization: Bearer. OAuth flow handled upstream. gho_16C7e42F292c6912E7710c838347Ae178B4a
X-GitHub-Org string 必填 (Yes) 无 (none) 无 (none) GitHub organization login/slug the tools operate on. my-company

The header names are configurable via GITHUB_TOKEN_HEADER / GITHUB_ORG_HEADER.

Service Parameters

Variable Required Default Description
AUTH_MODE No gateway gateway (per-request credentials, SOP-compliant) or env (shared credentials, dev only)
GITHUB_TOKEN_HEADER No X-GitHub-Token HTTP header carrying the OAuth token in gateway mode
GITHUB_ORG_HEADER No X-GitHub-Org HTTP header carrying the org slug in gateway mode
GITHUB_TOKEN env mode only OAuth access token used in env mode (local dev only)
GITHUB_ORG env mode only Org slug used in env mode (local dev only)
GITHUB_BASE_URL No https://api.github.com GitHub REST API base URL (change for GitHub Enterprise Server)
MCP_TRANSPORT No stdio Transport: http or stdio
MCP_HTTP_PORT No 8080 HTTP listen port
MCP_HTTP_HOST No 0.0.0.0 HTTP listen host

Auth Modes

gateway mode (default, production, SOP-compliant):

  • Each request must include the X-GitHub-Token and X-GitHub-Org headers.
  • No credentials are stored globally — isolated per request via Python contextvars.
  • Returns 401 if either header is missing.

env mode (local dev only — not SOP-compliant for production):

  • Set AUTH_MODE=env, GITHUB_TOKEN, and GITHUB_ORG in the environment or .env.
  • All requests share the same credentials loaded at startup — violates per-request credential isolation.
  • Do not use in production or multi-tenant deployments.

Tool List

All tools follow the naming convention github_<action>_<resource> and operate on the org resolved from the request context (X-GitHub-Org).

Tool Description Parameters
github_list_org_members List members of the organization role (str, all/admin/member, default all), filter (str, all/2fa_disabled, default all), per_page (int, default 30), page (int, default 1)
github_get_org_membership Get a user's membership role and state username (str, required)
github_set_org_membership Add a user to the org or update their role (invites if not a member) username (str, required), role (str, member/admin, default member)
github_remove_org_member Remove a user from the org (also removes from all teams) username (str, required)
github_list_org_invitations List pending member invitations per_page (int, default 30), page (int, default 1)
github_create_org_invitation Invite a user by user ID or email invitee_id (int, optional), email (str, optional), role (str, direct_member/admin/billing_manager, default direct_member), team_ids (list[int], optional) — exactly one of invitee_id/email
github_cancel_org_invitation Cancel a pending invitation invitation_id (int, required)

The token's OAuth scopes / org permissions determine which operations succeed. Write operations (set/remove/create/cancel) require the token to belong to an org owner or an app with the appropriate org-members permission.

Quick Start

Local development (stdio)

cp .env.example .env
# Edit .env: set GITHUB_TOKEN, GITHUB_ORG, AUTH_MODE=env, MCP_TRANSPORT=stdio
uv sync
python -m github_org_mcp

HTTP server (gateway mode — default, SOP-compliant)

MCP_TRANSPORT=http python -m github_org_mcp
# Pass credentials per-request via X-GitHub-Token and X-GitHub-Org headers

Docker

docker compose up --build

Test Examples

Health check

curl http://localhost:8080/health

Expected response:

{"status": "ok", "transport": "http", "auth_mode": "gateway"}

Missing headers → 401 (gateway mode)

curl -i -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
# → HTTP/1.1 401, body includes "required_headers": ["X-GitHub-Token", "X-GitHub-Org"]

List MCP tools

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "X-GitHub-Token: your_oauth_access_token" \
  -H "X-GitHub-Org: my-company" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

Call a tool — list org members

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "X-GitHub-Token: your_oauth_access_token" \
  -H "X-GitHub-Org: my-company" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "github_list_org_members",
      "arguments": {"role": "all", "per_page": 30, "page": 1}
    }
  }'

Call a tool — invite a user by email

curl -X POST http://localhost:8080/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "X-GitHub-Token: your_oauth_access_token" \
  -H "X-GitHub-Org: my-company" \
  -d '{
    "jsonrpc": "2.0",
    "id": 3,
    "method": "tools/call",
    "params": {
      "name": "github_create_org_invitation",
      "arguments": {"email": "newhire@example.com", "role": "direct_member"}
    }
  }'

Security

  • Credentials are never stored globally or persisted between requests.
  • Each request's token and org are isolated in contextvars.ContextVar and reset after the request completes.
  • The service runs as a non-root user (github, uid 1001) inside the container.
  • Never commit real tokens or org secrets — .gitignore excludes .env.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选