Skip to content

Commit 1e7807f

Browse files
committed
refactor: rename utils to mcpresult to fix revive issue
1 parent 0caa265 commit 1e7807f

26 files changed

+904
-873
lines changed

.github/agents/go-sdk-tool-migrator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When generating the migration guide, consider the following aspects:
1818
* The return type for the tool constructor function should be updated from `mcp.Tool, server.ToolHandlerFunc` to `(mcp.Tool, mcp.ToolHandlerFor[map[string]any, any])`.
1919
* The tool handler function signature should be updated to use generics, changing from `func(ctx context.Context, mcp.CallToolRequest) (*mcp.CallToolResult, error)` to `func(context.Context, *mcp.CallToolRequest, map[string]any) (*mcp.CallToolResult, any, error)`.
2020
* The `RequiredParam`, `RequiredInt`, `RequiredBigInt`, `OptionalParamOK`, `OptionalParam`, `OptionalIntParam`, `OptionalIntParamWithDefault`, `OptionalBoolParamWithDefault`, `OptionalStringArrayParam`, `OptionalBigIntArrayParam` and `OptionalCursorPaginationParams` functions should be changed to use the tool arguments that are now passed as a map in the tool handler function, rather than extracting them from the `mcp.CallToolRequest`.
21-
* `mcp.NewToolResultText`, `mcp.NewToolResultError`, `mcp.NewToolResultErrorFromErr` and `mcp.NewToolResultResource` no longer available in `modelcontextprotocol/go-sdk`. There are a few helper functions available in `pkg/utils/result.go` that can be used to replace these, in the `utils` package.
21+
* `mcp.NewToolResultText`, `mcp.NewToolResultError`, `mcp.NewToolResultErrorFromErr` and `mcp.NewToolResultResource` no longer available in `modelcontextprotocol/go-sdk`. There are a few helper functions available in `pkg/mcpresult/result.go` that can be used to replace these, in the `mcpresult` package.
2222

2323
### Schema Changes
2424

pkg/errors/error.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"net/http"
77

8-
"github.com/github/github-mcp-server/pkg/utils"
8+
"github.com/github/github-mcp-server/pkg/mcpresult"
99
"github.com/google/go-github/v79/github"
1010
"github.com/modelcontextprotocol/go-sdk/mcp"
1111
)
@@ -153,31 +153,31 @@ func addRawAPIErrorToContext(ctx context.Context, err *GitHubRawAPIError) (conte
153153
return nil, fmt.Errorf("context does not contain GitHubCtxErrors")
154154
}
155155

156-
// NewGitHubAPIErrorResponse returns an mcp.NewToolResultError and retains the error in the context for access via middleware
156+
// NewGitHubAPIErrorResponse returns an mcp.CallToolResult and retains the error in the context for access via middleware
157157
func NewGitHubAPIErrorResponse(ctx context.Context, message string, resp *github.Response, err error) *mcp.CallToolResult {
158158
apiErr := newGitHubAPIError(message, resp, err)
159159
if ctx != nil {
160160
_, _ = addGitHubAPIErrorToContext(ctx, apiErr) // Explicitly ignore error for graceful handling
161161
}
162-
return utils.NewToolResultErrorFromErr(message, err)
162+
return mcpresult.NewErrorFromErr(message, err)
163163
}
164164

165-
// NewGitHubGraphQLErrorResponse returns an mcp.NewToolResultError and retains the error in the context for access via middleware
165+
// NewGitHubGraphQLErrorResponse returns an mcp.CallToolResult and retains the error in the context for access via middleware
166166
func NewGitHubGraphQLErrorResponse(ctx context.Context, message string, err error) *mcp.CallToolResult {
167167
graphQLErr := newGitHubGraphQLError(message, err)
168168
if ctx != nil {
169169
_, _ = addGitHubGraphQLErrorToContext(ctx, graphQLErr) // Explicitly ignore error for graceful handling
170170
}
171-
return utils.NewToolResultErrorFromErr(message, err)
171+
return mcpresult.NewErrorFromErr(message, err)
172172
}
173173

174-
// NewGitHubRawAPIErrorResponse returns an mcp.NewToolResultError and retains the error in the context for access via middleware
174+
// NewGitHubRawAPIErrorResponse returns an mcp.CallToolResult and retains the error in the context for access via middleware
175175
func NewGitHubRawAPIErrorResponse(ctx context.Context, message string, resp *http.Response, err error) *mcp.CallToolResult {
176176
rawErr := newGitHubRawAPIError(message, resp, err)
177177
if ctx != nil {
178178
_, _ = addRawAPIErrorToContext(ctx, rawErr) // Explicitly ignore error for graceful handling
179179
}
180-
return utils.NewToolResultErrorFromErr(message, err)
180+
return mcpresult.NewErrorFromErr(message, err)
181181
}
182182

183183
// NewGitHubAPIStatusErrorResponse handles cases where the API call succeeds (err == nil)

0 commit comments

Comments
 (0)