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:
parent
2b1d10093e
commit
23d889254b
1 changed files with 110 additions and 92 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue