@@ -11,7 +11,7 @@ import (
1111 "time"
1212
1313 "github.com/getkin/kin-openapi/openapi3"
14- "github.com/modelcontextprotocol/go-sdk /jsonschema"
14+ "github.com/google/jsonschema-go /jsonschema"
1515 "github.com/modelcontextprotocol/go-sdk/mcp"
1616)
1717
@@ -189,58 +189,6 @@ func generateAIFriendlyDescription(op OpenAPIOperation, inputSchema jsonschema.S
189189 return desc .String ()
190190}
191191
192- // generateExampleValue creates appropriate example values based on the parameter schema
193- func generateExampleValue (prop map [string ]any ) any {
194- typeStr , _ := prop ["type" ].(string )
195-
196- // Check for enum values first
197- if enum , ok := prop ["enum" ].([]any ); ok && len (enum ) > 0 {
198- return enum [0 ]
199- }
200-
201- // Check for example values in schema
202- if example , ok := prop ["example" ]; ok {
203- return example
204- }
205-
206- // Generate based on type
207- switch typeStr {
208- case "string" :
209- if format , ok := prop ["format" ].(string ); ok {
210- switch format {
211- case "email" :
212- return "user@example.com"
213- case "uri" , "url" :
214- return "https://example.com"
215- case "date" :
216- return "2024-01-01"
217- case "date-time" :
218- return "2024-01-01T00:00:00Z"
219- case "uuid" :
220- return "123e4567-e89b-12d3-a456-426614174000"
221- default :
222- return "example_string"
223- }
224- }
225- return "example_string"
226- case "number" :
227- return 123.45
228- case "integer" :
229- return 123
230- case "boolean" :
231- return true
232- case "array" :
233- if items , ok := prop ["items" ].(map [string ]any ); ok {
234- return []any {generateExampleValue (items )}
235- }
236- return []any {"item1" , "item2" }
237- case "object" :
238- return map [string ]any {"key" : "value" }
239- default :
240- return nil
241- }
242- }
243-
244192// generateExampleValueFromSchema creates appropriate example values based on the jsonschema.Schema
245193func generateExampleValueFromSchema (prop * jsonschema.Schema ) any {
246194 if prop == nil {
@@ -492,7 +440,6 @@ func RegisterOpenAPITools(server *mcp.Server, ops []OpenAPIOperation, doc *opena
492440 tool := & mcp.Tool {
493441 Name : "externalDocs" ,
494442 Description : "Show the OpenAPI external documentation URL and description." ,
495- InputSchema : & jsonschema.Schema {Type : "object" , Properties : map [string ]* jsonschema.Schema {}},
496443 }
497444
498445 if opts != nil && opts .Version != "" {
@@ -501,7 +448,7 @@ func RegisterOpenAPITools(server *mcp.Server, ops []OpenAPIOperation, doc *opena
501448 }
502449 }
503450
504- mcp .AddTool (server , tool , func (ctx context.Context , session * mcp.ServerSession , params * mcp. CallToolParams ) (* mcp.CallToolResult , error ) {
451+ mcp .AddTool (server , tool , func (_ context.Context , req * mcp.CallToolRequest , _ any ) (* mcp.CallToolResult , any , error ) {
505452 info := "External documentation URL: " + doc .ExternalDocs .URL
506453 if doc .ExternalDocs .Description != "" {
507454 info += "\n Description: " + doc .ExternalDocs .Description
@@ -512,7 +459,7 @@ func RegisterOpenAPITools(server *mcp.Server, ops []OpenAPIOperation, doc *opena
512459 Text : info ,
513460 },
514461 },
515- }, nil
462+ }, nil , nil
516463 })
517464 toolNames = append (toolNames , "externalDocs" )
518465 }
@@ -522,7 +469,6 @@ func RegisterOpenAPITools(server *mcp.Server, ops []OpenAPIOperation, doc *opena
522469 tool := & mcp.Tool {
523470 Name : "info" ,
524471 Description : "Show API metadata: title, version, description, and terms of service." ,
525- InputSchema : & jsonschema.Schema {Type : "object" , Properties : map [string ]* jsonschema.Schema {}},
526472 }
527473
528474 if opts != nil && opts .Version != "" {
@@ -531,7 +477,7 @@ func RegisterOpenAPITools(server *mcp.Server, ops []OpenAPIOperation, doc *opena
531477 }
532478 }
533479
534- mcp .AddTool (server , tool , func (ctx context.Context , session * mcp.ServerSession , params * mcp. CallToolParams ) (* mcp.CallToolResult , error ) {
480+ mcp .AddTool (server , tool , func (_ context.Context , req * mcp.CallToolRequest , _ any ) (* mcp.CallToolResult , any , error ) {
535481 var sb strings.Builder
536482 if doc .Info .Title != "" {
537483 sb .WriteString ("Title: " + doc .Info .Title + "\n " )
@@ -551,7 +497,7 @@ func RegisterOpenAPITools(server *mcp.Server, ops []OpenAPIOperation, doc *opena
551497 Text : strings .TrimSpace (sb .String ()),
552498 },
553499 },
554- }, nil
500+ }, nil , nil
555501 })
556502 toolNames = append (toolNames , "info" )
557503 }
@@ -584,7 +530,7 @@ func RegisterOpenAPITools(server *mcp.Server, ops []OpenAPIOperation, doc *opena
584530 MIMEType : "application/json" ,
585531 }
586532
587- server .AddResource (& timestampResource , func (ctx context.Context , session * mcp.ServerSession , params * mcp.ReadResourceParams ) (* mcp.ReadResourceResult , error ) {
533+ server .AddResource (& timestampResource , func (ctx context.Context , req * mcp.ServerRequest [ * mcp.ReadResourceParams ] ) (* mcp.ReadResourceResult , error ) {
588534 now := time .Now ().Unix ()
589535 content := fmt .Sprintf (`{"unix_timestamp": %d, "iso8601": "%s", "timezone": "%s"}` ,
590536 now ,
0 commit comments