File size: 78,744 Bytes
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
 
 
 
 
abb32f1
 
a85f4e8
 
 
 
 
 
0f82736
 
 
 
abb32f1
 
 
 
0f82736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb32f1
8b1b1c7
 
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
0f82736
 
abb32f1
 
 
0f82736
abb32f1
 
0f82736
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
0f82736
 
abb32f1
 
 
6d05e15
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b1b1c7
 
abb32f1
 
 
 
 
 
 
880ef7f
 
 
 
6ae304e
880ef7f
 
 
8b1b1c7
 
54d748d
f42b8e7
8b1b1c7
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3578f6e
abb32f1
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
 
 
 
 
a85f4e8
 
 
 
 
 
 
0f82736
a85f4e8
 
 
 
 
0f82736
a85f4e8
 
 
 
 
0f82736
abb32f1
 
0f82736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
0f82736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 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28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
"""
Documentation Screen for TraceMind-AI
Comprehensive documentation for the TraceMind ecosystem
"""

import gradio as gr


def create_about_tab():
    """Create the About tab with ecosystem overview"""
    return gr.Markdown("""
# 🧠 TraceMind Ecosystem

<div align="center">
  <img src="https://raw.githubusercontent.com/Mandark-droid/TraceMind-AI/assets/Logo.png" alt="TraceMind Logo" width="300"/>
</div>

<br/>

**The Complete AI Agent Evaluation Platform**

<div align="center" style="display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;">
  <a href="https://github.com/modelcontextprotocol"><img src="https://img.shields.io/badge/MCP%27s%201st%20Birthday-Hackathon-blue" alt="MCP's 1st Birthday Hackathon"></a>
  <a href="https://github.com/modelcontextprotocol/hackathon"><img src="https://img.shields.io/badge/Track-MCP%20in%20Action%20(Enterprise)-purple" alt="Track 2"></a>
  <a href="https://huggingface.co/spaces/MCP-1st-Birthday/TraceMind"><img src="https://img.shields.io/badge/HuggingFace-TraceMind-yellow?logo=huggingface" alt="HF Space"></a>
  <a href="https://gradio.app/"><img src="https://img.shields.io/badge/Powered%20by-Gradio-orange" alt="Powered by Gradio"></a>
</div>

> **🎯 Track 2 Submission**: MCP in Action (Enterprise)
> **📅 MCP's 1st Birthday Hackathon**: November 14-30, 2025

TraceMind is a comprehensive ecosystem for evaluating, monitoring, and optimizing AI agents. Built on open-source foundations and powered by the Model Context Protocol (MCP), TraceMind provides everything you need for production-grade agent evaluation.

---

## 📖 Table of Contents

- [Architecture Overview](#️-architecture-overview)
- [The Complete Flow](#-the-complete-flow)
- [Key Features](#-key-features)
- [Built for MCP's 1st Birthday Hackathon](#-built-for-mcps-1st-birthday-hackathon)
- [Quick Links](#-quick-links)
- [Documentation Navigation](#-documentation-navigation)
- [Getting Started](#-getting-started)
- [Contributing](#-contributing)
- [Acknowledgments](#-acknowledgments)

---

<details open>
<summary><h2>🏗️ Architecture Overview</h2></summary>

<div align="center">
  <img src="https://raw.githubusercontent.com/Mandark-droid/TraceMind-AI/assets/TraceVerse_Logo.png" alt="TraceVerse Ecosystem" width="500"/>
</div>

<br/>

The TraceMind ecosystem consists of four integrated components:

```
┌─────────────────────────────────────────────────────────────┐
│                    TraceMind Ecosystem                       │
├─────────────────────────────────────────────────────────────┤
│                                                               │
│  1️⃣ TraceVerde (genai_otel_instrument)                      │
│     └─ Automatic OpenTelemetry Instrumentation              │
│        └─ Zero-code tracing for LLM frameworks               │
│                                                               │
│  2️⃣ SMOLTRACE                                                │
│     └─ Lightweight Agent Evaluation Engine                   │
│        └─ Generates structured datasets                      │
│                                                               │
│  3️⃣ TraceMind-MCP-Server                                     │
│     └─ MCP Server (Track 1: Building MCP)                    │
│        └─ Provides intelligent analysis tools                │
│                                                               │
│  4️⃣ TraceMind-AI (This App!)                                 │
│     └─ Gradio UI (Track 2: MCP in Action)                    │
│        └─ Visualizes data + consumes MCP tools               │
│                                                               │
└─────────────────────────────────────────────────────────────┘
```

</details>

---

<details open>
<summary><h2>🔄 The Complete Flow</h2></summary>

### 1. **Instrument Your Agents** (TraceVerde)
```python
import genai_otel

# Zero-code instrumentation
genai_otel.instrument()

# Your agent code runs normally, but now traced!
agent.run("What's the weather in Tokyo?")
```

### 2. **Evaluate with SMOLTRACE**
```bash
# Run comprehensive evaluation
smoltrace-eval \\
  --model openai/gpt-4 \\
  --agent-type both \\
  --enable-otel
```

### 3. **Analyze Results** (This UI)
- View leaderboard rankings
- Compare model performance
- Explore detailed traces
- Ask questions with MCP-powered chat

</details>

---

<details open>
<summary><h2>🎯 Key Features</h2></summary>

### For Developers
- ✅ **Zero-code Instrumentation**: Just import and go
- ✅ **Framework Agnostic**: Works with LiteLLM, Transformers, HF Inference, Ollama, etc.
- ✅ **Production Ready**: Lightweight, minimal overhead
- ✅ **Standards Compliant**: Uses OpenTelemetry conventions

### For Researchers
- ✅ **Comprehensive Metrics**: Token usage, costs, latency, GPU utilization
- ✅ **Reproducible Results**: Structured datasets on HuggingFace
- ✅ **Model Comparison**: Side-by-side analysis
- ✅ **Trace Visualization**: Step-by-step agent execution

### For Organizations
- ✅ **Cost Transparency**: Real-time cost tracking and estimation
- ✅ **Sustainability**: CO2 emissions monitoring (TraceVerde)
- ✅ **MCP Integration**: Connect to intelligent analysis tools
- ✅ **HuggingFace Native**: Seamless dataset integration

</details>

---

## 🏆 Built for MCP's 1st Birthday Hackathon

TraceMind demonstrates the complete MCP ecosystem:

**Track 1 (Building MCP)**: [TraceMind-mcp-server](https://huggingface.co/spaces/MCP-1st-Birthday/TraceMind-mcp-server)
- Provides MCP tools for leaderboard analysis, cost estimation, trace debugging

**Track 2 (MCP in Action)**: TraceMind-AI (this app!)
- Consumes MCP servers for autonomous agent chat and intelligent insights

---

## 🔗 Quick Links

### 📦 Component Links

| Component | Description | Links |
|-----------|-------------|-------|
| **TraceVerde** | OTEL Instrumentation | [GitHub](https://github.com/Mandark-droid/genai_otel_instrument) • [PyPI](https://pypi.org/project/genai-otel-instrument) |
| **SMOLTRACE** | Evaluation Engine | [GitHub](https://github.com/Mandark-droid/SMOLTRACE) • [PyPI](https://pypi.org/project/smoltrace/) |
| **MCP Server** | Building MCP (Track 1) | [HF Space](https://huggingface.co/spaces/MCP-1st-Birthday/TraceMind-mcp-server) |
| **TraceMind-AI** | MCP in Action (Track 2) | [HF Space](https://huggingface.co/spaces/MCP-1st-Birthday/TraceMind) |

### 🎬 Demo Videos

| Video | Duration | Link |
|-------|----------|------|
| **TraceMind-AI Full Demo** | 20 mins | [Watch on Loom](https://www.loom.com/share/70b9689b57204da58b8fef0d23c304fe) |
| **TraceMind-MCP-Server Quick Demo** | 5 mins | [Watch on Loom](https://www.loom.com/share/d4d0003f06fa4327b46ba5c081bdf835) |
| **TraceMind-MCP-Server Full Demo** | 20 mins | [Watch on Loom](https://www.loom.com/share/de559bb0aef749559c79117b7f951250) |

### 📢 Community Posts

- 🚀 [**TraceMind-AI Hackathon Submission**](https://www.linkedin.com/posts/kshitij-thakkar-2061b924_mcp1stbirthdayhackathon-mcp-modelcontextprotocol-activity-7399775530218065920-owgR) - MCP's 1st Birthday Hackathon final submission
- 📝 [**Building TraceMind Ecosystem Blog Post**](https://huggingface.co/blog/kshitijthakkar/tracemind-ecosystem) - Complete technical deep-dive into the TraceVerse ecosystem
- 🎉 [**TraceMind Teaser**](https://www.linkedin.com/posts/kshitij-thakkar-2061b924_mcpsfirstbirthdayhackathon-mcpsfirstbirthdayhackathon-activity-7395686529270013952-g_id) - MCP's 1st Birthday Hackathon announcement
- 📊 [**SMOLTRACE Launch**](https://www.linkedin.com/posts/kshitij-thakkar-2061b924_ai-machinelearning-llm-activity-7394350375908126720-im_T) - Lightweight agent evaluation engine
- 🔭 [**TraceVerde Launch**](https://www.linkedin.com/posts/kshitij-thakkar-2061b924_genai-opentelemetry-observability-activity-7390339855135813632-wqEg) - Zero-code OTEL instrumentation for LLMs
- 🙏 [**TraceVerde 3K Downloads**](https://www.linkedin.com/posts/kshitij-thakkar-2061b924_thank-you-open-source-community-a-week-activity-7392205780592132096-nu6U) - Thank you to the community!

---

## 📚 Documentation Navigation

Use the tabs above to explore detailed documentation for each component:

- **About**: This overview (you are here)
- **TraceVerde**: OpenTelemetry instrumentation for LLMs
- **SmolTrace**: Agent evaluation engine
- **TraceMind-MCP-Server**: MCP server implementation details

---

<details open>
<summary><h2>💡 Getting Started</h2></summary>

### Quick Start (5 minutes)
```bash
# 1. Install TraceVerde for instrumentation
pip install genai-otel-instrument

# 2. Install SMOLTRACE for evaluation
pip install smoltrace

# 3. Run your first evaluation
smoltrace-eval --model openai/gpt-4 --agent-type tool

# 4. View results in TraceMind-AI (this UI!)
```

### Learn More
- Read component-specific docs in the tabs above
- Try the **Agent Chat** for interactive queries
- Explore the **Leaderboard** to see real evaluation data
- Check the **Trace Detail** screen for deep inspection

</details>

---

## 🤝 Contributing

All components are open source under AGPL-3.0:
- Report issues on GitHub
- Submit pull requests
- Share your evaluation results
- Join the community discussions

---

## 👏 Acknowledgments

Built with ❤️ for **MCP's 1st Birthday Hackathon** by **Kshitij Thakkar**

Special thanks to:
- **Anthropic** - For the Model Context Protocol
- **Gradio Team** - For Gradio 6 with MCP integration
- **HuggingFace** - For Spaces and dataset infrastructure
- **Google** - For Gemini API access
- **OpenTelemetry** - For standardized observability
- **[Eliseu Silva](https://huggingface.co/elismasilva)** - For the [gradio_htmlplus](https://huggingface.co/spaces/elismasilva/gradio_htmlplus) custom component that powers our interactive leaderboard table. Eliseu's timely help and collaboration during the hackathon was invaluable!

---

*Last Updated: November 2025*
""")


