- Notifications
You must be signed in to change notification settings - Fork972
Bump mcp-go to 0.30.0#440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -33,7 +33,7 @@ func NewServer(version string, opts ...server.ServerOption) *server.MCPServer { | ||
// It returns the value, a boolean indicating if the parameter was present, and an error if the type is wrong. | ||
func OptionalParamOK[T any](r mcp.CallToolRequest, p string) (value T, ok bool, err error) { | ||
// Check if the parameter is present in the request | ||
val, exists := r.GetArguments()[p] | ||
williammartin marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if !exists { | ||
// Not present, return zero value, false, no error | ||
return | ||
@@ -68,21 +68,21 @@ func requiredParam[T comparable](r mcp.CallToolRequest, p string) (T, error) { | ||
var zero T | ||
// Check if the parameter is present in the request | ||
if _, ok := r.GetArguments()[p]; !ok { | ||
return zero, fmt.Errorf("missing required parameter: %s", p) | ||
} | ||
// Check if the parameter is of the expected type | ||
if _, ok := r.GetArguments()[p].(T); !ok { | ||
return zero, fmt.Errorf("parameter %s is not of type %T", p, zero) | ||
} | ||
if r.GetArguments()[p].(T) == zero { | ||
return zero, fmt.Errorf("missing required parameter: %s", p) | ||
} | ||
return r.GetArguments()[p].(T), nil | ||
williammartin marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} | ||
// RequiredInt is a helper function that can be used to fetch a requested parameter from the request. | ||
@@ -106,16 +106,16 @@ func OptionalParam[T any](r mcp.CallToolRequest, p string) (T, error) { | ||
var zero T | ||
// Check if the parameter is present in the request | ||
if _, ok := r.GetArguments()[p]; !ok { | ||
return zero, nil | ||
} | ||
// Check if the parameter is of the expected type | ||
if _, ok := r.GetArguments()[p].(T); !ok { | ||
return zero, fmt.Errorf("parameter %s is not of type %T, is %T", p, zero, r.GetArguments()[p]) | ||
} | ||
return r.GetArguments()[p].(T), nil | ||
} | ||
// OptionalIntParam is a helper function that can be used to fetch a requested parameter from the request. | ||
@@ -149,11 +149,11 @@ func OptionalIntParamWithDefault(r mcp.CallToolRequest, p string, d int) (int, e | ||
// 2. If it is present, iterates the elements and checks each is a string | ||
func OptionalStringArrayParam(r mcp.CallToolRequest, p string) ([]string, error) { | ||
// Check if the parameter is present in the request | ||
if _, ok := r.GetArguments()[p]; !ok { | ||
return []string{}, nil | ||
} | ||
switch v := r.GetArguments()[p].(type) { | ||
case nil: | ||
return []string{}, nil | ||
case []string: | ||
@@ -169,7 +169,7 @@ func OptionalStringArrayParam(r mcp.CallToolRequest, p string) ([]string, error) | ||
} | ||
return strSlice, nil | ||
default: | ||
return []string{}, fmt.Errorf("parameter %s could not be coerced to []string, is %T", p, r.GetArguments()[p]) | ||
} | ||
} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.