tushare-mcp-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -0
  3. package/README_CN.md +146 -0
  4. package/bin/cli.js +88 -0
  5. package/build_index.py +159 -0
  6. package/crawl_docs.py +321 -0
  7. package/docs/0019_/345/237/272/351/207/221/345/210/227/350/241/250.md +75 -0
  8. package/docs/0025_/350/202/241/347/245/250/345/210/227/350/241/250.md +95 -0
  9. package/docs/0026_/344/272/244/346/230/223/346/227/245/345/216/206.md +73 -0
  10. package/docs/0027_/345/216/206/345/217/262/346/227/245/347/272/277.md +81 -0
  11. package/docs/0028_/345/244/215/346/235/203/345/233/240/345/255/220.md +79 -0
  12. package/docs/0032_/346/257/217/346/227/245/346/214/207/346/240/207.md +89 -0
  13. package/docs/0033_/345/210/251/346/266/246/350/241/250.md +168 -0
  14. package/docs/0036_/350/265/204/344/272/247/350/264/237/345/200/272/350/241/250.md +234 -0
  15. package/docs/0044_/347/216/260/351/207/221/346/265/201/351/207/217/350/241/250.md +174 -0
  16. package/docs/0045_/344/270/232/347/273/251/351/242/204/345/221/212.md +85 -0
  17. package/docs/0046_/344/270/232/347/273/251/345/277/253/346/212/245.md +86 -0
  18. package/docs/0047_/346/262/252/346/267/261/346/270/257/351/200/232/350/265/204/351/207/221/346/265/201/345/220/221.md +75 -0
  19. package/docs/0048_/346/262/252/346/267/261/350/202/241/351/200/232/345/215/201/345/244/247/346/210/220/344/272/244/350/202/241.md +81 -0
  20. package/docs/0049_/346/270/257/350/202/241/351/200/232/345/215/201/345/244/247/346/210/220/344/272/244/350/202/241.md +129 -0
  21. package/docs/0058_/350/236/215/350/265/204/350/236/215/345/210/270/344/272/244/346/230/223/346/261/207/346/200/273.md +85 -0
  22. package/docs/0059_/350/236/215/350/265/204/350/236/215/345/210/270/344/272/244/346/230/223/346/230/216/347/273/206.md +128 -0
  23. package/docs/0061_/345/211/215/345/215/201/345/244/247/350/202/241/344/270/234.md +68 -0
  24. package/docs/0062_/345/211/215/345/215/201/345/244/247/346/265/201/351/200/232/350/202/241/344/270/234.md +68 -0
  25. package/docs/0079_/350/264/242/345/212/241/346/214/207/346/240/207/346/225/260/346/215/256.md +227 -0
  26. package/docs/0080_/350/264/242/345/212/241/345/256/241/350/256/241/346/204/217/350/247/201.md +60 -0
  27. package/docs/0081_/344/270/273/350/220/245/344/270/232/345/212/241/346/236/204/346/210/220.md +64 -0
  28. package/docs/0094_/346/214/207/346/225/260/345/237/272/346/234/254/344/277/241/346/201/257.md +107 -0
  29. package/docs/0095_/346/214/207/346/225/260/346/227/245/347/272/277/350/241/214/346/203/205.md +78 -0
  30. package/docs/0096_/346/214/207/346/225/260/346/210/220/345/210/206/345/222/214/346/235/203/351/207/215.md +59 -0
  31. package/docs/0100_/350/202/241/347/245/250/346/233/276/347/224/250/345/220/215.md +52 -0
  32. package/docs/0103_/345/210/206/347/272/242/351/200/201/350/202/241/346/225/260/346/215/256.md +72 -0
  33. package/docs/0106_/351/276/231/350/231/216/346/246/234/346/257/217/346/227/245/347/273/237/350/256/241.md +143 -0
  34. package/docs/0107_/351/276/231/350/231/216/346/246/234/346/234/272/346/236/204/344/272/244/346/230/223.md +75 -0
  35. package/docs/0109_/351/200/232/347/224/250/350/241/214/346/203/205/346/216/245/345/217/243.md +118 -0
  36. package/docs/0110_/350/202/241/346/235/203/350/264/250/346/212/274/347/273/237/350/256/241.md +72 -0
  37. package/docs/0111_/350/202/241/346/235/203/350/264/250/346/212/274/346/230/216/347/273/206.md +69 -0
  38. package/docs/0112_/344/270/212/345/270/202/345/205/254/345/217/270/345/237/272/346/234/254/344/277/241/346/201/257.md +77 -0
  39. package/docs/0118_/345/237/272/351/207/221/347/256/241/347/220/206/344/272/272.md +67 -0
  40. package/docs/0119_/345/237/272/351/207/221/345/207/200/345/200/274.md +63 -0
  41. package/docs/0120_/345/237/272/351/207/221/345/210/206/347/272/242.md +76 -0
  42. package/docs/0121_/345/237/272/351/207/221/346/214/201/344/273/223.md +76 -0
  43. package/docs/0123_IPO/346/226/260/350/202/241/344/270/212/345/270/202.md +81 -0
  44. package/docs/0124_/350/202/241/347/245/250/345/233/236/350/264/255.md +79 -0
  45. package/docs/0127_ETF/346/227/245/347/272/277/350/241/214/346/203/205.md +66 -0
  46. package/docs/0128_/345/244/247/347/233/230/346/214/207/346/225/260/346/257/217/346/227/245/346/214/207/346/240/207.md +66 -0
  47. package/docs/0135_/346/234/237/350/264/247/345/220/210/347/272/246/344/277/241/346/201/257.md +80 -0
  48. package/docs/0137_/346/234/237/350/264/247/344/272/244/346/230/223/346/227/245/345/216/206.md +113 -0
  49. package/docs/0138_/346/234/237/350/264/247/346/227/245/347/272/277/350/241/214/346/203/205.md +131 -0
  50. package/docs/0139_/346/234/237/350/264/247/346/257/217/346/227/245/346/214/201/344/273/223/346/216/222/345/220/215.md +98 -0
  51. package/docs/0140_/346/234/237/350/264/247/344/273/223/345/215/225/346/227/245/346/212/245.md +83 -0
  52. package/docs/0141_/346/234/237/350/264/247/346/257/217/346/227/245/347/273/223/347/256/227/345/217/202/346/225/260.md +123 -0
  53. package/docs/0143_/346/226/260/351/227/273/345/277/253/350/256/257.md +71 -0
  54. package/docs/0144_/345/221/250/347/272/277/350/241/214/346/203/205.md +108 -0
  55. package/docs/0145_/346/234/210/347/272/277/350/241/214/346/203/205.md +106 -0
  56. package/docs/0146_/345/244/215/346/235/203/350/241/214/346/203/205.md +68 -0
  57. package/docs/0149_Shibor/345/210/251/347/216/207.md +92 -0
  58. package/docs/0150_Shibor/346/212/245/344/273/267/346/225/260/346/215/256.md +112 -0
  59. package/docs/0151_LPR/350/264/267/346/254/276/345/237/272/347/241/200/345/210/251/347/216/207.md +84 -0
  60. package/docs/0152_Libor/345/210/251/347/216/207.md +108 -0
  61. package/docs/0153_Hibor/345/210/251/347/216/207.md +107 -0
  62. package/docs/0154_/346/226/260/351/227/273/350/201/224/346/222/255/346/226/207/345/255/227/347/250/277.md +61 -0
  63. package/docs/0155_/345/215/227/345/215/216/346/234/237/350/264/247/346/214/207/346/225/260/350/241/214/346/203/205.md +146 -0
  64. package/docs/0158_/346/234/237/346/235/203/345/220/210/347/272/246/344/277/241/346/201/257.md +82 -0
  65. package/docs/0159_/346/234/237/346/235/203/346/227/245/347/272/277/350/241/214/346/203/205.md +80 -0
  66. package/docs/0160_/351/231/220/345/224/256/350/202/241/350/247/243/347/246/201.md +107 -0
  67. package/docs/0161_/345/244/247/345/256/227/344/272/244/346/230/223.md +102 -0
  68. package/docs/0162_/350/264/242/346/212/245/346/212/253/351/234/262/346/227/245/346/234/237/350/241/250.md +66 -0
  69. package/docs/0166_/350/202/241/344/270/234/344/272/272/346/225/260.md +73 -0
  70. package/docs/0170_/344/270/252/350/202/241/350/265/204/351/207/221/346/265/201/345/220/221.md +130 -0
  71. package/docs/0171_/346/214/207/346/225/260/345/221/250/347/272/277/350/241/214/346/203/205.md +100 -0
  72. package/docs/0172_/346/214/207/346/225/260/346/234/210/347/272/277/350/241/214/346/203/205.md +104 -0
  73. package/docs/0173_/346/270/251/345/267/236/346/260/221/351/227/264/345/200/237/350/264/267/345/210/251/347/216/207.md +114 -0
  74. package/docs/0175_/350/202/241/344/270/234/345/242/236/345/207/217/346/214/201.md +99 -0
  75. package/docs/0176_/344/270/212/345/270/202/345/205/254/345/217/270/345/205/254/345/221/212.md +70 -0
  76. package/docs/0178_/345/244/226/346/261/207/345/237/272/347/241/200/344/277/241/346/201/257.md +92 -0
  77. package/docs/0179_/345/244/226/346/261/207/346/227/245/347/272/277/350/241/214/346/203/205.md +113 -0
  78. package/docs/0181_/347/224/263/344/270/207/350/241/214/344/270/232/345/210/206/347/261/273.md +600 -0
  79. package/docs/0183_/346/257/217/346/227/245/346/266/250/350/267/214/345/201/234/344/273/267/346/240/274.md +85 -0
  80. package/docs/0185_/345/217/257/350/275/254/345/200/272/345/237/272/347/241/200/344/277/241/346/201/257.md +83 -0
  81. package/docs/0186_/345/217/257/350/275/254/345/200/272/345/217/221/350/241/214.md +105 -0
  82. package/docs/0187_/345/217/257/350/275/254/345/200/272/350/241/214/346/203/205.md +115 -0
  83. package/docs/0188_/346/262/252/346/267/261/350/202/241/351/200/232/346/214/201/350/202/241/346/230/216/347/273/206.md +77 -0
  84. package/docs/0189_/346/234/237/350/264/247/344/270/273/345/212/233/344/270/216/350/277/236/347/273/255/345/220/210/347/272/246.md +80 -0
  85. package/docs/0191_/346/270/257/350/202/241/345/237/272/347/241/200/344/277/241/346/201/257.md +90 -0
  86. package/docs/0192_/346/270/257/350/202/241/346/227/245/347/272/277/350/241/214/346/203/205.md +91 -0
  87. package/docs/0193_/344/270/212/345/270/202/345/205/254/345/217/270/347/256/241/347/220/206/345/261/202.md +95 -0
  88. package/docs/0194_/347/256/241/347/220/206/345/261/202/350/226/252/351/205/254/345/222/214/346/214/201/350/202/241.md +82 -0
  89. package/docs/0195_/346/226/260/351/227/273/351/200/232/350/256/257/351/225/277/347/257/207.md +70 -0
  90. package/docs/0196_/346/270/257/350/202/241/351/200/232/346/257/217/346/227/245/346/210/220/344/272/244/347/273/237/350/256/241.md +89 -0
  91. package/docs/0197_/346/270/257/350/202/241/351/200/232/346/257/217/346/234/210/346/210/220/344/272/244/347/273/237/350/256/241.md +89 -0
  92. package/docs/0199_ETF/345/244/215/346/235/203/345/233/240/345/255/220.md +69 -0
  93. package/docs/0201_/345/233/275/345/200/272/346/224/266/347/233/212/347/216/207/346/233/262/347/272/277.md +74 -0
  94. package/docs/0207_/345/237/272/351/207/221/350/247/204/346/250/241.md +75 -0
  95. package/docs/0208_/345/237/272/351/207/221/347/273/217/347/220/206.md +74 -0
  96. package/docs/0211_/345/233/275/351/231/205/344/270/273/350/246/201/346/214/207/346/225/260.md +125 -0
  97. package/docs/0214_/346/257/217/346/227/245/345/201/234/345/244/215/347/211/214/344/277/241/346/201/257.md +74 -0
  98. package/docs/0215_/346/262/252/346/267/261/345/270/202/345/234/272/346/257/217/346/227/245/344/272/244/346/230/223/347/273/237/350/256/241.md +121 -0
  99. package/docs/0219_/347/276/216/345/233/275/345/233/275/345/200/272/346/224/266/347/233/212/347/216/207/346/233/262/347/272/277.md +82 -0
  100. package/docs/0227_/345/233/275/345/206/205/347/224/237/344/272/247/346/200/273/345/200/274GDP.md +77 -0
  101. package/docs/0228_/345/261/205/346/260/221/346/266/210/350/264/271/344/273/267/346/240/274/346/214/207/346/225/260CPI.md +84 -0
  102. package/docs/0242_/350/264/247/345/270/201/344/276/233/345/272/224/351/207/217/346/234/210.md +71 -0
  103. package/docs/0245_/345/267/245/344/270/232/347/224/237/344/272/247/350/200/205/345/207/272/345/216/202/344/273/267/346/240/274/346/214/207/346/225/260PPI.md +94 -0
  104. package/docs/0246_/345/217/257/350/275/254/345/200/272/350/275/254/350/202/241/344/273/267/345/217/230/345/212/250.md +57 -0
  105. package/docs/0247_/345/217/257/350/275/254/345/200/272/350/275/254/350/202/241/347/273/223/346/236/234.md +81 -0
  106. package/docs/0250_/346/270/257/350/202/241/344/272/244/346/230/223/346/227/245/345/216/206.md +65 -0
  107. package/docs/0252_/347/276/216/350/202/241/345/237/272/347/241/200/344/277/241/346/201/257.md +73 -0
  108. package/docs/0253_/347/276/216/350/202/241/344/272/244/346/230/223/346/227/245/345/216/206.md +67 -0
  109. package/docs/0254_/347/276/216/350/202/241/346/227/245/347/272/277/350/241/214/346/203/205.md +83 -0
  110. package/docs/0255_/345/244/207/347/224/250/350/241/214/346/203/205.md +86 -0
  111. package/docs/0256_/345/200/272/345/210/270/345/233/236/350/264/255/346/227/245/350/241/214/346/203/205.md +112 -0
  112. package/docs/0259_/345/220/214/350/212/261/351/241/272/350/241/214/344/270/232/346/246/202/345/277/265/346/235/277/345/235/227.md +70 -0
  113. package/docs/0260_/345/220/214/350/212/261/351/241/272/346/246/202/345/277/265/345/222/214/350/241/214/344/270/232/346/214/207/346/225/260/350/241/214/346/203/205.md +79 -0
  114. package/docs/0261_/345/220/214/350/212/261/351/241/272/350/241/214/344/270/232/346/246/202/345/277/265/346/210/220/345/210/206.md +60 -0
  115. package/docs/0262_/350/202/241/347/245/250/345/216/206/345/217/262/345/210/227/350/241/250.md +75 -0
  116. package/docs/0265_/345/220/204/346/270/240/351/201/223/345/205/254/345/213/237/345/237/272/351/207/221/351/224/200/345/224/256/344/277/235/346/234/211/350/247/204/346/250/241/345/215/240/346/257/224.md +62 -0
  117. package/docs/0266_/351/224/200/345/224/256/346/234/272/346/236/204/345/205/254/345/213/237/345/237/272/351/207/221/351/224/200/345/224/256/344/277/235/346/234/211/350/247/204/346/250/241.md +81 -0
  118. package/docs/0267_/345/210/270/345/225/206/346/234/210/345/272/246/351/207/221/350/202/241.md +54 -0
  119. package/docs/0269_/345/217/257/350/275/254/345/200/272/350/265/216/345/233/236/344/277/241/346/201/257.md +68 -0
  120. package/docs/0274_/344/270/255/345/244/256/347/273/223/347/256/227/347/263/273/347/273/237/346/214/201/350/202/241/346/230/216/347/273/206.md +71 -0
  121. package/docs/0275_/346/234/272/346/236/204/350/260/203/347/240/224/346/225/260/346/215/256.md +72 -0
  122. package/docs/0284_/344/270/212/346/265/267/351/273/204/351/207/221/345/237/272/347/241/200/344/277/241/346/201/257.md +73 -0
  123. package/docs/0285_/344/270/212/346/265/267/351/273/204/351/207/221/347/216/260/350/264/247/346/227/245/350/241/214/346/203/205.md +88 -0
  124. package/docs/0292_/345/210/270/345/225/206/347/233/210/345/210/251/351/242/204/346/265/213.md +89 -0
  125. package/docs/0293_/346/257/217/346/227/245/347/255/271/347/240/201/345/217/212/350/203/234/347/216/207.md +66 -0
  126. package/docs/0294_/346/257/217/346/227/245/347/255/271/347/240/201/345/210/206/345/270/203.md +59 -0
  127. package/docs/0295_/344/270/255/345/244/256/347/273/223/347/256/227/347/263/273/347/273/237/346/214/201/350/202/241/347/273/237/350/256/241.md +69 -0
  128. package/docs/0298_/346/266/250/350/267/214/345/201/234/345/222/214/347/202/270/346/235/277/346/225/260/346/215/256.md +83 -0
  129. package/docs/0304_/346/270/257/350/202/241/345/210/206/351/222/237/350/241/214/346/203/205.md +87 -0
  130. package/docs/0305_/345/217/257/350/275/254/345/200/272/347/245/250/351/235/242/345/210/251/347/216/207.md +63 -0
  131. package/docs/0308_/344/270/255/344/277/241/350/241/214/344/270/232/346/214/207/346/225/260/346/227/245/350/241/214/346/203/205.md +79 -0
  132. package/docs/0310_/347/244/276/350/236/215/345/242/236/351/207/217/346/234/210/345/272/246.md +82 -0
  133. package/docs/0311_/345/270/202/345/234/272/346/270/270/350/265/204/346/234/200/345/205/250/345/220/215/345/275/225.md +147 -0
  134. package/docs/0312_/346/270/270/350/265/204/344/272/244/346/230/223/346/257/217/346/227/245/346/230/216/347/273/206.md +59 -0
  135. package/docs/0325_/351/207/207/350/264/255/347/273/217/347/220/206/346/214/207/346/225/260PMI.md +120 -0
  136. package/docs/0326_/350/236/215/350/265/204/350/236/215/345/210/270/346/240/207/347/232/204/347/233/230/345/211/215.md +72 -0
  137. package/docs/0327_/347/224/263/344/270/207/350/241/214/344/270/232/346/214/207/346/225/260/346/227/245/350/241/214/346/203/205.md +78 -0
  138. package/docs/0328_/350/202/241/347/245/250/346/212/200/346/234/257/351/235/242/345/233/240/345/255/220.md +290 -0
  139. package/docs/0329_/346/257/217/346/227/245/350/202/241/346/234/254/347/233/230/345/211/215.md +62 -0
  140. package/docs/0331_/350/275/254/350/236/215/350/265/204/344/272/244/346/230/223/346/261/207/346/200/273.md +73 -0
  141. package/docs/0335_/347/224/263/344/270/207/350/241/214/344/270/232/346/210/220/345/210/206/345/210/206/347/272/247.md +82 -0
  142. package/docs/0336_/345/221/250/346/234/210/347/272/277/350/241/214/346/203/205/346/257/217/346/227/245/346/233/264/346/226/260.md +78 -0
  143. package/docs/0337_/346/234/237/350/264/247/345/221/250/346/234/210/347/272/277/350/241/214/346/203/205.md +48 -0
  144. package/docs/0338_/347/276/216/350/202/241/345/244/215/346/235/203/350/241/214/346/203/205.md +94 -0
  145. package/docs/0339_/346/270/257/350/202/241/345/244/215/346/235/203/350/241/214/346/203/205.md +92 -0
  146. package/docs/0341_/346/234/237/346/235/203/345/210/206/351/222/237/350/241/214/346/203/205.md +88 -0
  147. package/docs/0343_/350/241/214/344/270/232/350/265/204/351/207/221/346/265/201/345/220/221THS.md +67 -0
  148. package/docs/0344_/346/235/277/345/235/227/350/265/204/351/207/221/346/265/201/345/220/221DC.md +72 -0
  149. package/docs/0345_/345/244/247/347/233/230/350/265/204/351/207/221/346/265/201/345/220/221DC.md +75 -0
  150. package/docs/0348_/344/270/252/350/202/241/350/265/204/351/207/221/346/265/201/345/220/221THS.md +62 -0
  151. package/docs/0349_/344/270/252/350/202/241/350/265/204/351/207/221/346/265/201/345/220/221DC.md +82 -0
  152. package/docs/0362_/344/270/234/346/226/271/350/264/242/345/257/214/346/246/202/345/277/265/346/235/277/345/235/227.md +70 -0
  153. package/docs/0363_/344/270/234/346/226/271/350/264/242/345/257/214/346/246/202/345/277/265/346/210/220/345/210/206.md +72 -0
  154. package/docs/0365_/345/221/250/346/234/210/347/272/277/345/244/215/346/235/203/350/241/214/346/203/205/346/257/217/346/227/245/346/233/264/346/226/260.md +86 -0
  155. package/docs/0368_/346/234/237/350/264/247/345/220/210/347/272/246/346/266/250/350/267/214/345/201/234/344/273/267/346/240/274.md +80 -0
  156. package/docs/0370_/345/216/206/345/217/262/345/210/206/351/222/237.md +73 -0
  157. package/docs/0371_/346/235/277/345/235/227/350/265/204/351/207/221/346/265/201/345/220/221THS.md +65 -0
  158. package/docs/0372_/345/256/236/346/227/266/346/227/245/347/272/277.md +73 -0
  159. package/docs/0373_/344/270/255/344/277/241/350/241/214/344/270/232/346/210/220/345/210/206.md +124 -0
  160. package/docs/0374_/345/256/236/346/227/266/345/210/206/351/222/237.md +56 -0
  161. package/docs/0375_/345/214/227/344/272/244/346/211/200/346/226/260/346/227/247/344/273/243/347/240/201/345/257/271/347/205/247.md +60 -0
  162. package/docs/0385_ETF/345/237/272/346/234/254/344/277/241/346/201/257.md +110 -0
  163. package/docs/0386_ETF/345/237/272/345/207/206/346/214/207/346/225/260.md +70 -0
  164. package/docs/0387_ETF/345/216/206/345/217/262/345/210/206/351/222/237.md +73 -0
  165. package/docs/0388_/346/270/257/350/202/241/350/264/242/345/212/241/346/214/207/346/240/207/346/225/260/346/215/256.md +148 -0
  166. package/docs/0389_/346/270/257/350/202/241/345/210/251/346/266/246/350/241/250.md +92 -0
  167. package/docs/0390_/346/270/257/350/202/241/350/265/204/344/272/247/350/264/237/345/200/272/350/241/250.md +120 -0
  168. package/docs/0391_/346/270/257/350/202/241/347/216/260/351/207/221/346/265/201/351/207/217/350/241/250.md +115 -0
  169. package/docs/0393_/347/276/216/350/202/241/350/264/242/345/212/241/346/214/207/346/240/207/346/225/260/346/215/256.md +143 -0
  170. package/docs/0394_/347/276/216/350/202/241/345/210/251/346/266/246/350/241/250.md +79 -0
  171. package/docs/0395_/347/276/216/350/202/241/350/265/204/344/272/247/350/264/237/345/200/272/350/241/250.md +67 -0
  172. package/docs/0396_/347/276/216/350/202/241/347/216/260/351/207/221/346/265/201/351/207/217/350/241/250.md +79 -0
  173. package/docs/0397_ST/350/202/241/347/245/250/345/210/227/350/241/250.md +72 -0
  174. package/docs/0398_/346/262/252/346/267/261/346/270/257/351/200/232/350/202/241/347/245/250/345/210/227/350/241/250.md +82 -0
  175. package/docs/0399_AH/350/202/241/346/257/224/344/273/267.md +79 -0
  176. package/docs/0406_/345/233/275/345/256/266/346/224/277/347/255/226/345/272/223.md +70 -0
  177. package/docs/0408_ETF/344/273/275/351/242/235/350/247/204/346/250/241.md +65 -0
  178. package/docs/0415_/345/210/270/345/225/206/347/240/224/347/251/266/346/212/245/345/221/212.md +68 -0
  179. package/docs/0423_ST/351/243/216/351/231/251/350/255/246/347/244/272/346/235/277/350/202/241/347/245/250.md +65 -0
  180. package/docs/_api_index.json +1213 -0
  181. package/docs/_index.md +178 -0
  182. package/package.json +42 -0
  183. package/requirements.txt +2 -0
  184. package/server.py +736 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 erwanjun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # tushare-mcp-server
