Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/josephburnett/jd/v2 v2.5.0
github.com/lithammer/fuzzysearch v1.1.8
github.com/microcosm-cc/bluemonday v1.0.27
github.com/modelcontextprotocol/go-sdk v1.8.0
github.com/modelcontextprotocol/go-sdk v1.9.0
Comment thread
JoannaaKL marked this conversation as resolved.
Resolved
github.com/muesli/cache2go v0.0.0-20221011235721-518229cd8021
github.com/segmentio/encoding v0.5.4
github.com/shurcooL/githubv4 v0.0.0-20260209031235-2402fdf4a9ed
Expand All @@ -21,7 +21,7 @@ require (
github.com/stretchr/testify v1.12.1
github.com/yosida95/uritemplate/v3 v3.0.2
go.yaml.in/yaml/v3 v3.0.6
golang.org/x/net v0.61.0
golang.org/x/net v0.63.0
golang.org/x/oauth2 v0.38.0
)

Expand All @@ -39,8 +39,8 @@ require (
github.com/spf13/cast v1.10.0 // indirect
github.com/stretchr/objx v0.5.3 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
golang.org/x/sync v0.24.0 // indirect
golang.org/x/sys v0.49.0 // indirect
golang.org/x/text v0.43.0 // indirect
golang.org/x/sync v0.25.0 // indirect
golang.org/x/sys v0.50.0 // indirect
golang.org/x/text v0.44.0 // indirect
golang.org/x/time v0.15.0 // indirect
)
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/modelcontextprotocol/go-sdk v1.8.0 h1:KIvahhYqwtbeniWVPs3TcXEA7b8jEtwfBpOTAI+Urx4=
github.com/modelcontextprotocol/go-sdk v1.8.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts=
github.com/modelcontextprotocol/go-sdk v1.9.0 h1:XVjBrIMg82x7ff2bqwSPgRThLp4TC1lGTX74Ofaie1g=
github.com/modelcontextprotocol/go-sdk v1.9.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts=
github.com/muesli/cache2go v0.0.0-20221011235721-518229cd8021 h1:31Y+Yu373ymebRdJN1cWLLooHH8xAr0MhKTEJGV/87g=
github.com/muesli/cache2go v0.0.0-20221011235721-518229cd8021/go.mod h1:WERUkUryfUWlrHnFSO/BEUZ+7Ns8aZy7iVOGewxKzcc=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
Expand Down Expand Up @@ -86,23 +86,23 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw=
golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
golang.org/x/oauth2 v0.38.0 h1:uW7XQbcu1eoiQS7uMJvLOjPMl04bTbmY1VeRPxvbspI=
golang.org/x/oauth2 v0.38.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.24.0 h1:iqiDrGoDgyuvAKrhLQthUEzU/R378N78gXbBjxed7oA=
golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs=
golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
Expand All @@ -111,15 +111,15 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U=
golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.51.0 h1:k4Xc/1Om9jwkBJBo4NVLMSARBoWtK10mx+W5BnXCeAI=
golang.org/x/tools v0.51.0/go.mod h1:9eEncMayCV6zRMGhR5eZEC2iBx98qWcF1HZ9Z7wJOoA=
golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs=
golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
8 changes: 6 additions & 2 deletions internal/ghmcp/oauth_typed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,12 @@ func TestOAuthTypedHTTPHeaderBoundary(t *testing.T) {
req.Header.Set("Mcp-Protocol-Version", inventory.ProtocolVersionMultiRoundTrip)
req.Header.Set("Mcp-Method", "tools/call")
req.Header.Set("Mcp-Name", probeToolName)
req.Header.Set("Mcp-Param-owner", tc.owner)
req.Header.Set("Mcp-Param-repo", tc.repo)
if tc.name != "missing-required" && tc.name != "null-owner" {
req.Header.Set("Mcp-Param-owner", tc.owner)
}
if tc.name != "missing-required" {
req.Header.Set("Mcp-Param-repo", tc.repo)
}
rec := httptest.NewRecorder()
handler.ServeHTTP(rec, req)
return rec
Expand Down
8 changes: 4 additions & 4 deletions pkg/github/context_tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ func TestContextToolsTypedRegistration(t *testing.T) {
legacyResult, err := getMeTool.Handler(deps)(ContextWithDeps(context.Background(), deps), &request)
require.NoError(t, err)
assert.Equal(t, `{"login":"testuser","profile_url":"https://github.com/testuser","details":{"public_repos":0,"public_gists":0,"followers":0,"following":0,"created_at":"2020-01-02T03:04:05Z","updated_at":"0001-01-01T00:00:00Z"}}`, getTextResult(t, legacyResult).Text)
require.NoError(t, outputSchemas["get_me"].Validate(result.StructuredContent))
require.NoError(t, outputSchemas["get_me"].Validate(mustJSONValue(t, result.StructuredContent)))

result, err = clientSession.CallTool(context.Background(), &mcp.CallToolParams{
Name: "get_teams",
Expand All @@ -381,7 +381,7 @@ func TestContextToolsTypedRegistration(t *testing.T) {
legacyResult, err = getTeamsTool.Handler(deps)(ContextWithDeps(context.Background(), deps), &request)
require.NoError(t, err)
assert.Equal(t, `[{"org":"testorg","teams":[{"name":"team1","slug":"team1","description":"Team 1"}]}]`, getTextResult(t, legacyResult).Text)
require.NoError(t, outputSchemas["get_teams"].Validate(result.StructuredContent))
require.NoError(t, outputSchemas["get_teams"].Validate(mustJSONValue(t, result.StructuredContent)))
assert.Equal(t, 2, graphQLCalls)

result, err = clientSession.CallTool(context.Background(), &mcp.CallToolParams{
Expand All @@ -399,7 +399,7 @@ func TestContextToolsTypedRegistration(t *testing.T) {
legacyResult, err = teamMembersTool.Handler(deps)(ContextWithDeps(context.Background(), deps), &request)
require.NoError(t, err)
assert.Equal(t, `["user1","user2"]`, getTextResult(t, legacyResult).Text)
require.NoError(t, outputSchemas["get_team_members"].Validate(result.StructuredContent))
require.NoError(t, outputSchemas["get_team_members"].Validate(mustJSONValue(t, result.StructuredContent)))
assert.Equal(t, 4, graphQLCalls)

result, err = clientSession.CallTool(context.Background(), &mcp.CallToolParams{
Expand Down Expand Up @@ -450,7 +450,7 @@ func TestContextToolsTypedRegistration(t *testing.T) {
require.NoError(t, err)
assert.JSONEq(t, tc.structured, string(structuredJSON))
assert.JSONEq(t, string(structuredJSON), getTextResult(t, result).Text)
require.NoError(t, outputSchemas[tc.name].Validate(result.StructuredContent))
require.NoError(t, outputSchemas[tc.name].Validate(mustJSONValue(t, result.StructuredContent)))
}

failGetMe = true
Expand Down
4 changes: 1 addition & 3 deletions pkg/github/issue_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ func TestIssueArtifactRequests(t *testing.T) {
require.False(t, result.IsError, "%s", getTextResult(t, result).Text)
assert.Equal(t, 1, calls)
text := getTextResult(t, result).Text
var structured any
require.NoError(t, json.Unmarshal([]byte(text), &structured))
assert.Equal(t, structured, result.StructuredContent)
assert.JSONEq(t, text, mustMarshalJSON(t, result.StructuredContent))
switch tc.index {
case 2:
assert.JSONEq(t, `{"deleted":{"issue_number":12,"artifact_number":3,"message":"artifact deleted"}}`, text)
Expand Down
2 changes: 1 addition & 1 deletion pkg/github/repository_tool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func repositoryContentOutput(result *mcp.CallToolResult) (*RepositoryContentsOut
if block.Resource.Blob != nil {
blob := base64.StdEncoding.EncodeToString(block.Resource.Blob)
resource.Blob = &blob
} else if block.Resource.Text != "" {
} else {
resource.Text = &block.Resource.Text
}
out.Content = append(out.Content, RepositoryContentBlock{Resource: &RepositoryResourceBlock{Type: "resource", Resource: resource}})
Expand Down
2 changes: 1 addition & 1 deletion pkg/github/typed_consolidated_issue_enrichment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestTypedIssueReadIFCLabels(t *testing.T) {
assert.Equal(t, "public", label["confidentiality"])
if schema := schemas["issue_read"]; schema != nil {
require.NotNil(t, result.StructuredContent)
require.NoError(t, schema.Validate(result.StructuredContent))
require.NoError(t, schema.Validate(mustJSONValue(t, result.StructuredContent)))
} else {
assert.Nil(t, result.StructuredContent)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/github/typed_consolidated_pull_request_outputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ func runTypedPullRequestCases(t *testing.T, session *mcp.ClientSession, schemas
if tc.text == "null" {
assert.Equal(t, "null", text)
// Explicit wire presence is checked by the session middleware.
assert.Nil(t, result.StructuredContent, "%s %v", tc.tool, tc.args)
assert.NotNil(t, result.StructuredContent, "%s %v", tc.tool, tc.args)
assert.JSONEq(t, "null", mustMarshalJSON(t, result.StructuredContent))
require.NoError(t, schema.Validate(nil))
continue
}
Expand Down Expand Up @@ -507,7 +508,7 @@ func TestTypedPullRequestContentParity(t *testing.T) {
require.NotNil(t, result.Meta["ifc"])
if protocol == inventory.ProtocolVersionMultiRoundTrip {
assert.JSONEq(t, mustMarshalJSON(t, result.StructuredContent), text)
require.NoError(t, schemas["pull_request_read"].Validate(result.StructuredContent))
require.NoError(t, schemas["pull_request_read"].Validate(mustJSONValue(t, result.StructuredContent)))
} else {
assert.Nil(t, result.StructuredContent)
assert.Equal(t, `{"number":1,"title":"Subject","body":"body","state":"open","draft":false,"merged":false,"html_url":"https://github.com/owner/repo/pull/1","user":{"login":"octocat"}}`, text)
Expand Down
4 changes: 2 additions & 2 deletions pkg/github/typed_granular_issue_outputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestTypedGranularIssueWireOutputs(t *testing.T) {
assert.JSONEq(t, expected, mustMarshalJSON(t, result.StructuredContent))
assert.JSONEq(t, expected, getTextResult(t, result).Text)
assert.JSONEq(t, getTextResult(t, result).Text, mustMarshalJSON(t, result.StructuredContent))
require.NoError(t, schema.Validate(result.StructuredContent))
require.NoError(t, schema.Validate(mustJSONValue(t, result.StructuredContent)))
if strings.Contains(tc.name, "sub_issue") {
var output map[string]json.RawMessage
require.NoError(t, json.Unmarshal([]byte(mustMarshalJSON(t, result.StructuredContent)), &output))
Expand Down Expand Up @@ -426,7 +426,7 @@ func TestTypedGranularIssueWireErrors(t *testing.T) {
}
if schema := schemas[tc.name]; schema != nil {
assert.JSONEq(t, expectedText, mustMarshalJSON(t, result.StructuredContent))
require.NoError(t, schema.Validate(result.StructuredContent))
require.NoError(t, schema.Validate(mustJSONValue(t, result.StructuredContent)))
} else {
assert.Nil(t, result.StructuredContent)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/github/typed_issue_outputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ func TestTypedIssueNullOutput(t *testing.T) {
require.False(t, result.IsError)
assert.Equal(t, "null", getTextResult(t, result).Text)
if protocol == inventory.ProtocolVersionMultiRoundTrip {
assert.Nil(t, result.StructuredContent, "the SDK omits structuredContent when the typed output is null")
assert.NotNil(t, result.StructuredContent)
assert.JSONEq(t, "null", mustMarshalJSON(t, result.StructuredContent))
} else {
assert.Nil(t, result.StructuredContent)
}
Expand Down
17 changes: 12 additions & 5 deletions pkg/github/typed_search_outputs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestTypedProjectedReadToolOutputSchemas(t *testing.T) {
assert.JSONEq(t, mustMarshalJSON(t, ifc.LabelRepoMetadata(false)), mustMarshalJSON(t, branches.Meta["ifc"]))
if protocolVersion == inventory.ProtocolVersionMultiRoundTrip {
assert.Equal(t, "[]", mustMarshalJSON(t, branches.StructuredContent))
require.NoError(t, outputSchemas["list_branches"].Validate(branches.StructuredContent))
require.NoError(t, outputSchemas["list_branches"].Validate(mustJSONValue(t, branches.StructuredContent)))
} else {
assert.Nil(t, branches.StructuredContent)
}
Expand All @@ -140,7 +140,7 @@ func TestTypedProjectedReadToolOutputSchemas(t *testing.T) {
structured, err := json.Marshal(result.StructuredContent)
require.NoError(t, err)
assert.JSONEq(t, getTextResult(t, result).Text, string(structured))
require.NoError(t, outputSchemas["list_tags"].Validate(result.StructuredContent))
require.NoError(t, outputSchemas["list_tags"].Validate(mustJSONValue(t, result.StructuredContent)))
}

result, err = session.CallTool(context.Background(), &mcp.CallToolParams{
Expand All @@ -163,7 +163,7 @@ func TestTypedProjectedReadToolOutputSchemas(t *testing.T) {
structured, err := json.Marshal(result.StructuredContent)
require.NoError(t, err)
assert.JSONEq(t, getTextResult(t, result).Text, string(structured))
require.NoError(t, outputSchemas["search_code"].Validate(result.StructuredContent))
require.NoError(t, outputSchemas["search_code"].Validate(mustJSONValue(t, result.StructuredContent)))
}

result, err = session.CallTool(context.Background(), &mcp.CallToolParams{
Expand All @@ -177,7 +177,7 @@ func TestTypedProjectedReadToolOutputSchemas(t *testing.T) {
}
if protocolVersion == inventory.ProtocolVersionMultiRoundTrip {
assert.JSONEq(t, `{"total_count":1,"incomplete_results":false,"items":[{"name":"main.go","path":"cmd/main.go","sha":"abc123","repository":"owner/repo","text_matches":[{"object_type":"FileContent","property":"content","fragment":"func main()","matches":[{"text":"main","indices":[5,9]}]}]}]}`, getTextResult(t, result).Text)
require.NoError(t, outputSchemas["search_code"].Validate(result.StructuredContent))
require.NoError(t, outputSchemas["search_code"].Validate(mustJSONValue(t, result.StructuredContent)))
assert.JSONEq(t, getTextResult(t, result).Text, mustMarshalJSON(t, result.StructuredContent))
}

Expand All @@ -193,7 +193,7 @@ func TestTypedProjectedReadToolOutputSchemas(t *testing.T) {
} else {
assert.JSONEq(t, `{"total_count":1,"incomplete_results":false,"items":[{"number":42,"title":"A title","body":"A body","state":"open"}]}`, getTextResult(t, result).Text)
assert.JSONEq(t, getTextResult(t, result).Text, mustMarshalJSON(t, result.StructuredContent))
require.NoError(t, outputSchemas["search_issues"].Validate(result.StructuredContent))
require.NoError(t, outputSchemas["search_issues"].Validate(mustJSONValue(t, result.StructuredContent)))
}

failure, err := session.CallTool(context.Background(), &mcp.CallToolParams{
Expand Down Expand Up @@ -397,3 +397,10 @@ func mustMarshalJSON(t *testing.T, value any) string {
require.NoError(t, err)
return string(encoded)
}

func mustJSONValue(t *testing.T, value any) any {
t.Helper()
var decoded any
require.NoError(t, json.Unmarshal([]byte(mustMarshalJSON(t, value)), &decoded))
return decoded
}
Loading
Loading