MCPcopy Create free account
hub / github.com/astercloud/aster / Update

Method Update

server/handlers/tool.go:170–260  ·  view source on GitHub ↗

Update updates a tool

(c *gin.Context)

Source from the content-addressed store, hash-verified

168
169// Update updates a tool
170func (h *ToolHandler) Update(c *gin.Context) {
171 ctx := c.Request.Context()
172 id := c.Param("id")
173
174 var req struct {
175 Name *string `json:"name"`
176 Description *string `json:"description"`
177 Type *string `json:"type"`
178 Schema map[string]any `json:"schema"`
179 Config map[string]any `json:"config"`
180 Status *string `json:"status"`
181 Metadata map[string]any `json:"metadata"`
182 }
183
184 if err := c.ShouldBindJSON(&req); err != nil {
185 c.JSON(http.StatusBadRequest, gin.H{
186 "success": false,
187 "error": gin.H{
188 "code": "bad_request",
189 "message": err.Error(),
190 },
191 })
192 return
193 }
194
195 var tool ToolRecord
196 if err := (*h.store).Get(ctx, "tools", id, &tool); err != nil {
197 if errors.Is(err, store.ErrNotFound) {
198 c.JSON(http.StatusNotFound, gin.H{
199 "success": false,
200 "error": gin.H{
201 "code": "not_found",
202 "message": "Tool not found",
203 },
204 })
205 return
206 }
207 c.JSON(http.StatusInternalServerError, gin.H{
208 "success": false,
209 "error": gin.H{
210 "code": "internal_error",
211 "message": err.Error(),
212 },
213 })
214 return
215 }
216
217 // Update fields
218 if req.Name != nil {
219 tool.Name = *req.Name
220 }
221 if req.Description != nil {
222 tool.Description = *req.Description
223 }
224 if req.Type != nil {
225 tool.Type = *req.Type
226 }
227 if req.Schema != nil {

Callers

nothing calls this directly

Calls 6

InfoFunction · 0.92
JSONMethod · 0.80
ContextMethod · 0.65
ErrorMethod · 0.65
GetMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected