Skip to main content
Glama

fetch_repository_file

Fetch the content of a source code file from a GitHub repository, with optional start and end line numbers to extract specific sections. Ideal for reading code or configuration files.

Instructions

获取仓库内的源代码文件内容。

读取指定仓库中的文件内容,支持按行号范围截取。 内部自动通过 repo_path 获取 repo_id。 适用于查看源代码、配置文件等。

示例:

  • 获取完整文件: fetch_repository_file("owner/repo", "src/config.ts")

  • 获取前 50 行: fetch_repository_file("owner/repo", "src/config.ts", 1, 51)

  • 从第 100 行到末尾: fetch_repository_file("owner/repo", "src/config.ts", 100)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes仓库路径,格式: owner/repo 或完整 URL
file_pathYes文件在仓库中的路径,如 "src/config.ts", "README.md"
start_lineNo可选,开始行号(包含),从 1 开始计数
end_lineNo可选,结束行号(不包含),不指定则到文件末尾
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It discloses the read-only nature (file content retrieval) and internal logic (auto-resolving repo_id). It does not mention authentication or rate limits, but for a straightforward read operation, this is acceptable.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise (three sections: intro, detail, examples) with no filler. Every sentence adds information, and the example section is especially helpful for understanding parameter usage.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 4 parameters (2 required) and no output schema, the description covers input semantics well. It explains repo_path, file_path, and line ranges. However, it does not describe the output format (e.g., raw text, encoded), which would be helpful but not critical given the tool's simplicity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, but the description adds significant value: it explains line numbering (1-indexed, end_line exclusive), provides examples, and clarifies that start_line and end_line are optional. This goes beyond the schema definitions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool fetches file contents from a repository, with a specific verb ('获取') and resource ('仓库内的源代码文件内容'). It distinguishes from siblings like ask_repo_ai (AI queries) and fetch_documentation_page (docs) by focusing on source code files.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides concrete usage examples (full file, line ranges) and states its applicability ('适用于查看源代码、配置文件等'). However, it does not explicitly state when not to use it or mention alternative tools, though the sibling list implies distinct roles.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ejfkdev/zread-mcp'

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