Github Project Manager

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Supports loading environment configuration from .env files, used to store GitHub tokens and other configuration settings.

  • Allows management of GitHub issues, pull requests, and projects. Features include creating, updating, and listing issues; adding comments; creating, updating, and merging pull requests; managing pull request reviews; and creating and managing GitHub projects.

GitHub 项目经理

用于管理 GitHub 项目和问题的模型上下文协议 (MCP) 实现。此软件包为 AI 助手和应用程序提供了一个无缝接口,以便与 GitHub 存储库、问题、拉取请求和项目进行交互。

特征

GitHub 问题管理

  • 创建问题
  • 更新问题
  • 列出带有过滤选项的问题
  • 获取问题详细信息
  • 对问题添加评论
  • 关闭问题

GitHub 拉取请求管理

  • 创建拉取请求
  • 更新拉取请求
  • 使用过滤选项列出拉取请求
  • 获取拉取请求详细信息
  • 合并拉取请求
  • 检查拉取请求是否已合并
  • 创建和管理拉取请求评审
  • 添加并列出评论
  • 请求和删除审阅者
  • 更新拉取请求分支

GitHub 项目管理

  • 创建项目
  • 将问题添加到项目
  • 更新项目项(在列之间移动)
  • 列出项目项目

安装

npm install @monsoft/mcp-github-project-manager

用法

npx 快速入门

使用 GitHub 项目管理器的最快方法是直接使用 npx:

npx -y @monsoft/mcp-github-project-manager --GITHUB_PERSONAL_TOKEN=your_github_token_here

这将启动 MCP 服务器,然后 MCP 客户端可以连接到该服务器。

交通选择

GitHub 项目管理器支持两种传输方式:

Stdio 传输(默认)

这是默认传输,非常适合直接 CLI 集成和本地使用:

# Start with default Stdio transport npx -y @monsoft/mcp-github-project-manager --GITHUB_PERSONAL_TOKEN=your_github_token_here

服务器发送事件 (SSE) 传输

对于远程设置和 Web 集成,您可以使用启动 HTTP 服务器的 SSE 传输:

# Start with SSE transport on default port (3010) npx -y @monsoft/mcp-github-project-manager --GITHUB_PERSONAL_TOKEN=your_github_token_here --RUN_SSE=1 # Start with SSE transport on a custom port npx -y @monsoft/mcp-github-project-manager --GITHUB_PERSONAL_TOKEN=your_github_token_here --RUN_SSE=1 --PORT=8080

使用 SSE 传输时,服务器可通过以下方式访问:

  • SSE 端点: http://localhost:<PORT>/sse
  • 消息端点: http://localhost:<PORT>/messages

使用 MCP 客户端进行设置

要与 Anthropic 或 Cursor 中的 Claude 等 AI 助手一起使用此功能:

# Start the MCP server in your terminal npx -y @monsoft/mcp-github-project-manager --GITHUB_PERSONAL_TOKEN=your_github_token_here

然后配置你的AI助手以使用此MCP服务器。具体配置取决于你使用的客户端。

程序化使用

要在您自己的代码中使用 GitHub 项目管理器:

import { GitHubProjectManager } from '@monsoft/mcp-github-project-manager'; // The token will be automatically loaded from command line arguments const manager = new GitHubProjectManager(); // Now you can use the manager to interact with GitHub projects

运行应用程序时,提供 GitHub 令牌作为命令行参数:

node your-app.js --GITHUB_PERSONAL_TOKEN=your_github_token_here

您还可以指定传输类型和其他选项:

# Use SSE transport node your-app.js --GITHUB_PERSONAL_TOKEN=your_github_token_here --RUN_SSE=1 --PORT=3010 # Use default Stdio transport node your-app.js --GITHUB_PERSONAL_TOKEN=your_github_token_here

如果您需要以编程方式使用特定传输选项启动服务器:

import { startGitHubProjectManagerServer, startGitHubProjectManagerServerSSE, } from '@monsoft/mcp-github-project-manager'; // Start with Stdio transport await startGitHubProjectManagerServer('your_github_token_here'); // Or start with SSE transport await startGitHubProjectManagerServerSSE('your_github_token_here', 3010);

API 参考

问题管理

创建问题

const newIssue = await manager.createIssue({ owner: 'organization-name', repo: 'repository-name', title: 'Issue title', body: 'Detailed description of the issue', labels: ['bug', 'priority-high'], assignees: ['username1', 'username2'], });

获取问题详情

const issue = await manager.getIssue({ owner: 'organization-name', repo: 'repository-name', issue_number: 123, });

更新问题

await manager.updateIssue({ owner: 'organization-name', repo: 'repository-name', issue_number: 123, title: 'Updated title', body: 'Updated description', state: 'closed', });

列出问题

const issues = await manager.listIssues({ owner: 'organization-name', repo: 'repository-name', state: 'open', labels: ['bug'], sort: 'created', direction: 'desc', });

添加问题评论

await manager.addIssueComment({ owner: 'organization-name', repo: 'repository-name', issue_number: 123, body: 'This is a comment', });

拉取请求管理

创建拉取请求

const pr = await manager.createPullRequest({ owner: 'organization-name', repo: 'repository-name', title: 'Pull request title', body: 'Description of changes', head: 'feature-branch', base: 'main', });

获取拉取请求详细信息

const pullRequest = await manager.getPullRequest({ owner: 'organization-name', repo: 'repository-name', pull_number: 456, });

合并拉取请求

await manager.mergePullRequest({ owner: 'organization-name', repo: 'repository-name', pull_number: 456, merge_method: 'squash', });

创建评论

await manager.createPullRequestReview({ owner: 'organization-name', repo: 'repository-name', pull_number: 456, event: 'APPROVE', body: 'LGTM! Great work.', });

项目管理

创建项目

const project = await manager.createProject({ owner: 'organization-name', name: 'Project Name', body: 'Project description', });

将项目添加到项目

await manager.addProjectItem({ project_id: 12345, content_id: issue.id, content_type: 'Issue', });

列出项目项

const items = await manager.listProjectItems({ project_id: 12345, });

错误处理

该包提供了用于处理常见错误场景的自定义错误类:

try { // GitHub operations } catch (error) { if (error instanceof MissingGitHubTokenError) { console.error('GitHub token is missing. Please provide one via command line.'); } else if (error instanceof AuthenticationError) { console.error('Failed to authenticate with GitHub. Check your token.'); } else if (error instanceof RateLimitError) { console.error('GitHub API rate limit exceeded.'); } else { console.error('An unexpected error occurred:', error.message); } }

可用的错误类别:

  • MissingGitHubTokenError :未提供 GitHub 令牌时抛出
  • AuthenticationError :身份验证失败时抛出
  • ResourceNotFoundError :当请求的资源不存在时抛出
  • ValidationError :输入验证失败时抛出
  • RateLimitError :当超出 GitHub API 速率限制时抛出
  • NetworkError :发生网络通信问题时抛出
  • GitHubApiError :GitHub API 问题的一般错误

GitHub 令牌权限

您的 GitHub 个人访问令牌需要以下权限:

  • repo - 完全访问存储库
  • project - 访问项目
  • issues - 访问问题

发展

建筑

npm run build

验证

npm run validate

测试

npm test

代码检查

npm run lint

执照

麻省理工学院

ID: wajp07sk6l