import React from 'react';
const MCP_SERVERS = [
{ id: 'food', name: 'Food MCP', icon: 'restaurant', count: 14, color: '#FF3366' },
{ id: 'instamart', name: 'Instamart MCP', icon: 'local_convenience_store', count: 13, color: '#00E475' },
{ id: 'dineout', name: 'Dineout MCP', icon: 'table_restaurant', count: 8, color: '#FFB300' },
];
export default function MCPToolTrace({ events = [] }) {
const activeTool = events.length > 0 ? events[events.length - 1] : null;
const toolCalls = events.filter(e => e.type === 'tool_call');
const toolResults = events.filter(e => e.type === 'tool_result');
return (
{/* Header */}
Swiggy MCP Trace
Real-time tool execution pipeline
{toolCalls.length} Executed
{/* Server Category Cards */}
{MCP_SERVERS.map(s => {
const serverCalls = toolCalls.filter(tc => tc.server === s.id || (tc.tool && tc.tool.includes(s.id)));
const isActive = activeTool?.server === s.id || (activeTool?.tool && activeTool.tool.includes(s.id));
return (
{s.name}
{serverCalls.length} calls this session
);
})}
{/* Real-time Execution Feed */}
Execution Event Log
{activeTool?.streaming && (
Live
)}
{events.length === 0 ? (
sync
Ask the AI Agent to trigger live Swiggy MCP tools
) : (
events.map((ev, i) => (
{ev.tool || ev.name || 'MCP Execution'}
{ev.args && (
{JSON.stringify(ev.args).slice(0, 70)}...
)}
{ev.latency_ms && (
{ev.latency_ms}ms
)}
))
)}
{/* Footer */}
Total Latency: {toolResults.reduce((acc, r) => acc + (r.latency_ms || 0), 0)}ms
•
{toolCalls.length} tool calls
);
}
const styles = {
container: {
display: 'flex',
flexDirection: 'column',
height: '100%',
padding: 18,
gap: 14,
background: 'rgba(18, 16, 23, 0.75)',
backdropFilter: 'blur(20px)',
border: '1px solid var(--bg-border)',
borderRadius: 'var(--radius-lg)',
boxShadow: '0 10px 30px rgba(0,0,0,0.3)',
},
header: {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
},
title: {
fontFamily: 'var(--font-serif)',
fontSize: 18,
fontWeight: 700,
color: '#FFF',
},
subtitle: {
fontFamily: 'var(--font-sans)',
fontSize: 11,
color: 'var(--text-secondary)',
marginTop: 2,
},
countBadge: {
padding: '4px 10px',
background: 'rgba(255, 51, 102, 0.1)',
border: '1px solid rgba(255, 51, 102, 0.25)',
borderRadius: 'var(--radius-pill)',
fontSize: 11,
fontWeight: 600,
color: 'var(--accent-coral-pink)',
},
serverGrid: {
display: 'grid',
gridTemplateColumns: 'repeat(3, 1fr)',
gap: 10,
},
serverCard: {
background: 'rgba(255, 255, 255, 0.02)',
border: '1px solid var(--bg-border)',
borderRadius: 'var(--radius-md)',
padding: 10,
display: 'flex',
flexDirection: 'column',
gap: 6,
transition: 'all 0.2s ease',
},
serverCardTop: {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
},
serverIcon: {
width: 24,
height: 24,
borderRadius: 6,
border: '1px solid',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
serverBadge: {
fontSize: 9,
fontWeight: 700,
padding: '2px 6px',
borderRadius: 4,
},
serverName: {
fontFamily: 'var(--font-sans)',
fontSize: 11,
fontWeight: 600,
color: '#FFF',
},
serverCallsText: {
fontSize: 10,
color: 'var(--text-muted)',
},
feedHeader: {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
paddingTop: 6,
},
feedTitle: {
fontFamily: 'var(--font-sans)',
fontSize: 11,
fontWeight: 700,
textTransform: 'uppercase',
letterSpacing: '0.06em',
color: 'var(--text-secondary)',
},
livePulse: {
display: 'flex',
alignItems: 'center',
gap: 5,
fontSize: 10,
fontWeight: 600,
color: 'var(--accent-emerald)',
},
pulseDot: {
width: 6,
height: 6,
borderRadius: '50%',
background: 'var(--accent-emerald)',
boxShadow: '0 0 6px var(--accent-emerald)',
},
feed: {
flex: 1,
overflowY: 'auto',
display: 'flex',
flexDirection: 'column',
gap: 8,
},
emptyState: {
height: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
gap: 8,
color: 'var(--text-muted)',
fontSize: 12,
textAlign: 'center',
padding: 20,
},
eventRow: {
display: 'flex',
alignItems: 'center',
gap: 10,
padding: '8px 10px',
background: 'rgba(255, 255, 255, 0.02)',
border: '1px solid var(--bg-border)',
borderRadius: 10,
},
statusDot: {
width: 6,
height: 6,
borderRadius: '50%',
flexShrink: 0,
},
eventTool: {
fontFamily: 'var(--font-mono)',
fontSize: 12,
fontWeight: 600,
color: '#FFF',
},
eventArgs: {
fontFamily: 'var(--font-mono)',
fontSize: 10,
color: 'var(--text-muted)',
marginTop: 2,
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
},
latencyBadge: {
fontFamily: 'var(--font-mono)',
fontSize: 10,
color: 'var(--accent-coral-pink)',
background: 'rgba(255, 51, 102, 0.1)',
padding: '2px 6px',
borderRadius: 4,
},
footer: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 8,
fontSize: 11,
color: 'var(--text-muted)',
borderTop: '1px solid var(--bg-border)',
paddingTop: 10,
},
};