Skip to content

Commit 2c6d2d1

Browse files
waleedlatif1claude
andcommitted
feat(logs): show MCP icon and strip prefix in trace tool spans
Tool spans for MCP calls were rendering the raw id (e.g. `mcp-f908f259-planetscale_list_organizations`) with the default blank- square icon. Now they read just the tool name and render the MCP block's icon and bgColor, matching how workflow-execute tools render. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 15e2b41 commit 2c6d2d1

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

  • apps/sim/app/workspace/[workspaceId]/logs/components/log-details

apps/sim/app/workspace/[workspaceId]/logs/components/log-details/utils.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ import { getBlock, getBlockByToolName } from '@/blocks'
88
import { PROVIDER_DEFINITIONS } from '@/providers/models'
99
import { normalizeToolId } from '@/tools/normalize'
1010

11+
/**
12+
* Extracts the bare tool name from an MCP tool id of the form
13+
* `mcp-{serverId}-{toolName}`. Returns null when the id is not MCP-shaped.
14+
* Kept local to avoid importing from `@/lib/mcp/utils`, which pulls in
15+
* `next/server` and breaks client bundles.
16+
*/
17+
function tryParseMcpToolName(toolId: string): string | null {
18+
if (!toolId.startsWith('mcp-')) return null
19+
const parts = toolId.split('-')
20+
if (parts.length < 3) return null
21+
const toolName = parts.slice(2).join('-')
22+
return toolName.length > 0 ? toolName : null
23+
}
24+
1125
export const DEFAULT_BLOCK_COLOR = '#6b7280'
1226

1327
export interface BlockIconAndColor {
@@ -41,6 +55,10 @@ export function getBlockIconAndColor(
4155
): BlockIconAndColor {
4256
const lowerType = type.toLowerCase()
4357
if (lowerType === 'tool' && toolName) {
58+
if (tryParseMcpToolName(toolName)) {
59+
const mcpBlock = getBlock('mcp')
60+
if (mcpBlock) return { icon: mcpBlock.icon, bgColor: mcpBlock.bgColor }
61+
}
4462
const normalized = normalizeToolId(toolName)
4563
if (normalized === 'load_skill') return { icon: AgentSkillsIcon, bgColor: '#8B5CF6' }
4664
const toolBlock = getBlockByToolName(normalized)
@@ -90,7 +108,11 @@ export function formatTps(
90108
}
91109

92110
export function getDisplayName(span: TraceSpan): string {
93-
if (span.type?.toLowerCase() === 'tool') return normalizeToolId(span.name)
111+
if (span.type?.toLowerCase() === 'tool') {
112+
const mcpToolName = tryParseMcpToolName(span.name)
113+
if (mcpToolName) return mcpToolName
114+
return normalizeToolId(span.name)
115+
}
94116
return span.name
95117
}
96118

0 commit comments

Comments
 (0)