def create_traceverde_tab():
    """Create the TraceVerde documentation tab"""
    return gr.Markdown("""
# 🔭 TraceVerde (genai_otel_instrument)

<div align="center">
  <img src="https://raw.githubusercontent.com/Mandark-droid/genai_otel_instrument/main/.github/images/Logo.jpg" alt="TraceVerde Logo" width="400"/>
</div>

<br/>

<div align="center" style="display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;">
  <a href="https://badge.fury.io/py/genai-otel-instrument"><img src="https://badge.fury.io/py/genai-otel-instrument.svg" alt="PyPI version"></a>
  <a href="https://pypi.org/project/genai-otel-instrument/"><img src="https://img.shields.io/pypi/pyversions/genai-otel-instrument.svg" alt="Python Versions"></a>
  <a href="https://www.gnu.org/licenses/agpl-3.0"><img src="https://img.shields.io/badge/License-AGPL%203.0-blue.svg" alt="License"></a>
  <a href="https://pepy.tech/project/genai-otel-instrument"><img src="https://static.pepy.tech/badge/genai-otel-instrument" alt="Downloads"></a>
  <a href="https://pepy.tech/project/genai-otel-instrument"><img src="https://static.pepy.tech/badge/genai-otel-instrument/month" alt="Downloads/Month"></a>
</div>

<div align="center" style="display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;">
  <a href="https://github.com/Mandark-droid/genai_otel_instrument"><img src="https://img.shields.io/github/stars/Mandark-droid/genai_otel_instrument?style=social" alt="GitHub Stars"></a>
  <a href="https://github.com/Mandark-droid/genai_otel_instrument"><img src="https://img.shields.io/github/forks/Mandark-droid/genai_otel_instrument?style=social" alt="GitHub Forks"></a>
  <a href="https://github.com/Mandark-droid/genai_otel_instrument/issues"><img src="https://img.shields.io/github/issues/Mandark-droid/genai_otel_instrument" alt="GitHub Issues"></a>
</div>

<div align="center" style="display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;">
  <a href="https://opentelemetry.io/"><img src="https://img.shields.io/badge/OpenTelemetry-1.20%2B-blueviolet" alt="OpenTelemetry"></a>
  <a href="https://opentelemetry.io/docs/specs/semconv/gen-ai/"><img src="https://img.shields.io/badge/OTel%20Semconv-GenAI%20v1.28-orange" alt="Semantic Conventions"></a>
  <a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code Style: Black"></a>
</div>

**Automatic OpenTelemetry Instrumentation for LLM Applications**

---

## 📖 Table of Contents

- [What is TraceVerde?](#what-is-traceverde)
- [Installation](#-installation)
- [Quick Start](#-quick-start)
- [Supported Frameworks](#-supported-frameworks)
- [What Gets Captured?](#-what-gets-captured)
- [CO2 Emissions Tracking](#-co2-emissions-tracking)
- [Advanced Configuration](#-advanced-configuration)
- [Integration with SMOLTRACE](#-integration-with-smoltrace)
- [Use Cases](#-use-cases)
- [OpenTelemetry Standards](#-opentelemetry-standards)
- [Resources](#-resources)
- [Troubleshooting](#-troubleshooting)
- [License](#-license)
- [Contributing](#-contributing)

---

## What is TraceVerde?

TraceVerde is a **zero-code** OpenTelemetry instrumentation library for GenAI applications. It automatically captures:

- 🔹 Every LLM call (token usage, cost, latency)
- 🔹 Tool executions and results
- 🔹 Agent reasoning steps
- 🔹 GPU metrics (utilization, memory, temperature)
- 🔹 CO2 emissions (via CodeCarbon integration)

All with **one import statement** - no code changes required!

---

## 📦 Installation

```bash
pip install genai-otel-instrument

# With GPU metrics support
pip install genai-otel-instrument[gpu]

# With CO2 emissions tracking
pip install genai-otel-instrument[carbon]

# All features
pip install genai-otel-instrument[all]
```

---

<details open>
<summary><h2>🚀 Quick Start</h2></summary>

### Basic Usage

**Option 1: Environment Variables (No code changes)**

```bash
export OTEL_SERVICE_NAME=my-llm-app
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
python your_app.py
```

**Option 2: One line of code**

```python
import genai_otel
genai_otel.instrument()

# Your existing code works unchanged
import openai
client = openai.OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

# Traces are automatically captured and exported!
```

**Option 3: With OpenTelemetry Setup**

```python
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor

# 1. Setup OpenTelemetry (one-time setup)
trace.set_tracer_provider(TracerProvider())
span_processor = SimpleSpanProcessor(ConsoleSpanExporter())
trace.get_tracer_provider().add_span_processor(span_processor)

# 2. Instrument all LLM frameworks (one line!)
import genai_otel
genai_otel.instrument()

# 3. Use your LLM framework normally - it's now traced!
from litellm import completion

response = completion(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

# Traces are automatically captured and exported!
```

</details>

---

<details>
<summary><h2>🎯 Supported Frameworks</h2></summary>

TraceVerde automatically instruments **30+ LLM frameworks and providers**:

### 🔥 Popular Frameworks
| Framework | Status | Description |
|-----------|--------|-------------|
| **LiteLLM** | ✅ Full Support | Universal LLM gateway (100+ models) |
| **Transformers** | ✅ Full Support | HuggingFace models |
| **LangChain** | ✅ Full Support | LLM application framework |
| **LangGraph** | ✅ Full Support | LangChain graph-based workflows |
| **CrewAI** | ✅ Full Support | Multi-agent orchestration |
| **smolagents** | ✅ Full Support | HuggingFace agent framework |
| **LlamaIndex** | ✅ Full Support | Data framework for LLMs |

### 🏢 LLM Providers
| Provider | Status | Description |
|----------|--------|-------------|
| **OpenAI** | ✅ Full Support | GPT-4, GPT-3.5, etc. |
| **Anthropic** | ✅ Full Support | Claude models |
| **Google AI** | ✅ Full Support | Gemini models |
| **Cohere** | ✅ Full Support | Command models |
| **Mistral AI** | ✅ Full Support | Mistral models |
| **Groq** | ✅ Full Support | Fast LLM inference |
| **Together AI** | ✅ Full Support | Open source models |
| **Anyscale** | ✅ Full Support | Ray-based LLM serving |
| **Replicate** | ✅ Full Support | Open source model API |
| **SambaNova** | ✅ Full Support | Enterprise AI platform |
| **Hyperbolic** | ✅ Full Support | Decentralized AI |

### ☁️ Cloud AI Services
| Service | Status | Description |
|---------|--------|-------------|
| **Azure OpenAI** | ✅ Full Support | Azure-hosted OpenAI |
| **AWS Bedrock** | ✅ Full Support | Amazon LLM service |
| **Bedrock Agents** | ✅ Full Support | AWS agent framework |
| **Vertex AI** | ✅ Full Support | Google Cloud AI |

### 🤖 Agent & Workflow Frameworks
| Framework | Status | Description |
|-----------|--------|-------------|
| **AutoGen** | ✅ Full Support | Microsoft agent framework |
| **OpenAI Agents** | ✅ Full Support | OpenAI assistants API |
| **Pydantic AI** | ✅ Full Support | Type-safe agent framework |
| **DSPy** | ✅ Full Support | Programming framework for LMs |
| **Haystack** | ✅ Full Support | NLP framework |
| **Guardrails AI** | ✅ Full Support | LLM validation framework |
| **Instructor** | ✅ Full Support | Structured LLM outputs |

### 🖥️ Local & Self-Hosted
| Provider | Status | Description |
|----------|--------|-------------|
| **Ollama** | ✅ Full Support | Local LLM runtime |

**No code changes needed** - just import and use as normal!

</details>

---

<details>
<summary><h2>📊 What Gets Captured?</h2></summary>

### LLM Spans

Every LLM call creates a span with:

```json
{
  "span_name": "LLM Call - Reasoning",
  "attributes": {
    "gen_ai.system": "openai",
    "gen_ai.request.model": "gpt-4",
    "gen_ai.operation.name": "chat",
    "gen_ai.usage.prompt_tokens": 78,
    "gen_ai.usage.completion_tokens": 156,
    "gen_ai.usage.total_tokens": 234,
    "gen_ai.usage.cost.total": 0.0012,
    "gen_ai.response.finish_reasons": ["stop"],
    "gen_ai.request.temperature": 0.7
  }
}
```

### Tool Spans

Tool executions are traced with:

```json
{
  "span_name": "Tool Call - get_weather",
  "attributes": {
    "tool.name": "get_weather",
    "tool.input": "{\\"location\\": \\"Tokyo\\"}",
    "tool.output": "{\\"temp\\": \\"18°C\\"}",
    "tool.latency_ms": 890
  }
}
```

### GPU Metrics

When enabled, captures real-time GPU data:

```json
{
  "metrics": [
    {
      "name": "gen_ai.gpu.utilization",
      "value": 67.5,
      "unit": "%",
      "timestamp": "2025-11-18T14:23:00Z"
    },
    {
      "name": "gen_ai.gpu.memory.used",
      "value": 512.34,
      "unit": "MiB"
    }
  ]
}
```

</details>

---

## 🌱 CO2 Emissions Tracking

TraceVerde integrates with CodeCarbon for sustainability monitoring:

```python
import genai_otel

# Enable CO2 tracking
genai_otel.instrument(enable_carbon_tracking=True)

# Your LLM calls now track carbon emissions!
```

**Captured Metrics:**
- 🌍 CO2 emissions (grams)
- ⚡ Energy consumed (kWh)
- 📍 Geographic region
- 💻 Hardware type (CPU/GPU)

---

## 🔧 Advanced Configuration

### Custom Exporters

```python
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace.export import BatchSpanProcessor

# Export to Jaeger/Tempo/etc
otlp_exporter = OTLPSpanExporter(endpoint="http://localhost:4317")
span_processor = BatchSpanProcessor(otlp_exporter)
trace.get_tracer_provider().add_span_processor(span_processor)

import genai_otel
genai_otel.instrument()
```

### GPU Metrics

```python
# Enable GPU monitoring (requires pynvml)
import genai_otel
genai_otel.instrument(
    enable_gpu_metrics=True,
    gpu_poll_interval=1.0  # seconds
)
```

---

## 📈 Integration with SMOLTRACE

TraceVerde powers SMOLTRACE's evaluation capabilities:

```python
# SMOLTRACE automatically uses TraceVerde for instrumentation
from smoltrace import evaluate_agent

results = evaluate_agent(
    model="gpt-4",
    agent_type="tool",
    enable_otel=True  # Uses TraceVerde under the hood!
)
```

---

## 🎯 Use Cases

### 1. Development & Debugging
```python
# See exactly what your agent is doing
import genai_otel
genai_otel.instrument()

# Run your agent
agent.run("Complex task")

# View traces in console or Jaeger
```

### 2. Production Monitoring
```python
# Export to your observability platform
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter

otlp_exporter = OTLPSpanExporter(endpoint="https://your-otel-collector")
# ... setup processor ...

import genai_otel
genai_otel.instrument()
```

### 3. Cost Analysis
```python
# Track costs across all LLM calls
import genai_otel
genai_otel.instrument()

# Analyze cost per user/session/feature
# All costs automatically captured in span attributes
```

### 4. Sustainability Reporting
```python
# Monitor environmental impact
import genai_otel
genai_otel.instrument(
    enable_carbon_tracking=True,
    enable_gpu_metrics=True
)

# Generate CO2 reports from trace data
```

---

## 📐 OpenTelemetry Standards

TraceVerde follows the **Gen AI Semantic Conventions**:
- ✅ Consistent attribute naming (`gen_ai.*`)
- ✅ Standard span structure
- ✅ Compatible with all OTEL collectors
- ✅ Works with Jaeger, Tempo, Datadog, New Relic, etc.

---

## 🔗 Resources

- **GitHub**: [github.com/Mandark-droid/genai_otel_instrument](https://github.com/Mandark-droid/genai_otel_instrument)
- **PyPI**: [pypi.org/project/genai-otel-instrument](https://pypi.org/project/genai-otel-instrument)
- **Examples**: [github.com/Mandark-droid/genai_otel_instrument/examples](https://github.com/Mandark-droid/genai_otel_instrument/tree/main/examples)
- **OpenTelemetry Docs**: [opentelemetry.io](https://opentelemetry.io)

---

## 🐛 Troubleshooting

### Common Issues

**Q: Traces not appearing?**
```python
# Make sure you setup a tracer provider first
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider

trace.set_tracer_provider(TracerProvider())
```

**Q: GPU metrics not working?**
```bash
# Install GPU support
pip install genai-otel-instrument[gpu]

# Verify NVIDIA drivers installed
nvidia-smi
```

**Q: How to configure different options?**
```python
# Use environment variables or pass options to instrument()
import genai_otel
genai_otel.instrument(enable_gpu_metrics=True)
```

---

## 📄 License

**AGPL-3.0** - Open source and free to use

---

## 🤝 Contributing

Contributions welcome!
- Report bugs on GitHub Issues
- Submit PRs for new framework support
- Share your use cases

---

*TraceVerde - Making AI agents observable, one trace at a time* 🔭
""")


