You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@casbin.apache.org by hs...@apache.org on 2026/08/21 13:23:11 UTC
(casbin-gateway) branch master updated: fix: add entryDigest to MCP
This is an automated email from the ASF dual-hosted git repository.
hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-gateway.git
The following commit(s) were added to refs/heads/master by this push:
new 82ae18a fix: add entryDigest to MCP
82ae18a is described below
commit 82ae18ab1c4fa6e83a5cbfd5f79adf4f42d2380a
Author: Yang Luo <hs...@gmail.com>
AuthorDate: Fri Aug 21 21:23:05 2026 +0800
fix: add entryDigest to MCP
---
agentconfig/mcp_item.go | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/agentconfig/mcp_item.go b/agentconfig/mcp_item.go
index 99e4a51..f51c45c 100644
--- a/agentconfig/mcp_item.go
+++ b/agentconfig/mcp_item.go
@@ -15,6 +15,7 @@
package agentconfig
import (
+ "crypto/sha256"
"encoding/json"
"strings"
@@ -37,6 +38,7 @@ func mcpItems(agentId string, owner string, file string, entries map[string]map[
Url: stringField(entry, "url", "serverUrl", "endpoint"),
Managed: name == ManagedEntryName,
Transport: transportOf(entry),
+ Digest: entryDigest(entry),
}
items = append(items, item)
}
@@ -58,6 +60,18 @@ func mcpDetail(agentId string, owner string, file string, name string, entry map
return &Detail{Item: items[0], Content: string(content)}, nil
}
+// entryDigest identifies one server's definition, so the same name in two
+// agents can be told apart when the two definitions differ. Marshalling sorts
+// the keys, so the digest does not depend on how the file was written.
+func entryDigest(entry map[string]any) string {
+ raw, err := json.Marshal(entry)
+ if err != nil {
+ return ""
+ }
+ sum := sha256.Sum256(raw)
+ return shortDigest(sum[:])
+}
+
// transportOf reports how the agent reaches the server. An entry that names its
// own type is believed; otherwise a command means the server is spawned locally
// and a URL means it is reached over HTTP.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@casbin.apache.org
For additional commands, e-mail: commits-help@casbin.apache.org