MCPcopy Index your code
hub / github.com/winfunc/opcode / MCPWidget

Function MCPWidget

src/components/ToolWidgets.tsx:1293–1456  ·  view source on GitHub ↗
({ toolName, input, result: _result })

Source from the content-addressed store, hash-verified

1291 input?: any;
1292 result?: any;
1293}> = ({ toolName, input, result: _result }) => {
1294 const [isExpanded, setIsExpanded] = useState(false);
1295 const { theme } = useTheme();
1296 const syntaxTheme = getClaudeSyntaxTheme(theme);
1297
1298 // Parse the tool name to extract components
1299 // Format: mcp__namespace__method
1300 const parts = toolName.split('__');
1301 const namespace = parts[1] || '';
1302 const method = parts[2] || '';
1303
1304 // Format namespace for display (handle kebab-case and snake_case)
1305 const formatNamespace = (ns: string) => {
1306 return ns
1307 .replace(/-/g, ' ')
1308 .replace(/_/g, ' ')
1309 .split(' ')
1310 .map(word => word.charAt(0).toUpperCase() + word.slice(1))
1311 .join(' ');
1312 };
1313
1314 // Format method name
1315 const formatMethod = (m: string) => {
1316 return m
1317 .replace(/_/g, ' ')
1318 .split(' ')
1319 .map(word => word.charAt(0).toUpperCase() + word.slice(1))
1320 .join(' ');
1321 };
1322
1323 const hasInput = input && Object.keys(input).length > 0;
1324 const inputString = hasInput ? JSON.stringify(input, null, 2) : '';
1325 const isLargeInput = inputString.length > 200;
1326
1327 // Count tokens approximation (very rough estimate)
1328 const estimateTokens = (str: string) => {
1329 // Rough approximation: ~4 characters per token
1330 return Math.ceil(str.length / 4);
1331 };
1332
1333 const inputTokens = hasInput ? estimateTokens(inputString) : 0;
1334
1335 return (
1336 <div className="rounded-lg border border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-purple-500/5 overflow-hidden">
1337 {/* Header */}
1338 <div className="px-4 py-3 bg-gradient-to-r from-violet-500/10 to-purple-500/10 border-b border-violet-500/20">
1339 <div className="flex items-center justify-between">
1340 <div className="flex items-center gap-2">
1341 <div className="relative">
1342 <Package2 className="h-4 w-4 text-violet-500" />
1343 <Sparkles className="h-2.5 w-2.5 text-violet-400 absolute -top-1 -right-1" />
1344 </div>
1345 <span className="text-sm font-medium text-violet-600 dark:text-violet-400">MCP Tool</span>
1346 </div>
1347 {hasInput && (
1348 <div className="flex items-center gap-2">
1349 <Badge
1350 variant="outline"

Callers

nothing calls this directly

Calls 6

useThemeFunction · 0.90
getClaudeSyntaxThemeFunction · 0.90
cnFunction · 0.90
estimateTokensFunction · 0.85
formatNamespaceFunction · 0.85
formatMethodFunction · 0.85

Tested by

no test coverage detected