platform
This commit is contained in:
1 parent
e706f7d907
commit
21bcb63440
42 files changed
+5903
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
package mcp
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
)
|
||||
|
||||
// extractUCPAgentMeta checks whether the JSON arguments carry a "meta" key with
|
||||
// a nested "ucp-agent.profile" (the UCP-Agent profile advertisement, a sibling
|
||||
// of the real arguments per the UCP spec). If present it logs the profile for
|
||||
// observability and strips "meta" so it does not leak into the tool's argument
|
||||
// namespace. When absent it returns the arguments unchanged — a no-op for tools
|
||||
// that don't speak UCP.
|
||||
func extractUCPAgentMeta(arguments json.RawMessage) json.RawMessage {
|
||||
if len(arguments) == 0 {
|
||||
return arguments
|
||||
}
|
||||
var obj map[string]json.RawMessage
|
||||
if err := json.Unmarshal(arguments, &obj); err != nil {
|
||||
return arguments
|
||||
}
|
||||
metaRaw, hasMeta := obj["meta"]
|
||||
if !hasMeta {
|
||||
return arguments
|
||||
}
|
||||
var meta struct {
|
||||
UCPAgent *struct {
|
||||
Profile string `json:"profile"`
|
||||
} `json:"ucp-agent"`
|
||||
}
|
||||
if err := json.Unmarshal(metaRaw, &meta); err == nil && meta.UCPAgent != nil && meta.UCPAgent.Profile != "" {
|
||||
log.Printf("ucp-agent: profile=%s", meta.UCPAgent.Profile)
|
||||
}
|
||||
delete(obj, "meta")
|
||||
cleaned, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
return arguments
|
||||
}
|
||||
return cleaned
|
||||
}
|
||||
Reference in new issue
Block a user