create_file and update_file rely on base64 encoded content #72

Closed
opened 2026-02-11 09:24:08 +00:00 by c6sepl6p · 5 comments
c6sepl6p commented 2026-02-11 09:24:08 +00:00 (Migrated from codeberg.org)

I noticed that create_file and update_file rely on base64 encoded content. This causes errors as it isn't clearly communicated and also that would mean that the AI would have to use an external mechanism to encode the content first. Letting the model do the base64 encoding internally hasn't worked great for me in the past with more complex files.
What's your workflow here?

Tool: create_file
Description: Create file

Parameters:
  branch_name          string     required   Branch name
  content              string     required   Content
  filePath             string     required   File path
  message              string     required   Commit message
  new_branch_name      string     optional   New branch name
  owner                string     required   Repository owner
  repo                 string     required   Repository name

Here's an error message when the content in content: is not base64 encoded.

2026-02-11 09:17:36	ERROR	to/to.go:45	update file error: illegal base64 data at input byte 4
codeberg.org/goern/forgejo-mcp/v2/pkg/to.ErrorResult
	/go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/pkg/to/to.go:45
codeberg.org/goern/forgejo-mcp/v2/operation/repo.UpdateFileFn
	/go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/operation/repo/file.go:144
codeberg.org/goern/forgejo-mcp/v2/cmd.cliExec
	/go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/cmd/cli.go:323
codeberg.org/goern/forgejo-mcp/v2/cmd.RunCLI
	/go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/cmd/cli.go:141
codeberg.org/goern/forgejo-mcp/v2/cmd.Execute
	/go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/cmd/cmd.go:195
main.main
	/go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/main.go:17
runtime.main
	/usr/local/go/src/runtime/proc.go:290
Error: tool execution failed: update file error: illegal base64 data at input byte 4
I noticed that `create_file` and `update_file` rely on base64 encoded content. This causes errors as it isn't clearly communicated and also that would mean that the AI would have to use an external mechanism to encode the content first. Letting the model do the base64 encoding internally hasn't worked great for me in the past with more complex files. What's your workflow here? ``` Tool: create_file Description: Create file Parameters: branch_name string required Branch name content string required Content filePath string required File path message string required Commit message new_branch_name string optional New branch name owner string required Repository owner repo string required Repository name ``` Here's an error message when the content in `content:` is not base64 encoded. ``` 2026-02-11 09:17:36 ERROR to/to.go:45 update file error: illegal base64 data at input byte 4 codeberg.org/goern/forgejo-mcp/v2/pkg/to.ErrorResult /go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/pkg/to/to.go:45 codeberg.org/goern/forgejo-mcp/v2/operation/repo.UpdateFileFn /go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/operation/repo/file.go:144 codeberg.org/goern/forgejo-mcp/v2/cmd.cliExec /go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/cmd/cli.go:323 codeberg.org/goern/forgejo-mcp/v2/cmd.RunCLI /go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/cmd/cli.go:141 codeberg.org/goern/forgejo-mcp/v2/cmd.Execute /go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/cmd/cmd.go:195 main.main /go/pkg/mod/codeberg.org/goern/forgejo-mcp/v2@v2.10.0/main.go:17 runtime.main /usr/local/go/src/runtime/proc.go:290 Error: tool execution failed: update file error: illegal base64 data at input byte 4 ```
goern commented 2026-02-11 13:08:24 +00:00 (Migrated from codeberg.org)

hey @c6sepl6p thanks for the report. I'm not using it. Could you give an example of what would be best for your use case?

hey @c6sepl6p thanks for the report. I'm not using it. Could you give an example of what would be best for your use case?
c6sepl6p commented 2026-02-11 13:48:26 +00:00 (Migrated from codeberg.org)

https://codeberg.org/api/swagger#/repository/repoCreateFile

I looked into this a bit and it seems like the forgejo API requires content to be a base64 encoded string.
It seems like content is just passed through atm and the API throws the error.. The mcp server should encode the values of content to base64 before passing it to the API.

https://codeberg.org/api/swagger#/repository/repoCreateFile I looked into this a bit and it seems like the forgejo API requires content to be a base64 encoded string. It seems like content is just passed through atm and the API throws the error.. The mcp server should encode the values of content to base64 before passing it to the API.
goern commented 2026-02-11 22:45:25 +00:00 (Migrated from codeberg.org)

Thanks for the report and the investigation @c6sepl6p — you were spot on.

The fix has been implemented in commit 593eeb8:

  • create_file and update_file now automatically base64-encode the content parameter before passing it to the Forgejo API
  • The tool description for content has been updated to clarify it accepts plain text
  • Added tests with a mock Forgejo API server to verify the encoding

AI models (and users) can now pass plain text content directly — no manual base64 encoding needed.

Thanks for the report and the investigation @c6sepl6p — you were spot on. The fix has been implemented in commit `593eeb8`: - `create_file` and `update_file` now automatically base64-encode the `content` parameter before passing it to the Forgejo API - The tool description for `content` has been updated to clarify it accepts plain text - Added tests with a mock Forgejo API server to verify the encoding AI models (and users) can now pass plain text content directly — no manual base64 encoding needed.
goern commented 2026-02-11 22:48:13 +00:00 (Migrated from codeberg.org)

This fix is now on main. @c6sepl6p could you test with the current release and confirm it resolves the issue for you? If you run into any further problems, feel free to reopen.

This fix is now on `main`. @c6sepl6p could you test with the current release and confirm it resolves the issue for you? If you run into any further problems, feel free to reopen.
c6sepl6p commented 2026-02-12 08:21:29 +00:00 (Migrated from codeberg.org)

Thank you, works perfectly!

Thank you, works perfectly!
Sign in to join this conversation.
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#72
No description provided.