2
+
3
+ [中文文档](README_CN.md) | English
4
+
5
+ A [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server for [Tushare Pro](https://tushare.pro) financial data API. Provides AI assistants (GitHub Copilot, Claude, etc.) with direct access to comprehensive Chinese financial market data — covering A-shares, indices, funds, futures, options, bonds, forex, HK/US stocks, and macroeconomic indicators.
6
+
7
+ ## Features
8
+
9
+ - **Universal Query** — `tushare_query` calls any of the 173 Tushare Pro APIs
10
+ - **15 Convenience Tools** — Pre-built tools for stocks, indices, financials, funds, and more
11
+ - **Built-in Documentation** — `get_api_doc` / `search_api_docs` for API parameter lookup
12
+ - **Categorized Index** — 173 APIs organized into 18 categories
13
+
14
+ ### Data Coverage
15
+
16
+ | Category | # | Examples |
17
+ |----------|---|----------|
18
+ | A-Shares | 37 | stock_basic, daily, weekly, monthly, daily_basic, adj_factor, pro_bar |
19
+ | Financials | 9 | income, balancesheet, cashflow, fina_indicator, forecast |
20
+ | Market Reference | 23 | margin, top_list, block_trade, hsgt_top10, pledge_stat |
21
+ | Indices | 13 | index_basic, index_daily, index_weight, sw_daily, ci_daily |
22
+ | Money Flow | 8 | moneyflow, moneyflow_hsgt, moneyflow_ind_ths |
23
+ | Funds | 14 | fund_basic, fund_nav, fund_daily, etf_basic, fund_portfolio |
24
+ | Futures | 8 | fut_basic, fut_daily, fut_holding, fut_mapping |
25
+ | Options | 3 | opt_basic, opt_daily, opt_mins |
26
+ | Bonds / CB | 9 | cb_basic, cb_daily, cb_issue, repo_daily, yc_cb |
27
+ | HK Stocks | 9 | hk_basic, hk_daily, hk_income, hk_balancesheet |
28
+ | US Stocks | 8 | us_basic, us_daily, us_income, us_balancesheet |
29
+ | Macro Economy | 14 | shibor, cn_gdp, cn_cpi, cn_ppi, cn_pmi, libor |
30
+ | Sector / Concept | 5 | ths_index, ths_daily, dc_index, dc_member |
31
+ | Others | 13 | fx_daily, sge_daily, news, trade_cal, etc. |
32
+
33
+ ## Prerequisites
34
+
35
+ - Python 3.10+
36
+ - A [Tushare Pro](https://tushare.pro/register?invited_code=ANNJLJ) account and API token
37
+
38
+ ## Quick Start
39
+
40
+ ### Install via npx (recommended)
41
+
42
+ No installation needed — just configure your MCP client:
43
+
44
+ ```json
45
+ {
46
+ "servers": {
47
+ "tushare": {
48
+ "type": "stdio",
49
+ "command": "npx",
50
+ "args": ["-y", "tushare-mcp-server"],
51
+ "env": { "TUSHARE_TOKEN": "your_token_here" }
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ### Install from source
58
+
59
+ ```bash
60
+ git clone https://github.com/erwanjun/tushare-mcp-server.git
61
+ cd tushare-mcp-server
62
+ python3 -m venv .venv
63
+ source .venv/bin/activate
64
+ pip install mcp httpx
65
+ ```
66
+
67
+ ## Configuration
68
+
69
+ ### Tushare Token
70
+
71
+ Set your token via any of these methods:
72
+
73
+ 1. **`.env` file** (recommended) — create `.env` in the project root:
74
+ ```
75
+ TUSHARE_TOKEN=your_token_here
76
+ ```
77
+ 2. **Environment variable** — `export TUSHARE_TOKEN=your_token`
78
+ 3. **MCP client config** — pass via the `env` field (see examples below)
79
+
80
+ ### VS Code (GitHub Copilot)
81
+
82
+ `.vscode/mcp.json`:
83
+
84
+ ```json
85
+ {
86
+ "servers": {
87
+ "tushare": {
88
+ "type": "stdio",
89
+ "command": "npx",
90
+ "args": ["-y", "tushare-mcp-server"],
91
+ "env": { "TUSHARE_TOKEN": "your_token_here" }
92
+ }
93
+ }
94
+ }
95
+ ```
96
+
97
+ ### Claude Desktop
98
+
99
+ `claude_desktop_config.json`:
100
+
101
+ ```json
102
+ {
103
+ "mcpServers": {
104
+ "tushare": {
105
+ "command": "npx",
106
+ "args": ["-y", "tushare-mcp-server"],
107
+ "env": { "TUSHARE_TOKEN": "your_token_here" }
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ ## Tools
114
+
115
+ | Tool | Description |
116
+ |------|-------------|
117
+ | `tushare_query` | Universal query — call any Tushare Pro API |
118
+ | `get_stock_list` | A-share stock list |
119
+ | `get_trade_calendar` | Trading calendar |
120
+ | `get_daily_bars` | Daily OHLCV (unadjusted) |
121
+ | `get_daily_basic` | Daily indicators: PE, PB, market cap, turnover |
122
+ | `get_income` | Income statement |
123
+ | `get_balancesheet` | Balance sheet |
124
+ | `get_cashflow` | Cash flow statement |
125
+ | `get_fina_indicator` | Financial indicators (ROE, ROA, margins) |
126
+ | `get_index_daily` | Index daily bars |
127
+ | `get_moneyflow` | Stock money flow |
128
+ | `get_concept` | Concept / sector classification |
129
+ | `get_concept_detail` | Concept constituents |
130
+ | `get_fund_basic` | Fund list |
131
+ | `get_fund_nav` | Fund NAV |
132
+ | `get_shibor` | Shibor interest rates |
133
+ | `get_api_doc` | Full API documentation by endpoint name |
134
+ | `search_api_docs` | Search API docs by keyword |
135
+
136
+ ## Development
137
+
138
+ ```bash
139
+ # Re-crawl Tushare documentation
140
+ python crawl_docs.py
141
+
142
+ # Rebuild API index
143
+ python build_index.py
144
+ ```
145
+
146
+ ## License
147
+
148
+ MIT
package/README_CN.md ADDED
@@ -0,0 +1,146 @@
1
+ # tushare-mcp-server
2
+
3
+ [English](README.md) | 中文
4
+
5
+ [Tushare Pro](https://tushare.pro) 金融数据 MCP 服务器。通过 [Model Context Protocol (MCP)](https://modelcontextprotocol.io) 为 AI 助手(GitHub Copilot、Claude 等)提供 A 股、指数、基金、期货、期权、债券、外汇、港股、美股、宏观经济等全方位金融数据查询能力。
6
+
7
+ ## 功能
8
+
9
+ - **通用查询** `tushare_query` — 可调用任意 Tushare Pro 的 173 个 API 接口
10
+ - **15 个便捷工具** — 股票列表、日线行情、每日指标、利润表、资产负债表、现金流量表、财务指标、指数日线、资金流向、概念/板块、基金列表/净值、Shibor 利率
11
+ - **内置文档查询** `get_api_doc` / `search_api_docs` — 按接口名或关键词查询 API 参数说明
12
+ - **分类索引** — 173 个接口按 18 个类别整理
13
+
14
+ ### 数据覆盖
15
+
16
+ | 类别 | 数量 | 包含接口 |
17
+ |------|------|----------|
18
+ | 沪深股票 | 37 | stock_basic, daily, weekly, monthly, daily_basic, adj_factor, pro_bar 等 |
19
+ | 财务数据 | 9 | income, balancesheet, cashflow, fina_indicator, forecast 等 |
20
+ | 市场参考 | 23 | margin, top_list, block_trade, hsgt_top10, pledge_stat 等 |
21
+ | 指数数据 | 13 | index_basic, index_daily, index_weight, sw_daily, ci_daily 等 |
22
+ | 资金流向 | 8 | moneyflow, moneyflow_hsgt, moneyflow_ind_ths 等 |
23
+ | 基金数据 | 14 | fund_basic, fund_nav, fund_daily, etf_basic, fund_portfolio 等 |
24
+ | 期货数据 | 8 | fut_basic, fut_daily, fut_holding, fut_mapping 等 |
25
+ | 期权数据 | 3 | opt_basic, opt_daily, opt_mins |
26
+ | 债券/可转债 | 9 | cb_basic, cb_daily, cb_issue, repo_daily, yc_cb 等 |
27
+ | 港股数据 | 9 | hk_basic, hk_daily, hk_income, hk_balancesheet 等 |
28
+ | 美股数据 | 8 | us_basic, us_daily, us_income, us_balancesheet 等 |
29
+ | 宏观经济 | 14 | shibor, cn_gdp, cn_cpi, cn_ppi, cn_pmi, libor 等 |
30
+ | 概念板块 | 5 | ths_index, ths_daily, dc_index, dc_member, ths_member |
31
+ | 其他 | 13 | fx_daily, sge_daily, news, trade_cal 等 |
32
+
33
+ ## 前置条件
34
+
35
+ - Python 3.10+
36
+ - [Tushare Pro](https://tushare.pro/register?invited_code=ANNJLJ) 账号及 API Token
37
+
38
+ ## 快速开始
39
+
40
+ ### 通过 npx 安装(推荐)
41
+
42
+ 无需手动安装,在 MCP 客户端配置即可:
43
+
44
+ ```json
45
+ {
46
+ "servers": {
47
+ "tushare": {
48
+ "type": "stdio",
49
+ "command": "npx",
50
+ "args": ["-y", "tushare-mcp-server"],
51
+ "env": { "TUSHARE_TOKEN": "你的token" }
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ### 从源码安装
58
+
59
+ ```bash
60
+ git clone https://github.com/erwanjun/tushare-mcp-server.git
61
+ cd tushare-mcp-server
62
+ python3 -m venv .venv
63
+ source .venv/bin/activate
64
+ pip install mcp httpx
65
+ ```
66
+
67
+ ## 配置 Token
68
+
69
+ 三种方式(任选一种):
70
+
71
+ 1. **`.env` 文件**(推荐):在项目根目录创建 `.env`
72
+ ```
73
+ TUSHARE_TOKEN=你的token
74
+ ```
75
+ 2. **环境变量**:`export TUSHARE_TOKEN=你的token`
76
+ 3. **MCP 客户端配置**:通过 `env` 字段传入(见下方示例)
77
+
78
+ ### VS Code (GitHub Copilot)
79
+
80
+ `.vscode/mcp.json`:
81
+
82
+ ```json
83
+ {
84
+ "servers": {
85
+ "tushare": {
86
+ "type": "stdio",
87
+ "command": "npx",
88
+ "args": ["-y", "tushare-mcp-server"],
89
+ "env": { "TUSHARE_TOKEN": "你的token" }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ ### Claude Desktop
96
+
97
+ `claude_desktop_config.json`:
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "tushare": {
103
+ "command": "npx",
104
+ "args": ["-y", "tushare-mcp-server"],
105
+ "env": { "TUSHARE_TOKEN": "你的token" }
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ ## 工具列表
112
+
113
+ | 工具 | 说明 |
114
+ |------|------|
115
+ | `tushare_query` | 通用查询 — 可调用任意 Tushare Pro 接口 |
116
+ | `get_stock_list` | A 股股票列表 |
117
+ | `get_trade_calendar` | 交易日历 |
118
+ | `get_daily_bars` | A 股日线行情(未复权) |
119
+ | `get_daily_basic` | 每日指标:PE/PB/总市值/流通市值/换手率 |
120
+ | `get_income` | 利润表 |
121
+ | `get_balancesheet` | 资产负债表 |
122
+ | `get_cashflow` | 现金流量表 |
123
+ | `get_fina_indicator` | 财务指标(ROE/ROA/毛利率/净利率) |
124
+ | `get_index_daily` | 指数日线行情 |
125
+ | `get_moneyflow` | 个股资金流向 |
126
+ | `get_concept` | 概念股分类 |
127
+ | `get_concept_detail` | 概念股成分 |
128
+ | `get_fund_basic` | 基金列表 |
129
+ | `get_fund_nav` | 基金净值 |
130
+ | `get_shibor` | Shibor 拆借利率 |
131
+ | `get_api_doc` | 按接口名获取完整 API 文档 |
132
+ | `search_api_docs` | 按关键词搜索 API 文档 |
133
+
134
+ ## 维护
135
+
136
+ ```bash
137
+ # 重新爬取 Tushare 文档(如接口更新时)
138
+ python crawl_docs.py
139
+
140
+ # 重建 API 索引(爬取后需执行)
141
+ python build_index.py
142
+ ```
143
+
144
+ ## License
145
+
146
+ MIT
package/bin/cli.js ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * tushare-mcp-server CLI launcher
5
+ * Sets up Python environment and runs the MCP server.
6
+ */
7
+
8
+ const { spawn, execSync } = require("child_process");
9
+ const path = require("path");
10
+ const fs = require("fs");
11
+
12
+ const ROOT = path.resolve(__dirname, "..");
13
+ const SERVER_PY = path.join(ROOT, "server.py");
14
+ const VENV_DIR = path.join(ROOT, ".venv");
15
+ const REQUIREMENTS = path.join(ROOT, "requirements.txt");
16
+
17
+ function getPython() {
18
+ // Check venv first
19
+ const venvPy = path.join(VENV_DIR, "bin", "python");
20
+ if (fs.existsSync(venvPy)) return venvPy;
21
+
22
+ // Check system python
23
+ for (const cmd of ["python3", "python"]) {
24
+ try {
25
+ execSync(`${cmd} --version`, { stdio: "ignore" });
26
+ return cmd;
27
+ } catch {}
28
+ }
29
+ return null;
30
+ }
31
+
32
+ function ensureVenv(pythonCmd) {
33
+ if (fs.existsSync(path.join(VENV_DIR, "bin", "python"))) {
34
+ return path.join(VENV_DIR, "bin", "python");
35
+ }
36
+
37
+ process.stderr.write("[tushare-mcp] Creating Python venv...\n");
38
+ execSync(`${pythonCmd} -m venv "${VENV_DIR}"`, { stdio: "inherit" });
39
+
40
+ const venvPy = path.join(VENV_DIR, "bin", "python");
41
+ process.stderr.write("[tushare-mcp] Installing dependencies...\n");
42
+ execSync(`"${venvPy}" -m pip install --quiet -r "${REQUIREMENTS}"`, {
43
+ stdio: "inherit",
44
+ });
45
+
46
+ return venvPy;
47
+ }
48
+
49
+ function main() {
50
+ let python = getPython();
51
+
52
+ if (!python) {
53
+ process.stderr.write(
54
+ "[tushare-mcp] Error: Python 3.10+ is required but not found.\n" +
55
+ "Please install Python from https://www.python.org/downloads/\n"
56
+ );
57
+ process.exit(1);
58
+ }
59
+
60
+ // If not using venv python, set up venv
61
+ if (!python.includes(".venv")) {
62
+ python = ensureVenv(python);
63
+ }
64
+
65
+ // Check if dependencies are installed
66
+ try {
67
+ execSync(`"${python}" -c "import mcp; import httpx"`, { stdio: "ignore" });
68
+ } catch {
69
+ process.stderr.write("[tushare-mcp] Installing dependencies...\n");
70
+ execSync(`"${python}" -m pip install --quiet -r "${REQUIREMENTS}"`, {
71
+ stdio: "inherit",
72
+ });
73
+ }
74
+
75
+ // Launch the MCP server
76
+ const child = spawn(python, [SERVER_PY], {
77
+ stdio: "inherit",
78
+ env: { ...process.env },
79
+ });
80
+
81
+ child.on("exit", (code) => process.exit(code ?? 0));
82
+ child.on("error", (err) => {
83
+ process.stderr.write(`[tushare-mcp] Failed to start: ${err.message}\n`);
84
+ process.exit(1);
85
+ });
86
+ }
87
+
88
+ main();
package/build_index.py ADDED
@@ -0,0 +1,159 @@
1
+ """生成 api_name -> 文档文件名 的结构化映射(含分类与去重)"""
2
+ import json
3
+ import os
4
+ import re
5
+
6
+ docs_dir = "docs"
7
+ api_index: dict[str, dict] = {}
8
+
9
+ # ── API 分类映射 ──────────────────────────────────────────────────────
10
+ # 基于 api_name 前缀/精确名称自动分类
11
+ CATEGORY_RULES: list[tuple[str, list[str]]] = [
12
+ ("沪深股票", ["stock_basic", "stock_company", "stock_st", "stock_hsgt",
13
+ "stk_ah_comparison", "daily", "weekly", "monthly", "adj_factor",
14
+ "daily_basic", "daily_info", "suspend_d", "stk_limit",
15
+ "stk_factor_pro", "stk_premarket", "stk_week_month_adj",
16
+ "stk_weekly_monthly", "stk_holdernumber", "stk_holdertrade",
17
+ "stk_managers", "stk_rewards", "stk_surv", "stk_mins",
18
+ "namechange", "new_share", "repurchase", "bak_daily",
19
+ "bak_basic", "share_float", "dividend", "bse_mapping",
20
+ "pro_bar", "rt_k", "rt_min", "limit_list_d"]),
21
+ ("财务数据", ["income", "balancesheet", "cashflow", "forecast", "express",
22
+ "fina_indicator", "fina_audit", "fina_mainbz", "disclosure_date"]),
23
+ ("资金流向", ["moneyflow", "moneyflow_hsgt", "moneyflow_ind_ths",
24
+ "moneyflow_ind_dc", "moneyflow_mkt_dc", "moneyflow_ths",
25
+ "moneyflow_dc", "moneyflow_cnt_ths"]),
26
+ ("市场参考", ["margin", "margin_detail", "margin_secs", "top_list",
27
+ "top_inst", "block_trade", "hsgt_top10", "ggt_top10",
28
+ "ggt_daily", "ggt_monthly", "hk_hold", "ccass_hold",
29
+ "ccass_hold_detail", "slb_len", "hm_list", "hm_detail",
30
+ "cyq_perf", "cyq_chips", "pledge_stat", "pledge_detail",
31
+ "broker_recommend", "report_rc", "research_report"]),
32
+ ("指数数据", ["index_basic", "index_daily", "index_dailybasic",
33
+ "index_weight", "index_weekly", "index_monthly",
34
+ "index_classify", "index_member_all", "index_global",
35
+ "sw_daily", "ci_daily", "ci_index_member"]),
36
+ ("概念板块", ["concept", "concept_detail", "ths_index", "ths_daily",
37
+ "ths_member", "dc_index", "dc_member"]),
38
+ ("基金数据", ["fund_basic", "fund_nav", "fund_div", "fund_portfolio",
39
+ "fund_daily", "fund_adj", "fund_share", "fund_manager",
40
+ "fund_company", "fund_sales_ratio", "fund_sales_vol",
41
+ "etf_basic", "etf_index", "etf_share_size"]),
42
+ ("期货数据", ["fut_basic", "fut_daily", "fut_holding", "fut_wsr",
43
+ "fut_settle", "fut_mapping", "fut_weekly_monthly",
44
+ "ft_limit"]),
45
+ ("期权数据", ["opt_basic", "opt_daily", "opt_mins"]),
46
+ ("债券/可转债", ["cb_basic", "cb_issue", "cb_daily", "cb_price_chg",
47
+ "cb_share", "cb_call", "cb_rate", "repo_daily", "yc_cb"]),
48
+ ("港股数据", ["hk_basic", "hk_daily", "hk_tradecal", "hk_mins",
49
+ "hk_daily_adj", "hk_fina_indicator", "hk_income",
50
+ "hk_balancesheet", "hk_cashflow"]),
51
+ ("美股数据", ["us_basic", "us_tradecal", "us_daily", "us_daily_adj",
52
+ "us_fina_indicator", "us_income", "us_balancesheet",
53
+ "us_cashflow"]),
54
+ ("外汇数据", ["fx_obasic", "fx_daily"]),
55
+ ("宏观经济", ["cn_gdp", "cn_cpi", "cn_m", "cn_ppi", "cn_pmi",
56
+ "sf_month", "shibor", "shibor_quote", "shibor_lpr",
57
+ "libor", "hibor", "wz_index", "us_tycr", "npr"]),
58
+ ("黄金现货", ["sge_basic", "sge_daily"]),
59
+ ("新闻公告", ["news", "cctv_news", "major_news", "anns_d"]),
60
+ ("交易日历", ["trade_cal"]),
61
+ ]
62
+
63
+ _name_to_cat = {}
64
+ for cat, names in CATEGORY_RULES:
65
+ for n in names:
66
+ _name_to_cat[n] = cat
67
+
68
+
69
+ def classify(api_name: str) -> str:
70
+ if api_name in _name_to_cat:
71
+ return _name_to_cat[api_name]
72
+ # 前缀匹配兜底
73
+ for prefix in ("hk_", "us_", "fut_", "opt_", "cb_", "fx_", "fund_",
74
+ "index_", "etf_", "sge_", "cn_"):
75
+ if api_name.startswith(prefix):
76
+ for cat, names in CATEGORY_RULES:
77
+ if any(n.startswith(prefix) for n in names):
78
+ return cat
79
+ return "其他"
80
+
81
+
82
+ for f in sorted(os.listdir(docs_dir)):
83
+ if not f.endswith(".md") or f.startswith("_"):
84
+ continue
85
+ path = os.path.join(docs_dir, f)
86
+ content = open(path, encoding="utf-8").read()
87
+
88
+ # 提取标题
89
+ title_m = re.match(r"^# (.+)", content)
90
+ title = title_m.group(1).strip() if title_m else f[5:-3]
91
+
92
+ # 提取 doc_id
93
+ docid_m = re.search(r"文档ID:\s*(\d+)", content)
94
+ doc_id = int(docid_m.group(1)) if docid_m else 0
95
+
96
+ # 提取接口名(处理 "接口:" 和 "接口名称:" 等格式,含 markdown 粗体和转义 \_)
97
+ api_name = None
98
+ for pat in (r"接口[::]\s*([\w\\_]+)",
99
+ r"\*{0,2}接口名称\*{0,2}\s*[::]\s*([\w\\_]+)",
100
+ r"\*{0,2}接口说明\*{0,2}\s*[::]\s*([\w\\_]+)"):
101
+ m = re.search(pat, content)
102
+ if m:
103
+ api_name = m.group(1).replace("\\_", "_").replace("\\", "")
104
+ break
105
+
106
+ # 提取描述
107
+ desc = ""
108
+ desc_m = re.search(r"描述[::]\s*(.+)", content)
109
+ if desc_m:
110
+ desc = desc_m.group(1).strip()[:120]
111
+
112
+ entry = {
113
+ "title": title,
114
+ "doc_id": doc_id,
115
+ "description": desc,
116
+ "file": f,
117
+ "category": classify(api_name) if api_name else "其他",
118
+ }
119
+
120
+ if api_name:
121
+ # 重复 key 冲突:保留 doc_id 较小的(通常是 A 股 / 主版本)
122
+ if api_name in api_index:
123
+ existing = api_index[api_name]
124
+ if doc_id < existing["doc_id"]:
125
+ # 新条目是主版本,将旧条目用 title 后缀做别名
126
+ alias = f"{api_name}_{existing['file'][5:-3].split('_', 1)[-1]}" if '_' in existing['file'] else f"{api_name}_{existing['doc_id']}"
127
+ # 简化: 用类别区分
128
+ alias = f"{api_name}__{''.join(existing['title'].split()[:2])}"
129
+ api_index[alias] = existing
130
+ api_index[api_name] = entry
131
+ else:
132
+ alias = f"{api_name}__{''.join(title.split()[:2])}"
133
+ api_index[alias] = entry
134
+ else:
135
+ api_index[api_name] = entry
136
+ else:
137
+ api_index[f"_doc_{doc_id}"] = entry
138
+
139
+ out_path = os.path.join(docs_dir, "_api_index.json")
140
+ with open(out_path, "w", encoding="utf-8") as fh:
141
+ json.dump(api_index, fh, ensure_ascii=False, indent=2)
142
+
143
+ # 统计
144
+ cats = {}
145
+ for k, v in api_index.items():
146
+ c = v.get("category", "其他")
147
+ cats[c] = cats.get(c, 0) + 1
148
+
149
+ print(f"索引已生成: {len(api_index)} 个条目 -> {out_path}")
150
+ print(f"\n分类统计:")
151
+ for c in sorted(cats, key=lambda x: -cats[x]):
152
+ print(f" {c:12s}: {cats[c]} 个")
153
+
154
+ # 显示冲突处理结果
155
+ print(f"\n别名条目 (冲突解决):")
156
+ for k in sorted(api_index):
157
+ if "__" in k:
158
+ v = api_index[k]
159
+ print(f" {k:40s} -> {v['title']} (doc_id={v['doc_id']})")