Go SDK: Align hooks with SEP (#23)

The SEP spec and C# SDK use hooks (plural, JSON array) but the Go SDK
had hook (singular, single object). This meant the wire formats were
incompatible — Go would send `{"hook": {...}}` while everything else
expects `{"hooks": [...]}`.

Signed-off-by: Ukjae Jeong <jeongukjae@gmail.com>
This commit is contained in:
Ukjae Jeong 2026-06-16 15:49:49 +01:00 • committed by GitHub
commit 23d889254b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,7 +27,7 @@ func (e *Extension) handleList(_ context.Context, req *mcp.ServerRequest[*interc
all := e.getInterceptors()
infos := make([]interceptors.InterceptorInfo, 0, len(all))
for _, ri := range all {
if event != "" && !slices.Contains(ri.GetMetadata().Hook.Events, event) {
if event != "" && !hooksContainEvent(ri.GetMetadata().Hooks, event) {
continue
}
infos = append(infos, interceptors.InfoFromInterceptor(ri))
@ -105,3 +105,12 @@ func (e *Extension) handleInvoke(ctx context.Context, req *mcp.ServerRequest[*in
return result, nil
}
func hooksContainEvent(hooks []interceptors.Hook, event string) bool {
for _, h := range hooks {
if slices.Contains(h.Events, event) {
return true
}
}
return false
}