def create_smoltrace_tab():
    """Create the SMOLTRACE documentation tab"""
    return gr.Markdown("""
# 📊 SMOLTRACE

<div align="center">
  <img src="https://raw.githubusercontent.com/Mandark-droid/SMOLTRACE/main/.github/images/Logo.png" alt="SMOLTRACE Logo" width="400"/>
</div>

<br/>

**Lightweight Agent Evaluation Engine with Built-in OpenTelemetry Tracing**

<div align="center" style="display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;">
  <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/Python-3.10%2B-blue" alt="Python"></a>
  <a href="https://github.com/Mandark-droid/SMOLTRACE/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-AGPL--3.0-blue.svg" alt="License"></a>
  <a href="https://badge.fury.io/py/smoltrace"><img src="https://badge.fury.io/py/smoltrace.svg" alt="PyPI version"></a>
  <a href="https://pepy.tech/project/smoltrace"><img src="https://static.pepy.tech/badge/smoltrace" alt="Downloads"></a>
  <a href="https://pepy.tech/project/smoltrace"><img src="https://static.pepy.tech/badge/smoltrace/month" alt="Downloads/Month"></a>
</div>

<div align="center" style="display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;">
  <a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black"></a>
  <a href="https://pycqa.github.io/isort/"><img src="https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336" alt="Imports: isort"></a>
  <a href="https://github.com/Mandark-droid/SMOLTRACE/actions?query=workflow%3Atest"><img src="https://img.shields.io/github/actions/workflow/status/Mandark-droid/SMOLTRACE/test.yml?branch=main&label=tests" alt="Tests"></a>
  <a href="https://huggingface.co/docs/smoltrace/en/index"><img src="https://img.shields.io/badge/docs-stable-blue.svg" alt="Docs"></a>
</div>

---

## 📖 Table of Contents

- [What is SMOLTRACE?](#what-is-smoltrace)
- [Installation](#-installation)
- [Quick Start](#-quick-start)
- [Evaluation Types](#-evaluation-types)
- [What Gets Generated?](#-what-gets-generated)
- [Configuration Options](#-configuration-options)
- [Integration with HuggingFace Jobs](#️-integration-with-huggingface-jobs)
- [Integration with TraceMind-AI](#-integration-with-tracemind-ai)
- [Best Practices](#-best-practices)
- [Cost Estimation](#-cost-estimation)
- [Architecture](#-architecture)
- [Resources](#-resources)
- [Troubleshooting](#-troubleshooting)
- [License](#-license)
- [Contributing](#-contributing)

---

## What is SMOLTRACE?

SMOLTRACE is a **production-ready** evaluation framework for AI agents that:

- ✅ Evaluates agents across tool usage, code execution, and both
- ✅ Supports both API models (via LiteLLM) and local models (via Transformers)
- ✅ Automatically captures OpenTelemetry traces using TraceVerde
- ✅ Generates structured datasets for HuggingFace
- ✅ Tracks costs, GPU metrics, and CO2 emissions

**Goal**: Become HuggingFace's standard agent evaluation platform

---

## 📦 Installation

```bash
# Basic installation
pip install smoltrace

# With OpenTelemetry support
pip install smoltrace[otel]

# With GPU metrics
pip install smoltrace[otel,gpu]

# Everything
pip install smoltrace[all]
```

---

<details open>
<summary><h2>🚀 Quick Start</h2></summary>

### Command Line

```bash
# Evaluate GPT-4 as a tool agent
smoltrace-eval \\
  --model openai/gpt-4 \\
  --provider litellm \\
  --agent-type tool \\
  --enable-otel

# Evaluate local Llama model
smoltrace-eval \\
  --model meta-llama/Llama-3.1-8B \\
  --provider transformers \\
  --agent-type both \\
  --enable-otel \\
  --enable-gpu-metrics
```

### Python API

```python
from smoltrace import evaluate_agent

# Run evaluation
results = evaluate_agent(
    model="openai/gpt-4",
    provider="litellm",
    agent_type="tool",
    enable_otel=True,
    num_tests=100
)

# Access results
print(f"Success Rate: {results.success_rate}%")
print(f"Total Cost: ${results.total_cost}")
print(f"Avg Duration: {results.avg_duration_ms}ms")

# Upload to HuggingFace
results.upload_to_hf(
    results_repo="username/agent-results-gpt4",
    traces_repo="username/agent-traces-gpt4",
    leaderboard_repo="username/agent-leaderboard"
)
```

</details>

---

## 🎯 Evaluation Types

### 1. Tool Agent
Tests ability to use external tools:
```bash
smoltrace-eval --model gpt-4 --agent-type tool
```

**Example Task**: "What's the weather in Tokyo?"
- Agent must call `get_weather` tool
- Verify correct tool selection
- Check response quality

### 2. Code Agent
Tests code generation and execution:
```bash
smoltrace-eval --model gpt-4 --agent-type code
```

**Example Task**: "Calculate the sum of first 10 prime numbers"
- Agent must generate Python code
- Execute code safely
- Return correct result

### 3. Both (Combined)
Tests comprehensive agent capabilities:
```bash
smoltrace-eval --model gpt-4 --agent-type both
```

**Tests both tool usage AND code generation**

---

<details>
<summary><h2>📊 What Gets Generated?</h2></summary>

SMOLTRACE creates **4 structured datasets** on HuggingFace:

### 1. Leaderboard Dataset
Aggregate statistics for all evaluation runs:

```python
{
    "run_id": "uuid",
    "model": "openai/gpt-4",
    "agent_type": "tool",
    "provider": "litellm",

    # Performance
    "success_rate": 95.8,
    "total_tests": 100,
    "avg_duration_ms": 3200.0,

    # Cost & Resources
    "total_tokens": 15000,
    "total_cost_usd": 0.05,
    "co2_emissions_g": 0.22,
    "gpu_utilization_avg": 67.5,

    # Dataset References
    "results_dataset": "username/agent-results-gpt4",
    "traces_dataset": "username/agent-traces-gpt4",
    "metrics_dataset": "username/agent-metrics-gpt4",

    # Metadata
    "timestamp": "2025-11-18T14:23:00Z",
    "submitted_by": "username"
}
```

### 2. Results Dataset
Individual test case results:

```python
{
    "run_id": "uuid",
    "task_id": "task_001",
    "test_index": 0,

    # Test Case
    "prompt": "What's the weather in Tokyo?",
    "expected_tool": "get_weather",

    # Result
    "success": true,
    "response": "The weather in Tokyo is 18°C and clear.",
    "tool_called": "get_weather",

    # Metrics
    "execution_time_ms": 2450.0,
    "total_tokens": 234,
    "cost_usd": 0.0012,

    # Trace Reference
    "trace_id": "trace_abc123"
}
```

### 3. Traces Dataset
Full OpenTelemetry traces:

```python
{
    "trace_id": "trace_abc123",
    "run_id": "uuid",
    "spans": [
        {
            "spanId": "span_001",
            "name": "Agent Execution",
            "startTime": "2025-11-18T14:23:01.000Z",
            "endTime": "2025-11-18T14:23:03.450Z",
            "attributes": {
                "agent.type": "tool",
                "gen_ai.system": "openai",
                "gen_ai.request.model": "gpt-4"
            }
        },
        # ... more spans ...
    ]
}
```

### 4. Metrics Dataset
GPU metrics and performance data:

```python
{
    "run_id": "uuid",
    "trace_id": "trace_abc123",
    "metrics": [
        {
            "name": "gen_ai.gpu.utilization",
            "value": 67.5,
            "unit": "%",
            "timestamp": "2025-11-18T14:23:01.000Z"
        },
        {
            "name": "gen_ai.co2.emissions",
            "value": 0.22,
            "unit": "gCO2e"
        }
    ]
}
```

</details>

---

## 🔧 Configuration Options

### Model Selection

```bash
# API Models (via LiteLLM)
--model openai/gpt-4
--model anthropic/claude-3-5-sonnet
--model google/gemini-pro

# Local Models (via Transformers)
--model meta-llama/Llama-3.1-8B
--model mistralai/Mistral-7B-v0.1
```

### Provider Selection

```bash
--provider litellm      # For API models
--provider transformers # For local models
```

### Hardware Selection

Hardware is selected in HuggingFace Jobs configuration (`hardware:` field in job.yaml), not via CLI flags.

SMOLTRACE automatically detects available resources:
- API models (via litellm) → Uses CPU
- Local models (via transformers) → Uses available GPU if present

### OpenTelemetry Options

```bash
--enable-otel              # Enable tracing
--enable-gpu-metrics       # Capture GPU data
--enable-carbon-tracking   # Track CO2 emissions
```

---

## 🏗️ Integration with HuggingFace Jobs

SMOLTRACE works seamlessly with HuggingFace Jobs for running evaluations on cloud infrastructure.

### ⚠️ Requirements to Submit Jobs

**IMPORTANT**: To submit jobs via TraceMind UI or HF CLI, you must:

1. **🔑 HuggingFace Pro Account**
   - You must be a HuggingFace Pro user
   - **Credit card required** to pay for compute usage
   - Sign up at: https://huggingface.co/pricing

2. **🎫 HuggingFace Token Permissions**
   - Your HF token needs **Read + Write** permissions
   - Token must have **"Run Jobs"** permission enabled
   - Create/update token at: https://huggingface.co/settings/tokens
   - ⚠️ Read-only tokens will **NOT** work for job submission

3. **💳 Billing**
   - You will be charged for compute usage
   - Pricing: https://huggingface.co/pricing#spaces-pricing
   - Monitor usage at: https://huggingface.co/settings/billing

### Example Job Configuration

```yaml
# job.yaml
name: SMOLTRACE Evaluation
hardware: gpu-a10  # Use gpu-h200 for 70B+ models
environment:
  MODEL: meta-llama/Llama-3.1-8B
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
command: |
  pip install smoltrace[otel,gpu]
  smoltrace-eval \\
    --model $MODEL \\
    --provider transformers \\
    --agent-type both \\
    --enable-otel \\
    --enable-gpu-metrics \\
    --results-repo ${{ username }}/agent-results \\
    --leaderboard-repo huggingface/smolagents-leaderboard
```

### Hardware Selection

- 🔧 **cpu-basic**: API models (OpenAI, Anthropic via LiteLLM) - ~$0.05/hr
- 🎮 **t4-small**: Small models (4B-8B) - ~$0.60/hr
- 🔧 **a10g-small**: Medium models (7B-13B) - ~$1.10/hr
- 🚀 **a100-large**: Large models (70B+) - ~$3.00/hr

**Pricing**: See https://huggingface.co/pricing#spaces-pricing

### Benefits

- 📊 **Automatic Upload**: Results → HuggingFace datasets
- 🔄 **Reproducible**: Same environment every time
- ⚡ **Optimized Compute**: Right hardware for your model size
- 💰 **Pay-per-use**: Only pay for actual compute time

---

## 📈 Integration with TraceMind-AI

SMOLTRACE datasets power the TraceMind-AI interface:

```
SMOLTRACE Evaluation

    4 Datasets Created

┌────────┴────────┐
│                 │
│  TraceMind-AI   │  ← You are here!
│  (Gradio UI)    │
│                 │
└─────────────────┘
```

**What TraceMind-AI Shows:**
- 📊 **Leaderboard**: All evaluation runs
- 🔍 **Run Detail**: Individual test cases
- 🕵️ **Trace Detail**: OpenTelemetry visualization
- 🤖 **Agent Chat**: MCP-powered analysis

---

## 🎯 Best Practices

### 1. Start Small
```bash
# Test with 10 runs first
smoltrace-eval --model gpt-4 --num-tests 10

# Scale up after validation
smoltrace-eval --model gpt-4 --num-tests 1000
```

### 2. Choose Appropriate Hardware in HF Jobs
Hardware selection happens in your HuggingFace Jobs configuration:

```yaml
# For API models (OpenAI, Anthropic, etc.)
hardware: cpu-basic

# For 7B-13B local models
hardware: gpu-a10

# For 70B+ local models
hardware: gpu-h200
```

### 3. Enable Full Observability
```bash
# Capture everything
smoltrace-eval \\
  --model your-model \\
  --enable-otel \\
  --enable-gpu-metrics \\
  --enable-carbon-tracking
```

### 4. Organize Your Datasets
```bash
# Use descriptive repo names
--results-repo username/results-gpt4-tool-20251118
--traces-repo username/traces-gpt4-tool-20251118
--leaderboard-repo username/agent-leaderboard
```

---

## 🔍 Cost Estimation

Before running evaluations, estimate costs:

```python
from smoltrace import estimate_cost

# API model
api_cost = estimate_cost(
    model="openai/gpt-4",
    num_tests=1000,
    agent_type="tool"
)
print(f"Estimated cost: ${api_cost.total_cost}")

# GPU job
gpu_cost = estimate_cost(
    model="meta-llama/Llama-3.1-8B",
    num_tests=1000,
    hardware="gpu_h200"
)
print(f"Estimated cost: ${gpu_cost.total_cost}")
print(f"Estimated time: {gpu_cost.duration_minutes} minutes")
```

---

## 📐 Architecture

```
┌─────────────────────────────────────────┐
│         SMOLTRACE Core                   │
├─────────────────────────────────────────┤
│                                          │
│  ┌──────────────┐   ┌──────────────┐   │
│  │   LiteLLM    │   │ Transformers │   │
│  │   Provider   │   │   Provider   │   │
│  └──────┬───────┘   └──────┬───────┘   │
│         │                   │            │
│         └────────┬──────────┘            │
│                  ↓                        │
│         ┌──────────────┐                 │
│         │  TraceVerde  │                 │
│         │     (OTEL)   │                 │
│         └──────┬───────┘                 │
│                ↓                          │
│         ┌──────────────┐                 │
│         │   Dataset    │                 │
│         │   Generator  │                 │
│         └──────┬───────┘                 │
│                ↓                          │
│    ┌───────────────────────┐            │
│    │  HuggingFace Upload   │            │
│    └───────────────────────┘            │
│                                          │
└─────────────────────────────────────────┘
```

---

## 🔗 Resources

- **GitHub**: [github.com/Mandark-droid/SMOLTRACE](https://github.com/Mandark-droid/SMOLTRACE)
- **PyPI**: [pypi.org/project/smoltrace](https://pypi.org/project/smoltrace/)
- **Documentation**: [SMOLTRACE README](https://github.com/Mandark-droid/SMOLTRACE#readme)

---

## 🐛 Troubleshooting

### Common Issues

**Q: Evaluation is slow?**
```bash
# Use GPU for local models
--hardware gpu_h200

# Or reduce test count
--num-tests 10
```

**Q: Traces not captured?**
```bash
# Make sure OTEL is enabled
--enable-otel
```

**Q: Upload to HF failing?**
```bash
# Check HF token
export HF_TOKEN=your_token_here

# Verify repo exists or allow auto-create
```

---

## 📄 License

**AGPL-3.0** - Open source and free to use

---

## 🤝 Contributing

We welcome contributions!
- Add new agent types
- Support more frameworks
- Improve evaluation metrics
- Optimize performance

---

*SMOLTRACE - Lightweight evaluation for heavyweight results* 📊
""")


