feat: get_file_content returns plain text by default #116

Merged
BrilliantKahn merged 0 commits from refs/pull/116/head into main 2026-05-06 09:50:20 +00:00
BrilliantKahn commented 2026-05-05 18:22:43 +00:00 (Migrated from codeberg.org)

get_file_content currently decodes the base64-encoded GetContents response and returns only the content field — every file retrieval requires a base64 round-trip and the caller receives raw bytes with no surrounding metadata. This PR switches the default to GetFile (the SDK 's /raw/ endpoint), which returns plain UTF-8 text directly. An optional with_metadata boolean parameter is added: when true, the tool calls GetContents and returns the full ContentsResponse object (sha, encoding, links, type, size, base64 content) for callers that need the structured response.

Closes #114

The parameter name with_metadata was adopted directly from the maintainer's review of issue #114 — see this comment. The branch originally used as_binary as a placeholder; the rename to with_metadata better describes what the flag actually controls — the response shape (full ContentsResponse vs. plain text), not the content encoding of the file itself.

This branch has been running on an internal MCP deploy since 2026-05-05. All existing tests pass and two new tests cover the plain-text default and the with_metadata=true path.

`get_file_content` currently decodes the base64-encoded `GetContents` response and returns only the content field — every file retrieval requires a base64 round-trip and the caller receives raw bytes with no surrounding metadata. This PR switches the default to `GetFile` (the SDK 's `/raw/` endpoint), which returns plain UTF-8 text directly. An optional `with_metadata` boolean parameter is added: when `true`, the tool calls `GetContents` and returns the full `ContentsResponse` object (sha, encoding, links, type, size, base64 content) for callers that need the structured response. Closes #114 The parameter name `with_metadata` was adopted directly from the maintainer's review of issue #114 — see [this comment](https://codeberg.org/goern/forgejo-mcp/issues/114#issuecomment-14349905). The branch originally used `as_binary` as a placeholder; the rename to `with_metadata` better describes what the flag actually controls — the response shape (full `ContentsResponse` vs. plain text), not the content encoding of the file itself. This branch has been running on an internal MCP deploy since 2026-05-05. All existing tests pass and two new tests cover the plain-text default and the `with_metadata=true` path.
BrilliantKahn commented 2026-05-06 09:45:46 +00:00 (Migrated from codeberg.org)

Thanks for the review!
On the description update: I pushed it to the branch — used your suggested wording verbatim, it captures both the binary case and the metadata-for-update_file flow cleanly.
Also here, I hope you proceed with the merge as planned.
Looking forward to the release! :)

Thanks for the review! On the description update: I pushed it to the branch — used your suggested wording verbatim, it captures both the binary case and the metadata-for-update_file flow cleanly. Also here, I hope you proceed with the merge as planned. Looking forward to the release! :)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
agentic-forges/forgejo-mcp!116
No description provided.