GitHub Repository MCP Server
GitHub 存储库 MCP 服务器
此模型上下文协议 (MCP) 服务器允许 AI 模型访问 GitHub 仓库内容作为上下文。它提供工具来获取文件内容、仓库结构以及整个仓库,以用作 AI 交互的上下文。
特征
获取整个存储库内容作为上下文
从存储库获取特定文件内容
获取存储库结构(文件列表)
按扩展名过滤文件
排除特定路径
限制返回的文件数量
Related MCP server: GitHub Repo Explainer MCP
安装
# clone the repository
git clone https://github.com/shanksxz/github-mcp.git
cd github-mcp
# install dependencies
npm install
# build the project
npm run build用法
设置 GitHub 身份验证
虽然服务器无需身份验证即可处理公共仓库,但 GitHub API 对未经身份验证的请求有严格的速率限制(每小时 60 个请求)。要将此限制提高到每小时 5000 个请求,请设置GITHUB_TOKEN环境变量:
# create a file called gh.sh and add the following line:
export GITHUB_TOKEN=your_github_personal_access_token
# make the file executable
chmod +x gh.sh
# run the file
./gh.sh您可以在GitHub 开发者设置中创建个人访问令牌。
与游标一起使用
要将此服务器与 Cursor 一起使用,请按照以下步骤操作:
打开游标设置
搜索“MCP”
点击“添加新的 MCP 服务器”
输入以下信息:
名称:github-repo-context(或您想要的任何名称)
类型:命令
命令:/path/to/your-local-repo-setup/gh.sh
点击“保存”
单击服务器名称旁边的开关来启用服务器
您现在应该能够在项目中使用该服务器
服务器按照 MCP 协议通过 stdin/stdout 进行通信。
可用工具
该服务器提供以下工具:
get-repo-context :从 GitHub 存储库获取所有文件作为上下文
参数:
owner:GitHub 仓库所有者/组织名称repo:GitHub 存储库名称maxFiles(可选):要包含的最大文件数(默认值:50)fileExtensions(可选):要包含的文件扩展名(例如,['js','ts','md'])excludePaths(可选):要排除的路径(默认值:['node_modules','dist','build'])
get-file-content :从 GitHub 存储库获取特定文件的内容
参数:
owner:GitHub 仓库所有者/组织名称repo:GitHub 存储库名称path:存储库中的文件路径
get-repo-structure :获取 GitHub 存储库的结构
参数:
owner:GitHub 仓库所有者/组织名称repo:GitHub 存储库名称
例子
当与支持 MCP 的 AI 模型集成时,您可以使用以下命令:
Get the structure of the repository tensorflow/tensorflow然后,AI 将使用get-repo-structure工具来获取并显示存储库结构。
Available Tools
3 toolsget-file-contentC
Get content of a specific file from a GitHub repository
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | GitHub repository owner/organization name | |
| repo | Yes | GitHub repository name | |
| path | Yes | Path to the file in the repository |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves file content but omits critical details: it doesn't specify whether this is a read-only operation (implied but not explicit), mention authentication requirements, rate limits, error handling for missing files, or the format of returned content. For a tool with zero annotation coverage, this is a significant gap in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that directly states the tool's purpose without any fluff or redundancy. It is appropriately sized and front-loaded, making it easy for an agent to parse quickly. Every word earns its place, contributing to clarity without unnecessary elaboration.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (a read operation with 3 required parameters) and the absence of both annotations and an output schema, the description is incomplete. It doesn't explain what the return value looks like (e.g., file content as text or binary), error conditions, or behavioral traits like authentication needs. For a tool with no structured data to rely on, the description should provide more comprehensive context to guide the agent effectively.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with clear documentation for 'owner', 'repo', and 'path' parameters. The description adds no additional semantic context beyond what the schema provides, such as examples or constraints on path formatting. According to the rules, when schema coverage is high (>80%), the baseline score is 3, which applies here as the description doesn't compensate with extra parameter insights.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Get content') and resource ('specific file from a GitHub repository'), making the tool's purpose immediately understandable. It distinguishes from sibling tools like 'get-repo-context' and 'get-repo-structure' by focusing on file content retrieval rather than repository metadata or structure. However, it doesn't explicitly mention the verb 'read' or specify that it's for a single file, which would make it a perfect 5.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus its siblings. It doesn't mention alternatives like 'get-repo-context' for repository information or 'get-repo-structure' for directory listings, nor does it specify prerequisites such as needing a valid file path. This lack of context leaves the agent to infer usage scenarios without explicit direction.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get-repo-contextC
Get all files from a GitHub repository to use as context
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | GitHub repository owner/organization name | |
| repo | Yes | GitHub repository name | |
| maxFiles | No | Maximum number of files to include (default: 50) | |
| fileExtensions | No | File extensions to include (e.g., ['js', 'ts', 'md']) | |
| excludePaths | No | Paths to exclude (e.g., ['node_modules', 'dist']) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that files are retrieved 'to use as context', implying a read-only operation for contextual purposes, but fails to disclose critical behavioral traits such as rate limits, authentication requirements, pagination, error handling, or what the output format looks like (e.g., structured data vs. raw files). For a tool with 5 parameters and no output schema, this is a significant gap in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence that efficiently conveys the core purpose without unnecessary words. It's front-loaded with the main action and resource, making it easy for an agent to quickly understand the tool's intent. Every part of the sentence earns its place by specifying the scope ('all files') and purpose ('to use as context').
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity (5 parameters, no annotations, no output schema), the description is incomplete. It lacks details on behavioral aspects (e.g., how files are returned, error conditions), doesn't differentiate from sibling tools, and provides minimal usage guidance. While the input schema is well-documented, the description fails to add sufficient value beyond it, leaving gaps in understanding the tool's full context and operation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, meaning all parameters are well-documented in the input schema itself (e.g., owner, repo, maxFiles with default, fileExtensions, excludePaths). The description adds no additional parameter semantics beyond what the schema provides, such as explaining how fileExtensions or excludePaths interact or typical use cases. Given the high schema coverage, a baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('Get') and resource ('all files from a GitHub repository'), specifying the action and target. However, it doesn't explicitly differentiate from sibling tools like 'get-file-content' (which likely gets specific file contents) or 'get-repo-structure' (which might get directory structure), leaving room for ambiguity about what distinguishes this tool from those alternatives.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides minimal guidance: it states the tool is for getting files 'to use as context', but offers no explicit advice on when to use this tool versus the sibling tools (get-file-content, get-repo-structure). There's no mention of prerequisites, limitations, or alternative scenarios, leaving the agent to infer usage from the tool name and parameters alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get-repo-structureC
Get the structure of a GitHub repository
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | GitHub repository owner/organization name | |
| repo | Yes | GitHub repository name |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves repository structure but doesn't explain what that entails (e.g., returns a tree, includes file types, requires authentication, has rate limits, or is read-only). This leaves significant gaps in understanding how the tool behaves.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence with no wasted words. It's front-loaded with the core purpose, making it easy to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the lack of annotations and output schema, the description is incomplete. It doesn't clarify what 'structure' means, how results are formatted, or any behavioral traits like authentication needs. For a tool with two parameters and no structured context, more detail is needed to be fully helpful.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, clearly documenting both parameters ('owner' and 'repo'). The description adds no additional meaning beyond the schema, such as examples or constraints. Since schema coverage is high, the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('Get') and resource ('structure of a GitHub repository'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get-file-content' or 'get-repo-context', which likely retrieve different aspects of repository data.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'get-file-content' or 'get-repo-context'. It lacks context about what 'structure' means (e.g., directory tree, file metadata) or any prerequisites for usage.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
- First observed
get-file-content - First observed
get-repo-context - First observed
get-repo-structure
TDQS
Scored across 3 tools
The tools have overlapping purposes that could cause confusion. get-repo-context and get-repo-structure both retrieve repository information, with get-repo-context getting all files and get-repo-structure getting the structure, making their boundaries unclear. get-file-content is more distinct but still part of the same domain.
All tool names follow a consistent verb_noun pattern with hyphens (get-file-content, get-repo-context, get-repo-structure). The naming is predictable and readable throughout the set.
With only 3 tools, the server feels thin for a GitHub repository domain. It lacks essential operations like create, update, delete, or search, which are typical for such a purpose, making the scope incomplete and underpowered.
The tool surface is severely incomplete for a GitHub repository server. It only provides read-only file and structure retrieval, missing core CRUD operations (e.g., create/update files, manage issues/pull requests) and other common GitHub functionalities, leading to significant gaps that will hinder agent workflows.
Maintenance
Related MCP Connectors
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Access the GitHub API, enabling file operations, repository management, search functionality, and…
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analy…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to analyze GitHub repository structures and read file contents with features like directory traversal, file type analysis, syntax highlighting, and code pattern detection. Supports both public and private repositories through GitHub API integration.8 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to access live GitHub repository data without cloning, supporting repo summarization, file explanation, recent changes, and dependency analysis.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to analyze GitHub repositories, including fetching repository details, searching, and retrieving README content.494 npm2ISC
- FlicenseBqualityDmaintenanceEnables AI assistants to inspect local Git repositories and interact with the GitHub API for reading commits, diffs, files, issues, comments, pull requests, and project boards.10101 npm-