def create_mcp_server_tab():
    """Create the TraceMind-MCP-Server documentation tab"""
    return gr.Markdown("""
# 🔌 TraceMind-MCP-Server

<div align="center">
  <img src="https://raw.githubusercontent.com/Mandark-droid/TraceMind-mcp-server/assets/Logo.png" alt="TraceMind MCP Server Logo" width="300"/>
</div>

<br/>

**Building MCP: Intelligent Analysis Tools for Agent Evaluation**

<div align="center" style="display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;">
  <a href="https://github.com/modelcontextprotocol"><img src="https://img.shields.io/badge/MCP%27s%201st%20Birthday-Hackathon-blue" alt="MCP's 1st Birthday Hackathon"></a>
  <a href="https://github.com/modelcontextprotocol/hackathon"><img src="https://img.shields.io/badge/Track-Building%20MCP%20(Enterprise)-blue" alt="Track 1"></a>
  <a href="https://huggingface.co/spaces/MCP-1st-Birthday/TraceMind-mcp-server"><img src="https://img.shields.io/badge/HuggingFace-TraceMind--MCP--Server-yellow?logo=huggingface" alt="HF Space"></a>
  <a href="https://ai.google.dev/"><img src="https://img.shields.io/badge/Powered%20by-Google%20Gemini%202.5%20Pro-orange" alt="Google Gemini"></a>
</div>

> **🎯 Track 1 Submission**: Building MCP (Enterprise)
> **📅 MCP's 1st Birthday Hackathon**: November 14-30, 2025

---

## 📖 Table of Contents

- [What is TraceMind-MCP-Server?](#what-is-tracemind-mcp-server)
- [MCP Tools Provided](#️-mcp-tools-provided)
  - [analyze_leaderboard](#1-analyze_leaderboard)
  - [estimate_cost](#2-estimate_cost)
  - [debug_trace](#3-debug_trace)
  - [compare_runs](#4-compare_runs)
  - [analyze_results](#5-analyze_results)
- [Accessing the MCP Server](#-accessing-the-mcp-server)
- [Use Cases](#-use-cases)
- [Architecture](#️-architecture)
- [Configuration](#-configuration)
- [Dataset Requirements](#-dataset-requirements)
- [Learning Resources](#-learning-resources)
- [Troubleshooting](#-troubleshooting)
- [Links](#-links)
- [License](#-license)
- [Contributing](#-contributing)
- [MCP's 1st Birthday Hackathon](#-mcps-1st-birthday-hackathon)

---

## What is TraceMind-MCP-Server?

TraceMind-MCP-Server is a **Track 1 (Building MCP)** submission that provides MCP tools for intelligent agent evaluation analysis.

**Key Features:**
- 🤖 Powered by Google Gemini 2.5 Pro
- 🔌 Standards-compliant MCP implementation
- 📊 Analyzes HuggingFace evaluation datasets
- 💡 Provides actionable insights and recommendations
- 🌐 Accessible via SSE transport for Gradio integration

---

<details>
<summary><h2>🛠️ MCP Tools Provided</h2></summary>

### 1. `analyze_leaderboard`

**Purpose**: Generate AI-powered insights about evaluation leaderboard data

**Input Schema:**
```json
{
  "leaderboard_repo": "string",     // HF dataset (default: kshitijthakkar/smoltrace-leaderboard)
  "metric_focus": "string",         // "overall" | "accuracy" | "cost" | "latency" | "co2"
  "time_range": "string",           // "last_week" | "last_month" | "all_time"
  "top_n": "integer"                // Number of top models to highlight
}
```

**What It Does:**
1. Fetches leaderboard dataset from HuggingFace
2. Filters by time range
3. Analyzes trends based on metric focus
4. Uses Gemini to generate insights
5. Returns markdown-formatted analysis

**Example Output:**
```markdown
Based on 247 evaluations in the past week:

**Top Performers:**
- GPT-4 leads in accuracy at 95.8% but costs $0.05 per run
- Llama-3.1-8B offers best cost/performance at 93.4% accuracy for $0.002
- Qwen3-MoE is fastest at 1.7s average duration

**Trends:**
- API models dominate accuracy rankings
- GPU models are 10x more cost-effective
- H200 jobs show 2x faster execution vs A10

**Recommendations:**
- For production: Consider Llama-3.1-8B for cost-sensitive workloads
- For maximum accuracy: GPT-4 remains state-of-the-art
- For eco-friendly: Claude-3-Haiku has lowest CO2 emissions
```

---

### 2. `estimate_cost`

**Purpose**: Estimate evaluation costs with hardware recommendations

**Input Schema:**
```json
{
  "model": "string",                // Model name (e.g., "openai/gpt-4")
  "agent_type": "string",           // "tool" | "code" | "both"
  "num_tests": "integer",           // Number of test cases (default: 100)
  "hardware": "string"              // "cpu" | "gpu_a10" | "gpu_h200" (optional)
}
```

**What It Does:**
1. Determines if model is API or local
2. Calculates token usage estimates
3. Computes costs (API pricing or GPU time)
4. Estimates duration and CO2 emissions
5. Provides hardware recommendations

**Example Output:**
```markdown
## Cost Estimation: openai/gpt-4 (Tool Agent, 100 tests)

**Hardware**: CPU (API model)

**Cost Breakdown:**
- Total Tokens: ~15,000
- Prompt Tokens: ~5,000 ($0.03)
- Completion Tokens: ~10,000 ($0.06)
- **Total Cost: $0.09**

**Time Estimate:**
- Average per test: 3.2s
- Total duration: ~5.3 minutes

**CO2 Emissions:**
- Estimated: 0.45g CO2e

**Recommendations:**
- ✅ Good choice for accuracy-critical applications
- ⚠️ Consider Llama-3.1-8B for cost savings (10x cheaper)
- 💡 Use caching to reduce repeated API calls
```

---

### 3. `debug_trace`

**Purpose**: Answer questions about agent execution traces

**Input Schema:**
```json
{
  "trace_dataset": "string",        // HF dataset with OTEL traces
  "trace_id": "string",             // Specific trace to analyze
  "question": "string",             // Question about the trace
  "include_metrics": "boolean"      // Include GPU metrics (default: true)
}
```

**What It Does:**
1. Fetches trace data from HuggingFace
2. Parses OpenTelemetry spans
3. Analyzes execution flow
4. Uses Gemini to answer questions
5. Provides span-level details

**Example Output:**
```markdown
## Why was the tool called twice?

Based on trace analysis for `trace_abc123`:

**First Tool Call (span_003)**:
- Time: 14:23:19.000
- Tool: `search_web`
- Input: {"query": "latest AI news"}
- Result: 5 results returned
- Issue: Results were 2 days old

**Second Tool Call (span_005)**:
- Time: 14:23:21.200
- Tool: `search_web`
- Input: {"query": "latest AI news today"}
- Reasoning: LLM determined first results were outdated
- Duration: 1200ms

**Why Twice?**
The agent's reasoning chain shows it initially received outdated results.
The LLM then decided to refine the query with "today" keyword to get
more recent data.

**Performance Impact:**
- Added 2.09s to total execution
- Cost increase: +$0.0003
- This is normal for agents with iterative reasoning

**Recommendation:**
Consider adding date filters to initial tool calls to avoid retries.
```

---

### 4. `compare_runs`

**Purpose**: Side-by-side comparison of evaluation runs

**Input Schema:**
```json
{
  "leaderboard_repo": "string",     // HF leaderboard dataset
  "run_id_1": "string",             // First run ID
  "run_id_2": "string",             // Second run ID
  "comparison_focus": "string"      // "overall" | "cost" | "accuracy" | "speed"
}
```

**What It Does:**
1. Fetches data for both runs
2. Compares key metrics
3. Identifies strengths/weaknesses
4. Provides recommendations

**Example Output:**
```markdown
## Comparison: GPT-4 vs Llama-3.1-8B

| Metric | GPT-4 | Llama-3.1-8B | Winner |
|--------|-------|--------------|--------|
| Success Rate | 95.8% | 93.4% | GPT-4 (+2.4%) |
| Avg Duration | 3.2s | 2.1s | Llama (+34% faster) |
| Cost per Run | $0.05 | $0.002 | Llama (25x cheaper) |
| CO2 Emissions | 0.22g | 0.08g | Llama (64% less) |

**Analysis:**
- GPT-4 has slight accuracy edge but at significant cost premium
- Llama-3.1-8B offers excellent cost/performance ratio
- For 1000 runs: GPT-4 costs $50, Llama costs $2

**Recommendation:**
Use Llama-3.1-8B for production unless 95%+ accuracy is critical.
Consider hybrid approach: Llama for routine tasks, GPT-4 for complex ones.
```

---

### 5. `analyze_results`

**Purpose**: Deep dive into test case results

**Input Schema:**
```json
{
  "results_repo": "string",         // HF results dataset
  "run_id": "string",               // Run to analyze
  "focus": "string"                 // "failures" | "successes" | "all"
}
```

**What It Does:**
1. Loads results dataset
2. Filters by success/failure
3. Identifies patterns
4. Suggests optimizations

</details>

---

## 🌐 Accessing the MCP Server

### Via TraceMind-AI (This App!)

The **Agent Chat** screen uses TraceMind-MCP-Server automatically:

```python
# Happens automatically in the Chat screen
from mcp_client.sync_wrapper import get_sync_mcp_client

mcp = get_sync_mcp_client()
insights = mcp.analyze_leaderboard(
    metric_focus="overall",
    time_range="last_week"
)
```

### Via SSE Endpoint (for smolagents)

```python
from smolagents import MCPClient, ToolCallingAgent

# Connect to MCP server via SSE
mcp_client = MCPClient(
    "https://mcp-1st-birthday-tracemind-mcp-server.hf.space/gradio_api/mcp/sse"
)

# Create agent with MCP tools
agent = ToolCallingAgent(
    tools=[],
    model="hfapi",
    additional_authorized_imports=["requests", "pandas"]
)

# Tools automatically available!
agent.run("Analyze the leaderboard and show top 3 models")
```

### Via MCP SDK (for other clients)

```python
from mcp import ClientSession, StdioServerParameters

# For local development
session = ClientSession(
    StdioServerParameters(
        command="python",
        args=["-m", "mcp_tools"]
    )
)

# Call tools
result = await session.call_tool(
    "analyze_leaderboard",
    arguments={"metric_focus": "cost"}
)
```

---

## 🎯 Use Cases

### 1. Interactive Analysis (Agent Chat)
Ask natural language questions:
- "What are the top 3 models by accuracy?"
- "Compare GPT-4 and Claude-3 on cost"
- "Why is this agent slow?"

### 2. Automated Insights (Leaderboard)
Get AI summaries automatically:
- Weekly trend reports
- Cost optimization recommendations
- Performance alerts

### 3. Debugging (Trace Detail)
Understand agent behavior:
- "Why did the agent fail?"
- "Which tool took the longest?"
- "Why was the same tool called twice?"

### 4. Planning (Cost Estimator)
Before running evaluations:
- "How much will 1000 tests cost?"
- "Should I use A10 or H200?"
- "What's the CO2 impact?"

---

## 🏗️ Architecture

```
┌─────────────────────────────────────────────────────┐
│         TraceMind-MCP-Server (HF Space)              │
├─────────────────────────────────────────────────────┤
│                                                       │
│  ┌─────────────────┐        ┌──────────────────┐   │
│  │   Gradio App    │        │   MCP Protocol   │   │
│  │   (UI + SSE)    │◄──────►│   Handler        │   │
│  └─────────────────┘        └────────┬─────────┘   │
│                                       │              │
│                              ┌────────▼─────────┐   │
│                              │   Tool Router    │   │
│                              └────────┬─────────┘   │
│                                       │              │
│         ┌─────────────────────────────┼──────────┐  │
│         │                             │          │  │
│  ┌──────▼──────┐   ┌─────────▼───────▼──┐   ┌──▼──▼──┐
│  │ Leaderboard │   │  Cost Estimator   │   │ Trace  │
│  │  Analyzer   │   │                   │   │Debugger│
│  └─────────────┘   └───────────────────┘   └────────┘
│         │                     │                  │    │
│         └─────────────────────┴──────────────────┘    │
│                             │                          │
│                   ┌─────────▼──────────┐              │
│                   │  Gemini 2.5 Pro    │              │
│                   │  (Analysis Engine)  │              │
│                   └────────────────────┘              │
│                                                        │
└────────────────────────────────────────────────────────┘

                          │ MCP Protocol (SSE)


            ┌──────────────────────────┐
            │   TraceMind-AI (UI)      │
            │   Agent Chat Screen      │
            └──────────────────────────┘
```

---

## 🔧 Configuration

### Environment Variables

```env
# Google Gemini API (required)
GEMINI_API_KEY=your_api_key_here

# HuggingFace Token (for dataset access)
HF_TOKEN=your_token_here

# Default Leaderboard (optional)
DEFAULT_LEADERBOARD_REPO=kshitijthakkar/smoltrace-leaderboard
```

---

## 📊 Dataset Requirements

MCP tools expect datasets with specific schemas:

### Leaderboard Dataset
```python
{
    "run_id": "string",
    "model": "string",
    "success_rate": "float",
    "total_cost_usd": "float",
    "timestamp": "string",
    # ... other metrics
}
```

### Results Dataset
```python
{
    "run_id": "string",
    "task_id": "string",
    "success": "boolean",
    "trace_id": "string",
    # ... other fields
}
```

### Traces Dataset
```python
{
    "trace_id": "string",
    "spans": [
        {
            "spanId": "string",
            "name": "string",
            "attributes": {},
            # ... OTEL format
        }
    ]
}
```

---

## 🎓 Learning Resources

### MCP Documentation
- [Model Context Protocol Spec](https://modelcontextprotocol.io)
- [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)
- [Gradio MCP Integration](https://www.gradio.app/guides/creating-a-custom-chatbot-with-blocks#model-context-protocol-mcp)

### Implementation Examples
- **This Server**: [HF Space Code](https://huggingface.co/spaces/MCP-1st-Birthday/TraceMind-mcp-server/tree/main)
- **Client Integration**: [TraceMind-AI mcp_client/](https://github.com/Mandark-droid/TraceMind-AI/tree/main/mcp_client)

---

## 🐛 Troubleshooting

### Common Issues

**Q: MCP tools not appearing?**
```bash
# Verify MCP_SERVER_URL is correct
echo $MCP_SERVER_URL

# Should be: https://mcp-1st-birthday-tracemind-mcp-server.hf.space/gradio_api/mcp/sse
```

**Q: "Failed to load dataset" error?**
```bash
# Check HF token
export HF_TOKEN=your_token_here

# Verify dataset exists
huggingface-cli repo info kshitijthakkar/smoltrace-leaderboard
```

**Q: Gemini API errors?**
```bash
# Verify API key
curl -H "Authorization: Bearer $GEMINI_API_KEY" \\
  https://generativelanguage.googleapis.com/v1beta/models

# Check rate limits (10 requests/minute on free tier)
```

---

## 🔗 Links

- **Live Server**: [HF Space](https://huggingface.co/spaces/MCP-1st-Birthday/TraceMind-mcp-server)
- **Source Code**: [GitHub](https://github.com/Mandark-droid/TraceMind-mcp-server)
- **Client (This App)**: [TraceMind-AI](https://huggingface.co/spaces/MCP-1st-Birthday/TraceMind)
- **MCP Spec**: [modelcontextprotocol.io](https://modelcontextprotocol.io)

---

## 🎬 Demo Videos

| Video | Duration | Description |
|-------|----------|-------------|
| **TraceMind-AI Full Demo** | 20 mins | [Watch on Loom](https://www.loom.com/share/70b9689b57204da58b8fef0d23c304fe) - Complete walkthrough of TraceMind-AI features and workflows |
| **MCP Server Quick Demo** | 5 mins | [Watch on Loom](https://www.loom.com/share/d4d0003f06fa4327b46ba5c081bdf835) - Quick overview of TraceMind-MCP-Server features |
| **MCP Server Full Demo** | 20 mins | [Watch on Loom](https://www.loom.com/share/de559bb0aef749559c79117b7f951250) - Comprehensive walkthrough with detailed explanations |

---

## 📄 License

**AGPL-3.0** - Open source and free to use

---

## 🤝 Contributing

Help improve TraceMind-MCP-Server:
- Add new MCP tools
- Improve analysis quality
- Optimize performance
- Add support for more datasets

---

## 🏆 MCP's 1st Birthday Hackathon

**Track 1 Submission: Building MCP (Enterprise)**

TraceMind-MCP-Server demonstrates:
- ✅ Standards-compliant MCP implementation
- ✅ SSE transport for Gradio integration
- ✅ Real-world use case (agent evaluation)
- ✅ Gemini 2.5 Flash integration
- ✅ Production-ready deployment on HF Spaces

**Used by**: TraceMind-AI (Track 2) for autonomous agent chat

---

*TraceMind-MCP-Server - Intelligent analysis, one tool at a time* 🔌
""")


