mirror of
https://github.com/hanzoai/mcp.git
synced 2026-10-15 12:30:12 +00:00
* feat: cloud Mount() per HIP-0106 Adds pkg/mcp with the canonical Mount(*zip.App, cloud.Deps) entry so the unified cloud binary can serve the HIP-0300 tool surface under /v1/mcp. The route layer is pure-Go: it defines an Invoker contract and dispatches GET /v1/mcp/tools, POST /v1/mcp/tools/:name, plus the standard search and fetch shortcuts. The CGO-backed hanzomcp package implements Invoker; a build without CGO mounts the routes and returns 503 until SetInvoker registers a runtime. Adds schema/mcp.zap describing the typed surface. * refactor: collapse pkg/go/ → root + flatten cloud import Repo IS the package. Mount() at root. Consumers use `github.com/hanzoai/mcp/go` (no /pkg/go/ nesting).
18 lines
480 B
Go
18 lines
480 B
Go
package mcp
|
|
|
|
import "encoding/json"
|
|
|
|
// overrideAction rewrites the JSON object body so its "action" key is set
|
|
// to the given value. If the body is empty or not a JSON object, returns
|
|
// a minimal {"action": v} payload.
|
|
func overrideAction(body []byte, v string) []byte {
|
|
var m map[string]any
|
|
if len(body) == 0 || json.Unmarshal(body, &m) != nil {
|
|
out, _ := json.Marshal(map[string]any{"action": v})
|
|
return out
|
|
}
|
|
m["action"] = v
|
|
out, _ := json.Marshal(m)
|
|
return out
|
|
}
|