@sentry/mcp-server 0.21.0 → 0.22.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 (387) hide show
  1. package/dist/{agent-vFXI2vu1.js → agent-0WAnUgat.js} +7 -7
  2. package/dist/agent-0WAnUgat.js.map +1 -0
  3. package/dist/{agent-CuX9zpZq.d.ts → agent-BeTXxskw.d.ts} +12 -11
  4. package/dist/agent-BeTXxskw.d.ts.map +1 -0
  5. package/dist/{agent-_VPpnFmn.d.cts → agent-Bm5Hsfal.d.cts} +2 -2
  6. package/dist/{agent-_VPpnFmn.d.cts.map → agent-Bm5Hsfal.d.cts.map} +1 -1
  7. package/dist/{agent-CvjnNjVl.js → agent-C1Ros3Xx.js} +2 -2
  8. package/dist/{agent-CvjnNjVl.js.map → agent-C1Ros3Xx.js.map} +1 -1
  9. package/dist/{agent-BIhLK0w6.d.ts → agent-CJ6SVqAB.d.ts} +2 -2
  10. package/dist/{agent-BIhLK0w6.d.ts.map → agent-CJ6SVqAB.d.ts.map} +1 -1
  11. package/dist/{agent-DOraNng-.cjs → agent-Cm9hEq5d.cjs} +23 -13
  12. package/dist/agent-Cm9hEq5d.cjs.map +1 -0
  13. package/dist/{agent-CaZRIfIM.d.ts → agent-Cu85yHYm.d.ts} +25 -24
  14. package/dist/agent-Cu85yHYm.d.ts.map +1 -0
  15. package/dist/{agent-Bgg6nor6.cjs → agent-CyyRLYbF.cjs} +15 -9
  16. package/dist/agent-CyyRLYbF.cjs.map +1 -0
  17. package/dist/{agent-WO6BpLta.d.cts → agent-DYfi9MFV.d.cts} +29 -28
  18. package/dist/agent-DYfi9MFV.d.cts.map +1 -0
  19. package/dist/{agent-CzjC0wP8.js → agent-Dkgkv7Iz.js} +14 -10
  20. package/dist/agent-Dkgkv7Iz.js.map +1 -0
  21. package/dist/{agent-pad5p0Xr.cjs → agent-DtCRTWPZ.cjs} +3 -3
  22. package/dist/{agent-pad5p0Xr.cjs.map → agent-DtCRTWPZ.cjs.map} +1 -1
  23. package/dist/{agent-BePwIb80.d.cts → agent-TEZG63ug.d.cts} +12 -11
  24. package/dist/agent-TEZG63ug.d.cts.map +1 -0
  25. package/dist/{analyze-issue-with-seer-DHxMOCaf.cjs → analyze-issue-with-seer-B90r4g5J.cjs} +4 -4
  26. package/dist/{analyze-issue-with-seer-DHxMOCaf.cjs.map → analyze-issue-with-seer-B90r4g5J.cjs.map} +1 -1
  27. package/dist/{analyze-issue-with-seer-iXBAIlQL.js → analyze-issue-with-seer-Ji3KDm0O.js} +2 -2
  28. package/dist/{analyze-issue-with-seer-iXBAIlQL.js.map → analyze-issue-with-seer-Ji3KDm0O.js.map} +1 -1
  29. package/dist/{api-Cozv5F92.js → api-CBHyxA3Q.js} +2 -2
  30. package/dist/{api-Cozv5F92.js.map → api-CBHyxA3Q.js.map} +1 -1
  31. package/dist/{api-BkWv0o1h.cjs → api-CHgBJOv9.cjs} +2 -2
  32. package/dist/{api-BkWv0o1h.cjs.map → api-CHgBJOv9.cjs.map} +1 -1
  33. package/dist/api-client/client.cjs +4 -4
  34. package/dist/api-client/client.d.cts +3 -3
  35. package/dist/api-client/client.d.ts +3 -3
  36. package/dist/api-client/client.js +2 -2
  37. package/dist/api-client/index.cjs +4 -4
  38. package/dist/api-client/index.d.cts +3 -3
  39. package/dist/api-client/index.d.ts +3 -3
  40. package/dist/api-client/index.js +2 -2
  41. package/dist/api-client/schema.cjs +1 -1
  42. package/dist/api-client/schema.d.cts +1 -1
  43. package/dist/api-client/schema.d.ts +1 -1
  44. package/dist/api-client/types.d.cts +2 -2
  45. package/dist/api-client/types.d.ts +2 -2
  46. package/dist/{callEmbeddedAgent-B24rpPzZ.d.cts → callEmbeddedAgent-BIfQ-_5T.d.ts} +4 -4
  47. package/dist/callEmbeddedAgent-BIfQ-_5T.d.ts.map +1 -0
  48. package/dist/{callEmbeddedAgent-xTPNMk8s.cjs → callEmbeddedAgent-BPS472yg.cjs} +9 -4
  49. package/dist/callEmbeddedAgent-BPS472yg.cjs.map +1 -0
  50. package/dist/{callEmbeddedAgent-Dk48A2gz.d.ts → callEmbeddedAgent-CFHLQjFx.d.cts} +4 -4
  51. package/dist/callEmbeddedAgent-CFHLQjFx.d.cts.map +1 -0
  52. package/dist/{callEmbeddedAgent-B51_9ycP.js → callEmbeddedAgent-DavTx3Qo.js} +8 -3
  53. package/dist/callEmbeddedAgent-DavTx3Qo.js.map +1 -0
  54. package/dist/{chunk-DWy1uDak.cjs → chunk-CUT6urMc.cjs} +0 -9
  55. package/dist/cli/parse.cjs +1 -1
  56. package/dist/{client-DeGFkGAD.d.cts → client-0n2-4zOO.d.cts} +7 -7
  57. package/dist/{client-DeGFkGAD.d.cts.map → client-0n2-4zOO.d.cts.map} +1 -1
  58. package/dist/{client-BSlwJcxe.js → client-B7hvqupZ.js} +2 -2
  59. package/dist/{client-BSlwJcxe.js.map → client-B7hvqupZ.js.map} +1 -1
  60. package/dist/{client-D1Oq6Udl.d.ts → client-ByOC8aCf.d.ts} +9 -9
  61. package/dist/{client-D1Oq6Udl.d.ts.map → client-ByOC8aCf.d.ts.map} +1 -1
  62. package/dist/{client-DlJ_23xq.cjs → client-cC79LUJ5.cjs} +4 -4
  63. package/dist/{client-DlJ_23xq.cjs.map → client-cC79LUJ5.cjs.map} +1 -1
  64. package/dist/{create-dsn-erDvHRvv.cjs → create-dsn-9yIHr10B.cjs} +4 -4
  65. package/dist/{create-dsn-erDvHRvv.cjs.map → create-dsn-9yIHr10B.cjs.map} +1 -1
  66. package/dist/{create-dsn-CzaN7V1p.js → create-dsn-p2Ep6zDn.js} +2 -2
  67. package/dist/{create-dsn-CzaN7V1p.js.map → create-dsn-p2Ep6zDn.js.map} +1 -1
  68. package/dist/{create-project-B9dyzzyz.cjs → create-project-BQQx1iLm.cjs} +5 -5
  69. package/dist/{create-project-B9dyzzyz.cjs.map → create-project-BQQx1iLm.cjs.map} +1 -1
  70. package/dist/{create-project-BvmA3Xm7.js → create-project-CN0UneBm.js} +2 -2
  71. package/dist/{create-project-BvmA3Xm7.js.map → create-project-CN0UneBm.js.map} +1 -1
  72. package/dist/{create-team-Bb0ajRQO.js → create-team-CzFrsVdw.js} +2 -2
  73. package/dist/{create-team-Bb0ajRQO.js.map → create-team-CzFrsVdw.js.map} +1 -1
  74. package/dist/{create-team-CWC7s6TS.cjs → create-team-DFSriKVL.cjs} +4 -4
  75. package/dist/{create-team-CWC7s6TS.cjs.map → create-team-DFSriKVL.cjs.map} +1 -1
  76. package/dist/{dataset-fields-Bo9Nbtdn.cjs → dataset-fields-Bp_g-sD6.cjs} +3 -3
  77. package/dist/{dataset-fields-Bo9Nbtdn.cjs.map → dataset-fields-Bp_g-sD6.cjs.map} +1 -1
  78. package/dist/{error-handling-19djRJdh.cjs → error-handling-FGjcJT8U.cjs} +2 -2
  79. package/dist/{error-handling-19djRJdh.cjs.map → error-handling-FGjcJT8U.cjs.map} +1 -1
  80. package/dist/{find-dsns-Bqafhzp5.js → find-dsns-BzfYjE06.js} +2 -2
  81. package/dist/{find-dsns-Bqafhzp5.js.map → find-dsns-BzfYjE06.js.map} +1 -1
  82. package/dist/{find-dsns-MMdOXURp.cjs → find-dsns-DhHHtvpj.cjs} +4 -4
  83. package/dist/{find-dsns-MMdOXURp.cjs.map → find-dsns-DhHHtvpj.cjs.map} +1 -1
  84. package/dist/{find-organizations-D80maEbK.cjs → find-organizations-7ooGnnmP.cjs} +3 -3
  85. package/dist/{find-organizations-D80maEbK.cjs.map → find-organizations-7ooGnnmP.cjs.map} +1 -1
  86. package/dist/{find-organizations-DV7Za1d0.js → find-organizations-BJFAElbh.js} +2 -2
  87. package/dist/{find-organizations-DV7Za1d0.js.map → find-organizations-BJFAElbh.js.map} +1 -1
  88. package/dist/{find-projects-KrMwC18K.cjs → find-projects-BpEGRZya.cjs} +4 -4
  89. package/dist/{find-projects-KrMwC18K.cjs.map → find-projects-BpEGRZya.cjs.map} +1 -1
  90. package/dist/{find-projects-Dcqw9Vyi.js → find-projects-E5CMFbwU.js} +2 -2
  91. package/dist/{find-projects-Dcqw9Vyi.js.map → find-projects-E5CMFbwU.js.map} +1 -1
  92. package/dist/{find-releases-CHDuNU2z.js → find-releases-DWWonhlV.js} +2 -2
  93. package/dist/{find-releases-CHDuNU2z.js.map → find-releases-DWWonhlV.js.map} +1 -1
  94. package/dist/{find-releases-BPS53QTy.cjs → find-releases-Du5euXKS.cjs} +4 -4
  95. package/dist/{find-releases-BPS53QTy.cjs.map → find-releases-Du5euXKS.cjs.map} +1 -1
  96. package/dist/{find-teams-DPdnW18Q.js → find-teams-BM4yWKe_.js} +2 -2
  97. package/dist/{find-teams-DPdnW18Q.js.map → find-teams-BM4yWKe_.js.map} +1 -1
  98. package/dist/{find-teams-DFl7ESVe.cjs → find-teams-Bp6-Iu62.cjs} +4 -4
  99. package/dist/{find-teams-DFl7ESVe.cjs.map → find-teams-Bp6-Iu62.cjs.map} +1 -1
  100. package/dist/{formatters-Bb4El3CZ.cjs → formatters-B6H5qTFe.cjs} +2 -2
  101. package/dist/{formatters-Bb4El3CZ.cjs.map → formatters-B6H5qTFe.cjs.map} +1 -1
  102. package/dist/{formatters-Bta1mFce.cjs → formatters-ObdzRwld.cjs} +3 -3
  103. package/dist/{formatters-Bta1mFce.cjs.map → formatters-ObdzRwld.cjs.map} +1 -1
  104. package/dist/{formatting-BWMTp6lM.d.cts → formatting-Bw0FWiCH.d.cts} +4 -4
  105. package/dist/{formatting-BWMTp6lM.d.cts.map → formatting-Bw0FWiCH.d.cts.map} +1 -1
  106. package/dist/{formatting-CSkVn9rJ.d.ts → formatting-ClM7RU4L.d.ts} +4 -4
  107. package/dist/{formatting-CSkVn9rJ.d.ts.map → formatting-ClM7RU4L.d.ts.map} +1 -1
  108. package/dist/{get-doc-CGOI0C0A.js → get-doc-CWhlUoJe.js} +2 -2
  109. package/dist/{get-doc-CGOI0C0A.js.map → get-doc-CWhlUoJe.js.map} +1 -1
  110. package/dist/{get-doc-BWKx48zK.cjs → get-doc-DsOaSMIe.cjs} +3 -3
  111. package/dist/{get-doc-BWKx48zK.cjs.map → get-doc-DsOaSMIe.cjs.map} +1 -1
  112. package/dist/{get-event-attachment-CMPD67lQ.cjs → get-event-attachment-CTF-k6op.cjs} +4 -4
  113. package/dist/{get-event-attachment-CMPD67lQ.cjs.map → get-event-attachment-CTF-k6op.cjs.map} +1 -1
  114. package/dist/{get-event-attachment-C5nefGca.js → get-event-attachment-DDvsu6IQ.js} +2 -2
  115. package/dist/{get-event-attachment-C5nefGca.js.map → get-event-attachment-DDvsu6IQ.js.map} +1 -1
  116. package/dist/{get-issue-details-y1io-npG.js → get-issue-details-Bsax2jTY.js} +2 -2
  117. package/dist/{get-issue-details-y1io-npG.js.map → get-issue-details-Bsax2jTY.js.map} +1 -1
  118. package/dist/{get-issue-details-BxJ_lQN8.cjs → get-issue-details-CIZSksmd.cjs} +5 -5
  119. package/dist/{get-issue-details-BxJ_lQN8.cjs.map → get-issue-details-CIZSksmd.cjs.map} +1 -1
  120. package/dist/{get-trace-details-C9gJYPip.cjs → get-trace-details-Bc9GgkSs.cjs} +4 -4
  121. package/dist/{get-trace-details-C9gJYPip.cjs.map → get-trace-details-Bc9GgkSs.cjs.map} +1 -1
  122. package/dist/{get-trace-details-BOBNimN0.js → get-trace-details-Bkilw5oH.js} +2 -2
  123. package/dist/{get-trace-details-BOBNimN0.js.map → get-trace-details-Bkilw5oH.js.map} +1 -1
  124. package/dist/{handler-CU9ZxaP9.d.ts → handler-CASDrJ7z.d.ts} +3 -3
  125. package/dist/{handler-CU9ZxaP9.d.ts.map → handler-CASDrJ7z.d.ts.map} +1 -1
  126. package/dist/{handler-7ABtxyRG.d.cts → handler-CZEMKP9p.d.cts} +3 -3
  127. package/dist/{handler-7ABtxyRG.d.cts.map → handler-CZEMKP9p.d.cts.map} +1 -1
  128. package/dist/{handler-L0cEG-0-.cjs → handler-ChOaafS-.cjs} +8 -8
  129. package/dist/handler-ChOaafS-.cjs.map +1 -0
  130. package/dist/{handler-FxM1t6Wf.d.cts → handler-CmTBmIt9.d.cts} +3 -3
  131. package/dist/{handler-FxM1t6Wf.d.cts.map → handler-CmTBmIt9.d.cts.map} +1 -1
  132. package/dist/{handler-BDPbWDvJ.d.ts → handler-Cs5DcdpF.d.ts} +3 -3
  133. package/dist/{handler-BDPbWDvJ.d.ts.map → handler-Cs5DcdpF.d.ts.map} +1 -1
  134. package/dist/{handler-CK_gY4IH.cjs → handler-DQbc5eAJ.cjs} +9 -9
  135. package/dist/handler-DQbc5eAJ.cjs.map +1 -0
  136. package/dist/{handler-Dv8J_Uro.js → handler-bf2qu8DQ.js} +5 -5
  137. package/dist/handler-bf2qu8DQ.js.map +1 -0
  138. package/dist/{handler-DdgXX0YP.js → handler-y6EMhG0y.js} +5 -5
  139. package/dist/handler-y6EMhG0y.js.map +1 -0
  140. package/dist/index.cjs +44 -44
  141. package/dist/index.js +29 -29
  142. package/dist/internal/agents/callEmbeddedAgent.cjs +4 -3
  143. package/dist/internal/agents/callEmbeddedAgent.d.cts +1 -1
  144. package/dist/internal/agents/callEmbeddedAgent.d.ts +1 -1
  145. package/dist/internal/agents/callEmbeddedAgent.js +4 -3
  146. package/dist/internal/agents/openai-provider.cjs +2 -2
  147. package/dist/internal/agents/openai-provider.js +2 -2
  148. package/dist/internal/agents/tools/dataset-fields.cjs +6 -6
  149. package/dist/internal/agents/tools/dataset-fields.d.cts +7 -7
  150. package/dist/internal/agents/tools/dataset-fields.d.ts +7 -7
  151. package/dist/internal/agents/tools/dataset-fields.d.ts.map +1 -1
  152. package/dist/internal/agents/tools/dataset-fields.js +2 -2
  153. package/dist/internal/agents/tools/otel-semantics.cjs +6 -6
  154. package/dist/internal/agents/tools/otel-semantics.d.cts +7 -7
  155. package/dist/internal/agents/tools/otel-semantics.d.ts +7 -7
  156. package/dist/internal/agents/tools/otel-semantics.d.ts.map +1 -1
  157. package/dist/internal/agents/tools/otel-semantics.js +2 -2
  158. package/dist/internal/agents/tools/utils.cjs +5 -5
  159. package/dist/internal/agents/tools/utils.d.cts +1 -1
  160. package/dist/internal/agents/tools/utils.d.ts +1 -1
  161. package/dist/internal/agents/tools/utils.js +2 -2
  162. package/dist/internal/agents/tools/whoami.cjs +6 -6
  163. package/dist/internal/agents/tools/whoami.d.cts +7 -7
  164. package/dist/internal/agents/tools/whoami.d.ts +7 -7
  165. package/dist/internal/agents/tools/whoami.d.ts.map +1 -1
  166. package/dist/internal/agents/tools/whoami.js +2 -2
  167. package/dist/internal/error-handling.cjs +5 -5
  168. package/dist/internal/error-handling.d.cts +3 -3
  169. package/dist/internal/error-handling.d.ts +3 -3
  170. package/dist/internal/error-handling.js +2 -2
  171. package/dist/internal/formatting.d.cts +4 -4
  172. package/dist/internal/formatting.d.ts +4 -4
  173. package/dist/internal/test-fixtures.d.cts +2 -2
  174. package/dist/internal/test-fixtures.d.ts +2 -2
  175. package/dist/internal/tool-helpers/api.cjs +5 -5
  176. package/dist/internal/tool-helpers/api.d.cts +3 -3
  177. package/dist/internal/tool-helpers/api.d.ts +3 -3
  178. package/dist/internal/tool-helpers/api.js +3 -3
  179. package/dist/internal/tool-helpers/enhance-error.cjs +4 -4
  180. package/dist/internal/tool-helpers/enhance-error.d.cts +3 -3
  181. package/dist/internal/tool-helpers/enhance-error.d.ts +3 -3
  182. package/dist/internal/tool-helpers/enhance-error.js +2 -2
  183. package/dist/internal/tool-helpers/formatting.d.cts +3 -3
  184. package/dist/internal/tool-helpers/formatting.d.ts +3 -3
  185. package/dist/internal/tool-helpers/issue.d.cts +4 -4
  186. package/dist/internal/tool-helpers/issue.d.ts +4 -4
  187. package/dist/internal/tool-helpers/seer.d.cts +3 -3
  188. package/dist/internal/tool-helpers/seer.d.ts +3 -3
  189. package/dist/{logging-DrbQ8weU.cjs → logging-C-ST7-Ow.cjs} +2 -2
  190. package/dist/{logging-DrbQ8weU.cjs.map → logging-C-ST7-Ow.cjs.map} +1 -1
  191. package/dist/{openai-provider-CdGMI-ue.cjs → openai-provider-B7uvGxoI.cjs} +3 -3
  192. package/dist/{openai-provider-CdGMI-ue.cjs.map → openai-provider-B7uvGxoI.cjs.map} +1 -1
  193. package/dist/{openai-provider-BpAFXVih.js → openai-provider-DphaqrmX.js} +2 -2
  194. package/dist/{openai-provider-BpAFXVih.js.map → openai-provider-DphaqrmX.js.map} +1 -1
  195. package/dist/{otel-semantics-CgF1PqFd.cjs → otel-semantics-n8_5Ib9C.cjs} +3 -3
  196. package/dist/{otel-semantics-CgF1PqFd.cjs.map → otel-semantics-n8_5Ib9C.cjs.map} +1 -1
  197. package/dist/{parse-vgBG5mXu.cjs → parse-Br-BwKdT.cjs} +2 -2
  198. package/dist/{parse-vgBG5mXu.cjs.map → parse-Br-BwKdT.cjs.map} +1 -1
  199. package/dist/{schema-DUU4CA0j.cjs → schema-BGVOjcD7.cjs} +3 -3
  200. package/dist/{schema-DUU4CA0j.cjs.map → schema-BGVOjcD7.cjs.map} +1 -1
  201. package/dist/{schema-Y6BzAUmc.d.cts → schema-Cp8XI7-D.d.ts} +347 -347
  202. package/dist/schema-Cp8XI7-D.d.ts.map +1 -0
  203. package/dist/{schema-xBO557xH.d.ts → schema-D5oT-Zi7.d.cts} +285 -285
  204. package/dist/{schema-Y6BzAUmc.d.cts.map → schema-D5oT-Zi7.d.cts.map} +1 -1
  205. package/dist/{schema-CGiILhan.cjs → schema-DE4JpUSi.cjs} +2 -2
  206. package/dist/{schema-CGiILhan.cjs.map → schema-DE4JpUSi.cjs.map} +1 -1
  207. package/dist/schema.cjs +2 -2
  208. package/dist/{search-docs-Da7cAz8X.cjs → search-docs-DdOFZY3t.cjs} +3 -3
  209. package/dist/{search-docs-Da7cAz8X.cjs.map → search-docs-DdOFZY3t.cjs.map} +1 -1
  210. package/dist/{server-KMgWcsoE.cjs → server-BQBA0VNe.cjs} +25 -25
  211. package/dist/{server-KMgWcsoE.cjs.map → server-BQBA0VNe.cjs.map} +1 -1
  212. package/dist/{server-BaovxxmS.js → server-BVqPcPfx.js} +21 -21
  213. package/dist/{server-BaovxxmS.js.map → server-BVqPcPfx.js.map} +1 -1
  214. package/dist/server.cjs +40 -40
  215. package/dist/server.js +27 -27
  216. package/dist/{slug-validation-ByuBdbX_.cjs → slug-validation-D5VJqMwH.cjs} +2 -2
  217. package/dist/{slug-validation-ByuBdbX_.cjs.map → slug-validation-D5VJqMwH.cjs.map} +1 -1
  218. package/dist/{stdio-pNGJyuki.cjs → stdio-DPvrKLnJ.cjs} +3 -3
  219. package/dist/{stdio-pNGJyuki.cjs.map → stdio-DPvrKLnJ.cjs.map} +1 -1
  220. package/dist/{stdio-DHijjrp9.js → stdio-YKMCj_QV.js} +2 -2
  221. package/dist/{stdio-DHijjrp9.js.map → stdio-YKMCj_QV.js.map} +1 -1
  222. package/dist/telem/index.cjs +1 -1
  223. package/dist/telem/logging.cjs +1 -1
  224. package/dist/test-setup.cjs +3 -51873
  225. package/dist/test-setup.cjs.map +1 -1
  226. package/dist/test-setup.js +1 -51899
  227. package/dist/test-setup.js.map +1 -1
  228. package/dist/tools/analyze-issue-with-seer.cjs +8 -8
  229. package/dist/tools/analyze-issue-with-seer.js +4 -4
  230. package/dist/tools/create-dsn.cjs +8 -8
  231. package/dist/tools/create-dsn.js +4 -4
  232. package/dist/tools/create-project.cjs +8 -8
  233. package/dist/tools/create-project.js +4 -4
  234. package/dist/tools/create-team.cjs +8 -8
  235. package/dist/tools/create-team.js +4 -4
  236. package/dist/tools/find-dsns.cjs +8 -8
  237. package/dist/tools/find-dsns.d.cts +4 -4
  238. package/dist/tools/find-dsns.d.ts +4 -4
  239. package/dist/tools/find-dsns.js +4 -4
  240. package/dist/tools/find-organizations.cjs +8 -8
  241. package/dist/tools/find-organizations.d.cts +2 -2
  242. package/dist/tools/find-organizations.d.ts +2 -2
  243. package/dist/tools/find-organizations.js +4 -4
  244. package/dist/tools/find-projects.cjs +8 -8
  245. package/dist/tools/find-projects.d.cts +4 -4
  246. package/dist/tools/find-projects.d.ts +4 -4
  247. package/dist/tools/find-projects.js +4 -4
  248. package/dist/tools/find-releases.cjs +8 -8
  249. package/dist/tools/find-releases.js +4 -4
  250. package/dist/tools/find-teams.cjs +8 -8
  251. package/dist/tools/find-teams.d.cts +4 -4
  252. package/dist/tools/find-teams.d.ts +4 -4
  253. package/dist/tools/find-teams.js +4 -4
  254. package/dist/tools/get-doc.cjs +5 -5
  255. package/dist/tools/get-doc.js +3 -3
  256. package/dist/tools/get-event-attachment.cjs +8 -8
  257. package/dist/tools/get-event-attachment.d.cts +6 -6
  258. package/dist/tools/get-event-attachment.d.ts +6 -6
  259. package/dist/tools/get-event-attachment.js +4 -4
  260. package/dist/tools/get-issue-details.cjs +8 -8
  261. package/dist/tools/get-issue-details.js +4 -4
  262. package/dist/tools/get-trace-details.cjs +8 -8
  263. package/dist/tools/get-trace-details.d.cts +4 -4
  264. package/dist/tools/get-trace-details.d.ts +4 -4
  265. package/dist/tools/get-trace-details.js +4 -4
  266. package/dist/tools/index.cjs +40 -40
  267. package/dist/tools/index.d.cts +76 -76
  268. package/dist/tools/index.d.ts +76 -76
  269. package/dist/tools/index.js +27 -27
  270. package/dist/tools/search-docs.cjs +7 -7
  271. package/dist/tools/search-docs.js +2 -2
  272. package/dist/tools/search-events/agent.cjs +13 -12
  273. package/dist/tools/search-events/agent.d.cts +5 -5
  274. package/dist/tools/search-events/agent.d.ts +5 -5
  275. package/dist/tools/search-events/agent.js +6 -6
  276. package/dist/tools/search-events/formatters.cjs +7 -7
  277. package/dist/tools/search-events/formatters.d.cts +5 -5
  278. package/dist/tools/search-events/formatters.d.ts +5 -5
  279. package/dist/tools/search-events/formatters.js +2 -2
  280. package/dist/tools/search-events/handler.cjs +16 -16
  281. package/dist/tools/search-events/handler.d.cts +1 -1
  282. package/dist/tools/search-events/handler.d.ts +1 -1
  283. package/dist/tools/search-events/handler.js +7 -7
  284. package/dist/tools/search-events/index.cjs +16 -16
  285. package/dist/tools/search-events/index.d.cts +5 -5
  286. package/dist/tools/search-events/index.d.ts +5 -5
  287. package/dist/tools/search-events/index.js +7 -7
  288. package/dist/tools/search-events/utils.cjs +6 -6
  289. package/dist/tools/search-events/utils.d.cts +5 -5
  290. package/dist/tools/search-events/utils.d.ts +5 -5
  291. package/dist/tools/search-events/utils.js +2 -2
  292. package/dist/tools/search-issues/agent.cjs +12 -11
  293. package/dist/tools/search-issues/agent.d.cts +5 -5
  294. package/dist/tools/search-issues/agent.d.ts +5 -5
  295. package/dist/tools/search-issues/agent.js +6 -6
  296. package/dist/tools/search-issues/formatters.cjs +1 -1
  297. package/dist/tools/search-issues/formatters.d.cts +3 -3
  298. package/dist/tools/search-issues/formatters.d.ts +3 -3
  299. package/dist/tools/search-issues/handler.cjs +15 -15
  300. package/dist/tools/search-issues/handler.d.cts +1 -1
  301. package/dist/tools/search-issues/handler.d.ts +1 -1
  302. package/dist/tools/search-issues/handler.js +7 -7
  303. package/dist/tools/search-issues/index.cjs +15 -15
  304. package/dist/tools/search-issues/index.d.cts +5 -5
  305. package/dist/tools/search-issues/index.d.ts +5 -5
  306. package/dist/tools/search-issues/index.js +7 -7
  307. package/dist/tools/update-issue.cjs +8 -8
  308. package/dist/tools/update-issue.d.cts +7 -7
  309. package/dist/tools/update-issue.d.ts +7 -7
  310. package/dist/tools/update-issue.js +4 -4
  311. package/dist/tools/update-project.cjs +8 -8
  312. package/dist/tools/update-project.js +4 -4
  313. package/dist/tools/use-sentry/agent.cjs +4 -4
  314. package/dist/tools/use-sentry/agent.d.cts +2 -2
  315. package/dist/tools/use-sentry/agent.d.ts +2 -2
  316. package/dist/tools/use-sentry/agent.js +4 -4
  317. package/dist/tools/use-sentry/handler.cjs +40 -40
  318. package/dist/tools/use-sentry/handler.js +27 -27
  319. package/dist/tools/use-sentry/index.cjs +40 -40
  320. package/dist/tools/use-sentry/index.d.cts +2 -2
  321. package/dist/tools/use-sentry/index.d.ts +2 -2
  322. package/dist/tools/use-sentry/index.js +27 -27
  323. package/dist/tools/use-sentry/tool-wrapper.cjs +6 -6
  324. package/dist/tools/use-sentry/tool-wrapper.d.cts +6 -6
  325. package/dist/tools/use-sentry/tool-wrapper.d.ts +6 -6
  326. package/dist/tools/use-sentry/tool-wrapper.d.ts.map +1 -1
  327. package/dist/tools/use-sentry/tool-wrapper.js +2 -2
  328. package/dist/tools/whoami.cjs +6 -6
  329. package/dist/tools/whoami.js +4 -4
  330. package/dist/transports/stdio.cjs +2 -2
  331. package/dist/transports/stdio.js +2 -2
  332. package/dist/{types-CLI02LNZ.d.cts → types-CZI-5yyV.d.cts} +2 -2
  333. package/dist/{types-CLI02LNZ.d.cts.map → types-CZI-5yyV.d.cts.map} +1 -1
  334. package/dist/{types-DA9C6AdF.d.ts → types-WcBA7ZSQ.d.ts} +2 -2
  335. package/dist/{types-DA9C6AdF.d.ts.map → types-WcBA7ZSQ.d.ts.map} +1 -1
  336. package/dist/{update-issue-B9Y1Qftw.js → update-issue-B35n8MDT.js} +2 -2
  337. package/dist/{update-issue-B9Y1Qftw.js.map → update-issue-B35n8MDT.js.map} +1 -1
  338. package/dist/{update-issue-ADk9Bl3r.cjs → update-issue-DOVD2zXD.cjs} +4 -4
  339. package/dist/{update-issue-ADk9Bl3r.cjs.map → update-issue-DOVD2zXD.cjs.map} +1 -1
  340. package/dist/{update-project-CoVoAlvN.js → update-project-D361nWlU.js} +2 -2
  341. package/dist/{update-project-CoVoAlvN.js.map → update-project-D361nWlU.js.map} +1 -1
  342. package/dist/{update-project-CanU1PTp.cjs → update-project-DG3bwhNA.cjs} +5 -5
  343. package/dist/{update-project-CanU1PTp.cjs.map → update-project-DG3bwhNA.cjs.map} +1 -1
  344. package/dist/utils/slug-validation.cjs +1 -1
  345. package/dist/{utils-DfYLsLqN.d.cts → utils-Bzaer0D1.d.ts} +4 -4
  346. package/dist/utils-Bzaer0D1.d.ts.map +1 -0
  347. package/dist/{utils-Cv3R2iOS.d.cts → utils-C5oiuqkh.d.cts} +6 -6
  348. package/dist/{utils-Cv3R2iOS.d.cts.map → utils-C5oiuqkh.d.cts.map} +1 -1
  349. package/dist/{utils-_4aPBcrG.d.ts → utils-CAWsA9Cl.d.cts} +4 -4
  350. package/dist/{utils-DfYLsLqN.d.cts.map → utils-CAWsA9Cl.d.cts.map} +1 -1
  351. package/dist/{utils-Cr15-6aW.cjs → utils-CIt6Amml.cjs} +3 -3
  352. package/dist/{utils-Cr15-6aW.cjs.map → utils-CIt6Amml.cjs.map} +1 -1
  353. package/dist/{utils-Cj4NLgWf.d.ts → utils-CrKFhSC3.d.ts} +6 -6
  354. package/dist/{utils-Cj4NLgWf.d.ts.map → utils-CrKFhSC3.d.ts.map} +1 -1
  355. package/dist/{utils-B4iBngk1.cjs → utils-DJIwl8YR.cjs} +3 -3
  356. package/dist/{utils-B4iBngk1.cjs.map → utils-DJIwl8YR.cjs.map} +1 -1
  357. package/dist/{version-HXEfly4U.js → version-CCICHYna.js} +2 -2
  358. package/dist/{version-HXEfly4U.js.map → version-CCICHYna.js.map} +1 -1
  359. package/dist/{version-DZBMB6XD.cjs → version-CPcX-30c.cjs} +2 -2
  360. package/dist/{version-DZBMB6XD.cjs.map → version-CPcX-30c.cjs.map} +1 -1
  361. package/dist/version.cjs +1 -1
  362. package/dist/version.js +1 -1
  363. package/dist/{whoami-DcSsmS02.cjs → whoami-9JymZ3NV.cjs} +3 -3
  364. package/dist/{whoami-DcSsmS02.cjs.map → whoami-9JymZ3NV.cjs.map} +1 -1
  365. package/dist/{whoami-CZ02abcM.cjs → whoami-CRF9Ws25.cjs} +2 -2
  366. package/dist/{whoami-CZ02abcM.cjs.map → whoami-CRF9Ws25.cjs.map} +1 -1
  367. package/dist/{whoami-Cbo082cU.js → whoami-DCZN-m7R.js} +2 -2
  368. package/dist/{whoami-Cbo082cU.js.map → whoami-DCZN-m7R.js.map} +1 -1
  369. package/package.json +5 -4
  370. package/dist/agent-BePwIb80.d.cts.map +0 -1
  371. package/dist/agent-Bgg6nor6.cjs.map +0 -1
  372. package/dist/agent-CaZRIfIM.d.ts.map +0 -1
  373. package/dist/agent-CuX9zpZq.d.ts.map +0 -1
  374. package/dist/agent-CzjC0wP8.js.map +0 -1
  375. package/dist/agent-DOraNng-.cjs.map +0 -1
  376. package/dist/agent-WO6BpLta.d.cts.map +0 -1
  377. package/dist/agent-vFXI2vu1.js.map +0 -1
  378. package/dist/callEmbeddedAgent-B24rpPzZ.d.cts.map +0 -1
  379. package/dist/callEmbeddedAgent-B51_9ycP.js.map +0 -1
  380. package/dist/callEmbeddedAgent-Dk48A2gz.d.ts.map +0 -1
  381. package/dist/callEmbeddedAgent-xTPNMk8s.cjs.map +0 -1
  382. package/dist/handler-CK_gY4IH.cjs.map +0 -1
  383. package/dist/handler-DdgXX0YP.js.map +0 -1
  384. package/dist/handler-Dv8J_Uro.js.map +0 -1
  385. package/dist/handler-L0cEG-0-.cjs.map +0 -1
  386. package/dist/schema-xBO557xH.d.ts.map +0 -1
  387. package/dist/utils-_4aPBcrG.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"get-issue-details-y1io-npG.js","names":["context: ServerContext","orgSlug","issue","event: Awaited<ReturnType<typeof apiService.getEventForIssue>>","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","performanceTrace","issue: Awaited<ReturnType<typeof apiService.getIssue>>","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","event: Event"],"sources":["../src/tools/get-issue-details.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport {\n parseIssueParams,\n formatIssueOutput,\n} from \"../internal/tool-helpers/issue\";\nimport { enhanceNotFoundError } from \"../internal/tool-helpers/enhance-error\";\nimport { ApiNotFoundError } from \"../api-client\";\nimport type { SentryApiService } from \"../api-client\";\nimport type {\n Event,\n ErrorEvent,\n DefaultEvent,\n TransactionEvent,\n Trace,\n} from \"../api-client/types\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport { logError } from \"../telem/logging\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamIssueShortId,\n ParamIssueUrl,\n} from \"../schema\";\n\nexport default defineTool({\n name: \"get_issue_details\",\n requiredSkills: [\"inspect\", \"triage\", \"seer\"], // Available in inspect, triage, and seer skills\n requiredScopes: [\"event:read\"],\n description: [\n \"Get detailed information about a specific Sentry issue by ID.\",\n \"\",\n \"🔍 USE THIS TOOL WHEN USERS:\",\n \"- Provide a specific issue ID (e.g., 'CLOUDFLARE-MCP-41', 'PROJECT-123')\",\n \"- Ask to 'explain [ISSUE-ID]', 'tell me about [ISSUE-ID]'\",\n \"- Want details/stacktrace/analysis for a known issue\",\n \"- Provide a Sentry issue URL\",\n \"\",\n \"❌ DO NOT USE for:\",\n \"- General searching or listing issues (use search_issues)\",\n \"- Root cause analysis (use analyze_issue_with_seer)\",\n \"\",\n \"TRIGGER PATTERNS:\",\n \"- 'Explain ISSUE-123' → use get_issue_details\",\n \"- 'Tell me about PROJECT-456' → use get_issue_details\",\n \"- 'What happened in [issue URL]' → use get_issue_details\",\n \"\",\n \"<examples>\",\n \"### With Sentry URL (recommended - simplest approach)\",\n \"```\",\n \"get_issue_details(issueUrl='https://sentry.sentry.io/issues/6916805731/?project=4509062593708032&query=is%3Aunresolved')\",\n \"```\",\n \"\",\n \"### With issue ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', issueId='CLOUDFLARE-MCP-41')\",\n \"```\",\n \"\",\n \"### With event ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', eventId='c49541c747cb4d8aa3efb70ca5aba243')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- **IMPORTANT**: If user provides a Sentry URL, pass the ENTIRE URL to issueUrl parameter unchanged\",\n \"- When using issueUrl, all other parameters are automatically extracted - don't provide them separately\",\n \"- If using issueId (not URL), then organizationSlug is required\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug.optional(),\n regionUrl: ParamRegionUrl.optional(),\n issueId: ParamIssueShortId.optional(),\n eventId: z.string().trim().describe(\"The ID of the event.\").optional(),\n issueUrl: ParamIssueUrl.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n if (params.eventId) {\n const orgSlug = params.organizationSlug;\n const eventId = params.eventId; // Capture eventId for type safety\n if (!orgSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `eventId`\",\n );\n }\n\n setTag(\"organization.slug\", orgSlug);\n // API client will throw ApiClientError/ApiServerError which the MCP server wrapper handles\n const [issue] = await apiService.listIssues({\n organizationSlug: orgSlug,\n query: eventId,\n });\n if (!issue) {\n return `# Event Not Found\\n\\nNo issue found for Event ID: ${eventId}`;\n }\n // For this call, we might want to provide context if it fails\n let event: Awaited<ReturnType<typeof apiService.getEventForIssue>>;\n try {\n event = await apiService.getEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n } catch (error) {\n // Optionally enhance 404 errors with parameter context\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n }\n throw error;\n }\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n }\n\n // Validate that we have the minimum required parameters\n if (!params.issueUrl && !params.issueId) {\n throw new UserInputError(\n \"Either `issueId` or `issueUrl` must be provided\",\n );\n }\n\n if (!params.issueUrl && !params.organizationSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `issueId`\",\n );\n }\n\n const { organizationSlug: orgSlug, issueId: parsedIssueId } =\n parseIssueParams({\n organizationSlug: params.organizationSlug,\n issueId: params.issueId,\n issueUrl: params.issueUrl,\n });\n\n setTag(\"organization.slug\", orgSlug);\n\n // For the main issue lookup, provide parameter context on 404\n let issue: Awaited<ReturnType<typeof apiService.getIssue>>;\n try {\n issue = await apiService.getIssue({\n organizationSlug: orgSlug,\n issueId: parsedIssueId!,\n });\n } catch (error) {\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: parsedIssueId,\n });\n }\n throw error;\n }\n\n const event = await apiService.getLatestEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n },\n});\n\nasync function maybeFetchPerformanceTrace({\n apiService,\n organizationSlug,\n event,\n}: {\n apiService: SentryApiService;\n organizationSlug: string;\n event: Event;\n}): Promise<Trace | undefined> {\n const context = shouldFetchTraceForEvent(event);\n if (!context) {\n return undefined;\n }\n\n try {\n return await apiService.getTrace({\n organizationSlug,\n traceId: context.traceId,\n limit: 10000,\n });\n } catch (error) {\n logError(error);\n return undefined;\n }\n}\n\nfunction isErrorEvent(event: Event): event is ErrorEvent | DefaultEvent {\n // \"default\" type represents error events without exception data\n return event.type === \"error\" || event.type === \"default\";\n}\n\nfunction isTransactionEvent(event: Event): event is TransactionEvent {\n return event.type === \"transaction\";\n}\n\nfunction shouldFetchTraceForEvent(event: Event): { traceId: string } | null {\n // Only fetch traces for non-error events (transactions, profiling, etc.)\n if (isErrorEvent(event)) {\n return null;\n }\n\n // Check if we have a trace ID\n const traceId = event.contexts?.trace?.trace_id;\n\n if (typeof traceId !== \"string\" || traceId.length === 0) {\n return null;\n }\n\n return { traceId };\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,gCAAe,WAAW;CACxB,MAAM;CACN,gBAAgB;EAAC;EAAW;EAAU;CAAO;CAC7C,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkB,sBAAsB,UAAU;EAClD,WAAW,eAAe,UAAU;EACpC,SAAS,kBAAkB,UAAU;EACrC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,uBAAuB,CAAC,UAAU;EACtE,UAAU,cAAc,UAAU;CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAC5C,MAAM,aAAa,sBAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;AAEF,MAAI,OAAO,SAAS;GAClB,MAAMC,YAAU,OAAO;GACvB,MAAM,UAAU,OAAO;AACvB,QAAKA,UACH,OAAM,IAAI,eACR;AAIJ,UAAO,qBAAqBA,UAAQ;GAEpC,MAAM,CAACC,QAAM,GAAG,MAAM,WAAW,WAAW;IAC1C,kBAAkBD;IAClB,OAAO;GACR,EAAC;AACF,QAAKC,QAC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;EAED,MAAM,mBAAmB,MAAM,2BAA2B;GACxD;GACA,kBAAkB;GAClB;EACD,EAAC;AAEF,SAAO,kBAAkB;GACvB,kBAAkB;GAClB;GACA;GACA;GACA;GACA;EACD,EAAC;CACH;AACF,EAAC;AAEF,eAAe,2BAA2B,EACxC,YACA,kBACA,OAKD,EAA8B;CAC7B,MAAM,UAAU,yBAAyB,MAAM;AAC/C,MAAK,QACH;AAGF,KAAI;AACF,SAAO,MAAM,WAAW,SAAS;GAC/B;GACA,SAAS,QAAQ;GACjB,OAAO;EACR,EAAC;CACH,SAAQ,OAAO;AACd,WAAS,MAAM;AACf;CACD;AACF;AAED,SAAS,aAAaC,OAAkD;AAEtE,QAAO,MAAM,SAAS,WAAW,MAAM,SAAS;AACjD;AAMD,SAAS,yBAAyBA,OAA0C;AAE1E,KAAI,aAAa,MAAM,CACrB,QAAO;CAIT,MAAM,UAAU,MAAM,UAAU,OAAO;AAEvC,YAAW,YAAY,YAAY,QAAQ,WAAW,EACpD,QAAO;AAGT,QAAO,EAAE,QAAS;AACnB"}