def create_job_submission_tab():
    """Create the Job Submission tab with full details about Modal and HF Jobs"""
    return gr.Markdown("""
# ☁️ Job Submission

**Run SMOLTRACE Evaluations on Cloud Infrastructure**

TraceMind-AI provides seamless integration with two cloud compute platforms, allowing you to run agent evaluations with automated hardware selection, cost estimation, and real-time monitoring.

---

## 📋 Table of Contents

- [Platform Overview](#-platform-overview)
- [HuggingFace Jobs Integration](#-huggingface-jobs-integration)
- [Modal Integration](#-modal-integration)
- [Hardware Auto-Selection](#-hardware-auto-selection)
- [Cost Estimation](#-cost-estimation)
- [Job Monitoring](#-job-monitoring)
- [Step-by-Step Guide](#-step-by-step-guide)
- [Troubleshooting](#-troubleshooting)

---

## 🌟 Platform Overview

### Supported Platforms

| Platform | Best For | Pricing Model | GPU Options | Free Tier |
|----------|----------|---------------|-------------|-----------|
| **HuggingFace Jobs** | Managed infrastructure, dataset integration | Per-second | T4, L4, A10, A100, V5e | ❌ ($9/mo Pro required) |
| **Modal** | Serverless compute, pay-per-second | Per-second | T4, L4, A10, A100-80GB, H100, H200, B200 | ✅ Free credits available |

### Key Differences

**HuggingFace Jobs**:
- ✅ Native HuggingFace ecosystem integration
- ✅ Managed infrastructure with guaranteed availability
- ✅ Built-in dataset storage and versioning
- ✅ Per-second billing (no minimums)
- ⚠️ Requires Pro account ($9/month)
- ⚠️ Limited GPU options (no H100/H200)

**Modal**:
- ✅ Serverless architecture (no minimum charges)
- ✅ Pay-per-second billing
- ✅ Latest GPUs (H100, H200, B200 available)
- ✅ Free tier with credits
- ⚠️ Requires separate account setup
- ⚠️ Container cold start time (~2-3 minutes first run)

---

## 🤗 HuggingFace Jobs Integration

### Requirements

**1. HuggingFace Pro Account**
- Cost: $9/month
- Sign up: https://huggingface.co/pricing
- Includes compute credits and priority support

**2. HuggingFace Token with Run Jobs Permission**
```
Steps to create token:
1. Visit: https://huggingface.co/settings/tokens
2. Click "New token"
3. Name: "TraceMind Evaluation"
4. Permissions:
   ✅ Read (view datasets)
   ✅ Write (upload results)
   ✅ Run Jobs (submit evaluation jobs) ⚠️ REQUIRED
5. Copy token (starts with hf_)
6. Save in TraceMind Settings
```

### Hardware Options

| Hardware | vCPUs | GPU | Memory | Best For | Price/hr | Per-second |
|----------|-------|-----|--------|----------|----------|------------|
| `cpu-basic` | 2 | - | 16 GB | API models (OpenAI, Anthropic) | Free with Pro | - |
| `cpu-upgrade` | 8 | - | 32 GB | API models (high volume) | Free with Pro | - |
| `t4-small` | 4 | T4 (16GB) | 15 GB | Small models (4B-8B) | $0.40 | $0.000111 |
| `t4-medium` | 8 | T4 (16GB) | 30 GB | Small models (batched) | $0.60 | $0.000167 |
| `l4x1` | 8 | L4 (24GB) | 30 GB | Small-medium models | $0.80 | $0.000222 |
| `a10g-small` | 4 | A10G (24GB) | 32 GB | Medium models (7B-13B) | $1.00 | $0.000278 |
| `a10g-large` | 12 | A10G (24GB) | 92 GB | Medium models (high memory) | $1.50 | $0.000417 |
| `a100-large` | 12 | A100 (80GB) | 142 GB | Large models (70B+) | $2.50 | $0.000694 |
| `v5e-1x1` | 4 | TPU v5e | 16 GB | TPU-optimized workloads | TBD | TBD |

*Pricing from [HF Spaces GPU docs](https://huggingface.co/docs/hub/en/spaces-gpus). Billed **per-second** with no minimums.*

### Auto-Selection Logic

When you select `hardware: auto`, TraceMind applies this logic:

```python
# API models (LiteLLM/Inference)
if provider in ["litellm", "inference"]:
    hardware = "cpu-basic"

# Local models (Transformers)
elif "70b" in model.lower() or "65b" in model.lower():
    hardware = "a100-large"  # Large models
elif "13b" in model.lower() or "34b" in model.lower():
    hardware = "a10g-large"  # Medium models
elif "7b" in model.lower() or "8b" in model.lower() or "4b" in model.lower():
    hardware = "t4-small"  # Small models
else:
    hardware = "t4-small"  # Default
```

### Job Workflow

```
1. Configure Settings
   └─> Add HF Token (with Run Jobs permission)
   └─> Add LLM provider API keys

2. Create Evaluation
   └─> Select "HuggingFace Jobs" as infrastructure
   └─> Choose model and configuration
   └─> Hardware auto-selected or manually chosen

3. Submit Job
   └─> TraceMind validates credentials
   └─> Submits job via HF Jobs API
   └─> Returns job ID for monitoring

4. Job Execution
   └─> Container built with dependencies
   └─> SMOLTRACE runs evaluation
   └─> Results uploaded to HF datasets
   └─> Leaderboard updated automatically

5. Monitor Progress
   └─> Track at: https://huggingface.co/jobs
   └─> Or use Job Monitoring tab in TraceMind
```

---

## ⚡ Modal Integration

### Requirements

**1. Modal Account**
- Free tier: $30 free credits per month
- Sign up: https://modal.com

**2. Modal API Credentials**
```
Steps to get credentials:
1. Visit: https://modal.com/settings/tokens
2. Click "Create token"
3. Copy:
   - Token ID (starts with ak-)
   - Token Secret (starts with as-)
4. Save in TraceMind Settings:
   - MODAL_TOKEN_ID: ak-xxxxx
   - MODAL_TOKEN_SECRET: as-xxxxx
```

### Hardware Options

| Hardware | GPU | Memory | Best For | Price/sec | Equivalent $/hr |
|----------|-----|--------|----------|-----------|-----------------|
| `CPU` | - | 16 GB | API models | $0.0000131/core | ~$0.05 |
| `T4` | T4 (16GB) | 16 GB | Small models (4B-8B) | $0.000164 | ~$0.59 |
| `L4` | L4 (24GB) | 24 GB | Small-medium models | $0.000222 | ~$0.80 |
| `A10G` | A10G (24GB) | 32 GB | Medium models (7B-13B) | $0.000306 | ~$1.10 |
| `L40S` | L40S (48GB) | 48 GB | Large models (optimized) | $0.000542 | ~$1.95 |
| `A100` | A100 (40GB) | 64 GB | Large models | $0.000583 | ~$2.10 |
| `A100-80GB` | A100 (80GB) | 128 GB | Very large models (70B+) | $0.000694 | ~$2.50 |
| `H100` | H100 (80GB) | 192 GB | Latest generation inference | $0.001097 | ~$3.95 |
| `H200` | H200 (141GB) | 256 GB | Cutting-edge, highest memory | $0.001261 | ~$4.54 |
| `B200` | B200 (192GB) | 384 GB | Next-gen, massive memory | $0.001736 | ~$6.25 |

Full pricing: https://modal.com/pricing

**💡 Both platforms use per-second billing!** Choose Modal for H100/H200/B200 GPUs or if you don't have HF Pro.

### Auto-Selection Logic

When you select `hardware: auto`, TraceMind applies this logic:

```python
# API models
if provider in ["litellm", "inference"]:
    gpu = None  # CPU only

# Local models (Transformers)
elif "70b" in model.lower() or "65b" in model.lower():
    gpu = "A100-80GB"  # Large models need 80GB
elif "13b" in model.lower() or "34b" in model.lower():
    gpu = "A10G"  # Medium models
elif "7b" in model.lower() or "8b" in model.lower():
    gpu = "A10G"  # Small models efficient on A10G
else:
    gpu = "A10G"  # Default
```

### Modal-Specific Features

**Dynamic Python Version Matching**
```python
# Automatically matches your environment
python_version = f"{sys.version_info.major}.{sys.version_info.minor}"
# Example: "3.10" on HF Space, "3.12" locally
```

**Optimized Docker Images**
```python
# GPU jobs: CUDA-optimized base
image = "nvidia/cuda:12.6.0-cudnn-devel-ubuntu22.04"

# CPU jobs: Lightweight
image = "debian-slim"
```

**Smart Package Installation**
```python
# GPU jobs get full stack
packages = [
    "smoltrace",
    "transformers",
    "torch",
    "accelerate",  # For device_map
    "bitsandbytes",  # For quantization
    "hf_transfer",  # Fast downloads
    "nvidia-ml-py"  # GPU metrics
]

# CPU jobs get minimal dependencies
packages = ["smoltrace", "litellm", "ddgs"]
```

### Job Workflow

```
1. Configure Settings
   └─> Add Modal Token ID + Secret
   └─> Add HF Token (for dataset upload)
   └─> Add LLM provider API keys

2. Create Evaluation
   └─> Select "Modal" as infrastructure
   └─> Choose model and configuration
   └─> Hardware auto-selected

3. Submit Job
   └─> TraceMind creates dynamic Modal app
   └─> Submits job in background thread
   └─> Returns Modal Call ID

4. Job Execution
   └─> Image builds (or uses cache)
   └─> Model downloads to Modal storage
   └─> SMOLTRACE runs evaluation
   └─> Results uploaded to HF datasets

5. Monitor Progress
   └─> Track at: https://modal.com/apps
   └─> View real-time streaming logs
```

---

## 🎯 Hardware Auto-Selection

### How It Works

TraceMind **automatically selects optimal hardware** based on:
1. **Provider type**: LiteLLM/Inference (API) vs Transformers (local)
2. **Model size**: Extracted from model name (e.g., "70b", "13b", "8b")
3. **Platform**: Modal or HuggingFace Jobs

### Selection Matrix

| Model Type | Model Size | HF Jobs | Modal |
|------------|------------|---------|-------|
| API (OpenAI, Anthropic) | Any | `cpu-basic` | `CPU` |
| Transformers | 4B-8B | `t4-small` | `A10G` |
| Transformers | 13B-34B | `a10g-large` | `A10G` |
| Transformers | 70B+ | `a100-large` | `A100-80GB` |

### Override Auto-Selection

You can manually select hardware if needed:

```
Reasons to override:
- You know your model needs more memory
- You want to test performance on different GPUs
- You want to optimize cost vs speed tradeoff
```

### Cost Estimation Shows Auto-Selection

When you click **"💰 Estimate Cost"** with `auto` hardware:

**Modal Example**:
```
Hardware: auto → **A100-80GB** (Modal)
Estimated Cost: $0.45
Duration: 15 minutes
```

**HF Jobs Example**:
```
Hardware: auto → **a100-large** (HF Jobs)
Estimated Cost: $0.75
Duration: 15 minutes
```

---

## 💰 Cost Estimation

### How Cost Estimation Works

TraceMind provides **AI-powered cost estimation** before you submit jobs:

**Data Sources**:
1. **Historical Data** (preferred): Analyzes past runs from leaderboard
2. **MCP Server** (fallback): Uses `estimate_cost` MCP tool with Gemini 2.5 Flash

### Estimation Process

```
1. User clicks "💰 Estimate Cost"

2. TraceMind checks for historical data
   └─> If found: Use average cost/duration from past runs
   └─> If not found: Call MCP Server for AI analysis

3. Auto-selection applied
   └─> Determines actual hardware that will be used
   └─> Maps to pricing table

4. Display estimate
   └─> Cost breakdown
   └─> Duration estimate
   └─> Hardware details
```

### Cost Estimate Components

**Historical Data Estimate**:
```markdown
## 💰 Cost Estimate

**📊 Historical Data (5 past runs)**

| Metric | Value |
|--------|-------|
| Model | meta-llama/Llama-3.1-70B |
| Hardware | auto → **A100-80GB** (Modal) |
| Estimated Cost | $0.45 |
| Duration | 15.2 minutes |

---

*Based on 5 previous evaluation runs in the leaderboard.*
```

**MCP AI Estimate**:
```markdown
## 💰 Cost Estimate - AI Analysis

**🤖 Powered by MCP Server + Gemini 2.5 Flash**

*This estimate was generated by AI analysis since no historical
data is available for this model.*

**Hardware**: auto → **A100-80GB** (Modal)

---

Based on the model size (70B parameters) and evaluation
configuration, I estimate:

**Cost Breakdown**:
- Model download: ~5 minutes @ $0.0030/sec = $0.90
- Evaluation (100 tests): ~10 minutes @ $0.0030/sec = $1.80
- **Total estimated cost**: $2.70

**Duration**: 15-20 minutes

**Recommendations**:
- For cost savings, consider using A10G with quantization
- For faster inference, H200 reduces duration to ~8 minutes
```

### Accuracy of Estimates

**Historical estimates**: ±10% accuracy
- Based on actual past runs
- Accounts for model-specific behavior

**MCP AI estimates**: ±30% accuracy
- Uses model knowledge and heuristics
- Conservative (tends to overestimate)

**Factors affecting accuracy**:
- Model download time varies (network speed, caching)
- Evaluation complexity depends on dataset
- GPU availability can affect queue time

---

## 🔍 Job Monitoring

### HuggingFace Jobs Monitoring

**Built-in Tab**: Go to **"🔍 Job Monitoring"** in TraceMind

**Features**:
```
📋 Inspect Job
  └─> Enter HF Job ID
  └─> View status, hardware, timestamps
  └─> See next steps based on status

📜 Job Logs
  └─> Load execution logs
  └─> Auto-refresh option
  └─> Search and filter

📑 Recent Jobs
  └─> List your recent jobs
  └─> Quick status overview
  └─> Click to inspect
```

**Job Statuses**:
- ⏳ **QUEUED**: Waiting to start
- 🔄 **STARTING**: Initializing (1-2 min)
- ▶️ **RUNNING**: Executing evaluation
- ✅ **SUCCEEDED**: Completed successfully
- ❌ **FAILED**: Error occurred (check logs)
- 🚫 **CANCELLED**: Manually stopped

**External Monitoring**:
- HF Dashboard: https://huggingface.co/jobs
- CLI: `hf jobs ps` and `hf jobs logs <job_id>`

### Modal Monitoring

**Modal Dashboard**: https://modal.com/apps

**Features**:
- Real-time streaming logs
- GPU utilization graphs
- Cost tracking
- Container status

**Log Visibility**:
TraceMind uses streaming output for Modal jobs:
```python
# You'll see in real-time:
================================================================================
Starting SMOLTRACE evaluation on Modal
Command: smoltrace-eval --model Qwen/Qwen3-8B ...
Python version: 3.10.0
GPU: NVIDIA A10
GPU Memory: 23.68 GB
================================================================================

Note: Model download may take several minutes for large models (14B = ~28GB)
Downloading and initializing model...

[Download progress bars appear here]
[Evaluation progress appears here]

================================================================================
EVALUATION COMPLETED
Return code: 0
================================================================================
```

### Expected Duration

**CPU Jobs (API Models)**:
- Queue time: <1 minute
- Execution: 2-5 minutes
- **Total**: ~5 minutes

**GPU Jobs (Local Models)**:
- Queue time: 1-3 minutes
- Image build: 2-5 minutes (first run, then cached)
- Model download: 5-15 minutes (14B = ~10 min, 70B = ~15 min)
- Evaluation: 3-10 minutes (depends on dataset size)
- **Total**: 15-30 minutes

**Pro Tip**: Modal caches images and models, so subsequent runs are **much faster** (skip image build and model download).

---

## 📝 Step-by-Step Guide

### Complete Workflow Example

**Scenario**: Evaluate GPT-4 via LiteLLM on HuggingFace Jobs

#### Step 1: Configure API Keys

```
1. Go to "⚙️ Settings" tab
2. Under "HuggingFace Configuration":
   - HF Token: [your token with Run Jobs permission]
   - Click "Save API Keys"
3. Under "LLM Provider API Keys":
   - OpenAI API Key: [your key]
   - Click "Save API Keys"
```

#### Step 2: Navigate to New Evaluation

```
1. Click "🚀 New Evaluation" in sidebar
2. You'll see the evaluation form with multiple sections
```

#### Step 3: Configure Evaluation

**Infrastructure**:
```
Infrastructure Provider: HuggingFace Jobs
Hardware: auto (will select cpu-basic)
```

**Model Configuration**:
```
Model: openai/gpt-4
Provider: litellm
```

**Agent Configuration**:
```
Agent Type: both (tool + code)
Search Provider: duckduckgo
Tools: python_interpreter, visit_webpage, duckduckgo_search
```

**Test Configuration**:
```
Dataset: kshitijthakkar/smoltrace-tasks
Split: train
Difficulty: all
Parallel Workers: 1
```

**Output & Monitoring**:
```
Output Format: hub (HuggingFace datasets)
Enable OTEL: ✅
Enable GPU Metrics: ✅ (N/A for CPU)
Timeout: 1h
```

#### Step 4: Estimate Cost

```
1. Click "💰 Estimate Cost"
2. Review estimate:
   - Hardware: auto → **cpu-basic** (HF Jobs)
   - Cost: ~$0.08
   - Duration: ~3 minutes
```

#### Step 5: Submit Job

```
1. Click "Submit Evaluation"
2. Confirmation appears:
   ✅ Job submitted successfully!

   Job Details:
   - Run ID: job_abc12345
   - HF Job ID: kshitijthakkar/def67890
   - Hardware: cpu-basic
   - Platform: HuggingFace Jobs
```

#### Step 6: Monitor Job

**Option A: TraceMind Job Monitoring**
```
1. Go to "🔍 Job Monitoring" tab
2. Click "📋 Inspect Job"
3. Paste HF Job ID: kshitijthakkar/def67890
4. Click "🔍 Inspect Job"
5. View status and click "📥 Load Logs"
```

**Option B: HuggingFace Dashboard**
```
1. Visit: https://huggingface.co/jobs
2. Find your job by ID or timestamp
3. View logs and status
```

#### Step 7: View Results

```
When job completes (SUCCEEDED):
1. Go to "📊 Leaderboard" tab
2. Click "Load Leaderboard"
3. Find your run (job_abc12345)
4. Click row to view detailed results
```

---

## 🔧 Troubleshooting

### Common Issues & Solutions

#### 1. "Modal package not installed"

**Error**:
```
Modal package not installed. Install with: pip install modal
```

**Solution**:
```bash
pip install modal>=0.64.0
```

#### 2. "HuggingFace token not configured"

**Error**:
```
HuggingFace token not configured. Please set HF_TOKEN in Settings.
```

**Solution**:
1. Get token from: https://huggingface.co/settings/tokens
2. Add in Settings → HuggingFace Configuration
3. Ensure permissions include **Read**, **Write**, and **Run Jobs**

#### 3. "Modal authentication failed"

**Error**:
```
Modal authentication failed. Please verify your MODAL_TOKEN_ID
and MODAL_TOKEN_SECRET in Settings.
```

**Solution**:
1. Get credentials from: https://modal.com/settings/tokens
2. Add both:
   - MODAL_TOKEN_ID (starts with `ak-`)
   - MODAL_TOKEN_SECRET (starts with `as-`)
3. Save and retry

#### 4. "Job failed - Python version mismatch"

**Error** (in Modal logs):
```
The 'submit_modal_job.<locals>.run_evaluation' Function
was defined with Python 3.12, but its Image has 3.10.
```

**Solution**:
This is automatically fixed in the latest version! TraceMind now dynamically matches Python versions.

If still occurring:
1. Pull latest code: `git pull origin main`
2. Restart app

#### 5. "Fast download using 'hf_transfer' is enabled but package not available"

**Error** (in Modal logs):
```
ValueError: Fast download using 'hf_transfer' is enabled but
'hf_transfer' package is not available.
```

**Solution**:
This is automatically fixed in the latest version! TraceMind now includes `hf_transfer` in GPU job packages.

If still occurring:
1. Pull latest code
2. Modal will rebuild image with new dependencies

#### 6. "Job stuck at 'Downloading model'"

**Symptoms**:
- Logs show "Downloading and initializing model..."
- No progress for 10+ minutes

**Explanation**:
- Large models (14B+) take 10-15 minutes to download
- This is normal! Model size: 28GB for 14B, 140GB for 70B

**Solution**:
- Be patient - download is in progress (Modal's network is fast)
- Future runs will be cached and start instantly
- Check Modal dashboard for download progress

#### 7. "Job completed but no results in leaderboard"

**Symptoms**:
- Job status shows SUCCEEDED
- No entry in leaderboard

**Possible Causes**:
1. Results uploaded to different user's namespace
2. Leaderboard not refreshed
3. Job failed during result upload

**Solution**:
```
1. Refresh leaderboard: Click "Load Leaderboard"
2. Check HF dataset repos:
   - kshitijthakkar/smoltrace-leaderboard
   - kshitijthakkar/smoltrace-results-<timestamp>
3. Verify HF token has Write permission
4. Check job logs for upload errors
```

#### 8. "Cannot submit job - HuggingFace Pro required"

**Error**:
```
HuggingFace Pro Account ($9/month) required to submit jobs.
Free accounts cannot submit jobs.
```

**Solution**:
- Option A: Upgrade to HF Pro: https://huggingface.co/pricing
- Option B: Use Modal instead (has free tier with credits)

#### 9. "Modal job exits after image build"

**Symptoms**:
- Logs show: "Stopping app - local entrypoint completed"
- Job ends without running evaluation

**Solution**:
This was a known issue (fixed in latest version). The problem was using `.spawn()` with `with app.run()` context.

Current implementation uses `.remote()` in background thread, which ensures job completes.

If still occurring:
1. Pull latest code: `git pull origin main`
2. Restart app
3. Resubmit job

#### 10. "Cost estimate shows wrong hardware"

**Symptoms**:
- Selected Modal with 70B model
- Cost estimate shows "a10g-small" instead of "A100-80GB"

**Solution**:
This was a known issue (fixed in latest version). Cost estimation now applies platform-specific auto-selection logic.

Verify fix:
1. Pull latest code
2. Click "💰 Estimate Cost"
3. Should show: `auto → **A100-80GB** (Modal)`

---

## 📞 Getting Help

### Resources

**Documentation**:
- TraceMind Docs: This tab!
- SMOLTRACE Docs: [GitHub](https://github.com/Mandark-droid/SMOLTRACE)
- Modal Docs: https://modal.com/docs
- HF Jobs Docs: https://huggingface.co/docs/hub/spaces-sdks-docker

**Community**:
- GitHub Issues: [TraceMind-AI Issues](https://github.com/Mandark-droid/TraceMind-AI/issues)
- LinkedIn: [@kshitij-thakkar](https://www.linkedin.com/in/kshitij-thakkar-2061b924)

**Support**:
- For TraceMind bugs: Open GitHub issue
- For Modal issues: https://modal.com/docs/support
- For HF Jobs issues: /static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2F%3C%2Fspan%3E

---

*TraceMind-AI - Multi-cloud agent evaluation made simple* ☁️
""")


