call_forgejo_api double-encodes a string body, breaking every POST/PATCH #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
call_forgejo_apideclaresbody: z.any()and passes the value straight toforgejoRequest, which doesJSON.stringify(body). When an MCP client sendsbodyas a JSON string (which happens in practice), the stringify wraps it a second time and Forgejo receives a JSON string where it expects an object.Reproduced live twice while creating this very repo:
Confirmed mechanism:
The repo had to be created with curl instead. This makes the generic escape hatch unusable for every operation that takes a request body whenever the client serializes it as a string - which is the majority of POST/PUT/PATCH operations in the API.
Suggested fix
Coerce string bodies in
call_forgejo_api(or inforgejoRequest) before dispatch:Prefer doing this in
call_forgejo_apiso the low-level client keeps pass-through semantics, and note in the tool description that a JSON string is accepted.Tests
Add a unit test asserting that a string body and the equivalent object body produce identical request payloads, plus an integration test doing a real POST with a body through
call_forgejo_api.Severity
High - breaks the primary advertised capability (100 percent API coverage) for any write operation.