本项目是一个 GitHub 企业版 MCP(Message-Centered Protocol)服务器,可与 Claude Desktop 和 Perplexity AI 等工具进行交互,为用户提供便捷的代码搜索、问题跟踪等功能。
原文档未提供安装步骤,此章节跳过。
# 以下是使用该服务器部分功能的示例代码
# 假设已经有了一个有效的服务器实例 server
# 搜索代码
server.searchCode("example query")
# 获取仓库文件列表
server.getFilesInRepo("owner", "repo")
# 获取文件内容
server.getFileContent("owner", "repo", "file_path")
# 更复杂的搜索示例,结合多种搜索条件
# 搜索 JavaScript 语言,在指定仓库和路径下的代码
search_query = "language:javascript repo:owner/repo path:app/src"
server.searchCode(search_query)
# 创建一个带有标签的新问题
new_issue_title = "New issue title"
new_issue_content = "This is the content of the new issue."
labels = ["bug", "enhancement"]
server.createIssue(new_issue_title, new_issue_content, "owner", "repo", labels)
searchCode(query: string) - 根据给定的查询搜索代码。getFilesInRepo(owner: string, repo: string, path?: string) - 获取指定仓库或路径下的文件列表。getFileContent(owner: string, repo: string, file_path: string) - 返回指定文件的内容。searchCodeByLanguage(language: string) - 按编程语言搜索代码。searchCodeByPath(path: string) - 根据路径搜索代码。searchCodeByExtension(extension: string) - 根据文件扩展名搜索代码。searchIssues(query: string) - 搜索问题和拉取请求。getIssueDetails(owner: string, repo: string, issue_number: number) - 获取指定问题的详细信息。createIssue(title: string, content: string, owner: string, repo: string, labels?: Array) - 创建新的问题或拉取请求。updateIssueStatus(issue_id: string, state: string) - 更新问题或拉取请求的状态(打开或关闭)。searchUsers(query: string) - 搜索用户或组织。getUserDetails(username: string) - 获取指定用户的详细信息,包括仓库、关注者和参与的项目。followUser(followee: string) - 关注指定用户。getRepositoryDetails(owner: string, repo: string) - 获取指定仓库的详细信息,包括成员列表和权限。createRepository(name: string, description?: string) - 创建新的仓库。addRepositoryMember(repo_id: string, username: string, role: string) - 向指定仓库添加新成员。requestReview(pull_request_id: string, reviewer: string) - 请求对指定拉取请求进行代码审查。leaveComment(file_path: string, content: string, pull_request_id: string) - 在指定文件上留下评论。approvePullRequest(pull_request_id: string) - 批准指定的拉取请求。language: 过滤编程语言,例如:language:javascriptrepo:owner/name 指定仓库,例如:repo:octocat/hello-worldpath: 指定路径,例如:path:app/srcextension: 过滤文件扩展名,例如:extension:jsis:issue 或 is:pr 区分问题或拉取请求类型。is:open 或 is:closed 指定状态。label: 根据标签筛选,例如:label:bugauthor: 根据作者搜索。type:user 或 type:org 区分用户或组织类型。followers:> 按关注者数量过滤,例如:followers:>100原文档未提供技术实现细节,此章节跳过。
原文档未提供许可证信息,此章节跳过。