File size: 53,898 Bytes
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
 
 
 
 
abb32f1
 
a85f4e8
 
 
 
 
 
0f82736
 
 
 
abb32f1
 
 
 
0f82736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb32f1
8b1b1c7
 
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
0f82736
 
abb32f1
 
 
0f82736
abb32f1
 
0f82736
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b1b1c7
 
abb32f1
 
 
 
 
 
 
8b1b1c7
 
 
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
 
 
 
 
a85f4e8
 
 
 
 
 
 
0f82736
a85f4e8
 
 
 
 
0f82736
a85f4e8
 
 
 
 
0f82736
abb32f1
 
0f82736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
0f82736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
0f82736
abb32f1
 
0f82736
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
abb32f1
0f82736
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
555014b
 
 
 
 
 
abb32f1
 
a85f4e8
 
 
 
 
 
 
555014b
a85f4e8
 
 
 
 
 
0f82736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7e3ac1d
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
4449927
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb32f1
 
 
 
7e3ac1d
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4449927
 
 
 
 
 
 
 
 
 
7e3ac1d
abb32f1
 
7e3ac1d
4449927
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7e3ac1d
 
 
 
 
 
abb32f1
7e3ac1d
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
 
 
 
 
abb32f1
 
a85f4e8
 
 
 
 
 
0f82736
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0f82736
 
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d6d337
abb32f1
2d6d337
abb32f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d6d337
 
 
 
abb32f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
"""
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, LangChain, CrewAI, 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) |

### ๐Ÿ“ข Community Posts

- ๐ŸŽ‰ [**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

---

*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>

---

## ๐ŸŽฏ Supported Frameworks

TraceVerde automatically instruments:

| Framework | Status | Import Required |
|-----------|--------|-----------------|
| **LiteLLM** | โœ… Full Support | `from litellm import completion` |
| **Transformers** | โœ… Full Support | `from transformers import pipeline` |
| **LangChain** | โœ… Full Support | `from langchain import ...` |
| **CrewAI** | โœ… Full Support | `from crewai import Agent` |
| **smolagents** | โœ… Full Support | `from smolagents import ...` |
| **OpenAI SDK** | โœ… Full Support | `from openai import OpenAI` |

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

---

<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)

---

## ๐Ÿ“„ 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 Pro 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_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()

        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()