def create_documentation_screen():
    """
    Create the complete documentation screen with tabs

    Returns:
        gr.Column: Gradio Column component for documentation (can be shown/hidden)
    """
    with gr.Column(visible=False) as documentation_interface:
        gr.Markdown("""
        # 📚 TraceMind Documentation

        Comprehensive documentation for the entire TraceMind ecosystem
        """)

        with gr.Tabs():
            with gr.Tab("📖 About"):
                create_about_tab()

            with gr.Tab("🔭 TraceVerde"):
                create_traceverde_tab()

            with gr.Tab("📊 SmolTrace"):
                create_smoltrace_tab()

            with gr.Tab("🔌 TraceMind-MCP-Server"):
                create_mcp_server_tab()

            with gr.Tab("☁️ Job Submission"):
                create_job_submission_tab()

        gr.Markdown("""
        ---

        ### 💡 Quick Navigation

        - **Getting Started**: Start with the "About" tab for ecosystem overview
        - **Instrumentation**: See "TraceVerde" for adding observability to your agents
        - **Evaluation**: Check "SmolTrace" for running evaluations
        - **MCP Integration**: Explore "TraceMind-MCP-Server" for intelligent analysis

        ### 🔗 External Resources

        - [GitHub Organization](https://github.com/Mandark-droid)
        - [HuggingFace Spaces](https://huggingface.co/MCP-1st-Birthday)
        - [MCP Specification](https://modelcontextprotocol.io)

        *Built with ❤️ for MCP's 1st Birthday Hackathon*
        """)

    return documentation_interface


if __name__ == "__main__":
    # For standalone testing
    with gr.Blocks() as demo:
        doc_screen = create_documentation_screen()
        # Make it visible for standalone testing
        doc_screen.visible = True
    demo.launch()