1
+ {"version":3,"file":"get-issue-details-Bsax2jTY.js","names":["context: ServerContext","orgSlug","issue","event: Awaited<ReturnType<typeof apiService.getEventForIssue>>","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","performanceTrace","issue: Awaited<ReturnType<typeof apiService.getIssue>>","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","event: Event"],"sources":["../src/tools/get-issue-details.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport {\n parseIssueParams,\n formatIssueOutput,\n} from \"../internal/tool-helpers/issue\";\nimport { enhanceNotFoundError } from \"../internal/tool-helpers/enhance-error\";\nimport { ApiNotFoundError } from \"../api-client\";\nimport type { SentryApiService } from \"../api-client\";\nimport type {\n Event,\n ErrorEvent,\n DefaultEvent,\n TransactionEvent,\n Trace,\n} from \"../api-client/types\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport { logError } from \"../telem/logging\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamIssueShortId,\n ParamIssueUrl,\n} from \"../schema\";\n\nexport default defineTool({\n name: \"get_issue_details\",\n requiredSkills: [\"inspect\", \"triage\", \"seer\"], // Available in inspect, triage, and seer skills\n requiredScopes: [\"event:read\"],\n description: [\n \"Get detailed information about a specific Sentry issue by ID.\",\n \"\",\n \"🔍 USE THIS TOOL WHEN USERS:\",\n \"- Provide a specific issue ID (e.g., 'CLOUDFLARE-MCP-41', 'PROJECT-123')\",\n \"- Ask to 'explain [ISSUE-ID]', 'tell me about [ISSUE-ID]'\",\n \"- Want details/stacktrace/analysis for a known issue\",\n \"- Provide a Sentry issue URL\",\n \"\",\n \"❌ DO NOT USE for:\",\n \"- General searching or listing issues (use search_issues)\",\n \"- Root cause analysis (use analyze_issue_with_seer)\",\n \"\",\n \"TRIGGER PATTERNS:\",\n \"- 'Explain ISSUE-123' → use get_issue_details\",\n \"- 'Tell me about PROJECT-456' → use get_issue_details\",\n \"- 'What happened in [issue URL]' → use get_issue_details\",\n \"\",\n \"<examples>\",\n \"### With Sentry URL (recommended - simplest approach)\",\n \"```\",\n \"get_issue_details(issueUrl='https://sentry.sentry.io/issues/6916805731/?project=4509062593708032&query=is%3Aunresolved')\",\n \"```\",\n \"\",\n \"### With issue ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', issueId='CLOUDFLARE-MCP-41')\",\n \"```\",\n \"\",\n \"### With event ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', eventId='c49541c747cb4d8aa3efb70ca5aba243')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- **IMPORTANT**: If user provides a Sentry URL, pass the ENTIRE URL to issueUrl parameter unchanged\",\n \"- When using issueUrl, all other parameters are automatically extracted - don't provide them separately\",\n \"- If using issueId (not URL), then organizationSlug is required\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug.optional(),\n regionUrl: ParamRegionUrl.optional(),\n issueId: ParamIssueShortId.optional(),\n eventId: z.string().trim().describe(\"The ID of the event.\").optional(),\n issueUrl: ParamIssueUrl.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n if (params.eventId) {\n const orgSlug = params.organizationSlug;\n const eventId = params.eventId; // Capture eventId for type safety\n if (!orgSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `eventId`\",\n );\n }\n\n setTag(\"organization.slug\", orgSlug);\n // API client will throw ApiClientError/ApiServerError which the MCP server wrapper handles\n const [issue] = await apiService.listIssues({\n organizationSlug: orgSlug,\n query: eventId,\n });\n if (!issue) {\n return `# Event Not Found\\n\\nNo issue found for Event ID: ${eventId}`;\n }\n // For this call, we might want to provide context if it fails\n let event: Awaited<ReturnType<typeof apiService.getEventForIssue>>;\n try {\n event = await apiService.getEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n } catch (error) {\n // Optionally enhance 404 errors with parameter context\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n }\n throw error;\n }\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n }\n\n // Validate that we have the minimum required parameters\n if (!params.issueUrl && !params.issueId) {\n throw new UserInputError(\n \"Either `issueId` or `issueUrl` must be provided\",\n );\n }\n\n if (!params.issueUrl && !params.organizationSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `issueId`\",\n );\n }\n\n const { organizationSlug: orgSlug, issueId: parsedIssueId } =\n parseIssueParams({\n organizationSlug: params.organizationSlug,\n issueId: params.issueId,\n issueUrl: params.issueUrl,\n });\n\n setTag(\"organization.slug\", orgSlug);\n\n // For the main issue lookup, provide parameter context on 404\n let issue: Awaited<ReturnType<typeof apiService.getIssue>>;\n try {\n issue = await apiService.getIssue({\n organizationSlug: orgSlug,\n issueId: parsedIssueId!,\n });\n } catch (error) {\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: parsedIssueId,\n });\n }\n throw error;\n }\n\n const event = await apiService.getLatestEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n },\n});\n\nasync function maybeFetchPerformanceTrace({\n apiService,\n organizationSlug,\n event,\n}: {\n apiService: SentryApiService;\n organizationSlug: string;\n event: Event;\n}): Promise<Trace | undefined> {\n const context = shouldFetchTraceForEvent(event);\n if (!context) {\n return undefined;\n }\n\n try {\n return await apiService.getTrace({\n organizationSlug,\n traceId: context.traceId,\n limit: 10000,\n });\n } catch (error) {\n logError(error);\n return undefined;\n }\n}\n\nfunction isErrorEvent(event: Event): event is ErrorEvent | DefaultEvent {\n // \"default\" type represents error events without exception data\n return event.type === \"error\" || event.type === \"default\";\n}\n\nfunction isTransactionEvent(event: Event): event is TransactionEvent {\n return event.type === \"transaction\";\n}\n\nfunction shouldFetchTraceForEvent(event: Event): { traceId: string } | null {\n // Only fetch traces for non-error events (transactions, profiling, etc.)\n if (isErrorEvent(event)) {\n return null;\n }\n\n // Check if we have a trace ID\n const traceId = event.contexts?.trace?.trace_id;\n\n if (typeof traceId !== \"string\" || traceId.length === 0) {\n return null;\n }\n\n return { traceId };\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,gCAAe,WAAW;CACxB,MAAM;CACN,gBAAgB;EAAC;EAAW;EAAU;CAAO;CAC7C,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkB,sBAAsB,UAAU;EAClD,WAAW,eAAe,UAAU;EACpC,SAAS,kBAAkB,UAAU;EACrC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,uBAAuB,CAAC,UAAU;EACtE,UAAU,cAAc,UAAU;CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAC5C,MAAM,aAAa,sBAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;AAEF,MAAI,OAAO,SAAS;GAClB,MAAMC,YAAU,OAAO;GACvB,MAAM,UAAU,OAAO;AACvB,QAAKA,UACH,OAAM,IAAI,eACR;AAIJ,UAAO,qBAAqBA,UAAQ;GAEpC,M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BAAe,MAAM,WAAW,gBAAgB;IAC9C,kBAAkB;IAClB,SAAS,MAAM;GAChB,EAAC;EACH,SAAQ,OAAO,CAGf;EAED,MAAM,mBAAmB,MAAM,2BAA2B;GACxD;GACA,kBAAkB;GAClB;EACD,EAAC;AAEF,SAAO,kBAAkB;GACvB,kBAAkB;GAClB;GACA;GACA;GACA;GACA;EACD,EAAC;CACH;AACF,EAAC;AAEF,eAAe,2BAA2B,EACxC,YACA,kBACA,OAKD,EAA8B;CAC7B,MAAM,UAAU,yBAAyB,MAAM;AAC/C,MAAK,QACH;AAGF,KAAI;AACF,SAAO,MAAM,WAAW,SAAS;GAC/B;GACA,SAAS,QAAQ;GACjB,OAAO;EACR,EAAC;CACH,SAAQ,OAAO;AACd,WAAS,MAAM;AACf;CACD;AACF;AAED,SAAS,aAAaC,OAAkD;AAEtE,QAAO,MAAM,SAAS,WAAW,MAAM,SAAS;AACjD;AAMD,SAAS,yBAAyBA,OAA0C;AAE1E,KAAI,aAAa,MAAM,CACrB,QAAO;CAIT,MAAM,UAAU,MAAM,UAAU,OAAO;AAEvC,YAAW,YAAY,YAAY,QAAQ,WAAW,EACpD,QAAO;AAGT,QAAO,EAAE,QAAS;AACnB"}
@@ -1,10 +1,10 @@
1
- const require_chunk = require('./chunk-DWy1uDak.cjs');
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
2
  const require_errors = require('./errors-umQzF_vW.cjs');
3
3
  const require_define = require('./define-CLp6EtpZ.cjs');
4
- const require_logging = require('./logging-DrbQ8weU.cjs');
4
+ const require_logging = require('./logging-C-ST7-Ow.cjs');
5
5
  const require_errors$1 = require('./errors-DWysOIMw.cjs');
6
- const require_api = require('./api-BkWv0o1h.cjs');
7
- const require_schema = require('./schema-DUU4CA0j.cjs');
6
+ const require_api = require('./api-CHgBJOv9.cjs');
7
+ const require_schema = require('./schema-BGVOjcD7.cjs');
8
8
  const require_issue_helpers = require('./issue-helpers-D-hBnXTk.cjs');
9
9
  const require_formatting = require('./formatting-5u-ZFz8H.cjs');
10
10
  const require_enhance_error = require('./enhance-error-vihkdCX5.cjs');
@@ -198,4 +198,4 @@ Object.defineProperty(exports, 'get_issue_details_default', {
198
198
  return get_issue_details_default;
199
199
  }
200
200
  });
