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

Function MCPServerList

src/components/MCPServerList.tsx:47–434  ·  view source on GitHub ↗
({
  servers,
  loading,
  onServerRemoved,
  onRefresh,
})

Source from the content-addressed store, hash-verified

45 * Shows servers grouped by scope with status indicators
46 */
47export const MCPServerList: React.FC<MCPServerListProps> = ({
48 servers,
49 loading,
50 onServerRemoved,
51 onRefresh,
52}) => {
53 const [removingServer, setRemovingServer] = useState<string | null>(null);
54 const [testingServer, setTestingServer] = useState<string | null>(null);
55 const [expandedServers, setExpandedServers] = useState<Set<string>>(new Set());
56 const [copiedServer, setCopiedServer] = useState<string | null>(null);
57 const [connectedServers] = useState<string[]>([]);
58
59 // Analytics tracking
60 const trackEvent = useTrackEvent();
61
62 // Group servers by scope
63 const serversByScope = servers.reduce((acc, server) => {
64 const scope = server.scope || "local";
65 if (!acc[scope]) acc[scope] = [];
66 acc[scope].push(server);
67 return acc;
68 }, {} as Record<string, MCPServer[]>);
69
70 /**
71 * Toggles expanded state for a server
72 */
73 const toggleExpanded = (serverName: string) => {
74 setExpandedServers(prev => {
75 const next = new Set(prev);
76 if (next.has(serverName)) {
77 next.delete(serverName);
78 } else {
79 next.add(serverName);
80 }
81 return next;
82 });
83 };
84
85 /**
86 * Copies command to clipboard
87 */
88 const copyCommand = async (command: string, serverName: string) => {
89 try {
90 await navigator.clipboard.writeText(command);
91 setCopiedServer(serverName);
92 setTimeout(() => setCopiedServer(null), 2000);
93 } catch (error) {
94 console.error("Failed to copy command:", error);
95 }
96 };
97
98 /**
99 * Removes a server
100 */
101 const handleRemoveServer = async (name: string) => {
102 try {
103 setRemovingServer(name);
104

Callers

nothing calls this directly

Calls 3

useTrackEventFunction · 0.90
getScopeIconFunction · 0.85
getScopeDisplayNameFunction · 0.85

Tested by

no test coverage detected