improve(agent): clarify MCP tool registration logging

Separate tool counting metrics for better clarity:
- unique_tools: number of distinct MCP tools
- total_registrations: total tool registrations across all agents
- agent_count: number of agents receiving the tools

Previously, tool_count was misleading as it showed total registrations,
making it appear that more unique tools were registered than actually exist.

Addresses Copilot code review feedback.
This commit is contained in:
yuchou87
2026-02-19 19:31:13 +08:00
parent ffa01986ce
commit dea381c385
+10 -4
View File
@@ -162,8 +162,12 @@ func (al *AgentLoop) Run(ctx context.Context) error {
// Register MCP tools for all agents
servers := mcpManager.GetServers()
toolCount := 0
uniqueTools := 0
totalRegistrations := 0
agentCount := len(al.registry.ListAgentIDs())
for serverName, conn := range servers {
uniqueTools += len(conn.Tools)
for _, tool := range conn.Tools {
for _, agentID := range al.registry.ListAgentIDs() {
agent, ok := al.registry.GetAgent(agentID)
@@ -172,7 +176,7 @@ func (al *AgentLoop) Run(ctx context.Context) error {
}
mcpTool := tools.NewMCPTool(mcpManager, serverName, tool)
agent.Tools.Register(mcpTool)
toolCount++
totalRegistrations++
logger.DebugCF("agent", "Registered MCP tool",
map[string]interface{}{
"agent_id": agentID,
@@ -185,8 +189,10 @@ func (al *AgentLoop) Run(ctx context.Context) error {
}
logger.InfoCF("agent", "MCP tools registered successfully",
map[string]interface{}{
"server_count": len(servers),
"tool_count": toolCount,
"server_count": len(servers),
"unique_tools": uniqueTools,
"total_registrations": totalRegistrations,
"agent_count": agentCount,
})
}
}