34 lines
971 B
Go
34 lines
971 B
Go
package toolsrv
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// SetOnToolsChanged sets the callback for tool directory changes.
|
|
func (s *Server) SetOnToolsChanged(fn func(string)) {
|
|
s.OnToolsChanged = fn
|
|
}
|
|
|
|
// ToolRegistryRevision returns the current registry revision for this server's session.
|
|
// Returns 0 if no registry is configured.
|
|
func (s *Server) ToolRegistryRevision() uint64 {
|
|
if s.toolRegistry == nil || s.sessionID == "" {
|
|
return 0
|
|
}
|
|
return s.toolRegistry.Revision(s.sessionID)
|
|
}
|
|
|
|
// buildToolListing formats a slice of ToolInfo into the preamble listing
|
|
// format consumed by agent.refreshToolListing: "- **name** — description\n" per entry.
|
|
// Only local tools (Server == "") with a non-empty description are included.
|
|
func buildToolListing(infos []ToolInfo) string {
|
|
var sb strings.Builder
|
|
for _, ti := range infos {
|
|
if ti.Description != "" && ti.Server == "" {
|
|
fmt.Fprintf(&sb, "- **%s** — %s\n", ti.Name, ti.Description)
|
|
}
|
|
}
|
|
return sb.String()
|
|
}
|