Skip to main content
Glama

Read a file or directory

forgejo_get_file
Read-onlyIdempotent

Read a file's contents or list a directory's entries from a Forgejo repository at a chosen branch, tag, or SHA.

Instructions

Reads a text file's contents, or lists a directory, at a given revision.

Parameters:

  • owner, repo (optional when defaults are configured)

  • path (string, required): path from the repository root, e.g. 'lib/filters.ts'; '' or '.' for the root

  • ref (string, optional): branch, tag or SHA. Defaults to the main branch

  • response_format

Returns, for a file: { type: 'file', path, size, sha, content, truncated, html_url } Returns, for a directory: { type: 'directory', path, entries: [{ name, type, size }] }

Binary files are not decoded: their size and SHA are returned with an explicit note. Contents are truncated past the context limit and the cut is reported.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refNoBranch, tag or SHA. Defaults to the main branch.
pathNoFile or directory path. Empty = root.
repoNoRepository name. Defaults to FORGEJO_DEFAULT_REPO.
ownerNoRepository owner (user or organisation). Defaults to FORGEJO_DEFAULT_OWNER.
response_formatNo'markdown' for a readable rendering, 'json' for the full data.markdown

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv1.0.0

TDQS

A4.6/5.0
Behavior5/5

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

The annotations already declare readOnly/idempotent behavior, and the description adds significant value beyond them: binary files are not decoded, contents are truncated with the cut reported, and exact return shapes are given for both files and directories. This fully discloses behavioral edge cases.

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

Conciseness4/5

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

The description is well-structured with a summary first, followed by parameters, return shapes, and edge cases. Each section earns its place; the only minor cost is a parameter list that partially duplicates schema fields, though it adds practical usage details.

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

Completeness5/5

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

With no output schema, the description takes on the burden of explaining return values and does so thoroughly: file objects, directory entry objects, binary-file behavior, truncation reporting, and revision defaults. For a tool of this complexity, nothing an agent needs to invoke it correctly is missing.

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

Parameters4/5

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

Schema coverage is 100%, so baseline is 3, but the description enriches parameters meaningfully: path semantics ('', '.', repository-root-relative examples), ref types and default branch, response_format intent, and optionality of owner/repo under configured defaults.

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 opens with a specific action and resource: 'Reads a text file's contents, or lists a directory, at a given revision.' It clearly distinguishes this tool from the sibling issue/pr/repo/branch tools and even covers both file and directory behavior in one sentence.

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?

Clear selection context is provided: it targets repository file/directory contents, accepts a revision via ref, and notes owner/repo are optional when defaults are configured. No explicit exclusions are given, but none are needed since no sibling tool covers file access.

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

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/Birdiz/forgejo-mcp'

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