add built-in tool_active: list currently loaded/promoted tools

This commit is contained in:
ollie 2026-07-28 23:24:33 +02:00
parent 6735a6ab26
commit e9644e7a3d
2 changed files with 35 additions and 0 deletions

View File

@ -56,6 +56,8 @@ func (e *Server) Dispatch(ctx context.Context, name string, args json.RawMessage
return dispatchToolList(ctx, e, args)
case "tool_load":
return dispatchToolLoad(ctx, e, args)
case "tool_active":
return dispatchToolActive(ctx, e, args)
default:
return "", fmt.Errorf("unknown execute tool: %s", name)
}
@ -192,3 +194,24 @@ func dispatchToolLoad(ctx context.Context, e *Server, args json.RawMessage) (str
}
return fmt.Sprintf("loaded: %s", a.Name), nil
}
// dispatchToolActive lists tools currently loaded (promoted) in this session.
func dispatchToolActive(ctx context.Context, e *Server, args json.RawMessage) (string, error) {
if e.toolRegistry == nil || e.sessionID == "" {
return "(no tools loaded)", nil
}
loaded := e.toolRegistry.Loaded(e.sessionID)
if len(loaded) == 0 {
return "(no tools loaded)", nil
}
var out strings.Builder
for _, t := range loaded {
out.WriteString(t.Name)
if t.Description != "" {
out.WriteString(" — ")
out.WriteString(t.Description)
}
out.WriteString("\n")
}
return strings.TrimRight(out.String(), "\n"), nil
}

View File

@ -176,6 +176,18 @@ After loading, the tool becomes a native callable function.`,
}
}`),
},
{
Name: "tool_active",
Description: `List tools currently loaded (promoted) in this session.
Usage: (no arguments)
Returns tools with descriptions, one per line.`,
InputSchema: json.RawMessage(`{
"type": "object",
"properties": {}
}`),
},
}
if e.toolRegistry != nil && e.sessionID != "" {