@@ -33,7 +33,7 @@ func NewServer(version string, opts ...server.ServerOption) *server.MCPServer {
33
33
// It returns the value, a boolean indicating if the parameter was present, and an error if the type is wrong.
34
34
func OptionalParamOK [T any ](r mcp.CallToolRequest , p string ) (value T , ok bool , err error ) {
35
35
// Check if the parameter is present in the request
36
- val , exists := r .Params . Arguments [p ]
36
+ val , exists := r .GetArguments () [p ]
37
37
if ! exists {
38
38
// Not present, return zero value, false, no error
39
39
return
@@ -68,21 +68,21 @@ func requiredParam[T comparable](r mcp.CallToolRequest, p string) (T, error) {
68
68
var zero T
69
69
70
70
// Check if the parameter is present in the request
71
- if _ , ok := r .Params . Arguments [p ]; ! ok {
71
+ if _ , ok := r .GetArguments () [p ]; ! ok {
72
72
return zero , fmt .Errorf ("missing required parameter: %s" , p )
73
73
}
74
74
75
75
// Check if the parameter is of the expected type
76
- if _ , ok := r .Params . Arguments [p ].(T ); ! ok {
76
+ if _ , ok := r .GetArguments () [p ].(T ); ! ok {
77
77
return zero , fmt .Errorf ("parameter %s is not of type %T" , p , zero )
78
78
}
79
79
80
- if r .Params . Arguments [p ].(T ) == zero {
80
+ if r .GetArguments () [p ].(T ) == zero {
81
81
return zero , fmt .Errorf ("missing required parameter: %s" , p )
82
82
83
83
}
84
84
85
- return r .Params . Arguments [p ].(T ), nil
85
+ return r .GetArguments () [p ].(T ), nil
86
86
}
87
87
88
88
// 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) {
106
106
var zero T
107
107
108
108
// Check if the parameter is present in the request
109
- if _ , ok := r .Params . Arguments [p ]; ! ok {
109
+ if _ , ok := r .GetArguments () [p ]; ! ok {
110
110
return zero , nil
111
111
}
112
112
113
113
// Check if the parameter is of the expected type
114
- if _ , ok := r .Params . Arguments [p ].(T ); ! ok {
115
- return zero , fmt .Errorf ("parameter %s is not of type %T, is %T" , p , zero , r .Params . Arguments [p ])
114
+ if _ , ok := r .GetArguments () [p ].(T ); ! ok {
115
+ return zero , fmt .Errorf ("parameter %s is not of type %T, is %T" , p , zero , r .GetArguments () [p ])
116
116
}
117
117
118
- return r .Params . Arguments [p ].(T ), nil
118
+ return r .GetArguments () [p ].(T ), nil
119
119
}
120
120
121
121
// 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
149
149
// 2. If it is present, iterates the elements and checks each is a string
150
150
func OptionalStringArrayParam (r mcp.CallToolRequest , p string ) ([]string , error ) {
151
151
// Check if the parameter is present in the request
152
- if _ , ok := r .Params . Arguments [p ]; ! ok {
152
+ if _ , ok := r .GetArguments () [p ]; ! ok {
153
153
return []string {}, nil
154
154
}
155
155
156
- switch v := r .Params . Arguments [p ].(type ) {
156
+ switch v := r .GetArguments () [p ].(type ) {
157
157
case nil :
158
158
return []string {}, nil
159
159
case []string :
@@ -169,7 +169,7 @@ func OptionalStringArrayParam(r mcp.CallToolRequest, p string) ([]string, error)
169
169
}
170
170
return strSlice , nil
171
171
default :
172
- return []string {}, fmt .Errorf ("parameter %s could not be coerced to []string, is %T" , p , r .Params . Arguments [p ])
172
+ return []string {}, fmt .Errorf ("parameter %s could not be coerced to []string, is %T" , p , r .GetArguments () [p ])
173
173
}
174
174
}
175
175
0 commit comments