201
- //# sourceMappingURL=get-issue-details-BxJ_lQN8.cjs.map
201
+ //# sourceMappingURL=get-issue-details-CIZSksmd.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-issue-details-BxJ_lQN8.cjs","names":["context: ServerContext","orgSlug","UserInputError","issue","event: Awaited<ReturnType<typeof apiService.getEventForIssue>>","ApiNotFoundError","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","performanceTrace","issue: Awaited<ReturnType<typeof apiService.getIssue>>","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","event: Event"],"sources":["../src/tools/get-issue-details.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport {\n parseIssueParams,\n formatIssueOutput,\n} from \"../internal/tool-helpers/issue\";\nimport { enhanceNotFoundError } from \"../internal/tool-helpers/enhance-error\";\nimport { ApiNotFoundError } from \"../api-client\";\nimport type { SentryApiService } from \"../api-client\";\nimport type {\n Event,\n ErrorEvent,\n DefaultEvent,\n TransactionEvent,\n Trace,\n} from \"../api-client/types\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport { logError } from \"../telem/logging\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamIssueShortId,\n ParamIssueUrl,\n} from \"../schema\";\n\nexport default defineTool({\n name: \"get_issue_details\",\n requiredSkills: [\"inspect\", \"triage\", \"seer\"], // Available in inspect, triage, and seer skills\n requiredScopes: [\"event:read\"],\n description: [\n \"Get detailed information about a specific Sentry issue by ID.\",\n \"\",\n \"🔍 USE THIS TOOL WHEN USERS:\",\n \"- Provide a specific issue ID (e.g., 'CLOUDFLARE-MCP-41', 'PROJECT-123')\",\n \"- Ask to 'explain [ISSUE-ID]', 'tell me about [ISSUE-ID]'\",\n \"- Want details/stacktrace/analysis for a known issue\",\n \"- Provide a Sentry issue URL\",\n \"\",\n \"❌ DO NOT USE for:\",\n \"- General searching or listing issues (use search_issues)\",\n \"- Root cause analysis (use analyze_issue_with_seer)\",\n \"\",\n \"TRIGGER PATTERNS:\",\n \"- 'Explain ISSUE-123' → use get_issue_details\",\n \"- 'Tell me about PROJECT-456' → use get_issue_details\",\n \"- 'What happened in [issue URL]' → use get_issue_details\",\n \"\",\n \"<examples>\",\n \"### With Sentry URL (recommended - simplest approach)\",\n \"```\",\n \"get_issue_details(issueUrl='https://sentry.sentry.io/issues/6916805731/?project=4509062593708032&query=is%3Aunresolved')\",\n \"```\",\n \"\",\n \"### With issue ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', issueId='CLOUDFLARE-MCP-41')\",\n \"```\",\n \"\",\n \"### With event ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', eventId='c49541c747cb4d8aa3efb70ca5aba243')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- **IMPORTANT**: If user provides a Sentry URL, pass the ENTIRE URL to issueUrl parameter unchanged\",\n \"- When using issueUrl, all other parameters are automatically extracted - don't provide them separately\",\n \"- If using issueId (not URL), then organizationSlug is required\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug.optional(),\n regionUrl: ParamRegionUrl.optional(),\n issueId: ParamIssueShortId.optional(),\n eventId: z.string().trim().describe(\"The ID of the event.\").optional(),\n issueUrl: ParamIssueUrl.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n if (params.eventId) {\n const orgSlug = params.organizationSlug;\n const eventId = params.eventId; // Capture eventId for type safety\n if (!orgSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `eventId`\",\n );\n }\n\n setTag(\"organization.slug\", orgSlug);\n // API client will throw ApiClientError/ApiServerError which the MCP server wrapper handles\n const [issue] = await apiService.listIssues({\n organizationSlug: orgSlug,\n query: eventId,\n });\n if (!issue) {\n return `# Event Not Found\\n\\nNo issue found for Event ID: ${eventId}`;\n }\n // For this call, we might want to provide context if it fails\n let event: Awaited<ReturnType<typeof apiService.getEventForIssue>>;\n try {\n event = await apiService.getEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n } catch (error) {\n // Optionally enhance 404 errors with parameter context\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n }\n throw error;\n }\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n }\n\n // Validate that we have the minimum required parameters\n if (!params.issueUrl && !params.issueId) {\n throw new UserInputError(\n \"Either `issueId` or `issueUrl` must be provided\",\n );\n }\n\n if (!params.issueUrl && !params.organizationSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `issueId`\",\n );\n }\n\n const { organizationSlug: orgSlug, issueId: parsedIssueId } =\n parseIssueParams({\n organizationSlug: params.organizationSlug,\n issueId: params.issueId,\n issueUrl: params.issueUrl,\n });\n\n setTag(\"organization.slug\", orgSlug);\n\n // For the main issue lookup, provide parameter context on 404\n let issue: Awaited<ReturnType<typeof apiService.getIssue>>;\n try {\n issue = await apiService.getIssue({\n organizationSlug: orgSlug,\n issueId: parsedIssueId!,\n });\n } catch (error) {\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: parsedIssueId,\n });\n }\n throw error;\n }\n\n const event = await apiService.getLatestEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n },\n});\n\nasync function maybeFetchPerformanceTrace({\n apiService,\n organizationSlug,\n event,\n}: {\n apiService: SentryApiService;\n organizationSlug: string;\n event: Event;\n}): Promise<Trace | undefined> {\n const context = shouldFetchTraceForEvent(event);\n if (!context) {\n return undefined;\n }\n\n try {\n return await apiService.getTrace({\n organizationSlug,\n traceId: context.traceId,\n limit: 10000,\n });\n } catch (error) {\n logError(error);\n return undefined;\n }\n}\n\nfunction isErrorEvent(event: Event): event is ErrorEvent | DefaultEvent {\n // \"default\" type represents error events without exception data\n return event.type === \"error\" || event.type === \"default\";\n}\n\nfunction isTransactionEvent(event: Event): event is TransactionEvent {\n return event.type === \"transaction\";\n}\n\nfunction shouldFetchTraceForEvent(event: Event): { traceId: string } | null {\n // Only fetch traces for non-error events (transactions, profiling, etc.)\n if (isErrorEvent(event)) {\n return null;\n }\n\n // Check if we have a trace ID\n const traceId = event.contexts?.trace?.trace_id;\n\n if (typeof traceId !== \"string\" || traceId.length === 0) {\n return null;\n }\n\n return { traceId };\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,gCAAe,0BAAW;CACxB,MAAM;CACN,gBAAgB;EAAC;EAAW;EAAU;CAAO;CAC7C,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkB,qCAAsB,UAAU;EAClD,WAAW,8BAAe,UAAU;EACpC,SAAS,iCAAkB,UAAU;EACrC,SAAS,MAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,uBAAuB,CAAC,UAAU;EACtE,UAAU,6BAAc,UAAU;CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAC5C,MAAM,aAAa,kCAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;AAEF,MAAI,OAAO,SAAS;GAClB,MAAMC,YAAU,OAAO;GACvB,MAAM,UAAU,OAAO;AACvB,QAAKA,UACH,OAAM,IAAIC,8BACR;AAIJ,6BAAO,qBAAqBD,UAAQ;GAEpC,MAAM,CAACE,QAAM,GAAG,MAAM,WAAW,WAAW;IAC1C,kBAAkBF;IAClB,OAAO;GACR,EAAC;AACF,QAAKE,QACH,SAAQ,oDAAoD;GAG9D,IAAIC;AACJ,OAAI;AACF,cAAQ,MAAM,WAAW,iBAAiB;KACxC,kBAAkBH;KAClB,SAASE,QAAM;KACf;IACD,EAAC;GACH,SAAQ,OAAO;AAEd,QAAI,iBAAiBE,kCACnB,OAAM,2CAAqB,OAAO;KAChC,kBAAkBJ;KAClB,SAASE,QAAM;KACf;IACD,EAAC;AAEJ,UAAM;GACP;GAGD,IAAIG;AAG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AACF,SAAO,MAAM,WAAW,SAAS;GAC/B;GACA,SAAS,QAAQ;GACjB,OAAO;EACR,EAAC;CACH,SAAQ,OAAO;AACd,2BAAS,MAAM;AACf;CACD;AACF;AAED,SAAS,aAAaC,OAAkD;AAEtE,QAAO,MAAM,SAAS,WAAW,MAAM,SAAS;AACjD;AAMD,SAAS,yBAAyBA,OAA0C;AAE1E,KAAI,aAAa,MAAM,CACrB,QAAO;CAIT,MAAM,UAAU,MAAM,UAAU,OAAO;AAEvC,YAAW,YAAY,YAAY,QAAQ,WAAW,EACpD,QAAO;AAGT,QAAO,EAAE,QAAS;AACnB"}
1
+ {"version":3,"file":"get-issue-details-CIZSksmd.cjs","names":["context: ServerContext","orgSlug","UserInputError","issue","event: Awaited<ReturnType<typeof apiService.getEventForIssue>>","ApiNotFoundError","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","performanceTrace","issue: Awaited<ReturnType<typeof apiService.getIssue>>","autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined","event: Event"],"sources":["../src/tools/get-issue-details.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport {\n parseIssueParams,\n formatIssueOutput,\n} from \"../internal/tool-helpers/issue\";\nimport { enhanceNotFoundError } from \"../internal/tool-helpers/enhance-error\";\nimport { ApiNotFoundError } from \"../api-client\";\nimport type { SentryApiService } from \"../api-client\";\nimport type {\n Event,\n ErrorEvent,\n DefaultEvent,\n TransactionEvent,\n Trace,\n} from \"../api-client/types\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport { logError } from \"../telem/logging\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamIssueShortId,\n ParamIssueUrl,\n} from \"../schema\";\n\nexport default defineTool({\n name: \"get_issue_details\",\n requiredSkills: [\"inspect\", \"triage\", \"seer\"], // Available in inspect, triage, and seer skills\n requiredScopes: [\"event:read\"],\n description: [\n \"Get detailed information about a specific Sentry issue by ID.\",\n \"\",\n \"🔍 USE THIS TOOL WHEN USERS:\",\n \"- Provide a specific issue ID (e.g., 'CLOUDFLARE-MCP-41', 'PROJECT-123')\",\n \"- Ask to 'explain [ISSUE-ID]', 'tell me about [ISSUE-ID]'\",\n \"- Want details/stacktrace/analysis for a known issue\",\n \"- Provide a Sentry issue URL\",\n \"\",\n \"❌ DO NOT USE for:\",\n \"- General searching or listing issues (use search_issues)\",\n \"- Root cause analysis (use analyze_issue_with_seer)\",\n \"\",\n \"TRIGGER PATTERNS:\",\n \"- 'Explain ISSUE-123' → use get_issue_details\",\n \"- 'Tell me about PROJECT-456' → use get_issue_details\",\n \"- 'What happened in [issue URL]' → use get_issue_details\",\n \"\",\n \"<examples>\",\n \"### With Sentry URL (recommended - simplest approach)\",\n \"```\",\n \"get_issue_details(issueUrl='https://sentry.sentry.io/issues/6916805731/?project=4509062593708032&query=is%3Aunresolved')\",\n \"```\",\n \"\",\n \"### With issue ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', issueId='CLOUDFLARE-MCP-41')\",\n \"```\",\n \"\",\n \"### With event ID and organization\",\n \"```\",\n \"get_issue_details(organizationSlug='my-organization', eventId='c49541c747cb4d8aa3efb70ca5aba243')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- **IMPORTANT**: If user provides a Sentry URL, pass the ENTIRE URL to issueUrl parameter unchanged\",\n \"- When using issueUrl, all other parameters are automatically extracted - don't provide them separately\",\n \"- If using issueId (not URL), then organizationSlug is required\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug.optional(),\n regionUrl: ParamRegionUrl.optional(),\n issueId: ParamIssueShortId.optional(),\n eventId: z.string().trim().describe(\"The ID of the event.\").optional(),\n issueUrl: ParamIssueUrl.optional(),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n if (params.eventId) {\n const orgSlug = params.organizationSlug;\n const eventId = params.eventId; // Capture eventId for type safety\n if (!orgSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `eventId`\",\n );\n }\n\n setTag(\"organization.slug\", orgSlug);\n // API client will throw ApiClientError/ApiServerError which the MCP server wrapper handles\n const [issue] = await apiService.listIssues({\n organizationSlug: orgSlug,\n query: eventId,\n });\n if (!issue) {\n return `# Event Not Found\\n\\nNo issue found for Event ID: ${eventId}`;\n }\n // For this call, we might want to provide context if it fails\n let event: Awaited<ReturnType<typeof apiService.getEventForIssue>>;\n try {\n event = await apiService.getEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n } catch (error) {\n // Optionally enhance 404 errors with parameter context\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n eventId,\n });\n }\n throw error;\n }\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n }\n\n // Validate that we have the minimum required parameters\n if (!params.issueUrl && !params.issueId) {\n throw new UserInputError(\n \"Either `issueId` or `issueUrl` must be provided\",\n );\n }\n\n if (!params.issueUrl && !params.organizationSlug) {\n throw new UserInputError(\n \"`organizationSlug` is required when providing `issueId`\",\n );\n }\n\n const { organizationSlug: orgSlug, issueId: parsedIssueId } =\n parseIssueParams({\n organizationSlug: params.organizationSlug,\n issueId: params.issueId,\n issueUrl: params.issueUrl,\n });\n\n setTag(\"organization.slug\", orgSlug);\n\n // For the main issue lookup, provide parameter context on 404\n let issue: Awaited<ReturnType<typeof apiService.getIssue>>;\n try {\n issue = await apiService.getIssue({\n organizationSlug: orgSlug,\n issueId: parsedIssueId!,\n });\n } catch (error) {\n if (error instanceof ApiNotFoundError) {\n throw enhanceNotFoundError(error, {\n organizationSlug: orgSlug,\n issueId: parsedIssueId,\n });\n }\n throw error;\n }\n\n const event = await apiService.getLatestEventForIssue({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n\n // Try to fetch Seer analysis context (non-blocking)\n let autofixState:\n | Awaited<ReturnType<typeof apiService.getAutofixState>>\n | undefined;\n try {\n autofixState = await apiService.getAutofixState({\n organizationSlug: orgSlug,\n issueId: issue.shortId,\n });\n } catch (error) {\n // Silently continue if Seer analysis is not available\n // This ensures the tool works even if Seer is not enabled\n }\n\n const performanceTrace = await maybeFetchPerformanceTrace({\n apiService,\n organizationSlug: orgSlug,\n event,\n });\n\n return formatIssueOutput({\n organizationSlug: orgSlug,\n issue,\n event,\n apiService,\n autofixState,\n performanceTrace,\n });\n },\n});\n\nasync function maybeFetchPerformanceTrace({\n apiService,\n organizationSlug,\n event,\n}: {\n apiService: SentryApiService;\n organizationSlug: string;\n event: Event;\n}): Promise<Trace | undefined> {\n const context = shouldFetchTraceForEvent(event);\n if (!context) {\n return undefined;\n }\n\n try {\n return await apiService.getTrace({\n organizationSlug,\n traceId: context.traceId,\n limit: 10000,\n });\n } catch (error) {\n logError(error);\n return undefined;\n }\n}\n\nfunction isErrorEvent(event: Event): event is ErrorEvent | DefaultEvent {\n // \"default\" type represents error events without exception data\n return event.type === \"error\" || event.type === \"default\";\n}\n\nfunction isTransactionEvent(event: Event): event is TransactionEvent {\n return event.type === \"transaction\";\n}\n\nfunction shouldFetchTraceForEvent(event: Event): { traceId: string } | null {\n // Only fetch traces for non-error events (transactions, profiling, etc.)\n if (isErrorEvent(event)) {\n return null;\n }\n\n // Check if we have a trace ID\n const traceId = event.contexts?.trace?.trace_id;\n\n if (typeof traceId !== \"string\" || traceId.length === 0) {\n return null;\n }\n\n return { traceId };\n}\n"],"mappings":";;;;;;;;;;;;;;AA4BA,gCAAe,0BAAW;CACxB,MAAM;CACN,gBAAgB;EAAC;EAAW;EAAU;CAAO;CAC7C,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkB,qCAAsB,UAAU;EAClD,WAAW,8BAAe,UAAU;EACpC,SAAS,iCAAkB,UAAU;EACrC,SAAS,MAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,uBAAuB,CAAC,UAAU;EACtE,UAAU,6BAAc,UAAU;CACnC;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQA,SAAwB;EAC5C,MAAM,aAAa,kCAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;AAEF,MAAI,OAAO,SAAS;GAClB,MAAMC,YAAU,OAAO;GACvB,MAAM,UAAU,OAAO;AACvB,QAAKA,UACH,OAAM,IAAIC,8BACR;AAIJ,6BAAO,qBAAqBD,UAAQ;GAEpC,MAAM,CAACE,QAAM,GAAG,MAAM,WAAW,WAAW;IAC1C,kBAAkBF;IAClB,OAAO;GACR,EAAC;AACF,QAAKE,QACH,SAAQ,oDAAoD;GAG9D,IAAIC;AACJ,OAAI;AACF,cAAQ,MAAM,WAAW,iBAAiB;KACxC,kBAAkBH;KAClB,SAASE,QAAM;KACf;IACD,EAAC;GACH,SAAQ,OAAO;AA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C;CACH;AACF,EAAC;AAEF,eAAe,2BAA2B,EACxC,YACA,kBACA,OAKD,EAA8B;CAC7B,MAAM,UAAU,yBAAyB,MAAM;AAC/C,MAAK,QACH;AAGF,KAAI;AACF,SAAO,MAAM,WAAW,SAAS;GAC/B;GACA,SAAS,QAAQ;GACjB,OAAO;EACR,EAAC;CACH,SAAQ,OAAO;AACd,2BAAS,MAAM;AACf;CACD;AACF;AAED,SAAS,aAAaC,OAAkD;AAEtE,QAAO,MAAM,SAAS,WAAW,MAAM,SAAS;AACjD;AAMD,SAAS,yBAAyBA,OAA0C;AAE1E,KAAI,aAAa,MAAM,CACrB,QAAO;CAIT,MAAM,UAAU,MAAM,UAAU,OAAO;AAEvC,YAAW,YAAY,YAAY,QAAQ,WAAW,EACpD,QAAO;AAGT,QAAO,EAAE,QAAS;AACnB"}
@@ -1,8 +1,8 @@
1
- const require_chunk = require('./chunk-DWy1uDak.cjs');
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
2
  const require_errors = require('./errors-umQzF_vW.cjs');
