mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-08-14 04:13:07 +00:00
efcbdbb17f
## Summary Replace `github.com/mark3labs/mcp-go` with the official `github.com/modelcontextprotocol/go-sdk v1.7.0`. All 54 existing tools, scopes, CLI, `stdio` and HTTP (`/mcp`) modes, and per-request authentication remain supported. This PR is limited to the SDK equivalence migration; the stateless 2026 HTTP transport is deferred to a follow-up PR. ## Verification - Tool definitions were compared with `main` and matched for all 54 tools. - `make lint`, `make fmt`, `go test -count=1 -race ./...`, `make build`, and `make tidy` pass. --------- Co-authored-by: bircni <bircni@icloud.com> Co-authored-by: silverwind <me@silverwind.io> Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/223 Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com> Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package annotation
|
|
|
|
import (
|
|
"encoding/json"
|
|
"maps"
|
|
"testing"
|
|
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
)
|
|
|
|
// The hints are what clients use to decide whether a tool needs confirmation, so
|
|
// assert the encoded form: an omitted readOnlyHint reads as false either way, but
|
|
// only the explicit form survives a client that checks for the key.
|
|
func TestAnnotations(t *testing.T) {
|
|
for _, test := range []struct {
|
|
name string
|
|
annotations *mcp.ToolAnnotations
|
|
want map[string]any
|
|
}{
|
|
{
|
|
name: "ReadOnly",
|
|
annotations: ReadOnly("Read"),
|
|
want: map[string]any{"title": "Read", "readOnlyHint": true, "idempotentHint": false},
|
|
},
|
|
{
|
|
name: "Write",
|
|
annotations: Write("Write"),
|
|
want: map[string]any{"title": "Write", "readOnlyHint": false, "idempotentHint": false},
|
|
},
|
|
{
|
|
name: "Destructive",
|
|
annotations: Destructive("Delete"),
|
|
want: map[string]any{"title": "Delete", "readOnlyHint": false, "idempotentHint": false, "destructiveHint": true},
|
|
},
|
|
} {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
encoded, err := json.Marshal(test.annotations)
|
|
if err != nil {
|
|
t.Fatalf("json.Marshal() error = %v", err)
|
|
}
|
|
var got map[string]any
|
|
if err := json.Unmarshal(encoded, &got); err != nil {
|
|
t.Fatalf("json.Unmarshal() error = %v", err)
|
|
}
|
|
if !maps.Equal(got, test.want) {
|
|
t.Errorf("annotations = %s, want %v", encoded, test.want)
|
|
}
|
|
})
|
|
}
|
|
}
|