11import { ChevronDown , ChevronUp } from 'lucide-react' ;
22import { useState } from 'react' ;
3- import type { MCPTool } from "@/lib/types/tools" ; ;
3+ import type { MCPTool } from '@/lib/types/tools' ;
4+ import { cn } from '@/lib/utils' ;
45import { getTypeBadgeVariant , parseMCPInputSchema } from '@/lib/utils/mcp-schema-parser' ;
56import { Badge } from '../ui/badge' ;
67import { Button } from '../ui/button' ;
@@ -11,9 +12,10 @@ interface ToolCardProps {
1112 description ?: string ;
1213 inputSchema ?: any ;
1314 } ;
15+ isActive : boolean ;
1416}
1517
16- function ToolCard ( { tool } : ToolCardProps ) {
18+ function ToolCard ( { tool, isActive } : ToolCardProps ) {
1719 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
1820 const [ showFullDescription , setShowFullDescription ] = useState ( false ) ;
1921
@@ -33,7 +35,10 @@ function ToolCard({ tool }: ToolCardProps) {
3335 { /* Tool header */ }
3436 < div className = "flex items-center justify-between" >
3537 < div className = "flex items-center gap-2" >
36- < Badge variant = "code" className = "bg-transparent text-foreground" >
38+ < Badge
39+ variant = { isActive ? 'primary' : 'code' }
40+ className = { cn ( ! isActive && 'bg-transparent text-foreground' ) }
41+ >
3742 { tool . name }
3843 </ Badge >
3944 { parsedSchema ?. hasProperties && (
@@ -97,7 +102,13 @@ function ToolCard({ tool }: ToolCardProps) {
97102 ) ;
98103}
99104
100- export function AvailableToolsCard ( { tools } : { tools : MCPTool [ 'availableTools' ] } ) {
105+ export function AvailableToolsCard ( {
106+ tools,
107+ activeTools,
108+ } : {
109+ tools : MCPTool [ 'availableTools' ] ;
110+ activeTools : MCPTool [ 'config' ] [ 'mcp' ] [ 'activeTools' ] ;
111+ } ) {
101112 if ( ! tools ) return null ; // parent component already makes sure to handle this
102113
103114 return (
@@ -109,9 +120,11 @@ export function AvailableToolsCard({ tools }: { tools: MCPTool['availableTools']
109120 </ Badge >
110121 </ div >
111122 < div className = "space-y-2" >
112- { tools . map ( ( availableTool ) => (
113- < ToolCard key = { availableTool . name } tool = { availableTool } />
114- ) ) }
123+ { tools . map ( ( availableTool ) => {
124+ const isActive =
125+ activeTools === undefined ? true : activeTools ?. includes ( availableTool . name ) ;
126+ return < ToolCard key = { availableTool . name } tool = { availableTool } isActive = { ! ! isActive } /> ;
127+ } ) }
115128 </ div >
116129 </ div >
117130 ) ;
0 commit comments