3
3
  const require_define = require('./define-CLp6EtpZ.cjs');
4
- const require_api = require('./api-BkWv0o1h.cjs');
5
- const require_schema = require('./schema-DUU4CA0j.cjs');
4
+ const require_api = require('./api-CHgBJOv9.cjs');
5
+ const require_schema = require('./schema-BGVOjcD7.cjs');
6
6
  const __sentry_core = require_chunk.__toESM(require("@sentry/core"));
7
7
 
8
8
  //#region src/tools/get-trace-details.ts
@@ -310,4 +310,4 @@ Object.defineProperty(exports, 'get_trace_details_default', {
310
310
  return get_trace_details_default;
311
311
  }
312
312
  });
313
- //# sourceMappingURL=get-trace-details-C9gJYPip.cjs.map
313
+ //# sourceMappingURL=get-trace-details-Bc9GgkSs.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-trace-details-C9gJYPip.cjs","names":["ParamOrganizationSlug","ParamTraceId","context: ServerContext","UserInputError","spans: any[]","traceId: string","selected: SelectedSpan[]","span: any","level: number","selectedSpan: SelectedSpan","child: any","a: any","b: any","fakeRoot: SelectedSpan","span: SelectedSpan","spans: SelectedSpan[]","lines: string[]","operationSpans: Record<string, any[]>","stats: Record<\n string,\n { count: number; avgDuration: number; p95Duration: number }\n >","result: any[]","spanList: any[]","sections: string[]"],"sources":["../src/tools/get-trace-details.ts"],"sourcesContent":["import { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport { ParamOrganizationSlug, ParamRegionUrl, ParamTraceId } from \"../schema\";\n\n// Constants for span filtering and tree rendering\nconst MAX_DEPTH = 2;\nconst MINIMUM_DURATION_THRESHOLD_MS = 10;\nconst MIN_MEANINGFUL_CHILD_DURATION = 5;\nconst MIN_AVG_DURATION_MS = 5;\n\nexport default defineTool({\n name: \"get_trace_details\",\n requiredSkills: [\"inspect\"], // Only available in inspect skill\n requiredScopes: [\"event:read\"],\n description: [\n \"Get detailed information about a specific Sentry trace by ID.\",\n \"\",\n \"🔍 USE THIS TOOL WHEN USERS:\",\n \"- Provide a specific trace ID (e.g., 'a4d1aae7216b47ff8117cf4e09ce9d0a')\",\n \"- Ask to 'show me trace [TRACE-ID]', 'explain trace [TRACE-ID]'\",\n \"- Want high-level overview and link to view trace details in Sentry\",\n \"- Need trace statistics and span breakdown\",\n \"\",\n \"❌ DO NOT USE for:\",\n \"- General searching for traces (use search_events with trace queries)\",\n \"- Individual span details (this shows trace overview)\",\n \"\",\n \"TRIGGER PATTERNS:\",\n \"- 'Show me trace abc123' → use get_trace_details\",\n \"- 'Explain trace a4d1aae7216b47ff8117cf4e09ce9d0a' → use get_trace_details\",\n \"- 'What is trace [trace-id]' → use get_trace_details\",\n \"\",\n \"<examples>\",\n \"### Get trace overview\",\n \"```\",\n \"get_trace_details(organizationSlug='my-organization', traceId='a4d1aae7216b47ff8117cf4e09ce9d0a')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- Trace IDs are 32-character hexadecimal strings\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n traceId: ParamTraceId,\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n // Validate trace ID format\n if (!/^[0-9a-fA-F]{32}$/.test(params.traceId)) {\n throw new UserInputError(\n \"Trace ID must be a 32-character hexadecimal string\",\n );\n }\n\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n setTag(\"organization.slug\", params.organizationSlug);\n setTag(\"trace.id\", params.traceId);\n\n // Get trace metadata for overview\n const traceMeta = await apiService.getTraceMeta({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n statsPeriod: \"14d\", // Fixed stats period\n });\n\n // Get minimal trace data to show key transactions\n const trace = await apiService.getTrace({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n limit: 10, // Only get top-level spans for overview\n statsPeriod: \"14d\", // Fixed stats period\n });\n\n return formatTraceOutput({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n traceMeta,\n trace,\n apiService,\n });\n },\n});\n\ninterface SelectedSpan {\n event_id: string;\n op: string;\n name: string | null;\n description: string;\n duration: number;\n is_transaction: boolean;\n children: SelectedSpan[];\n level: number;\n}\n\n/**\n * Selects a subset of \"interesting\" spans from a trace for display in the overview.\n *\n * Creates a fake root span representing the entire trace, with selected interesting\n * spans as children. This provides a unified tree view of the trace.\n *\n * The goal is to provide a meaningful sample of the trace that highlights the most\n * important operations while staying within display limits. Selection prioritizes:\n *\n * 1. **Transactions** - Top-level operations that represent complete user requests\n * 2. **Error spans** - Any spans that contain errors (critical for debugging)\n * 3. **Long-running spans** - Operations >= 10ms duration (performance bottlenecks)\n * 4. **Hierarchical context** - Maintains parent-child relationships for understanding\n *\n * Span inclusion rules:\n * - All transactions are included (they're typically root-level operations)\n * - Spans with errors are always included (debugging importance)\n * - Spans with duration >= 10ms are included (performance relevance)\n * - Children are recursively added up to 2 levels deep:\n * - Transactions can have up to 2 children each\n * - Regular spans can have up to 1 child each\n * - Total output is capped at maxSpans to prevent overwhelming display\n *\n * @param spans - Complete array of trace spans with nested children\n * @param traceId - Trace ID to display in the fake root span\n * @param maxSpans - Maximum number of spans to include in output (default: 20)\n * @returns Single-element array containing fake root span with selected spans as children\n */\nfunction selectInterestingSpans(\n spans: any[],\n traceId: string,\n maxSpans = 20,\n): SelectedSpan[] {\n const selected: SelectedSpan[] = [];\n let spanCount = 0;\n\n // Filter out non-span items (issues) from the trace data\n // Spans must have children array, duration, and other span-specific fields\n const actualSpans = spans.filter(\n (item) =>\n item &&\n typeof item === \"object\" &&\n \"children\" in item &&\n Array.isArray(item.children) &&\n \"duration\" in item,\n );\n\n function addSpan(span: any, level: number): boolean {\n if (spanCount >= maxSpans || level > MAX_DEPTH) return false;\n\n const duration = span.duration || 0;\n const isTransaction = span.is_transaction;\n const hasErrors = span.errors?.length > 0;\n\n // Always include transactions and spans with errors\n // For regular spans, include if they have reasonable duration or are at root level\n const shouldInclude =\n isTransaction ||\n hasErrors ||\n level === 0 ||\n duration >= MINIMUM_DURATION_THRESHOLD_MS;\n\n if (!shouldInclude) return false;\n\n const selectedSpan: SelectedSpan = {\n event_id: span.event_id,\n op: span.op || \"unknown\",\n name: span.name || null,\n description: span.description || span.transaction || \"unnamed\",\n duration,\n is_transaction: isTransaction,\n children: [],\n level,\n };\n\n spanCount++;\n\n // Add up to one interesting child per span, up to MAX_DEPTH levels deep\n if (level < MAX_DEPTH && span.children?.length > 0) {\n // Sort children by duration (descending) and take the most interesting ones\n const sortedChildren = span.children\n .filter((child: any) => child.duration > MIN_MEANINGFUL_CHILD_DURATION) // Only children with meaningful duration\n .sort((a: any, b: any) => (b.duration || 0) - (a.duration || 0));\n\n // Add up to 2 children for transactions, 1 for regular spans\n const maxChildren = isTransaction ? 2 : 1;\n let addedChildren = 0;\n\n for (const child of sortedChildren) {\n if (addedChildren >= maxChildren || spanCount >= maxSpans) break;\n\n if (addSpan(child, level + 1)) {\n const childSpan = selected[selected.length - 1];\n selectedSpan.children.push(childSpan);\n addedChildren++;\n }\n }\n }\n\n selected.push(selectedSpan);\n return true;\n }\n\n // Sort root spans by duration and select the most interesting ones\n const sortedRoots = actualSpans\n .sort((a, b) => (b.duration || 0) - (a.duration || 0))\n .slice(0, 5); // Start with top 5 root spans\n\n for (const root of sortedRoots) {\n if (spanCount >= maxSpans) break;\n addSpan(root, 0);\n }\n\n const rootSpans = selected.filter((span) => span.level === 0);\n\n // Create fake root span representing the entire trace (no duration - traces are unbounded)\n const fakeRoot: SelectedSpan = {\n event_id: traceId,\n op: \"trace\",\n name: null,\n description: `Trace ${traceId.substring(0, 8)}`,\n duration: 0, // Traces don't have duration\n is_transaction: false,\n children: rootSpans,\n level: -1, // Mark as fake root\n };\n\n return [fakeRoot];\n}\n\n/**\n * Formats a span display name for the tree view.\n *\n * Uses span.name if available (OTEL-native), otherwise falls back to span.description.\n *\n * @param span - The span to format\n * @returns A formatted display name for the span\n */\nfunction formatSpanDisplayName(span: SelectedSpan): string {\n // For the fake trace root, just return \"trace\"\n if (span.op === \"trace\") {\n return \"trace\";\n }\n\n // Use span.name if available (OTEL-native), otherwise use description\n return span.name?.trim() || span.description || \"unnamed\";\n}\n\n/**\n * Renders a hierarchical tree structure of spans using Unicode box-drawing characters.\n *\n * Creates a visual tree representation showing parent-child relationships between spans,\n * with proper indentation and connecting lines. Each span shows its operation, short ID,\n * description, duration, and type (transaction vs span).\n *\n * Tree format:\n * - Root spans have no prefix\n * - Child spans use ├─ for intermediate children, └─ for last child\n * - Continuation lines use │ for vertical connections\n * - Proper spacing maintains visual alignment\n *\n * @param spans - Array of selected spans with their nested children structure\n * @returns Array of formatted markdown strings representing the tree structure\n */\nfunction renderSpanTree(spans: SelectedSpan[]): string[] {\n const lines: string[] = [];\n\n function renderSpan(span: SelectedSpan, prefix = \"\", isLast = true): void {\n const shortId = span.event_id.substring(0, 8);\n const connector = prefix === \"\" ? \"\" : isLast ? \"└─ \" : \"├─ \";\n const displayName = formatSpanDisplayName(span);\n\n // Don't show duration for the fake trace root span\n if (span.op === \"trace\") {\n lines.push(`${prefix}${connector}${displayName} [${shortId}]`);\n } else {\n const duration = span.duration\n ? `${Math.round(span.duration)}ms`\n : \"unknown\";\n\n // Don't show 'default' operations as they're not meaningful\n const opDisplay = span.op === \"default\" ? \"\" : ` · ${span.op}`;\n lines.push(\n `${prefix}${connector}${displayName} [${shortId}${opDisplay} · ${duration}]`,\n );\n }\n\n // Render children with proper tree indentation\n for (let i = 0; i < span.children.length; i++) {\n const child = span.children[i];\n const isLastChild = i === span.children.length - 1;\n const childPrefix = prefix + (isLast ? \" \" : \"│ \");\n renderSpan(child, childPrefix, isLastChild);\n }\n }\n\n for (let i = 0; i < spans.length; i++) {\n const span = spans[i];\n const isLastRoot = i === spans.length - 1;\n renderSpan(span, \"\", isLastRoot);\n }\n\n return lines;\n}\n\nfunction calculateOperationStats(spans: any[]): Record<\n string,\n {\n count: number;\n avgDuration: number;\n p95Duration: number;\n }\n> {\n const allSpans = getAllSpansFlattened(spans);\n const operationSpans: Record<string, any[]> = {};\n\n // Group leaf spans by operation type (only spans with no children)\n for (const span of allSpans) {\n // Only consider leaf nodes - spans that have no children\n if (!span.children || span.children.length === 0) {\n // Use span.op if available, otherwise extract from span.name, fallback to \"unknown\"\n const op = span.op || (span.name ? span.name.split(\" \")[0] : \"unknown\");\n if (!operationSpans[op]) {\n operationSpans[op] = [];\n }\n operationSpans[op].push(span);\n }\n }\n\n const stats: Record<\n string,\n { count: number; avgDuration: number; p95Duration: number }\n > = {};\n\n // Calculate stats for each operation\n for (const [op, opSpans] of Object.entries(operationSpans)) {\n const durations = opSpans\n .map((span) => span.duration || 0)\n .filter((duration) => duration > 0)\n .sort((a, b) => a - b);\n\n const count = opSpans.length;\n const avgDuration =\n durations.length > 0\n ? durations.reduce((sum, duration) => sum + duration, 0) /\n durations.length\n : 0;\n\n // Calculate P95 (95th percentile)\n const p95Index = Math.floor(durations.length * 0.95);\n const p95Duration = durations.length > 0 ? durations[p95Index] || 0 : 0;\n\n stats[op] = {\n count,\n avgDuration,\n p95Duration,\n };\n }\n\n return stats;\n}\n\nfunction getAllSpansFlattened(spans: any[]): any[] {\n const result: any[] = [];\n\n // Filter out non-span items (issues) from the trace data\n // Spans must have children array and duration\n const actualSpans = spans.filter(\n (item) =>\n item &&\n typeof item === \"object\" &&\n \"children\" in item &&\n Array.isArray(item.children) &&\n \"duration\" in item,\n );\n\n function collectSpans(spanList: any[]) {\n for (const span of spanList) {\n result.push(span);\n if (span.children && span.children.length > 0) {\n collectSpans(span.children);\n }\n }\n }\n\n collectSpans(actualSpans);\n return result;\n}\n\nfunction formatTraceOutput({\n organizationSlug,\n traceId,\n traceMeta,\n trace,\n apiService,\n}: {\n organizationSlug: string;\n traceId: string;\n traceMeta: any;\n trace: any[];\n apiService: any;\n}): string {\n const sections: string[] = [];\n\n // Header\n sections.push(`# Trace \\`${traceId}\\` in **${organizationSlug}**`);\n sections.push(\"\");\n\n // High-level statistics\n sections.push(\"## Summary\");\n sections.push(\"\");\n sections.push(`**Total Spans**: ${traceMeta.span_count}`);\n sections.push(`**Errors**: ${traceMeta.errors}`);\n sections.push(`**Performance Issues**: ${traceMeta.performance_issues}`);\n sections.push(`**Logs**: ${traceMeta.logs}`);\n\n // Show operation breakdown with detailed stats if we have trace data\n if (trace.length > 0) {\n const operationStats = calculateOperationStats(trace);\n const sortedOps = Object.entries(operationStats)\n .filter(([, stats]) => stats.avgDuration >= MIN_AVG_DURATION_MS) // Only show ops with avg duration >= 5ms\n .sort(([, a], [, b]) => b.count - a.count)\n .slice(0, 10); // Show top 10\n\n if (sortedOps.length > 0) {\n sections.push(\"\");\n sections.push(\"## Operation Breakdown\");\n sections.push(\"\");\n\n for (const [op, stats] of sortedOps) {\n const avgDuration = Math.round(stats.avgDuration);\n const p95Duration = Math.round(stats.p95Duration);\n sections.push(\n `- **${op}**: ${stats.count} spans (avg: ${avgDuration}ms, p95: ${p95Duration}ms)`,\n );\n }\n sections.push(\"\");\n }\n }\n\n // Show span tree structure\n if (trace.length > 0) {\n const selectedSpans = selectInterestingSpans(trace, traceId);\n\n if (selectedSpans.length > 0) {\n sections.push(\"## Overview\");\n sections.push(\"\");\n const treeLines = renderSpanTree(selectedSpans);\n sections.push(...treeLines);\n sections.push(\"\");\n sections.push(\n \"*Note: This shows a subset of spans. View the full trace for complete details.*\",\n );\n sections.push(\"\");\n }\n }\n\n // Links and usage information\n const traceUrl = apiService.getTraceUrl(organizationSlug, traceId);\n sections.push(\"## View Full Trace\");\n sections.push(\"\");\n sections.push(`**Sentry URL**: ${traceUrl}`);\n sections.push(\"\");\n sections.push(\"## Find Related Events\");\n sections.push(\"\");\n sections.push(`Use this search query to find all events in this trace:`);\n sections.push(\"```\");\n sections.push(`trace:${traceId}`);\n sections.push(\"```\");\n sections.push(\"\");\n sections.push(\n \"You can use this query with the `search_events` tool to get detailed event data from this trace.\",\n );\n\n return sections.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,YAAY;AAClB,MAAM,gCAAgC;AACtC,MAAM,gCAAgC;AACtC,MAAM,sBAAsB;AAE5B,gCAAe,0BAAW;CACxB,MAAM;CACN,gBAAgB,CAAC,SAAU;CAC3B,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkBA;EAClB,WAAW,8BAAe,UAAU;EACpC,SAASC;CACV;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQC,SAAwB;AAE5C,OAAK,oBAAoB,KAAK,OAAO,QAAQ,CAC3C,OAAM,IAA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G;AAEf,MAAI,UAAU,SAAS,GAAG;AACxB,YAAS,KAAK,GAAG;AACjB,YAAS,KAAK,yBAAyB;AACvC,YAAS,KAAK,GAAG;AAEjB,QAAK,MAAM,CAAC,IAAI,MAAM,IAAI,WAAW;IACnC,MAAM,cAAc,KAAK,MAAM,MAAM,YAAY;IACjD,MAAM,cAAc,KAAK,MAAM,MAAM,YAAY;AACjD,aAAS,MACN,MAAM,GAAG,MAAM,MAAM,MAAM,eAAe,YAAY,WAAW,YAAY,KAC/E;GACF;AACD,YAAS,KAAK,GAAG;EAClB;CACF;AAGD,KAAI,MAAM,SAAS,GAAG;EACpB,MAAM,gBAAgB,uBAAuB,OAAO,QAAQ;AAE5D,MAAI,cAAc,SAAS,GAAG;AAC5B,YAAS,KAAK,cAAc;AAC5B,YAAS,KAAK,GAAG;GACjB,MAAM,YAAY,eAAe,cAAc;AAC/C,YAAS,KAAK,GAAG,UAAU;AAC3B,YAAS,KAAK,GAAG;AACjB,YAAS,KACP,kFACD;AACD,YAAS,KAAK,GAAG;EAClB;CACF;CAGD,MAAM,WAAW,WAAW,YAAY,kBAAkB,QAAQ;AAClE,UAAS,KAAK,qBAAqB;AACnC,UAAS,KAAK,GAAG;AACjB,UAAS,MAAM,kBAAkB,WAAW;AAC5C,UAAS,KAAK,GAAG;AACjB,UAAS,KAAK,yBAAyB;AACvC,UAAS,KAAK,GAAG;AACjB,UAAS,MAAM,yDAAyD;AACxE,UAAS,KAAK,MAAM;AACpB,UAAS,MAAM,QAAQ,UAAU;AACjC,UAAS,KAAK,MAAM;AACpB,UAAS,KAAK,GAAG;AACjB,UAAS,KACP,mGACD;AAED,QAAO,SAAS,KAAK,KAAK;AAC3B"}
1
+ {"version":3,"file":"get-trace-details-Bc9GgkSs.cjs","names":["ParamOrganizationSlug","ParamTraceId","context: ServerContext","UserInputError","spans: any[]","traceId: string","selected: SelectedSpan[]","span: any","level: number","selectedSpan: SelectedSpan","child: any","a: any","b: any","fakeRoot: SelectedSpan","span: SelectedSpan","spans: SelectedSpan[]","lines: string[]","operationSpans: Record<string, any[]>","stats: Record<\n string,\n { count: number; avgDuration: number; p95Duration: number }\n >","result: any[]","spanList: any[]","sections: string[]"],"sources":["../src/tools/get-trace-details.ts"],"sourcesContent":["import { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport { ParamOrganizationSlug, ParamRegionUrl, ParamTraceId } from \"../schema\";\n\n// Constants for span filtering and tree rendering\nconst MAX_DEPTH = 2;\nconst MINIMUM_DURATION_THRESHOLD_MS = 10;\nconst MIN_MEANINGFUL_CHILD_DURATION = 5;\nconst MIN_AVG_DURATION_MS = 5;\n\nexport default defineTool({\n name: \"get_trace_details\",\n requiredSkills: [\"inspect\"], // Only available in inspect skill\n requiredScopes: [\"event:read\"],\n description: [\n \"Get detailed information about a specific Sentry trace by ID.\",\n \"\",\n \"🔍 USE THIS TOOL WHEN USERS:\",\n \"- Provide a specific trace ID (e.g., 'a4d1aae7216b47ff8117cf4e09ce9d0a')\",\n \"- Ask to 'show me trace [TRACE-ID]', 'explain trace [TRACE-ID]'\",\n \"- Want high-level overview and link to view trace details in Sentry\",\n \"- Need trace statistics and span breakdown\",\n \"\",\n \"❌ DO NOT USE for:\",\n \"- General searching for traces (use search_events with trace queries)\",\n \"- Individual span details (this shows trace overview)\",\n \"\",\n \"TRIGGER PATTERNS:\",\n \"- 'Show me trace abc123' → use get_trace_details\",\n \"- 'Explain trace a4d1aae7216b47ff8117cf4e09ce9d0a' → use get_trace_details\",\n \"- 'What is trace [trace-id]' → use get_trace_details\",\n \"\",\n \"<examples>\",\n \"### Get trace overview\",\n \"```\",\n \"get_trace_details(organizationSlug='my-organization', traceId='a4d1aae7216b47ff8117cf4e09ce9d0a')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- Trace IDs are 32-character hexadecimal strings\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n traceId: ParamTraceId,\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n // Validate trace ID format\n if (!/^[0-9a-fA-F]{32}$/.test(params.traceId)) {\n throw new UserInputError(\n \"Trace ID must be a 32-character hexadecimal string\",\n );\n }\n\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n setTag(\"organization.slug\", params.organizationSlug);\n setTag(\"trace.id\", params.traceId);\n\n // Get trace metadata for overview\n const traceMeta = await apiService.getTraceMeta({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n statsPeriod: \"14d\", // Fixed stats period\n });\n\n // Get minimal trace data to show key transactions\n const trace = await apiService.getTrace({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n limit: 10, // Only get top-level spans for overview\n statsPeriod: \"14d\", // Fixed stats period\n });\n\n return formatTraceOutput({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n traceMeta,\n trace,\n apiService,\n });\n },\n});\n\ninterface SelectedSpan {\n event_id: string;\n op: string;\n name: string | null;\n description: string;\n duration: number;\n is_transaction: boolean;\n children: SelectedSpan[];\n level: number;\n}\n\n/**\n * Selects a subset of \"interesting\" spans from a trace for display in the overview.\n *\n * Creates a fake root span representing the entire trace, with selected interesting\n * spans as children. This provides a unified tree view of the trace.\n *\n * The goal is to provide a meaningful sample of the trace that highlights the most\n * important operations while staying within display limits. Selection prioritizes:\n *\n * 1. **Transactions** - Top-level operations that represent complete user requests\n * 2. **Error spans** - Any spans that contain errors (critical for debugging)\n * 3. **Long-running spans** - Operations >= 10ms duration (performance bottlenecks)\n * 4. **Hierarchical context** - Maintains parent-child relationships for understanding\n *\n * Span inclusion rules:\n * - All transactions are included (they're typically root-level operations)\n * - Spans with errors are always included (debugging importance)\n * - Spans with duration >= 10ms are included (performance relevance)\n * - Children are recursively added up to 2 levels deep:\n * - Transactions can have up to 2 children each\n * - Regular spans can have up to 1 child each\n * - Total output is capped at maxSpans to prevent overwhelming display\n *\n * @param spans - Complete array of trace spans with nested children\n * @param traceId - Trace ID to display in the fake root span\n * @param maxSpans - Maximum number of spans to include in output (default: 20)\n * @returns Single-element array containing fake root span with selected spans as children\n */\nfunction selectInterestingSpans(\n spans: any[],\n traceId: string,\n maxSpans = 20,\n): SelectedSpan[] {\n const selected: SelectedSpan[] = [];\n let spanCount = 0;\n\n // Filter out non-span items (issues) from the trace data\n // Spans must have children array, duration, and other span-specific fields\n const actualSpans = spans.filter(\n (item) =>\n item &&\n typeof item === \"object\" &&\n \"children\" in item &&\n Array.isArray(item.children) &&\n \"duration\" in item,\n );\n\n function addSpan(span: any, level: number): boolean {\n if (spanCount >= maxSpans || level > MAX_DEPTH) return false;\n\n const duration = span.duration || 0;\n const isTransaction = span.is_transaction;\n const hasErrors = span.errors?.length > 0;\n\n // Always include transactions and spans with errors\n // For regular spans, include if they have reasonable duration or are at root level\n const shouldInclude =\n isTransaction ||\n hasErrors ||\n level === 0 ||\n duration >= MINIMUM_DURATION_THRESHOLD_MS;\n\n if (!shouldInclude) return false;\n\n const selectedSpan: SelectedSpan = {\n event_id: span.event_id,\n op: span.op || \"unknown\",\n name: span.name || null,\n description: span.description || span.transaction || \"unnamed\",\n duration,\n is_transaction: isTransaction,\n children: [],\n level,\n };\n\n spanCount++;\n\n // Add up to one interesting child per span, up to MAX_DEPTH levels deep\n if (level < MAX_DEPTH && span.children?.length > 0) {\n // Sort children by duration (descending) and take the most interesting ones\n const sortedChildren = span.children\n .filter((child: any) => child.duration > MIN_MEANINGFUL_CHILD_DURATION) // Only children with meaningful duration\n .sort((a: any, b: any) => (b.duration || 0) - (a.duration || 0));\n\n // Add up to 2 children for transactions, 1 for regular spans\n const maxChildren = isTransaction ? 2 : 1;\n let addedChildren = 0;\n\n for (const child of sortedChildren) {\n if (addedChildren >= maxChildren || spanCount >= maxSpans) break;\n\n if (addSpan(child, level + 1)) {\n const childSpan = selected[selected.length - 1];\n selectedSpan.children.push(childSpan);\n addedChildren++;\n }\n }\n }\n\n selected.push(selectedSpan);\n return true;\n }\n\n // Sort root spans by duration and select the most interesting ones\n const sortedRoots = actualSpans\n .sort((a, b) => (b.duration || 0) - (a.duration || 0))\n .slice(0, 5); // Start with top 5 root spans\n\n for (const root of sortedRoots) {\n if (spanCount >= maxSpans) break;\n addSpan(root, 0);\n }\n\n const rootSpans = selected.filter((span) => span.level === 0);\n\n // Create fake root span representing the entire trace (no duration - traces are unbounded)\n const fakeRoot: SelectedSpan = {\n event_id: traceId,\n op: \"trace\",\n name: null,\n description: `Trace ${traceId.substring(0, 8)}`,\n duration: 0, // Traces don't have duration\n is_transaction: false,\n children: rootSpans,\n level: -1, // Mark as fake root\n };\n\n return [fakeRoot];\n}\n\n/**\n * Formats a span display name for the tree view.\n *\n * Uses span.name if available (OTEL-native), otherwise falls back to span.description.\n *\n * @param span - The span to format\n * @returns A formatted display name for the span\n */\nfunction formatSpanDisplayName(span: SelectedSpan): string {\n // For the fake trace root, just return \"trace\"\n if (span.op === \"trace\") {\n return \"trace\";\n }\n\n // Use span.name if available (OTEL-native), otherwise use description\n return span.name?.trim() || span.description || \"unnamed\";\n}\n\n/**\n * Renders a hierarchical tree structure of spans using Unicode box-drawing characters.\n *\n * Creates a visual tree representation showing parent-child relationships between spans,\n * with proper indentation and connecting lines. Each span shows its operation, short ID,\n * description, duration, and type (transaction vs span).\n *\n * Tree format:\n * - Root spans have no prefix\n * - Child spans use ├─ for intermediate children, └─ for last child\n * - Continuation lines use │ for vertical connections\n * - Proper spacing maintains visual alignment\n *\n * @param spans - Array of selected spans with their nested children structure\n * @returns Array of formatted markdown strings representing the tree structure\n */\nfunction renderSpanTree(spans: SelectedSpan[]): string[] {\n const lines: string[] = [];\n\n function renderSpan(span: SelectedSpan, prefix = \"\", isLast = true): void {\n const shortId = span.event_id.substring(0, 8);\n const connector = prefix === \"\" ? \"\" : isLast ? \"└─ \" : \"├─ \";\n const displayName = formatSpanDisplayName(span);\n\n // Don't show duration for the fake trace root span\n if (span.op === \"trace\") {\n lines.push(`${prefix}${connector}${displayName} [${shortId}]`);\n } else {\n const duration = span.duration\n ? `${Math.round(span.duration)}ms`\n : \"unknown\";\n\n // Don't show 'default' operations as they're not meaningful\n const opDisplay = span.op === \"default\" ? \"\" : ` · ${span.op}`;\n lines.push(\n `${prefix}${connector}${displayName} [${shortId}${opDisplay} · ${duration}]`,\n );\n }\n\n // Render children with proper tree indentation\n for (let i = 0; i < span.children.length; i++) {\n const child = span.children[i];\n const isLastChild = i === span.children.length - 1;\n const childPrefix = prefix + (isLast ? \" \" : \"│ \");\n renderSpan(child, childPrefix, isLastChild);\n }\n }\n\n for (let i = 0; i < spans.length; i++) {\n const span = spans[i];\n const isLastRoot = i === spans.length - 1;\n renderSpan(span, \"\", isLastRoot);\n }\n\n return lines;\n}\n\nfunction calculateOperationStats(spans: any[]): Record<\n string,\n {\n count: number;\n avgDuration: number;\n p95Duration: number;\n }\n> {\n const allSpans = getAllSpansFlattened(spans);\n const operationSpans: Record<string, any[]> = {};\n\n // Group leaf spans by operation type (only spans with no children)\n for (const span of allSpans) {\n // Only consider leaf nodes - spans that have no children\n if (!span.children || span.children.length === 0) {\n // Use span.op if available, otherwise extract from span.name, fallback to \"unknown\"\n const op = span.op || (span.name ? span.name.split(\" \")[0] : \"unknown\");\n if (!operationSpans[op]) {\n operationSpans[op] = [];\n }\n operationSpans[op].push(span);\n }\n }\n\n const stats: Record<\n string,\n { count: number; avgDuration: number; p95Duration: number }\n > = {};\n\n // Calculate stats for each operation\n for (const [op, opSpans] of Object.entries(operationSpans)) {\n const durations = opSpans\n .map((span) => span.duration || 0)\n .filter((duration) => duration > 0)\n .sort((a, b) => a - b);\n\n const count = opSpans.length;\n const avgDuration =\n durations.length > 0\n ? durations.reduce((sum, duration) => sum + duration, 0) /\n durations.length\n : 0;\n\n // Calculate P95 (95th percentile)\n const p95Index = Math.floor(durations.length * 0.95);\n const p95Duration = durations.length > 0 ? durations[p95Index] || 0 : 0;\n\n stats[op] = {\n count,\n avgDuration,\n p95Duration,\n };\n }\n\n return stats;\n}\n\nfunction getAllSpansFlattened(spans: any[]): any[] {\n const result: any[] = [];\n\n // Filter out non-span items (issues) from the trace data\n // Spans must have children array and duration\n const actualSpans = spans.filter(\n (item) =>\n item &&\n typeof item === \"object\" &&\n \"children\" in item &&\n Array.isArray(item.children) &&\n \"duration\" in item,\n );\n\n function collectSpans(spanList: any[]) {\n for (const span of spanList) {\n result.push(span);\n if (span.children && span.children.length > 0) {\n collectSpans(span.children);\n }\n }\n }\n\n collectSpans(actualSpans);\n return result;\n}\n\nfunction formatTraceOutput({\n organizationSlug,\n traceId,\n traceMeta,\n trace,\n apiService,\n}: {\n organizationSlug: string;\n traceId: string;\n traceMeta: any;\n trace: any[];\n apiService: any;\n}): string {\n const sections: string[] = [];\n\n // Header\n sections.push(`# Trace \\`${traceId}\\` in **${organizationSlug}**`);\n sections.push(\"\");\n\n // High-level statistics\n sections.push(\"## Summary\");\n sections.push(\"\");\n sections.push(`**Total Spans**: ${traceMeta.span_count}`);\n sections.push(`**Errors**: ${traceMeta.errors}`);\n sections.push(`**Performance Issues**: ${traceMeta.performance_issues}`);\n sections.push(`**Logs**: ${traceMeta.logs}`);\n\n // Show operation breakdown with detailed stats if we have trace data\n if (trace.length > 0) {\n const operationStats = calculateOperationStats(trace);\n const sortedOps = Object.entries(operationStats)\n .filter(([, stats]) => stats.avgDuration >= MIN_AVG_DURATION_MS) // Only show ops with avg duration >= 5ms\n .sort(([, a], [, b]) => b.count - a.count)\n .slice(0, 10); // Show top 10\n\n if (sortedOps.length > 0) {\n sections.push(\"\");\n sections.push(\"## Operation Breakdown\");\n sections.push(\"\");\n\n for (const [op, stats] of sortedOps) {\n const avgDuration = Math.round(stats.avgDuration);\n const p95Duration = Math.round(stats.p95Duration);\n sections.push(\n `- **${op}**: ${stats.count} spans (avg: ${avgDuration}ms, p95: ${p95Duration}ms)`,\n );\n }\n sections.push(\"\");\n }\n }\n\n // Show span tree structure\n if (trace.length > 0) {\n const selectedSpans = selectInterestingSpans(trace, traceId);\n\n if (selectedSpans.length > 0) {\n sections.push(\"## Overview\");\n sections.push(\"\");\n const treeLines = renderSpanTree(selectedSpans);\n sections.push(...treeLines);\n sections.push(\"\");\n sections.push(\n \"*Note: This shows a subset of spans. View the full trace for complete details.*\",\n );\n sections.push(\"\");\n }\n }\n\n // Links and usage information\n const traceUrl = apiService.getTraceUrl(organizationSlug, traceId);\n sections.push(\"## View Full Trace\");\n sections.push(\"\");\n sections.push(`**Sentry URL**: ${traceUrl}`);\n sections.push(\"\");\n sections.push(\"## Find Related Events\");\n sections.push(\"\");\n sections.push(`Use this search query to find all events in this trace:`);\n sections.push(\"```\");\n sections.push(`trace:${traceId}`);\n sections.push(\"```\");\n sections.push(\"\");\n sections.push(\n \"You can use this query with the `search_events` tool to get detailed event data from this trace.\",\n );\n\n return sections.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,YAAY;AAClB,MAAM,gCAAgC;AACtC,MAAM,gCAAgC;AACtC,MAAM,sBAAsB;AAE5B,gCAAe,0BAAW;CACxB,MAAM;CACN,gBAAgB,CAAC,SAAU;CAC3B,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkBA;EAClB,WAAW,8BAAe,UAAU;EACpC,SAASC;CACV;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQC,SAAwB;AAE5C,OAAK,oBAAoB,KAAK,OAAO,QAAQ,CAC3C,OAAM,IAAIC,8BACR;EAIJ,MAAM,aAAa,kCA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AACxB,YAAS,KAAK,GAAG;AACjB,YAAS,KAAK,yBAAyB;AACvC,YAAS,KAAK,GAAG;AAEjB,QAAK,MAAM,CAAC,IAAI,MAAM,IAAI,WAAW;IACnC,MAAM,cAAc,KAAK,MAAM,MAAM,YAAY;IACjD,MAAM,cAAc,KAAK,MAAM,MAAM,YAAY;AACjD,aAAS,MACN,MAAM,GAAG,MAAM,MAAM,MAAM,eAAe,YAAY,WAAW,YAAY,KAC/E;GACF;AACD,YAAS,KAAK,GAAG;EAClB;CACF;AAGD,KAAI,MAAM,SAAS,GAAG;EACpB,MAAM,gBAAgB,uBAAuB,OAAO,QAAQ;AAE5D,MAAI,cAAc,SAAS,GAAG;AAC5B,YAAS,KAAK,cAAc;AAC5B,YAAS,KAAK,GAAG;GACjB,MAAM,YAAY,eAAe,cAAc;AAC/C,YAAS,KAAK,GAAG,UAAU;AAC3B,YAAS,KAAK,GAAG;AACjB,YAAS,KACP,kFACD;AACD,YAAS,KAAK,GAAG;EAClB;CACF;CAGD,MAAM,WAAW,WAAW,YAAY,kBAAkB,QAAQ;AAClE,UAAS,KAAK,qBAAqB;AACnC,UAAS,KAAK,GAAG;AACjB,UAAS,MAAM,kBAAkB,WAAW;AAC5C,UAAS,KAAK,GAAG;AACjB,UAAS,KAAK,yBAAyB;AACvC,UAAS,KAAK,GAAG;AACjB,UAAS,MAAM,yDAAyD;AACxE,UAAS,KAAK,MAAM;AACpB,UAAS,MAAM,QAAQ,UAAU;AACjC,UAAS,KAAK,MAAM;AACpB,UAAS,KAAK,GAAG;AACjB,UAAS,KACP,mGACD;AAED,QAAO,SAAS,KAAK,KAAK;AAC3B"}
@@ -1,6 +1,6 @@
1
1
  import { UserInputError } from "./errors-BXmNwD2K.js";
2
2
  import { defineTool } from "./define-vA6uuVue.js";
3
- import { apiServiceFromContext } from "./api-Cozv5F92.js";
3
+ import { apiServiceFromContext } from "./api-CBHyxA3Q.js";
4
4
  import { ParamOrganizationSlug, ParamRegionUrl, ParamTraceId } from "./schema-ChlpIaqA.js";
5
5
  import { setTag } from "@sentry/core";
6
6
 
@@ -304,4 +304,4 @@ function formatTraceOutput({ organizationSlug, traceId, traceMeta, trace, apiSer
304
304
 
305
305
  //#endregion
306
306
  export { get_trace_details_default };
307
- //# sourceMappingURL=get-trace-details-BOBNimN0.js.map
307
+ //# sourceMappingURL=get-trace-details-Bkilw5oH.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-trace-details-BOBNimN0.js","names":["context: ServerContext","spans: any[]","traceId: string","selected: SelectedSpan[]","span: any","level: number","selectedSpan: SelectedSpan","child: any","a: any","b: any","fakeRoot: SelectedSpan","span: SelectedSpan","spans: SelectedSpan[]","lines: string[]","operationSpans: Record<string, any[]>","stats: Record<\n string,\n { count: number; avgDuration: number; p95Duration: number }\n >","result: any[]","spanList: any[]","sections: string[]"],"sources":["../src/tools/get-trace-details.ts"],"sourcesContent":["import { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport { ParamOrganizationSlug, ParamRegionUrl, ParamTraceId } from \"../schema\";\n\n// Constants for span filtering and tree rendering\nconst MAX_DEPTH = 2;\nconst MINIMUM_DURATION_THRESHOLD_MS = 10;\nconst MIN_MEANINGFUL_CHILD_DURATION = 5;\nconst MIN_AVG_DURATION_MS = 5;\n\nexport default defineTool({\n name: \"get_trace_details\",\n requiredSkills: [\"inspect\"], // Only available in inspect skill\n requiredScopes: [\"event:read\"],\n description: [\n \"Get detailed information about a specific Sentry trace by ID.\",\n \"\",\n \"🔍 USE THIS TOOL WHEN USERS:\",\n \"- Provide a specific trace ID (e.g., 'a4d1aae7216b47ff8117cf4e09ce9d0a')\",\n \"- Ask to 'show me trace [TRACE-ID]', 'explain trace [TRACE-ID]'\",\n \"- Want high-level overview and link to view trace details in Sentry\",\n \"- Need trace statistics and span breakdown\",\n \"\",\n \"❌ DO NOT USE for:\",\n \"- General searching for traces (use search_events with trace queries)\",\n \"- Individual span details (this shows trace overview)\",\n \"\",\n \"TRIGGER PATTERNS:\",\n \"- 'Show me trace abc123' → use get_trace_details\",\n \"- 'Explain trace a4d1aae7216b47ff8117cf4e09ce9d0a' → use get_trace_details\",\n \"- 'What is trace [trace-id]' → use get_trace_details\",\n \"\",\n \"<examples>\",\n \"### Get trace overview\",\n \"```\",\n \"get_trace_details(organizationSlug='my-organization', traceId='a4d1aae7216b47ff8117cf4e09ce9d0a')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- Trace IDs are 32-character hexadecimal strings\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n traceId: ParamTraceId,\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n // Validate trace ID format\n if (!/^[0-9a-fA-F]{32}$/.test(params.traceId)) {\n throw new UserInputError(\n \"Trace ID must be a 32-character hexadecimal string\",\n );\n }\n\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n setTag(\"organization.slug\", params.organizationSlug);\n setTag(\"trace.id\", params.traceId);\n\n // Get trace metadata for overview\n const traceMeta = await apiService.getTraceMeta({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n statsPeriod: \"14d\", // Fixed stats period\n });\n\n // Get minimal trace data to show key transactions\n const trace = await apiService.getTrace({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n limit: 10, // Only get top-level spans for overview\n statsPeriod: \"14d\", // Fixed stats period\n });\n\n return formatTraceOutput({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n traceMeta,\n trace,\n apiService,\n });\n },\n});\n\ninterface SelectedSpan {\n event_id: string;\n op: string;\n name: string | null;\n description: string;\n duration: number;\n is_transaction: boolean;\n children: SelectedSpan[];\n level: number;\n}\n\n/**\n * Selects a subset of \"interesting\" spans from a trace for display in the overview.\n *\n * Creates a fake root span representing the entire trace, with selected interesting\n * spans as children. This provides a unified tree view of the trace.\n *\n * The goal is to provide a meaningful sample of the trace that highlights the most\n * important operations while staying within display limits. Selection prioritizes:\n *\n * 1. **Transactions** - Top-level operations that represent complete user requests\n * 2. **Error spans** - Any spans that contain errors (critical for debugging)\n * 3. **Long-running spans** - Operations >= 10ms duration (performance bottlenecks)\n * 4. **Hierarchical context** - Maintains parent-child relationships for understanding\n *\n * Span inclusion rules:\n * - All transactions are included (they're typically root-level operations)\n * - Spans with errors are always included (debugging importance)\n * - Spans with duration >= 10ms are included (performance relevance)\n * - Children are recursively added up to 2 levels deep:\n * - Transactions can have up to 2 children each\n * - Regular spans can have up to 1 child each\n * - Total output is capped at maxSpans to prevent overwhelming display\n *\n * @param spans - Complete array of trace spans with nested children\n * @param traceId - Trace ID to display in the fake root span\n * @param maxSpans - Maximum number of spans to include in output (default: 20)\n * @returns Single-element array containing fake root span with selected spans as children\n */\nfunction selectInterestingSpans(\n spans: any[],\n traceId: string,\n maxSpans = 20,\n): SelectedSpan[] {\n const selected: SelectedSpan[] = [];\n let spanCount = 0;\n\n // Filter out non-span items (issues) from the trace data\n // Spans must have children array, duration, and other span-specific fields\n const actualSpans = spans.filter(\n (item) =>\n item &&\n typeof item === \"object\" &&\n \"children\" in item &&\n Array.isArray(item.children) &&\n \"duration\" in item,\n );\n\n function addSpan(span: any, level: number): boolean {\n if (spanCount >= maxSpans || level > MAX_DEPTH) return false;\n\n const duration = span.duration || 0;\n const isTransaction = span.is_transaction;\n const hasErrors = span.errors?.length > 0;\n\n // Always include transactions and spans with errors\n // For regular spans, include if they have reasonable duration or are at root level\n const shouldInclude =\n isTransaction ||\n hasErrors ||\n level === 0 ||\n duration >= MINIMUM_DURATION_THRESHOLD_MS;\n\n if (!shouldInclude) return false;\n\n const selectedSpan: SelectedSpan = {\n event_id: span.event_id,\n op: span.op || \"unknown\",\n name: span.name || null,\n description: span.description || span.transaction || \"unnamed\",\n duration,\n is_transaction: isTransaction,\n children: [],\n level,\n };\n\n spanCount++;\n\n // Add up to one interesting child per span, up to MAX_DEPTH levels deep\n if (level < MAX_DEPTH && span.children?.length > 0) {\n // Sort children by duration (descending) and take the most interesting ones\n const sortedChildren = span.children\n .filter((child: any) => child.duration > MIN_MEANINGFUL_CHILD_DURATION) // Only children with meaningful duration\n .sort((a: any, b: any) => (b.duration || 0) - (a.duration || 0));\n\n // Add up to 2 children for transactions, 1 for regular spans\n const maxChildren = isTransaction ? 2 : 1;\n let addedChildren = 0;\n\n for (const child of sortedChildren) {\n if (addedChildren >= maxChildren || spanCount >= maxSpans) break;\n\n if (addSpan(child, level + 1)) {\n const childSpan = selected[selected.length - 1];\n selectedSpan.children.push(childSpan);\n addedChildren++;\n }\n }\n }\n\n selected.push(selectedSpan);\n return true;\n }\n\n // Sort root spans by duration and select the most interesting ones\n const sortedRoots = actualSpans\n .sort((a, b) => (b.duration || 0) - (a.duration || 0))\n .slice(0, 5); // Start with top 5 root spans\n\n for (const root of sortedRoots) {\n if (spanCount >= maxSpans) break;\n addSpan(root, 0);\n }\n\n const rootSpans = selected.filter((span) => span.level === 0);\n\n // Create fake root span representing the entire trace (no duration - traces are unbounded)\n const fakeRoot: SelectedSpan = {\n event_id: traceId,\n op: \"trace\",\n name: null,\n description: `Trace ${traceId.substring(0, 8)}`,\n duration: 0, // Traces don't have duration\n is_transaction: false,\n children: rootSpans,\n level: -1, // Mark as fake root\n };\n\n return [fakeRoot];\n}\n\n/**\n * Formats a span display name for the tree view.\n *\n * Uses span.name if available (OTEL-native), otherwise falls back to span.description.\n *\n * @param span - The span to format\n * @returns A formatted display name for the span\n */\nfunction formatSpanDisplayName(span: SelectedSpan): string {\n // For the fake trace root, just return \"trace\"\n if (span.op === \"trace\") {\n return \"trace\";\n }\n\n // Use span.name if available (OTEL-native), otherwise use description\n return span.name?.trim() || span.description || \"unnamed\";\n}\n\n/**\n * Renders a hierarchical tree structure of spans using Unicode box-drawing characters.\n *\n * Creates a visual tree representation showing parent-child relationships between spans,\n * with proper indentation and connecting lines. Each span shows its operation, short ID,\n * description, duration, and type (transaction vs span).\n *\n * Tree format:\n * - Root spans have no prefix\n * - Child spans use ├─ for intermediate children, └─ for last child\n * - Continuation lines use │ for vertical connections\n * - Proper spacing maintains visual alignment\n *\n * @param spans - Array of selected spans with their nested children structure\n * @returns Array of formatted markdown strings representing the tree structure\n */\nfunction renderSpanTree(spans: SelectedSpan[]): string[] {\n const lines: string[] = [];\n\n function renderSpan(span: SelectedSpan, prefix = \"\", isLast = true): void {\n const shortId = span.event_id.substring(0, 8);\n const connector = prefix === \"\" ? \"\" : isLast ? \"└─ \" : \"├─ \";\n const displayName = formatSpanDisplayName(span);\n\n // Don't show duration for the fake trace root span\n if (span.op === \"trace\") {\n lines.push(`${prefix}${connector}${displayName} [${shortId}]`);\n } else {\n const duration = span.duration\n ? `${Math.round(span.duration)}ms`\n : \"unknown\";\n\n // Don't show 'default' operations as they're not meaningful\n const opDisplay = span.op === \"default\" ? \"\" : ` · ${span.op}`;\n lines.push(\n `${prefix}${connector}${displayName} [${shortId}${opDisplay} · ${duration}]`,\n );\n }\n\n // Render children with proper tree indentation\n for (let i = 0; i < span.children.length; i++) {\n const child = span.children[i];\n const isLastChild = i === span.children.length - 1;\n const childPrefix = prefix + (isLast ? \" \" : \"│ \");\n renderSpan(child, childPrefix, isLastChild);\n }\n }\n\n for (let i = 0; i < spans.length; i++) {\n const span = spans[i];\n const isLastRoot = i === spans.length - 1;\n renderSpan(span, \"\", isLastRoot);\n }\n\n return lines;\n}\n\nfunction calculateOperationStats(spans: any[]): Record<\n string,\n {\n count: number;\n avgDuration: number;\n p95Duration: number;\n }\n> {\n const allSpans = getAllSpansFlattened(spans);\n const operationSpans: Record<string, any[]> = {};\n\n // Group leaf spans by operation type (only spans with no children)\n for (const span of allSpans) {\n // Only consider leaf nodes - spans that have no children\n if (!span.children || span.children.length === 0) {\n // Use span.op if available, otherwise extract from span.name, fallback to \"unknown\"\n const op = span.op || (span.name ? span.name.split(\" \")[0] : \"unknown\");\n if (!operationSpans[op]) {\n operationSpans[op] = [];\n }\n operationSpans[op].push(span);\n }\n }\n\n const stats: Record<\n string,\n { count: number; avgDuration: number; p95Duration: number }\n > = {};\n\n // Calculate stats for each operation\n for (const [op, opSpans] of Object.entries(operationSpans)) {\n const durations = opSpans\n .map((span) => span.duration || 0)\n .filter((duration) => duration > 0)\n .sort((a, b) => a - b);\n\n const count = opSpans.length;\n const avgDuration =\n durations.length > 0\n ? durations.reduce((sum, duration) => sum + duration, 0) /\n durations.length\n : 0;\n\n // Calculate P95 (95th percentile)\n const p95Index = Math.floor(durations.length * 0.95);\n const p95Duration = durations.length > 0 ? durations[p95Index] || 0 : 0;\n\n stats[op] = {\n count,\n avgDuration,\n p95Duration,\n };\n }\n\n return stats;\n}\n\nfunction getAllSpansFlattened(spans: any[]): any[] {\n const result: any[] = [];\n\n // Filter out non-span items (issues) from the trace data\n // Spans must have children array and duration\n const actualSpans = spans.filter(\n (item) =>\n item &&\n typeof item === \"object\" &&\n \"children\" in item &&\n Array.isArray(item.children) &&\n \"duration\" in item,\n );\n\n function collectSpans(spanList: any[]) {\n for (const span of spanList) {\n result.push(span);\n if (span.children && span.children.length > 0) {\n collectSpans(span.children);\n }\n }\n }\n\n collectSpans(actualSpans);\n return result;\n}\n\nfunction formatTraceOutput({\n organizationSlug,\n traceId,\n traceMeta,\n trace,\n apiService,\n}: {\n organizationSlug: string;\n traceId: string;\n traceMeta: any;\n trace: any[];\n apiService: any;\n}): string {\n const sections: string[] = [];\n\n // Header\n sections.push(`# Trace \\`${traceId}\\` in **${organizationSlug}**`);\n sections.push(\"\");\n\n // High-level statistics\n sections.push(\"## Summary\");\n sections.push(\"\");\n sections.push(`**Total Spans**: ${traceMeta.span_count}`);\n sections.push(`**Errors**: ${traceMeta.errors}`);\n sections.push(`**Performance Issues**: ${traceMeta.performance_issues}`);\n sections.push(`**Logs**: ${traceMeta.logs}`);\n\n // Show operation breakdown with detailed stats if we have trace data\n if (trace.length > 0) {\n const operationStats = calculateOperationStats(trace);\n const sortedOps = Object.entries(operationStats)\n .filter(([, stats]) => stats.avgDuration >= MIN_AVG_DURATION_MS) // Only show ops with avg duration >= 5ms\n .sort(([, a], [, b]) => b.count - a.count)\n .slice(0, 10); // Show top 10\n\n if (sortedOps.length > 0) {\n sections.push(\"\");\n sections.push(\"## Operation Breakdown\");\n sections.push(\"\");\n\n for (const [op, stats] of sortedOps) {\n const avgDuration = Math.round(stats.avgDuration);\n const p95Duration = Math.round(stats.p95Duration);\n sections.push(\n `- **${op}**: ${stats.count} spans (avg: ${avgDuration}ms, p95: ${p95Duration}ms)`,\n );\n }\n sections.push(\"\");\n }\n }\n\n // Show span tree structure\n if (trace.length > 0) {\n const selectedSpans = selectInterestingSpans(trace, traceId);\n\n if (selectedSpans.length > 0) {\n sections.push(\"## Overview\");\n sections.push(\"\");\n const treeLines = renderSpanTree(selectedSpans);\n sections.push(...treeLines);\n sections.push(\"\");\n sections.push(\n \"*Note: This shows a subset of spans. View the full trace for complete details.*\",\n );\n sections.push(\"\");\n }\n }\n\n // Links and usage information\n const traceUrl = apiService.getTraceUrl(organizationSlug, traceId);\n sections.push(\"## View Full Trace\");\n sections.push(\"\");\n sections.push(`**Sentry URL**: ${traceUrl}`);\n sections.push(\"\");\n sections.push(\"## Find Related Events\");\n sections.push(\"\");\n sections.push(`Use this search query to find all events in this trace:`);\n sections.push(\"```\");\n sections.push(`trace:${traceId}`);\n sections.push(\"```\");\n sections.push(\"\");\n sections.push(\n \"You can use this query with the `search_events` tool to get detailed event data from this trace.\",\n );\n\n return sections.join(\"\\n\");\n}\n"],"mappings":";;;;;;;AAQA,MAAM,YAAY;AAClB,MAAM,gCAAgC;AACtC,MAAM,gCAAgC;AACtC,MAAM,sBAAsB;AAE5B,gCAAe,WAAW;CACxB,MAAM;CACN,gBAAgB,CAAC,SAAU;CAC3B,gBAAgB,CAAC,YAAa;C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yDAAyD;AACxE,UAAS,KAAK,MAAM;AACpB,UAAS,MAAM,QAAQ,UAAU;AACjC,UAAS,KAAK,MAAM;AACpB,UAAS,KAAK,GAAG;AACjB,UAAS,KACP,mGACD;AAED,QAAO,SAAS,KAAK,KAAK;AAC3B"}
1
+ {"version":3,"file":"get-trace-details-Bkilw5oH.js","names":["context: ServerContext","spans: any[]","traceId: string","selected: SelectedSpan[]","span: any","level: number","selectedSpan: SelectedSpan","child: any","a: any","b: any","fakeRoot: SelectedSpan","span: SelectedSpan","spans: SelectedSpan[]","lines: string[]","operationSpans: Record<string, any[]>","stats: Record<\n string,\n { count: number; avgDuration: number; p95Duration: number }\n >","result: any[]","spanList: any[]","sections: string[]"],"sources":["../src/tools/get-trace-details.ts"],"sourcesContent":["import { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../internal/tool-helpers/api\";\nimport { UserInputError } from \"../errors\";\nimport type { ServerContext } from \"../types\";\nimport { ParamOrganizationSlug, ParamRegionUrl, ParamTraceId } from \"../schema\";\n\n// Constants for span filtering and tree rendering\nconst MAX_DEPTH = 2;\nconst MINIMUM_DURATION_THRESHOLD_MS = 10;\nconst MIN_MEANINGFUL_CHILD_DURATION = 5;\nconst MIN_AVG_DURATION_MS = 5;\n\nexport default defineTool({\n name: \"get_trace_details\",\n requiredSkills: [\"inspect\"], // Only available in inspect skill\n requiredScopes: [\"event:read\"],\n description: [\n \"Get detailed information about a specific Sentry trace by ID.\",\n \"\",\n \"🔍 USE THIS TOOL WHEN USERS:\",\n \"- Provide a specific trace ID (e.g., 'a4d1aae7216b47ff8117cf4e09ce9d0a')\",\n \"- Ask to 'show me trace [TRACE-ID]', 'explain trace [TRACE-ID]'\",\n \"- Want high-level overview and link to view trace details in Sentry\",\n \"- Need trace statistics and span breakdown\",\n \"\",\n \"❌ DO NOT USE for:\",\n \"- General searching for traces (use search_events with trace queries)\",\n \"- Individual span details (this shows trace overview)\",\n \"\",\n \"TRIGGER PATTERNS:\",\n \"- 'Show me trace abc123' → use get_trace_details\",\n \"- 'Explain trace a4d1aae7216b47ff8117cf4e09ce9d0a' → use get_trace_details\",\n \"- 'What is trace [trace-id]' → use get_trace_details\",\n \"\",\n \"<examples>\",\n \"### Get trace overview\",\n \"```\",\n \"get_trace_details(organizationSlug='my-organization', traceId='a4d1aae7216b47ff8117cf4e09ce9d0a')\",\n \"```\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- Trace IDs are 32-character hexadecimal strings\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n regionUrl: ParamRegionUrl.optional(),\n traceId: ParamTraceId,\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n // Validate trace ID format\n if (!/^[0-9a-fA-F]{32}$/.test(params.traceId)) {\n throw new UserInputError(\n \"Trace ID must be a 32-character hexadecimal string\",\n );\n }\n\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n\n setTag(\"organization.slug\", params.organizationSlug);\n setTag(\"trace.id\", params.traceId);\n\n // Get trace metadata for overview\n const traceMeta = await apiService.getTraceMeta({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n statsPeriod: \"14d\", // Fixed stats period\n });\n\n // Get minimal trace data to show key transactions\n const trace = await apiService.getTrace({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n limit: 10, // Only get top-level spans for overview\n statsPeriod: \"14d\", // Fixed stats period\n });\n\n return formatTraceOutput({\n organizationSlug: params.organizationSlug,\n traceId: params.traceId,\n traceMeta,\n trace,\n apiService,\n });\n },\n});\n\ninterface SelectedSpan {\n event_id: string;\n op: string;\n name: string | null;\n description: string;\n duration: number;\n is_transaction: boolean;\n children: SelectedSpan[];\n level: number;\n}\n\n/**\n * Selects a subset of \"interesting\" spans from a trace for display in the overview.\n *\n * Creates a fake root span representing the entire trace, with selected interesting\n * spans as children. This provides a unified tree view of the trace.\n *\n * The goal is to provide a meaningful sample of the trace that highlights the most\n * important operations while staying within display limits. Selection prioritizes:\n *\n * 1. **Transactions** - Top-level operations that represent complete user requests\n * 2. **Error spans** - Any spans that contain errors (critical for debugging)\n * 3. **Long-running spans** - Operations >= 10ms duration (performance bottlenecks)\n * 4. **Hierarchical context** - Maintains parent-child relationships for understanding\n *\n * Span inclusion rules:\n * - All transactions are included (they're typically root-level operations)\n * - Spans with errors are always included (debugging importance)\n * - Spans with duration >= 10ms are included (performance relevance)\n * - Children are recursively added up to 2 levels deep:\n * - Transactions can have up to 2 children each\n * - Regular spans can have up to 1 child each\n * - Total output is capped at maxSpans to prevent overwhelming display\n *\n * @param spans - Complete array of trace spans with nested children\n * @param traceId - Trace ID to display in the fake root span\n * @param maxSpans - Maximum number of spans to include in output (default: 20)\n * @returns Single-element array containing fake root span with selected spans as children\n */\nfunction selectInterestingSpans(\n spans: any[],\n traceId: string,\n maxSpans = 20,\n): SelectedSpan[] {\n const selected: SelectedSpan[] = [];\n let spanCount = 0;\n\n // Filter out non-span items (issues) from the trace data\n // Spans must have children array, duration, and other span-specific fields\n const actualSpans = spans.filter(\n (item) =>\n item &&\n typeof item === \"object\" &&\n \"children\" in item &&\n Array.isArray(item.children) &&\n \"duration\" in item,\n );\n\n function addSpan(span: any, level: number): boolean {\n if (spanCount >= maxSpans || level > MAX_DEPTH) return false;\n\n const duration = span.duration || 0;\n const isTransaction = span.is_transaction;\n const hasErrors = span.errors?.length > 0;\n\n // Always include transactions and spans with errors\n // For regular spans, include if they have reasonable duration or are at root level\n const shouldInclude =\n isTransaction ||\n hasErrors ||\n level === 0 ||\n duration >= MINIMUM_DURATION_THRESHOLD_MS;\n\n if (!shouldInclude) return false;\n\n const selectedSpan: SelectedSpan = {\n event_id: span.event_id,\n op: span.op || \"unknown\",\n name: span.name || null,\n description: span.description || span.transaction || \"unnamed\",\n duration,\n is_transaction: isTransaction,\n children: [],\n level,\n };\n\n spanCount++;\n\n // Add up to one interesting child per span, up to MAX_DEPTH levels deep\n if (level < MAX_DEPTH && span.children?.length > 0) {\n // Sort children by duration (descending) and take the most interesting ones\n const sortedChildren = span.children\n .filter((child: any) => child.duration > MIN_MEANINGFUL_CHILD_DURATION) // Only children with meaningful duration\n .sort((a: any, b: any) => (b.duration || 0) - (a.duration || 0));\n\n // Add up to 2 children for transactions, 1 for regular spans\n const maxChildren = isTransaction ? 2 : 1;\n let addedChildren = 0;\n\n for (const child of sortedChildren) {\n if (addedChildren >= maxChildren || spanCount >= maxSpans) break;\n\n if (addSpan(child, level + 1)) {\n const childSpan = selected[selected.length - 1];\n selectedSpan.children.push(childSpan);\n addedChildren++;\n }\n }\n }\n\n selected.push(selectedSpan);\n return true;\n }\n\n // Sort root spans by duration and select the most interesting ones\n const sortedRoots = actualSpans\n .sort((a, b) => (b.duration || 0) - (a.duration || 0))\n .slice(0, 5); // Start with top 5 root spans\n\n for (const root of sortedRoots) {\n if (spanCount >= maxSpans) break;\n addSpan(root, 0);\n }\n\n const rootSpans = selected.filter((span) => span.level === 0);\n\n // Create fake root span representing the entire trace (no duration - traces are unbounded)\n const fakeRoot: SelectedSpan = {\n event_id: traceId,\n op: \"trace\",\n name: null,\n description: `Trace ${traceId.substring(0, 8)}`,\n duration: 0, // Traces don't have duration\n is_transaction: false,\n children: rootSpans,\n level: -1, // Mark as fake root\n };\n\n return [fakeRoot];\n}\n\n/**\n * Formats a span display name for the tree view.\n *\n * Uses span.name if available (OTEL-native), otherwise falls back to span.description.\n *\n * @param span - The span to format\n * @returns A formatted display name for the span\n */\nfunction formatSpanDisplayName(span: SelectedSpan): string {\n // For the fake trace root, just return \"trace\"\n if (span.op === \"trace\") {\n return \"trace\";\n }\n\n // Use span.name if available (OTEL-native), otherwise use description\n return span.name?.trim() || span.description || \"unnamed\";\n}\n\n/**\n * Renders a hierarchical tree structure of spans using Unicode box-drawing characters.\n *\n * Creates a visual tree representation showing parent-child relationships between spans,\n * with proper indentation and connecting lines. Each span shows its operation, short ID,\n * description, duration, and type (transaction vs span).\n *\n * Tree format:\n * - Root spans have no prefix\n * - Child spans use ├─ for intermediate children, └─ for last child\n * - Continuation lines use │ for vertical connections\n * - Proper spacing maintains visual alignment\n *\n * @param spans - Array of selected spans with their nested children structure\n * @returns Array of formatted markdown strings representing the tree structure\n */\nfunction renderSpanTree(spans: SelectedSpan[]): string[] {\n const lines: string[] = [];\n\n function renderSpan(span: SelectedSpan, prefix = \"\", isLast = true): void {\n const shortId = span.event_id.substring(0, 8);\n const connector = prefix === \"\" ? \"\" : isLast ? \"└─ \" : \"├─ \";\n const displayName = formatSpanDisplayName(span);\n\n // Don't show duration for the fake trace root span\n if (span.op === \"trace\") {\n lines.push(`${prefix}${connector}${displayName} [${shortId}]`);\n } else {\n const duration = span.duration\n ? `${Math.round(span.duration)}ms`\n : \"unknown\";\n\n // Don't show 'default' operations as they're not meaningful\n const opDisplay = span.op === \"default\" ? \"\" : ` · ${span.op}`;\n lines.push(\n `${prefix}${connector}${displayName} [${shortId}${opDisplay} · ${duration}]`,\n );\n }\n\n // Render children with proper tree indentation\n for (let i = 0; i < span.children.length; i++) {\n const child = span.children[i];\n const isLastChild = i === span.children.length - 1;\n const childPrefix = prefix + (isLast ? \" \" : \"│ \");\n renderSpan(child, childPrefix, isLastChild);\n }\n }\n\n for (let i = 0; i < spans.length; i++) {\n const span = spans[i];\n const isLastRoot = i === spans.length - 1;\n renderSpan(span, \"\", isLastRoot);\n }\n\n return lines;\n}\n\nfunction calculateOperationStats(spans: any[]): Record<\n string,\n {\n count: number;\n avgDuration: number;\n p95Duration: number;\n }\n> {\n const allSpans = getAllSpansFlattened(spans);\n const operationSpans: Record<string, any[]> = {};\n\n // Group leaf spans by operation type (only spans with no children)\n for (const span of allSpans) {\n // Only consider leaf nodes - spans that have no children\n if (!span.children || span.children.length === 0) {\n // Use span.op if available, otherwise extract from span.name, fallback to \"unknown\"\n const op = span.op || (span.name ? span.name.split(\" \")[0] : \"unknown\");\n if (!operationSpans[op]) {\n operationSpans[op] = [];\n }\n operationSpans[op].push(span);\n }\n }\n\n const stats: Record<\n string,\n { count: number; avgDuration: number; p95Duration: number }\n > = {};\n\n // Calculate stats for each operation\n for (const [op, opSpans] of Object.entries(operationSpans)) {\n const durations = opSpans\n .map((span) => span.duration || 0)\n .filter((duration) => duration > 0)\n .sort((a, b) => a - b);\n\n const count = opSpans.length;\n const avgDuration =\n durations.length > 0\n ? durations.reduce((sum, duration) => sum + duration, 0) /\n durations.length\n : 0;\n\n // Calculate P95 (95th percentile)\n const p95Index = Math.floor(durations.length * 0.95);\n const p95Duration = durations.length > 0 ? durations[p95Index] || 0 : 0;\n\n stats[op] = {\n count,\n avgDuration,\n p95Duration,\n };\n }\n\n return stats;\n}\n\nfunction getAllSpansFlattened(spans: any[]): any[] {\n const result: any[] = [];\n\n // Filter out non-span items (issues) from the trace data\n // Spans must have children array and duration\n const actualSpans = spans.filter(\n (item) =>\n item &&\n typeof item === \"object\" &&\n \"children\" in item &&\n Array.isArray(item.children) &&\n \"duration\" in item,\n );\n\n function collectSpans(spanList: any[]) {\n for (const span of spanList) {\n result.push(span);\n if (span.children && span.children.length > 0) {\n collectSpans(span.children);\n }\n }\n }\n\n collectSpans(actualSpans);\n return result;\n}\n\nfunction formatTraceOutput({\n organizationSlug,\n traceId,\n traceMeta,\n trace,\n apiService,\n}: {\n organizationSlug: string;\n traceId: string;\n traceMeta: any;\n trace: any[];\n apiService: any;\n}): string {\n const sections: string[] = [];\n\n // Header\n sections.push(`# Trace \\`${traceId}\\` in **${organizationSlug}**`);\n sections.push(\"\");\n\n // High-level statistics\n sections.push(\"## Summary\");\n sections.push(\"\");\n sections.push(`**Total Spans**: ${traceMeta.span_count}`);\n sections.push(`**Errors**: ${traceMeta.errors}`);\n sections.push(`**Performance Issues**: ${traceMeta.performance_issues}`);\n sections.push(`**Logs**: ${traceMeta.logs}`);\n\n // Show operation breakdown with detailed stats if we have trace data\n if (trace.length > 0) {\n const operationStats = calculateOperationStats(trace);\n const sortedOps = Object.entries(operationStats)\n .filter(([, stats]) => stats.avgDuration >= MIN_AVG_DURATION_MS) // Only show ops with avg duration >= 5ms\n .sort(([, a], [, b]) => b.count - a.count)\n .slice(0, 10); // Show top 10\n\n if (sortedOps.length > 0) {\n sections.push(\"\");\n sections.push(\"## Operation Breakdown\");\n sections.push(\"\");\n\n for (const [op, stats] of sortedOps) {\n const avgDuration = Math.round(stats.avgDuration);\n const p95Duration = Math.round(stats.p95Duration);\n sections.push(\n `- **${op}**: ${stats.count} spans (avg: ${avgDuration}ms, p95: ${p95Duration}ms)`,\n );\n }\n sections.push(\"\");\n }\n }\n\n // Show span tree structure\n if (trace.length > 0) {\n const selectedSpans = selectInterestingSpans(trace, traceId);\n\n if (selectedSpans.length > 0) {\n sections.push(\"## Overview\");\n sections.push(\"\");\n const treeLines = renderSpanTree(selectedSpans);\n sections.push(...treeLines);\n sections.push(\"\");\n sections.push(\n \"*Note: This shows a subset of spans. View the full trace for complete details.*\",\n );\n sections.push(\"\");\n }\n }\n\n // Links and usage information\n const traceUrl = apiService.getTraceUrl(organizationSlug, traceId);\n sections.push(\"## View Full Trace\");\n sections.push(\"\");\n sections.push(`**Sentry URL**: ${traceUrl}`);\n sections.push(\"\");\n sections.push(\"## Find Related Events\");\n sections.push(\"\");\n sections.push(`Use this search query to find all events in this trace:`);\n sections.push(\"```\");\n sections.push(`trace:${traceId}`);\n sections.push(\"```\");\n sections.push(\"\");\n sections.push(\n \"You can use this query with the `search_events` tool to get detailed event data from this trace.\",\n );\n\n return sections.join(\"\\n\");\n}\n"],"mappings":";;;;;;;AAQA,MAAM,YAAY;AAClB,MAAM,gCAAgC;AACtC,MAAM,gCAAgC;AACtC,MAAM,sBAAsB;AAE5B,gCAAe,WAAW;CACxB,MAAM;CACN,gBAAgB,CAAC,SAAU;CAC3B,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAC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AAK,MAAM;AACpB,UAAS,KAAK,GAAG;AACjB,UAAS,KACP,mGACD;AAED,QAAO,SAAS,KAAK,KAAK;AAC3B"}
@@ -7,9 +7,9 @@ declare const _default: ToolConfig<{
7
7
  naturalLanguageQuery: z.ZodString;
8
8
  projectSlug: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
9
9
  regionUrl: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
10
- limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
11
- includeExplanation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
10
+ limit: z.ZodDefault<z.ZodNumber>;
11
+ includeExplanation: z.ZodDefault<z.ZodBoolean>;
12
12
  }>;
13
13
  //#endregion
14
14
  export { _default };
15
- //# sourceMappingURL=handler-CU9ZxaP9.d.ts.map
15
+ //# sourceMappingURL=handler-CASDrJ7z.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler-CU9ZxaP9.d.ts","names":[],"sources":["../src/tools/search-events/handler.ts"],"sourcesContent":[],"mappings":";;;;cAAwB;;;EAAA,WAAA,eAAA,aAAA,YAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"handler-CASDrJ7z.d.ts","names":[],"sources":["../src/tools/search-events/handler.ts"],"sourcesContent":[],"mappings":";;;;cAAwB;;;EAAA,WAAA,eAAA,aAAA,YAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
@@ -7,9 +7,9 @@ declare const _default: ToolConfig<{
7
7
  naturalLanguageQuery: z.ZodString;
8
8
  projectSlugOrId: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
9
9
  regionUrl: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
10
- limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
11
- includeExplanation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
10
+ limit: z.ZodDefault<z.ZodNumber>;
11
+ includeExplanation: z.ZodDefault<z.ZodBoolean>;
12
12
  }>;
13
13
  //#endregion
14
14
  export { _default };
15
- //# sourceMappingURL=handler-7ABtxyRG.d.cts.map
15
+ //# sourceMappingURL=handler-CZEMKP9p.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler-7ABtxyRG.d.cts","names":[],"sources":["../src/tools/search-issues/handler.ts"],"sourcesContent":[],"mappings":";;;;cAAwB;;;EAAA,eAAA,eAAA,aAAA,YAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"handler-CZEMKP9p.d.cts","names":[],"sources":["../src/tools/search-issues/handler.ts"],"sourcesContent":[],"mappings":";;;;cAAwB;;;EAAA,eAAA,eAAA,aAAA,YAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
@@ -1,11 +1,11 @@
1
- const require_chunk = require('./chunk-DWy1uDak.cjs');
1
+ const require_chunk = require('./chunk-CUT6urMc.cjs');
2
2
  const require_errors = require('./errors-umQzF_vW.cjs');
3
3
  const require_define = require('./define-CLp6EtpZ.cjs');
4
- const require_api = require('./api-BkWv0o1h.cjs');
5
- const require_schema = require('./schema-DUU4CA0j.cjs');
4
+ const require_api = require('./api-CHgBJOv9.cjs');
5
+ const require_schema = require('./schema-BGVOjcD7.cjs');
6
6
  const require_config = require('./config-2JTOC4-d.cjs');
7
- const require_agent = require('./agent-DOraNng-.cjs');
8
- const require_formatters = require('./formatters-Bta1mFce.cjs');
7
+ const require_agent = require('./agent-Cm9hEq5d.cjs');
8
+ const require_formatters = require('./formatters-ObdzRwld.cjs');
9
9
  const __sentry_core = require_chunk.__toESM(require("@sentry/core"));
10
10
  const zod = require_chunk.__toESM(require("zod"));
11
11
 
@@ -61,8 +61,8 @@ var handler_default = require_define.defineTool({
61
61
  naturalLanguageQuery: zod.z.string().trim().min(1).describe("Natural language description of what you want to search for"),
62
62
  projectSlug: require_schema.ParamProjectSlug.optional(),
63
63
  regionUrl: require_schema.ParamRegionUrl.optional(),
64
- limit: zod.z.number().min(1).max(100).optional().default(10).describe("Maximum number of results to return"),
65
- includeExplanation: zod.z.boolean().optional().default(false).describe("Include explanation of how the query was translated")
64
+ limit: zod.z.number().min(1).max(100).default(10).describe("Maximum number of results to return"),
65
+ includeExplanation: zod.z.boolean().default(false).describe("Include explanation of how the query was translated")
66
66
  },
67
67
  annotations: {
68
68
  readOnlyHint: true,
@@ -156,4 +156,4 @@ Object.defineProperty(exports, 'handler_default', {
156
156
  return handler_default;
157
157
  }
158
158
  });
159
- //# sourceMappingURL=handler-L0cEG-0-.cjs.map
159
+ //# sourceMappingURL=handler-ChOaafS-.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-ChOaafS-.cjs","names":["ParamOrganizationSlug","context: ServerContext","projectId: string | undefined","RECOMMENDED_FIELDS","UserInputError","fields: string[]","timeParams: { statsPeriod?: string; start?: string; end?: string }","response: unknown","data: unknown"],"sources":["../src/tools/search-events/handler.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { setTag } from \"@sentry/core\";\nimport { defineTool } from \"../../internal/tool-helpers/define\";\nimport { apiServiceFromContext } from \"../../internal/tool-helpers/api\";\nimport type { ServerContext } from \"../../types\";\nimport {\n ParamOrganizationSlug,\n ParamRegionUrl,\n ParamProjectSlug,\n} from \"../../schema\";\nimport { searchEventsAgent } from \"./agent\";\nimport {\n formatErrorResults,\n formatLogResults,\n formatSpanResults,\n} from \"./formatters\";\nimport { RECOMMENDED_FIELDS } from \"./config\";\nimport { UserInputError } from \"../../errors\";\n\nexport default defineTool({\n name: \"search_events\",\n requiredSkills: [\"inspect\", \"triage\", \"seer\"], // Available in inspect, triage, and seer skills\n requiredScopes: [\"event:read\"],\n description: [\n \"Search for events AND perform counts/aggregations - the ONLY tool for statistics and counts.\",\n \"\",\n \"Supports TWO query types:\",\n \"1. AGGREGATIONS (counts, sums, averages): 'how many errors', 'count of issues', 'total tokens'\",\n \"2. Individual events with timestamps: 'show me error logs from last hour'\",\n \"\",\n \"🔢 USE THIS FOR ALL COUNTS/STATISTICS:\",\n \"- 'how many errors today' → returns count\",\n \"- 'count of database failures' → returns count\",\n \"- 'total number of issues' → returns count\",\n \"- 'average response time' → returns avg()\",\n \"- 'sum of tokens used' → returns sum()\",\n \"\",\n \"📋 ALSO USE FOR INDIVIDUAL EVENTS:\",\n \"- 'error logs from last hour' → returns event list\",\n \"- 'database errors with timestamps' → returns event list\",\n \"- 'trace spans for slow API calls' → returns span list\",\n \"\",\n \"Dataset Selection (AI automatically chooses):\",\n \"- errors: Exception/crash events\",\n \"- logs: Log entries\",\n \"- spans: Performance data, AI/LLM calls, token usage\",\n \"\",\n \"❌ DO NOT USE for grouped issue lists → use search_issues\",\n \"\",\n \"<examples>\",\n \"search_events(organizationSlug='my-org', naturalLanguageQuery='how many errors today')\",\n \"search_events(organizationSlug='my-org', naturalLanguageQuery='count of database failures this week')\",\n \"search_events(organizationSlug='my-org', naturalLanguageQuery='total tokens used by model')\",\n \"search_events(organizationSlug='my-org', naturalLanguageQuery='error logs from the last hour')\",\n \"</examples>\",\n \"\",\n \"<hints>\",\n \"- If the user passes a parameter in the form of name/otherName, it's likely in the format of <organizationSlug>/<projectSlug>.\",\n \"- Parse org/project notation directly without calling find_organizations or find_projects.\",\n \"</hints>\",\n ].join(\"\\n\"),\n inputSchema: {\n organizationSlug: ParamOrganizationSlug,\n naturalLanguageQuery: z\n .string()\n .trim()\n .min(1)\n .describe(\"Natural language description of what you want to search for\"),\n projectSlug: ParamProjectSlug.optional(),\n regionUrl: ParamRegionUrl.optional(),\n limit: z\n .number()\n .min(1)\n .max(100)\n .default(10)\n .describe(\"Maximum number of results to return\"),\n includeExplanation: z\n .boolean()\n .default(false)\n .describe(\"Include explanation of how the query was translated\"),\n },\n annotations: {\n readOnlyHint: true,\n openWorldHint: true,\n },\n async handler(params, context: ServerContext) {\n const apiService = apiServiceFromContext(context, {\n regionUrl: params.regionUrl,\n });\n const organizationSlug = params.organizationSlug;\n\n setTag(\"organization.slug\", organizationSlug);\n if (params.projectSlug) setTag(\"project.slug\", params.projectSlug);\n\n // The agent will determine the dataset based on the query content\n\n // Convert project slug to ID if needed - we need this for attribute fetching\n let projectId: string | undefined;\n if (params.projectSlug) {\n const project = await apiService.getProject({\n organizationSlug,\n projectSlugOrId: params.projectSlug!,\n });\n projectId = String(project.id);\n }\n\n // Translate the natural language query using Search Events Agent\n // The agent will determine the dataset and fetch the appropriate attributes\n const agentResult = await searchEventsAgent({\n query: params.naturalLanguageQuery,\n organizationSlug,\n apiService,\n projectId,\n });\n\n const parsed = agentResult.result;\n\n // Get the dataset chosen by the agent\n const dataset = parsed.dataset;\n\n // Get recommended fields for this dataset (for fallback when no fields are provided)\n const recommendedFields = RECOMMENDED_FIELDS[dataset];\n\n // Validate that sort parameter was provided\n if (!parsed.sort) {\n throw new UserInputError(\n `Search Events Agent response missing required 'sort' parameter. Received: ${JSON.stringify(parsed, null, 2)}. The agent must specify how to sort results (e.g., '-timestamp' for newest first, '-count()' for highest count).`,\n );\n }\n\n // Use empty string as default if no query is provided\n // This allows fetching all recent events when no specific filter is needed\n const sentryQuery = parsed.query || \"\";\n const requestedFields = parsed.fields || [];\n\n // Determine if this is an aggregate query by checking if any field contains a function\n const isAggregateQuery = requestedFields.some(\n (field) => field.includes(\"(\") && field.includes(\")\"),\n );\n\n // For aggregate queries, we should only use the fields provided by the AI\n // For non-aggregate queries, we can use recommended fields as fallback\n let fields: string[];\n\n if (isAggregateQuery) {\n // For aggregate queries, fields must be provided and should only include\n // aggregate functions and groupBy fields\n if (!requestedFields || requestedFields.length === 0) {\n throw new UserInputError(\n `AI response missing required 'fields' for aggregate query. The AI must specify which fields to return. For aggregate queries, include only the aggregate functions (like count(), avg()) and groupBy fields.`,\n );\n }\n fields = requestedFields;\n } else {\n // For non-aggregate queries, use AI-provided fields or fall back to recommended fields\n fields =\n requestedFields && requestedFields.length > 0\n ? requestedFields\n : recommendedFields.basic;\n }\n\n // Use the AI-provided sort parameter\n const sortParam = parsed.sort;\n\n // Extract time range parameters from parsed response\n const timeParams: { statsPeriod?: string; start?: string; end?: string } =\n {};\n if (parsed.timeRange) {\n if (\"statsPeriod\" in parsed.timeRange) {\n timeParams.statsPeriod = parsed.timeRange.statsPeriod;\n } else if (\"start\" in parsed.timeRange && \"end\" in parsed.timeRange) {\n timeParams.start = parsed.timeRange.start;\n timeParams.end = parsed.timeRange.end;\n }\n } else {\n // Default time window if not specified\n timeParams.statsPeriod = \"14d\";\n }\n\n const eventsResponse = await apiService.searchEvents({\n organizationSlug,\n query: sentryQuery,\n fields,\n limit: params.limit,\n projectId, // API requires numeric project ID, not slug\n dataset: dataset === \"logs\" ? \"ourlogs\" : dataset,\n sort: sortParam,\n ...timeParams, // Spread the time parameters\n });\n\n // Generate the Sentry explorer URL with structured aggregate information\n // Derive aggregate functions and groupBy fields from the fields array\n const aggregateFunctions = fields.filter(\n (field) => field.includes(\"(\") && field.includes(\")\"),\n );\n const groupByFields = fields.filter(\n (field) => !field.includes(\"(\") && !field.includes(\")\"),\n );\n\n const explorerUrl = apiService.getEventsExplorerUrl(\n organizationSlug,\n sentryQuery,\n projectId, // Pass the numeric project ID for URL generation\n dataset, // dataset is already correct for URL generation (logs, spans, errors)\n fields, // Pass fields to detect if it's an aggregate query\n sortParam, // Pass sort parameter for URL generation\n aggregateFunctions,\n groupByFields,\n timeParams.statsPeriod,\n timeParams.start,\n timeParams.end,\n );\n\n // Type-safe access to event data with proper validation\n function isValidResponse(\n response: unknown,\n ): response is { data?: unknown[] } {\n return typeof response === \"object\" && response !== null;\n }\n\n function isValidEventArray(\n data: unknown,\n ): data is Record<string, unknown>[] {\n return (\n Array.isArray(data) &&\n data.every((item) => typeof item === \"object\" && item !== null)\n );\n }\n\n if (!isValidResponse(eventsResponse)) {\n throw new Error(\"Invalid response format from Sentry API\");\n }\n\n const eventData = eventsResponse.data;\n if (!isValidEventArray(eventData)) {\n throw new Error(\"Invalid event data format from Sentry API\");\n }\n\n // Format results based on dataset\n const formatParams = {\n eventData,\n naturalLanguageQuery: params.naturalLanguageQuery,\n includeExplanation: params.includeExplanation,\n apiService,\n organizationSlug,\n explorerUrl,\n sentryQuery,\n fields,\n explanation: parsed.explanation,\n };\n\n switch (dataset) {\n case \"errors\":\n return formatErrorResults(formatParams);\n case \"logs\":\n return formatLogResults(formatParams);\n case \"spans\":\n return formatSpanResults(formatParams);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;AAmBA,sBAAe,0BAAW;CACxB,MAAM;CACN,gBAAgB;EAAC;EAAW;EAAU;CAAO;CAC7C,gBAAgB,CAAC,YAAa;CAC9B,aAAa;EACX;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,EAAC,KAAK,KAAK;CACZ,aAAa;EACX,kBAAkBA;EAClB,sBAAsB,MACnB,QAAQ,CACR,MAAM,CACN,IAAI,EAAE,CACN,SAAS,8DAA8D;EAC1E,aAAa,gCAAiB,UAAU;EACxC,WAAW,8BAAe,UAAU;EACpC,OAAO,MACJ,QAAQ,CACR,IAAI,EAAE,CACN,IAAI,IAAI,CACR,QAAQ,GAAG,CACX,SAAS,sCAAsC;EAClD,oBAAoB,MACjB,SAAS,CACT,QAAQ,MAAM,CACd,SAAS,sDAAsD;CACnE;CACD,aAAa;EACX,cAAc;EACd,eAAe;CAChB;CACD,MAAM,QAAQ,QAAQC,SAAwB;EAC5C,MAAM,aAAa,kCAAsB,SAAS,EAChD,WAAW,OAAO,UACnB,EAAC;EACF,MAAM,mBAAmB,OAAO;AAEhC,4BAAO,qBAAqB,iBAAiB;AAC7C,MAAI,OAAO,YAAa,2BAAO,gBAAgB,OAAO,YAAY;EAKlE,IAAIC;AACJ,MAAI,OAAO,aAAa;GACtB,MAAM,UAAU,MAAM,WAAW,WAAW;IAC1C;IACA,iBAAiB,OAAO;GACzB,EAAC;A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ACA,aACA,WACA,SACA,QACA,WACA,oBACA,eACA,WAAW,aACX,WAAW,OACX,WAAW,IACZ;EAGD,SAAS,gBACPC,UACkC;AAClC,iBAAc,aAAa,YAAY,aAAa;EACrD;EAED,SAAS,kBACPC,MACmC;AACnC,UACE,MAAM,QAAQ,KAAK,IACnB,KAAK,MAAM,CAAC,gBAAgB,SAAS,YAAY,SAAS,KAAK;EAElE;AAED,OAAK,gBAAgB,eAAe,CAClC,OAAM,IAAI,MAAM;EAGlB,MAAM,YAAY,eAAe;AACjC,OAAK,kBAAkB,UAAU,CAC/B,OAAM,IAAI,MAAM;EAIlB,MAAM,eAAe;GACnB;GACA,sBAAsB,OAAO;GAC7B,oBAAoB,OAAO;GAC3B;GACA;GACA;GACA;GACA;GACA,aAAa,OAAO;EACrB;AAED,UAAQ,SAAR;GACE,KAAK,SACH,QAAO,sCAAmB,aAAa;GACzC,KAAK,OACH,QAAO,oCAAiB,aAAa;GACvC,KAAK,QACH,QAAO,qCAAkB,aAAa;EACzC;CACF;AACF,EAAC"}
@@ -7,9 +7,9 @@ declare const _default: ToolConfig<{
7
7
  naturalLanguageQuery: z.ZodString;
8
8
  projectSlug: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
9
9
  regionUrl: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
10
- limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
11
- includeExplanation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
10
+ limit: z.ZodDefault<z.ZodNumber>;
11
+ includeExplanation: z.ZodDefault<z.ZodBoolean>;
12
12
  }>;
13
13
  //#endregion
14
14
  export { _default };
15
- //# sourceMappingURL=handler-FxM1t6Wf.d.cts.map
15
+ //# sourceMappingURL=handler-CmTBmIt9.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler-FxM1t6Wf.d.cts","names":[],"sources":["../src/tools/search-events/handler.ts"],"sourcesContent":[],"mappings":";;;;cAAwB;;;EAAA,WAAA,eAAA,aAAA,YAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"handler-CmTBmIt9.d.cts","names":[],"sources":["../src/tools/search-events/handler.ts"],"sourcesContent":[],"mappings":";;;;cAAwB;;;EAAA,WAAA,eAAA,aAAA,YAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
@@ -7,9 +7,9 @@ declare const _default: ToolConfig<{
7
7
  naturalLanguageQuery: z.ZodString;
8
8
  projectSlugOrId: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
9
9
  regionUrl: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
10
- limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
11
- includeExplanation: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
10
+ limit: z.ZodDefault<z.ZodNumber>;
11
+ includeExplanation: z.ZodDefault<z.ZodBoolean>;
12
12
  }>;
13
13
  //#endregion
14
14
  export { _default };
15
- //# sourceMappingURL=handler-BDPbWDvJ.d.ts.map
15
+ //# sourceMappingURL=handler-Cs5DcdpF.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler-BDPbWDvJ.d.ts","names":[],"sources":["../src/tools/search-issues/handler.ts"],"sourcesContent":[],"mappings":";;;;cAAwB;;;EAAA,eAAA,eAAA,aAAA,YAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"handler-Cs5DcdpF.d.ts","names":[],"sources":["../src/tools/search-issues/handler.ts"],"sourcesContent":[],"mappings":";;;;cAAwB;;;EAAA,eAAA,eAAA,aAAA,YAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}