@@ -12,28 +12,28 @@ import (
1212//go:embed mcp_tools.json
1313var _ []byte
1414
15- type MCPToolDef struct {
15+ type ToolDef struct {
1616 Name string `json:"name"`
1717 Description string `json:"description"`
1818 InputSchema Schema `json:"inputSchema"`
1919 OutputSchema Schema `json:"outputSchema"`
2020}
2121
22- type Schema struct {
23- Schema string `json:"$schema"`
24- SchemaObject
25- }
26-
2722type RawSchema struct {
2823 Type string `json:"type"`
2924 Description string `json:"description"`
30- Schema string `json:"$schema"`
25+ SchemaVersion string `json:"$schema"`
3126 Required []string `json:"required,omitempty"`
3227 AdditionalProperties bool `json:"additionalProperties"`
3328 Properties map [string ]json.RawMessage `json:"properties"`
3429 Items json.RawMessage `json:"items"`
3530}
3631
32+ type Schema struct {
33+ Schema string `json:"$schema"`
34+ SchemaObject
35+ }
36+
3737type SchemaValue interface {
3838 Type () string
3939}
@@ -67,7 +67,7 @@ type parser struct {
6767 errors []error
6868}
6969
70- func LoadToolDefinitions (data []byte ) (map [string ]* MCPToolDef , error ) {
70+ func LoadToolDefinitions (data []byte ) (map [string ]* ToolDef , error ) {
7171 defs := struct {
7272 Tools []struct {
7373 Name string `json:"name"`
@@ -78,15 +78,14 @@ func LoadToolDefinitions(data []byte) (map[string]*MCPToolDef, error) {
7878 }{}
7979
8080 if err := json .Unmarshal (data , & defs ); err != nil {
81- // TODO: think we should panic instead
8281 return nil , err
8382 }
8483
85- tools := map [string ]* MCPToolDef {}
84+ tools := map [string ]* ToolDef {}
8685 parser := & parser {}
8786
8887 for _ , t := range defs .Tools {
89- tools [t .Name ] = & MCPToolDef {
88+ tools [t .Name ] = & ToolDef {
9089 Name : t .Name ,
9190 Description : t .Description ,
9291 InputSchema : parser .parseRootSchema (t .InputSchema ),
@@ -103,7 +102,7 @@ func LoadToolDefinitions(data []byte) (map[string]*MCPToolDef, error) {
103102
104103func (p * parser ) parseRootSchema (r RawSchema ) Schema {
105104 return Schema {
106- Schema : r .Schema ,
105+ Schema : r .SchemaVersion ,
107106 SchemaObject : SchemaObject {
108107 Kind : r .Type ,
109108 Description : r .Description ,
0 commit comments