Compare commits

...

1 Commits

Author SHA1 Message Date
GitCaddy
9bd0a95e9f fix(mcp): use json.RawMessage for proper JSON unmarshaling
Some checks failed
Build and Release / Create Release (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m15s
Build and Release / Build Binaries (amd64, darwin) (push) Has been cancelled
Build and Release / Build Binaries (amd64, linux) (push) Has been cancelled
Build and Release / Build Binaries (amd64, windows) (push) Has been cancelled
Build and Release / Build Binaries (arm64, darwin) (push) Has been cancelled
Build and Release / Build Binaries (arm64, linux) (push) Has been cancelled
Build and Release / Lint (push) Has been cancelled
Build and Release / Unit Tests (push) Has been cancelled
Add RawMessage type alias to modules/json and use it in MCP handler.
The custom RawMessage type was not implementing json.Unmarshaler,
causing parse errors when receiving MCP tool calls with params object.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 00:37:16 +00:00
2 changed files with 8 additions and 7 deletions

View File

@@ -109,3 +109,7 @@ func UnmarshalHandleDoubleEncode(bs []byte, v any) error {
}
return err
}
// RawMessage is a raw encoded JSON value.
// It implements Marshaler and Unmarshaler and can be used to delay JSON decoding.
type RawMessage = json.RawMessage

View File

@@ -22,16 +22,13 @@ import (
"code.gitea.io/gitea/services/context"
)
// RawMessage is a raw encoded JSON value (equivalent to encoding/json.RawMessage)
type RawMessage []byte
// MCP Protocol Types (JSON-RPC 2.0)
type MCPRequest struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Method string `json:"method"`
Params RawMessage `json:"params,omitempty"`
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
type MCPResponse struct {