@@ -33,7 +33,7 @@ func NewServer(version string, opts ...server.ServerOption) *server.MCPServer {
3333// It returns the value, a boolean indicating if the parameter was present, and an error if the type is wrong.
3434func OptionalParamOK [T any ](r mcp.CallToolRequest , p string ) (value T , ok bool , err error ) {
3535 // Check if the parameter is present in the request
36- val , exists := r .Params . Arguments [p ]
36+ val , exists := r .GetArguments () [p ]
3737 if ! exists {
3838 // Not present, return zero value, false, no error
3939 return
@@ -68,21 +68,21 @@ func requiredParam[T comparable](r mcp.CallToolRequest, p string) (T, error) {
6868 var zero T
6969
7070 // Check if the parameter is present in the request
71- if _ , ok := r .Params . Arguments [p ]; ! ok {
71+ if _ , ok := r .GetArguments () [p ]; ! ok {
7272 return zero , fmt .Errorf ("missing required parameter: %s" , p )
7373 }
7474
7575 // 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 {
7777 return zero , fmt .Errorf ("parameter %s is not of type %T" , p , zero )
7878 }
7979
80- if r .Params . Arguments [p ].(T ) == zero {
80+ if r .GetArguments () [p ].(T ) == zero {
8181 return zero , fmt .Errorf ("missing required parameter: %s" , p )
8282
8383 }
8484
85- return r .Params . Arguments [p ].(T ), nil
85+ return r .GetArguments () [p ].(T ), nil
8686}
8787
8888// 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) {
106106 var zero T
107107
108108 // Check if the parameter is present in the request
109- if _ , ok := r .Params . Arguments [p ]; ! ok {
109+ if _ , ok := r .GetArguments () [p ]; ! ok {
110110 return zero , nil
111111 }
112112
113113 // 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 ])
116116 }
117117
118- return r .Params . Arguments [p ].(T ), nil
118+ return r .GetArguments () [p ].(T ), nil
119119}
120120
121121// 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
149149// 2. If it is present, iterates the elements and checks each is a string
150150func OptionalStringArrayParam (r mcp.CallToolRequest , p string ) ([]string , error ) {
151151 // Check if the parameter is present in the request
152- if _ , ok := r .Params . Arguments [p ]; ! ok {
152+ if _ , ok := r .GetArguments () [p ]; ! ok {
153153 return []string {}, nil
154154 }
155155
156- switch v := r .Params . Arguments [p ].(type ) {
156+ switch v := r .GetArguments () [p ].(type ) {
157157 case nil :
158158 return []string {}, nil
159159 case []string :
@@ -169,7 +169,7 @@ func OptionalStringArrayParam(r mcp.CallToolRequest, p string) ([]string, error)
169169 }
170170 return strSlice , nil
171171 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 ])
173173 }
174174}
175175
0 commit comments