Add IsSelf flag to identify tendrils server node

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-02-04 11:42:07 -08:00
parent aee1487f22
commit 48e1e69fde
3 changed files with 24 additions and 2 deletions

22
mcp.go
View File

@@ -76,7 +76,11 @@ func (t *Tendrils) mcpListNodes(ctx context.Context, req mcp.CallToolRequest) (*
nodeType = "unknown"
}
sb.WriteString(fmt.Sprintf("• %s [%s]\n", name, nodeType))
if node.IsSelf {
sb.WriteString(fmt.Sprintf("• %s [%s] ← THIS SERVER\n", name, nodeType))
} else {
sb.WriteString(fmt.Sprintf("• %s [%s]\n", name, nodeType))
}
for _, iface := range node.Interfaces {
sb.WriteString(fmt.Sprintf(" - %s", iface.MAC))
@@ -150,6 +154,9 @@ func formatNodeDetails(node *Node, links []*Link) string {
if node.Type != "" {
sb.WriteString(fmt.Sprintf("Type: %s\n", node.Type))
}
if node.IsSelf {
sb.WriteString("This Server: YES (tendrils is running here)\n")
}
if node.Unreachable {
sb.WriteString("Status: UNREACHABLE\n")
}
@@ -297,7 +304,11 @@ func (t *Tendrils) mcpSearchNodes(ctx context.Context, req mcp.CallToolRequest)
nodeType = "unknown"
}
sb.WriteString(fmt.Sprintf("• %s [%s]\n", name, nodeType))
if node.IsSelf {
sb.WriteString(fmt.Sprintf("• %s [%s] ← THIS SERVER\n", name, nodeType))
} else {
sb.WriteString(fmt.Sprintf("• %s [%s]\n", name, nodeType))
}
for _, iface := range node.Interfaces {
sb.WriteString(fmt.Sprintf(" - %s", iface.MAC))
if len(iface.IPs) > 0 {
@@ -339,6 +350,7 @@ func (t *Tendrils) mcpGetTopology(ctx context.Context, req mcp.CallToolRequest)
typeCounts := map[string]int{}
var unreachable int
var selfNode *Node
for _, node := range nodes {
nodeType := string(node.Type)
if nodeType == "" {
@@ -348,11 +360,17 @@ func (t *Tendrils) mcpGetTopology(ctx context.Context, req mcp.CallToolRequest)
if node.Unreachable {
unreachable++
}
if node.IsSelf {
selfNode = node
}
}
var sb strings.Builder
sb.WriteString("Network Topology Summary\n")
sb.WriteString("========================\n\n")
if selfNode != nil {
sb.WriteString(fmt.Sprintf("This server: %s\n", selfNode.DisplayName()))
}
sb.WriteString(fmt.Sprintf("Total nodes: %d\n", len(nodes)))
sb.WriteString(fmt.Sprintf("Total links: %d\n", len(links)))
sb.WriteString(fmt.Sprintf("Active errors: %d\n", len(errors)))