|
6 | 6 | "net/http" |
7 | 7 | "time" |
8 | 8 |
|
| 9 | + "github.com/google/jsonschema-go/jsonschema" |
9 | 10 | "github.com/modelcontextprotocol/go-sdk/mcp" |
10 | 11 |
|
11 | 12 | "github.com/stacklok/toolhive/pkg/logger" |
@@ -104,141 +105,141 @@ func registerTools(mcpServer *mcp.Server, handler *Handler) { |
104 | 105 | mcpServer.AddTool(&mcp.Tool{ |
105 | 106 | Name: "search_registry", |
106 | 107 | Description: "Search the ToolHive registry for MCP servers", |
107 | | - InputSchema: map[string]interface{}{ |
108 | | - "type": "object", |
109 | | - "properties": map[string]interface{}{ |
110 | | - "query": map[string]interface{}{ |
111 | | - "type": "string", |
112 | | - "description": "Search query to find MCP servers", |
| 108 | + InputSchema: &jsonschema.Schema{ |
| 109 | + Type: "object", |
| 110 | + Properties: map[string]*jsonschema.Schema{ |
| 111 | + "query": { |
| 112 | + Type: "string", |
| 113 | + Description: "Search query to find MCP servers", |
113 | 114 | }, |
114 | 115 | }, |
115 | | - "required": []string{"query"}, |
| 116 | + Required: []string{"query"}, |
116 | 117 | }, |
117 | 118 | }, handler.SearchRegistry) |
118 | 119 |
|
119 | 120 | mcpServer.AddTool(&mcp.Tool{ |
120 | 121 | Name: "run_server", |
121 | 122 | Description: "Run an MCP server from the ToolHive registry", |
122 | | - InputSchema: map[string]interface{}{ |
123 | | - "type": "object", |
124 | | - "properties": map[string]interface{}{ |
125 | | - "server": map[string]interface{}{ |
126 | | - "type": "string", |
127 | | - "description": "Name of the server to run (e.g., 'fetch', 'github')", |
| 123 | + InputSchema: &jsonschema.Schema{ |
| 124 | + Type: "object", |
| 125 | + Properties: map[string]*jsonschema.Schema{ |
| 126 | + "server": { |
| 127 | + Type: "string", |
| 128 | + Description: "Name of the server to run (e.g., 'fetch', 'github')", |
128 | 129 | }, |
129 | | - "name": map[string]interface{}{ |
130 | | - "type": "string", |
131 | | - "description": "Optional custom name for the server instance", |
| 130 | + "name": { |
| 131 | + Type: "string", |
| 132 | + Description: "Optional custom name for the server instance", |
132 | 133 | }, |
133 | | - "env": map[string]interface{}{ |
134 | | - "type": "object", |
135 | | - "description": "Environment variables to pass to the server", |
136 | | - "additionalProperties": map[string]interface{}{ |
137 | | - "type": "string", |
| 134 | + "env": { |
| 135 | + Type: "object", |
| 136 | + Description: "Environment variables to pass to the server", |
| 137 | + AdditionalProperties: &jsonschema.Schema{ |
| 138 | + Type: "string", |
138 | 139 | }, |
139 | 140 | }, |
140 | | - "secrets": map[string]interface{}{ |
141 | | - "type": "array", |
142 | | - "description": "Secrets to pass to the server as environment variables", |
143 | | - "items": map[string]interface{}{ |
144 | | - "type": "object", |
145 | | - "properties": map[string]interface{}{ |
146 | | - "name": map[string]interface{}{ |
147 | | - "type": "string", |
148 | | - "description": "Name of the secret in the ToolHive secrets store", |
| 141 | + "secrets": { |
| 142 | + Type: "array", |
| 143 | + Description: "Secrets to pass to the server as environment variables", |
| 144 | + Items: &jsonschema.Schema{ |
| 145 | + Type: "object", |
| 146 | + Properties: map[string]*jsonschema.Schema{ |
| 147 | + "name": { |
| 148 | + Type: "string", |
| 149 | + Description: "Name of the secret in the ToolHive secrets store", |
149 | 150 | }, |
150 | | - "target": map[string]interface{}{ |
151 | | - "type": "string", |
152 | | - "description": "Target environment variable name in the server container", |
| 151 | + "target": { |
| 152 | + Type: "string", |
| 153 | + Description: "Target environment variable name in the server container", |
153 | 154 | }, |
154 | 155 | }, |
155 | | - "required": []string{"name", "target"}, |
| 156 | + Required: []string{"name", "target"}, |
156 | 157 | }, |
157 | 158 | }, |
158 | 159 | }, |
159 | | - "required": []string{"server"}, |
| 160 | + Required: []string{"server"}, |
160 | 161 | }, |
161 | 162 | }, handler.RunServer) |
162 | 163 |
|
163 | 164 | mcpServer.AddTool(&mcp.Tool{ |
164 | 165 | Name: "list_servers", |
165 | 166 | Description: "List all running ToolHive MCP servers", |
166 | | - InputSchema: map[string]interface{}{ |
167 | | - "type": "object", |
168 | | - "properties": map[string]interface{}{}, |
| 167 | + InputSchema: &jsonschema.Schema{ |
| 168 | + Type: "object", |
| 169 | + Properties: map[string]*jsonschema.Schema{}, |
169 | 170 | }, |
170 | 171 | }, handler.ListServers) |
171 | 172 |
|
172 | 173 | mcpServer.AddTool(&mcp.Tool{ |
173 | 174 | Name: "stop_server", |
174 | 175 | Description: "Stop a running MCP server", |
175 | | - InputSchema: map[string]interface{}{ |
176 | | - "type": "object", |
177 | | - "properties": map[string]interface{}{ |
178 | | - "name": map[string]interface{}{ |
179 | | - "type": "string", |
180 | | - "description": "Name of the server to stop", |
| 176 | + InputSchema: &jsonschema.Schema{ |
| 177 | + Type: "object", |
| 178 | + Properties: map[string]*jsonschema.Schema{ |
| 179 | + "name": { |
| 180 | + Type: "string", |
| 181 | + Description: "Name of the server to stop", |
181 | 182 | }, |
182 | 183 | }, |
183 | | - "required": []string{"name"}, |
| 184 | + Required: []string{"name"}, |
184 | 185 | }, |
185 | 186 | }, handler.StopServer) |
186 | 187 |
|
187 | 188 | mcpServer.AddTool(&mcp.Tool{ |
188 | 189 | Name: "remove_server", |
189 | 190 | Description: "Remove a stopped MCP server", |
190 | | - InputSchema: map[string]interface{}{ |
191 | | - "type": "object", |
192 | | - "properties": map[string]interface{}{ |
193 | | - "name": map[string]interface{}{ |
194 | | - "type": "string", |
195 | | - "description": "Name of the server to remove", |
| 191 | + InputSchema: &jsonschema.Schema{ |
| 192 | + Type: "object", |
| 193 | + Properties: map[string]*jsonschema.Schema{ |
| 194 | + "name": { |
| 195 | + Type: "string", |
| 196 | + Description: "Name of the server to remove", |
196 | 197 | }, |
197 | 198 | }, |
198 | | - "required": []string{"name"}, |
| 199 | + Required: []string{"name"}, |
199 | 200 | }, |
200 | 201 | }, handler.RemoveServer) |
201 | 202 |
|
202 | 203 | mcpServer.AddTool(&mcp.Tool{ |
203 | 204 | Name: "get_server_logs", |
204 | 205 | Description: "Get logs from a running MCP server", |
205 | | - InputSchema: map[string]interface{}{ |
206 | | - "type": "object", |
207 | | - "properties": map[string]interface{}{ |
208 | | - "name": map[string]interface{}{ |
209 | | - "type": "string", |
210 | | - "description": "Name of the server to get logs from", |
| 206 | + InputSchema: &jsonschema.Schema{ |
| 207 | + Type: "object", |
| 208 | + Properties: map[string]*jsonschema.Schema{ |
| 209 | + "name": { |
| 210 | + Type: "string", |
| 211 | + Description: "Name of the server to get logs from", |
211 | 212 | }, |
212 | 213 | }, |
213 | | - "required": []string{"name"}, |
| 214 | + Required: []string{"name"}, |
214 | 215 | }, |
215 | 216 | }, handler.GetServerLogs) |
216 | 217 |
|
217 | 218 | mcpServer.AddTool(&mcp.Tool{ |
218 | 219 | Name: "list_secrets", |
219 | 220 | Description: "List all available secrets in the ToolHive secrets store", |
220 | | - InputSchema: map[string]interface{}{ |
221 | | - "type": "object", |
222 | | - "properties": map[string]interface{}{}, |
| 221 | + InputSchema: &jsonschema.Schema{ |
| 222 | + Type: "object", |
| 223 | + Properties: map[string]*jsonschema.Schema{}, |
223 | 224 | }, |
224 | 225 | }, handler.ListSecrets) |
225 | 226 |
|
226 | 227 | mcpServer.AddTool(&mcp.Tool{ |
227 | 228 | Name: "set_secret", |
228 | 229 | Description: "Set a secret by reading its value from a file", |
229 | | - InputSchema: map[string]interface{}{ |
230 | | - "type": "object", |
231 | | - "properties": map[string]interface{}{ |
232 | | - "name": map[string]interface{}{ |
233 | | - "type": "string", |
234 | | - "description": "Name of the secret to set", |
| 230 | + InputSchema: &jsonschema.Schema{ |
| 231 | + Type: "object", |
| 232 | + Properties: map[string]*jsonschema.Schema{ |
| 233 | + "name": { |
| 234 | + Type: "string", |
| 235 | + Description: "Name of the secret to set", |
235 | 236 | }, |
236 | | - "file_path": map[string]interface{}{ |
237 | | - "type": "string", |
238 | | - "description": "Path to the file containing the secret value", |
| 237 | + "file_path": { |
| 238 | + Type: "string", |
| 239 | + Description: "Path to the file containing the secret value", |
239 | 240 | }, |
240 | 241 | }, |
241 | | - "required": []string{"name", "file_path"}, |
| 242 | + Required: []string{"name", "file_path"}, |
242 | 243 | }, |
243 | 244 | }, handler.SetSecret) |
244 | 245 | } |
0 commit comments