Skip to content

Uploading files fails with HTTP error 406 #330

@UweKeim

Description

@UweKeim

I'm using OpenAI Codex CLI. When trying to upload files (even very small text files) to be attached to issues/issue notes, I get e.g. this error:

Called gitlab.upload_markdown({"project_id":"153","file_path":"C:\\issue-attachment.txt"})
  └ Error: tool call error: tool call failed for `gitlab/upload_markdown`
        Caused by:
            tools/call failed: Mcp error: -32603: GitLab API error: 406 Not Acceptable
            {"status":406,"error":"Not Acceptable"}

When doing it manually via command line, it succeeds:

curl --request POST ^
  --header "PRIVATE-TOKEN: glpat-of-mine" ^
  --form "file=@C:\issue-attachment.txt" ^
  "https://<my-gitlab>/api/v4/projects/153/uploads"

and returns e.g.:

{"id":3014,"alt":"issue-attachment.txt","url":"/uploads/6693457bebceb62f3bb3f167a18eee41/issue-attachment.txt","full_path":"/-/project/153/uploads/6693457bebceb62f3bb3f167a18eee41/issue-attachment.txt","markdown":"[issue-attachment.txt](/uploads/6693457bebceb62f3bb3f167a18eee41/issue-attachment.txt)"}

An excerpt of my "config.toml" from Codex looks like this:

# ...

[mcp_servers.gitlab]
command = "npx"
args = ["-y", "@zereight/mcp-gitlab"]

[mcp_servers.gitlab.env]
GITLAB_PERSONAL_ACCESS_TOKEN = "glpat-of-mine"
GITLAB_API_URL = "https://<my-gitlab>/api/v4"
GITLAB_READ_ONLY_MODE = "false"
USE_GITLAB_WIKI = "false"
USE_MILESTONE = "false"
USE_PIPELINE = "false"

# ...

My question

Am I doing something wrong here?

Update 1

I've let Codex analyze the log files on the GitLab server:

This typically points to a missing or malformed multipart/form-data upload (e.g. an incorrect or missing file field), or incompatible request headers. The GitLab server logs unfortunately do not contain any additional details beyond the "406 Not Acceptable" response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions