Skip to main content
Glama
pranjal-sen-2004

GitHub Activity MCP Server

🚀 GitHub Activity MCP Server

一个使用 FastMCPPyGithub 构建的 MCP(Model Context Protocol)服务器,可将 AI 助手连接到 GitHub——搜索仓库、管理 Issue 与 PR、分析贡献,以及更多。

什么是 MCP? Model Context Protocol 是一种开放标准,让 AI 助手通过统一接口连接到外部数据和工具。可以把它想象成“AI 界的 USB-C”。


✨ 功能特性

该服务器提供 13 个工具3 个资源提供者3 个提示模板,覆盖全部三种 MCP 原语。

🔧 工具(模型控制)

AI 可自主执行的操作:

工具

说明

search_repositories

按查询、语言、星标搜索 GitHub 仓库

get_repository

获取仓库详细信息(星标、fork、主题等)

get_file_contents

读取仓库中的任意文件

list_commits

列出最近的提交,支持筛选

list_issues

按状态/标签/指派对象筛选 issue

get_issue

获取 issue 的完整详情 + 评论

create_issue

创建新的 issue

add_issue_comment

在 issue 上发表评论

list_pull_requests

按状态/分支筛选 PR

get_pull_request

获取 PR 详情 + 合并状态

get_pull_request_diff

查看 PR 代码改动

get_user_profile

获取用户的公开资料

list_user_repos

列出用户的所有仓库

📦 资源(应用控制)

AI 可读取的上下文数据:

资源 URI

说明

github://repo/{owner}/{repo}/readme

仓库 README(Markdown)

github://repo/{owner}/{repo}/tree

完整文件树列表

github://repo/{owner}/{repo}/languages

语言占比分布

💬 提示词(用户触发)

预置的工作流模板:

提示词

说明

analyze-repo

全面的仓库分析

review-pr

代码审查(遵循最佳实践)

issue-triage

对未关闭的 issue 分类并排定优先级


Related MCP server: GitHub MCP Server

🏗️ 架构

graph LR
    A[AI Assistant] <-->|MCP Protocol| B[GitHub MCP Server]
    B <-->|REST API| C[GitHub API]

    subgraph "MCP Server (FastMCP)"
        B --> D[Tools]
        B --> E[Resources]
        B --> F[Prompts]
    end

    subgraph "Tools"
        D --> D1[Repos]
        D --> D2[Issues]
        D --> D3[Pull Requests]
        D --> D4[Users]
    end

🚀 快速开始

前置要求

  • Python ≥ 3.10

  • GitHub 个人访问令牌(可选,但建议使用以获得更高的速率限制)

安装

# Clone the repository
git clone https://github.com/YOUR_USERNAME/github-mcp-server.git
cd github-mcp-server

# Install dependencies
pip install fastmcp PyGithub

设置你的 GitHub Token(可选)

创建一个具有 reporead:user 权限范围的个人访问令牌

# Linux/macOS
export GITHUB_TOKEN=ghp_your_token_here

# Windows (PowerShell)
$env:GITHUB_TOKEN = "ghp_your_token_here"

注意: 没有 token 时,你每小时仅限 60 次 API 请求;有 token 后,每小时可达 5,000 次。

运行服务器

# Run directly
fastmcp run src/server.py

# Or with Python
python -m src.server

使用 FastMCP 开发模式测试

fastmcp dev src/server.py

⚙️ 配置

Claude Desktop

在 Claude Desktop 配置中添加(macOS 上路径为 ~/Library/Application Support/Claude/claude_desktop_config.json,Windows 上为 %APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "github": {
      "command": "fastmcp",
      "args": ["run", "src/server.py"],
      "cwd": "/absolute/path/to/github-mcp-server",
      "env": {
        "GITHUB_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

Cursor

在 Cursor 的 MCP 配置中添加(项目中的 .cursor/mcp.json 或全局配置):

{
  "mcpServers": {
    "github": {
      "command": "fastmcp",
      "args": ["run", "src/server.py"],
      "cwd": "/absolute/path/to/github-mcp-server",
      "env": {
        "GITHUB_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

VS Code(GitHub Copilot)

在 VS Code 设置中添加(.vscode/settings.json):

{
  "mcp": {
    "servers": {
      "github": {
        "command": "fastmcp",
        "args": ["run", "src/server.py"],
        "cwd": "/absolute/path/to/github-mcp-server",
        "env": {
          "GITHUB_TOKEN": "ghp_your_token_here"
        }
      }
    }
  }
}

📁 项目结构

github-mcp-server/
├── src/
│   ├── __init__.py
│   ├── server.py             # FastMCP server instance & entry point
│   ├── github_client.py      # PyGithub client wrapper & error handling
│   ├── resources.py          # Resource providers (README, tree, languages)
│   ├── prompts.py            # Prompt templates (analyze, review, triage)
│   └── tools/
│       ├── __init__.py
│       ├── repos.py          # Repository tools (search, get, file contents, commits)
│       ├── issues.py         # Issue tools (list, get, create, comment)
│       ├── pulls.py          # Pull request tools (list, get, diff)
│       └── users.py          # User tools (profile, repos)
├── pyproject.toml
├── README.md
├── LICENSE
└── .gitignore

🛠️ 技术栈

技术

用途

FastMCP

高级 MCP 服务器框架

PyGithub

GitHub REST API 客户端

Model Context Protocol

AI 工具集成的开放标准


🤝 参与贡献

欢迎贡献!步骤如下:

  1. Fork 此仓库

  2. 创建功能分支(git checkout -b feature/amazing-feature

  3. 提交你的更改(git commit -m 'Add amazing feature'

  4. 推送到分支(git push origin feature/amazing-feature

  5. 打开一个 Pull Request


📄 许可证

本项目采用 MIT 许可证授权——详情请见 LICENSE 文件。


Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.

  • Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analy…

  • Screens public GitHub repos and PRs to generate risk maps, findings, and merge-readiness signals.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pranjal-sen-2004/github-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server