1- //go:generate ../../scripts/gen-mcp-tool-json.sh mcp_tools.json
21package mcp
32
43import (
@@ -13,10 +12,10 @@ import (
1312var _ []byte
1413
1514type ToolDef struct {
16- Name string `json:"name"`
17- Description string `json:"description"`
18- InputSchema Schema `json:"inputSchema"`
19- OutputSchema Schema `json:"outputSchema"`
15+ Name string `json:"name"`
16+ Description string `json:"description"`
17+ InputSchema SchemaObject `json:"inputSchema"`
18+ OutputSchema SchemaObject `json:"outputSchema"`
2019}
2120
2221type RawSchema struct {
@@ -29,39 +28,35 @@ type RawSchema struct {
2928 Items json.RawMessage `json:"items"`
3029}
3130
32- type Schema struct {
33- Schema string `json:"$schema"`
34- SchemaObject
35- }
36-
3731type SchemaValue interface {
38- Type () string
32+ ValueType () string
3933}
4034
4135type SchemaObject struct {
42- Kind string `json:"type"`
36+ Type string `json:"type"`
4337 Description string `json:"description"`
38+ Schema string `json:"$schema,omitempty"`
4439 Required []string `json:"required,omitempty"`
4540 AdditionalProperties bool `json:"additionalProperties"`
4641 Properties map [string ]SchemaValue `json:"properties"`
4742}
4843
49- func (s SchemaObject ) Type () string { return s .Kind }
44+ func (s SchemaObject ) ValueType () string { return s .Type }
5045
5146type SchemaArray struct {
52- Kind string `json:"type"`
47+ Type string `json:"type"`
5348 Description string `json:"description"`
5449 Items SchemaValue `json:"items,omitempty"`
5550}
5651
57- func (s SchemaArray ) Type () string { return s .Kind }
52+ func (s SchemaArray ) ValueType () string { return s .Type }
5853
5954type SchemaPrimitive struct {
55+ Type string `json:"type"`
6056 Description string `json:"description"`
61- Kind string `json:"type"`
6257}
6358
64- func (s SchemaPrimitive ) Type () string { return s .Kind }
59+ func (s SchemaPrimitive ) ValueType () string { return s .Type }
6560
6661type decoder struct {
6762 errors []error
@@ -100,24 +95,22 @@ func LoadToolDefinitions(data []byte) (map[string]*ToolDef, error) {
10095 return tools , nil
10196}
10297
103- func (d * decoder ) decodeRootSchema (r RawSchema ) Schema {
104- return Schema {
105- Schema : r .SchemaVersion ,
106- SchemaObject : SchemaObject {
107- Kind : r .Type ,
108- Description : r .Description ,
109- Required : r .Required ,
110- AdditionalProperties : r .AdditionalProperties ,
111- Properties : d .decodeProperties (r .Properties ),
112- },
98+ func (d * decoder ) decodeRootSchema (r RawSchema ) SchemaObject {
99+ return SchemaObject {
100+ Schema : r .SchemaVersion ,
101+ Type : r .Type ,
102+ Description : r .Description ,
103+ Required : r .Required ,
104+ AdditionalProperties : r .AdditionalProperties ,
105+ Properties : d .decodeProperties (r .Properties ),
113106 }
114107}
115108
116109func (d * decoder ) decodeSchema (r * RawSchema ) SchemaValue {
117110 switch r .Type {
118111 case "object" :
119112 return & SchemaObject {
120- Kind : r .Type ,
113+ Type : r .Type ,
121114 Description : r .Description ,
122115 Required : r .Required ,
123116 AdditionalProperties : r .AdditionalProperties ,
@@ -140,13 +133,13 @@ func (d *decoder) decodeSchema(r *RawSchema) SchemaValue {
140133 }
141134 }
142135 return & SchemaArray {
143- Kind : r .Type ,
136+ Type : r .Type ,
144137 Description : r .Description ,
145138 Items : items ,
146139 }
147140 default :
148141 return & SchemaPrimitive {
149- Kind : r .Type ,
142+ Type : r .Type ,
150143 Description : r .Description ,
151144 }
152145 }
0 commit comments