@langwatch/mcp-server 0.6.1 → 0.8.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 (241) hide show
  1. package/.release-please-shim +1 -0
  2. package/CHANGELOG.md +89 -0
  3. package/README.md +51 -8
  4. package/dist/{archive-scenario-YFD5THOR.js → archive-scenario-YKGLJ4MZ.js} +4 -4
  5. package/dist/archive-suite-QFNDO3Y3.js +15 -0
  6. package/dist/assign-prompt-tag-Y2B4CBBT.js +19 -0
  7. package/dist/chunk-B57MZ4WI.js +1573 -0
  8. package/dist/{chunk-IX6QJKAD.js → chunk-CPUPGDNA.js} +2 -2
  9. package/dist/chunk-FBRKHHJV.js +48 -0
  10. package/dist/{chunk-5UOPNRXW.js → chunk-HDJDFKZR.js} +10 -3
  11. package/dist/chunk-KOO5733S.js +72 -0
  12. package/dist/chunk-KZNBCKWG.js +39 -0
  13. package/dist/chunk-L6QENXYA.js +42 -0
  14. package/dist/{chunk-6U4TCGFC.js → chunk-NACSR6B7.js} +2 -2
  15. package/dist/chunk-NUFPTHKU.js +9 -0
  16. package/dist/chunk-OVQF3D5R.js +86 -0
  17. package/dist/chunk-PO7FM7IX.js +35 -0
  18. package/dist/chunk-PZUWCWOS.js +25 -0
  19. package/dist/chunk-WVI5CJ6S.js +21 -0
  20. package/dist/{chunk-LLRQIF52.js → chunk-YH2IBTEL.js} +54 -6
  21. package/dist/chunk-YI3OG4PI.js +71 -0
  22. package/dist/config.d.ts +17 -0
  23. package/dist/config.js +13 -0
  24. package/dist/create-agent-YRSDH7P7.js +23 -0
  25. package/dist/create-annotation-FYQNKMVJ.js +24 -0
  26. package/dist/create-dashboard-CORBR4YQ.js +18 -0
  27. package/dist/create-dataset-ZC63T6BB.js +22 -0
  28. package/dist/create-dataset-records-ILVNVKVR.js +22 -0
  29. package/dist/{create-evaluator-E5X5ZP3B.js → create-evaluator-2AU3PXFB.js} +4 -4
  30. package/dist/create-mcp-server.d.ts +8 -0
  31. package/dist/create-mcp-server.js +8 -0
  32. package/dist/{create-prompt-7Z35MIL6.js → create-prompt-NKRJ47YY.js} +7 -4
  33. package/dist/create-prompt-tag-S4JX3ULL.js +17 -0
  34. package/dist/{create-scenario-DIMPJRPY.js → create-scenario-BPRF75KF.js} +4 -4
  35. package/dist/create-suite-4YN7D6K2.js +38 -0
  36. package/dist/delete-agent-Y72R2YQA.js +18 -0
  37. package/dist/delete-annotation-UHWDMHSH.js +17 -0
  38. package/dist/delete-dashboard-LPWT36KN.js +18 -0
  39. package/dist/delete-dataset-GGPQRHKX.js +20 -0
  40. package/dist/delete-dataset-records-LTG5LT26.js +21 -0
  41. package/dist/delete-evaluator-F7QLXDHU.js +15 -0
  42. package/dist/delete-prompt-tag-B5UKZL45.js +17 -0
  43. package/dist/delete-workflow-4DGUDIDE.js +17 -0
  44. package/dist/get-agent-YEVICUX4.js +28 -0
  45. package/dist/{get-analytics-4YJW4S5L.js → get-analytics-3W5CMU3F.js} +22 -5
  46. package/dist/get-dashboard-NCQHN6MW.js +29 -0
  47. package/dist/get-dataset-KBK6PH36.js +48 -0
  48. package/dist/{get-evaluator-WDEH2F7M.js → get-evaluator-QDUL5LXR.js} +4 -4
  49. package/dist/{get-prompt-F6PDVC76.js → get-prompt-XCSSNRKR.js} +4 -4
  50. package/dist/{get-scenario-H24ZYNT5.js → get-scenario-FNRKOY7E.js} +4 -4
  51. package/dist/get-simulation-run-WOEKUF7K.js +56 -0
  52. package/dist/get-suite-U5AOD5TC.js +44 -0
  53. package/dist/{get-trace-27USKGO7.js → get-trace-MUWEJM2Z.js} +3 -3
  54. package/dist/get-workflow-SOA7MT7L.js +25 -0
  55. package/dist/http-server-7DMOCB75.js +224 -0
  56. package/dist/index.js +61640 -31868
  57. package/dist/langwatch-api-annotations-Q57NDUVR.js +17 -0
  58. package/dist/langwatch-api-dashboards-VBWWXV3Y.js +17 -0
  59. package/dist/langwatch-api-monitors-L3IY7FDT.js +52 -0
  60. package/dist/langwatch-api-secrets-S5HHF3XR.js +40 -0
  61. package/dist/langwatch-api-triggers-ME33QE26.js +30 -0
  62. package/dist/langwatch-api-workflows-4CJQAYP2.js +15 -0
  63. package/dist/list-agents-3HGIBJFM.js +32 -0
  64. package/dist/list-annotations-KWXYVEPI.js +33 -0
  65. package/dist/list-dashboards-VQ2LH666.js +32 -0
  66. package/dist/list-dataset-records-RNRGROJP.js +39 -0
  67. package/dist/list-datasets-I4A2LT2S.js +60 -0
  68. package/dist/{list-evaluators-KRGI72EH.js → list-evaluators-AKKRJ5MX.js} +4 -4
  69. package/dist/{list-model-providers-A5YCFTPI.js → list-model-providers-DVFEHFHZ.js} +4 -4
  70. package/dist/list-prompt-tags-PL5OISUA.js +23 -0
  71. package/dist/{list-prompts-LKJSE7XN.js → list-prompts-7VTFWE2Z.js} +3 -3
  72. package/dist/{list-scenarios-ZK5CMGC4.js → list-scenarios-5BZWZ6ZN.js} +4 -4
  73. package/dist/list-simulation-runs-WCZ6RLPE.js +43 -0
  74. package/dist/list-suites-RRQ2JX5Y.js +42 -0
  75. package/dist/list-workflows-UQB5FCX5.js +35 -0
  76. package/dist/rename-prompt-tag-TURD6KYU.js +18 -0
  77. package/dist/run-agent-BEJ4K4CM.js +36 -0
  78. package/dist/run-evaluation-AJ7WZNQD.js +64 -0
  79. package/dist/run-suite-U7V432G2.js +29 -0
  80. package/dist/run-workflow-5WX7DK5T.js +36 -0
  81. package/dist/{search-traces-SOKAAMAR.js → search-traces-ZCHNOMTX.js} +3 -3
  82. package/dist/{set-model-provider-7MGULZDH.js → set-model-provider-6CFHMCNE.js} +4 -4
  83. package/dist/update-agent-UE6UWLZP.js +20 -0
  84. package/dist/update-dataset-4XQZZE4S.js +22 -0
  85. package/dist/update-dataset-record-GNNM5TKM.js +19 -0
  86. package/dist/{update-evaluator-A3XINFLJ.js → update-evaluator-LHVDXIZD.js} +4 -4
  87. package/dist/{update-prompt-IW7X2UQM.js → update-prompt-3XEHECJ7.js} +5 -3
  88. package/dist/{update-scenario-ZT7TOBFR.js → update-scenario-DFPREYCD.js} +4 -4
  89. package/dist/update-suite-RATU5THO.js +39 -0
  90. package/package.json +22 -8
  91. package/src/__tests__/all-tools.integration.test.ts +353 -0
  92. package/src/__tests__/config.unit.test.ts +81 -1
  93. package/src/__tests__/datasets.integration.test.ts +620 -0
  94. package/src/__tests__/datasets.unit.test.ts +244 -0
  95. package/src/__tests__/docker.integration.test.ts +234 -0
  96. package/src/__tests__/http-transport.integration.test.ts +397 -0
  97. package/src/__tests__/langwatch-api.unit.test.ts +174 -0
  98. package/src/__tests__/scenario-tools.unit.test.ts +3 -0
  99. package/src/__tests__/tools.unit.test.ts +177 -0
  100. package/src/config.d.ts +15 -0
  101. package/src/config.ts +85 -7
  102. package/src/create-mcp-server.d.ts +6 -0
  103. package/src/create-mcp-server.ts +1799 -0
  104. package/src/http-server.ts +329 -0
  105. package/src/index.ts +22 -593
  106. package/src/langwatch-api-agents.ts +108 -0
  107. package/src/langwatch-api-annotations.ts +49 -0
  108. package/src/langwatch-api-dashboards.ts +48 -0
  109. package/src/langwatch-api-datasets.ts +191 -0
  110. package/src/langwatch-api-evaluators.ts +10 -0
  111. package/src/langwatch-api-monitors.ts +82 -0
  112. package/src/langwatch-api-secrets.ts +48 -0
  113. package/src/langwatch-api-simulation-runs.ts +51 -0
  114. package/src/langwatch-api-suites.ts +118 -0
  115. package/src/langwatch-api-triggers.ts +48 -0
  116. package/src/langwatch-api-workflows.ts +41 -0
  117. package/src/langwatch-api.ts +65 -3
  118. package/src/schemas/create-dataset.ts +48 -0
  119. package/src/schemas/index.ts +1 -0
  120. package/src/tools/archive-suite.ts +12 -0
  121. package/src/tools/assign-prompt-tag.ts +16 -0
  122. package/src/tools/create-agent.ts +15 -0
  123. package/src/tools/create-annotation.ts +18 -0
  124. package/src/tools/create-dashboard.ts +7 -0
  125. package/src/tools/create-dataset-records.ts +23 -0
  126. package/src/tools/create-dataset.ts +22 -0
  127. package/src/tools/create-prompt-tag.ts +12 -0
  128. package/src/tools/create-prompt.ts +4 -0
  129. package/src/tools/create-suite.ts +42 -0
  130. package/src/tools/delete-agent.ts +7 -0
  131. package/src/tools/delete-annotation.ts +7 -0
  132. package/src/tools/delete-dashboard.ts +7 -0
  133. package/src/tools/delete-dataset-records.ts +22 -0
  134. package/src/tools/delete-dataset.ts +20 -0
  135. package/src/tools/delete-evaluator.ts +12 -0
  136. package/src/tools/delete-prompt-tag.ts +12 -0
  137. package/src/tools/delete-workflow.ts +7 -0
  138. package/src/tools/format-dataset-mutation.ts +25 -0
  139. package/src/tools/get-agent.ts +21 -0
  140. package/src/tools/get-analytics.ts +30 -3
  141. package/src/tools/get-dashboard.ts +22 -0
  142. package/src/tools/get-dataset.ts +63 -0
  143. package/src/tools/get-prompt.ts +2 -1
  144. package/src/tools/get-simulation-run.ts +60 -0
  145. package/src/tools/get-suite.ts +47 -0
  146. package/src/tools/get-workflow.ts +17 -0
  147. package/src/tools/list-agents.ts +27 -0
  148. package/src/tools/list-annotations.ts +33 -0
  149. package/src/tools/list-dashboards.ts +27 -0
  150. package/src/tools/list-dataset-records.ts +46 -0
  151. package/src/tools/list-datasets.ts +80 -0
  152. package/src/tools/list-prompt-tags.ts +21 -0
  153. package/src/tools/list-simulation-runs.ts +49 -0
  154. package/src/tools/list-suites.ts +43 -0
  155. package/src/tools/list-workflows.ts +31 -0
  156. package/src/tools/rename-prompt-tag.ts +14 -0
  157. package/src/tools/run-agent.ts +36 -0
  158. package/src/tools/run-evaluation.ts +87 -0
  159. package/src/tools/run-suite.ts +28 -0
  160. package/src/tools/run-workflow.ts +36 -0
  161. package/src/tools/update-agent.ts +13 -0
  162. package/src/tools/update-dataset-record.ts +21 -0
  163. package/src/tools/update-dataset.ts +23 -0
  164. package/src/tools/update-prompt.ts +3 -0
  165. package/src/tools/update-suite.ts +44 -0
  166. package/src/utils/escape-markdown.ts +12 -0
  167. package/uv.lock +188 -530
  168. package/build.js +0 -12
  169. package/dist/archive-scenario-YFD5THOR.js.map +0 -1
  170. package/dist/chunk-5UOPNRXW.js.map +0 -1
  171. package/dist/chunk-6U4TCGFC.js.map +0 -1
  172. package/dist/chunk-AAQNA53E.js +0 -28
  173. package/dist/chunk-AAQNA53E.js.map +0 -1
  174. package/dist/chunk-IX6QJKAD.js.map +0 -1
  175. package/dist/chunk-LLRQIF52.js.map +0 -1
  176. package/dist/chunk-ZXKLPC2E.js.map +0 -1
  177. package/dist/config-FIQWQRUB.js +0 -11
  178. package/dist/config-FIQWQRUB.js.map +0 -1
  179. package/dist/create-evaluator-E5X5ZP3B.js.map +0 -1
  180. package/dist/create-prompt-7Z35MIL6.js.map +0 -1
  181. package/dist/create-scenario-DIMPJRPY.js.map +0 -1
  182. package/dist/discover-evaluator-schema-H23XCLNE.js.map +0 -1
  183. package/dist/discover-scenario-schema-MEEEVND7.js.map +0 -1
  184. package/dist/discover-schema-3T52ORPB.js.map +0 -1
  185. package/dist/get-analytics-4YJW4S5L.js.map +0 -1
  186. package/dist/get-evaluator-WDEH2F7M.js.map +0 -1
  187. package/dist/get-prompt-F6PDVC76.js.map +0 -1
  188. package/dist/get-scenario-H24ZYNT5.js.map +0 -1
  189. package/dist/get-trace-27USKGO7.js.map +0 -1
  190. package/dist/index.js.map +0 -1
  191. package/dist/list-evaluators-KRGI72EH.js.map +0 -1
  192. package/dist/list-model-providers-A5YCFTPI.js.map +0 -1
  193. package/dist/list-prompts-LKJSE7XN.js.map +0 -1
  194. package/dist/list-scenarios-ZK5CMGC4.js.map +0 -1
  195. package/dist/search-traces-SOKAAMAR.js.map +0 -1
  196. package/dist/set-model-provider-7MGULZDH.js.map +0 -1
  197. package/dist/update-evaluator-A3XINFLJ.js.map +0 -1
  198. package/dist/update-prompt-IW7X2UQM.js.map +0 -1
  199. package/dist/update-scenario-ZT7TOBFR.js.map +0 -1
  200. package/tests/evaluations.ipynb +0 -649
  201. package/tests/fixtures/azure/azure_openai_stream_bot_expected.py +0 -102
  202. package/tests/fixtures/azure/azure_openai_stream_bot_input.py +0 -78
  203. package/tests/fixtures/dspy/dspy_bot_expected.py +0 -61
  204. package/tests/fixtures/dspy/dspy_bot_input.py +0 -53
  205. package/tests/fixtures/fastapi/fastapi_app_expected.py +0 -68
  206. package/tests/fixtures/fastapi/fastapi_app_input.py +0 -60
  207. package/tests/fixtures/fastapi/prompt_management_fastapi_expected.py +0 -114
  208. package/tests/fixtures/fastapi/prompt_management_fastapi_input.py +0 -88
  209. package/tests/fixtures/haystack/haystack_bot_expected.py +0 -141
  210. package/tests/fixtures/haystack/haystack_bot_input.py +0 -69
  211. package/tests/fixtures/langchain/langchain_bot_expected.py +0 -53
  212. package/tests/fixtures/langchain/langchain_bot_input.py +0 -45
  213. package/tests/fixtures/langchain/langchain_bot_with_memory_expected.py +0 -69
  214. package/tests/fixtures/langchain/langchain_bot_with_memory_input.py +0 -61
  215. package/tests/fixtures/langchain/langchain_rag_bot_expected.py +0 -97
  216. package/tests/fixtures/langchain/langchain_rag_bot_input.py +0 -77
  217. package/tests/fixtures/langchain/langchain_rag_bot_vertex_ai_expected.py +0 -116
  218. package/tests/fixtures/langchain/langchain_rag_bot_vertex_ai_input.py +0 -81
  219. package/tests/fixtures/langchain/langgraph_rag_bot_with_threads_expected.py +0 -331
  220. package/tests/fixtures/langchain/langgraph_rag_bot_with_threads_input.py +0 -106
  221. package/tests/fixtures/litellm/litellm_bot_expected.py +0 -40
  222. package/tests/fixtures/litellm/litellm_bot_input.py +0 -35
  223. package/tests/fixtures/openai/openai_bot_expected.py +0 -43
  224. package/tests/fixtures/openai/openai_bot_function_call_expected.py +0 -91
  225. package/tests/fixtures/openai/openai_bot_function_call_input.py +0 -82
  226. package/tests/fixtures/openai/openai_bot_input.py +0 -36
  227. package/tests/fixtures/openai/openai_bot_rag_expected.py +0 -73
  228. package/tests/fixtures/openai/openai_bot_rag_input.py +0 -51
  229. package/tests/fixtures/opentelemetry/openinference_dspy_bot_expected.py +0 -63
  230. package/tests/fixtures/opentelemetry/openinference_dspy_bot_input.py +0 -58
  231. package/tests/fixtures/opentelemetry/openinference_langchain_bot_expected.py +0 -53
  232. package/tests/fixtures/opentelemetry/openinference_langchain_bot_input.py +0 -52
  233. package/tests/fixtures/opentelemetry/openinference_openai_bot_expected.py +0 -49
  234. package/tests/fixtures/opentelemetry/openinference_openai_bot_input.py +0 -41
  235. package/tests/fixtures/opentelemetry/openllmetry_openai_bot_expected.py +0 -44
  236. package/tests/fixtures/opentelemetry/openllmetry_openai_bot_input.py +0 -40
  237. package/tests/fixtures/strands/strands_bot_expected.py +0 -84
  238. package/tests/fixtures/strands/strands_bot_input.py +0 -52
  239. package/tests/scenario-openai.test.ts +0 -160
  240. package/tsup.config.ts +0 -10
  241. package/vitest.config.js +0 -7
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  makeRequest
3
- } from "./chunk-LLRQIF52.js";
3
+ } from "./chunk-YH2IBTEL.js";
4
4
 
5
5
  // src/langwatch-api-model-providers.ts
6
6
  async function listModelProviders() {
@@ -19,4 +19,4 @@ export {
19
19
  listModelProviders,
20
20
  setModelProvider
21
21
  };
22
- //# sourceMappingURL=chunk-IX6QJKAD.js.map
22
+ //# sourceMappingURL=chunk-CPUPGDNA.js.map
@@ -0,0 +1,48 @@
1
+ import {
2
+ makeRequest
3
+ } from "./chunk-YH2IBTEL.js";
4
+
5
+ // src/langwatch-api-suites.ts
6
+ async function listSuites() {
7
+ return makeRequest("GET", "/api/suites");
8
+ }
9
+ async function getSuite(id) {
10
+ return makeRequest(
11
+ "GET",
12
+ `/api/suites/${encodeURIComponent(id)}`
13
+ );
14
+ }
15
+ async function createSuite(data) {
16
+ return makeRequest("POST", "/api/suites", data);
17
+ }
18
+ async function updateSuite(params) {
19
+ const { id, ...data } = params;
20
+ return makeRequest(
21
+ "PATCH",
22
+ `/api/suites/${encodeURIComponent(id)}`,
23
+ data
24
+ );
25
+ }
26
+ async function runSuite(id, idempotencyKey) {
27
+ return makeRequest(
28
+ "POST",
29
+ `/api/suites/${encodeURIComponent(id)}/run`,
30
+ { idempotencyKey: idempotencyKey ?? `mcp-${Date.now()}-${Math.random().toString(36).slice(2)}` }
31
+ );
32
+ }
33
+ async function archiveSuite(id) {
34
+ return makeRequest(
35
+ "DELETE",
36
+ `/api/suites/${encodeURIComponent(id)}`
37
+ );
38
+ }
39
+
40
+ export {
41
+ listSuites,
42
+ getSuite,
43
+ createSuite,
44
+ updateSuite,
45
+ runSuite,
46
+ archiveSuite
47
+ };
48
+ //# sourceMappingURL=chunk-FBRKHHJV.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  makeRequest
3
- } from "./chunk-LLRQIF52.js";
3
+ } from "./chunk-YH2IBTEL.js";
4
4
 
5
5
  // src/langwatch-api-evaluators.ts
6
6
  function getEvaluatorType(evaluator) {
@@ -26,12 +26,19 @@ async function updateEvaluator(params) {
26
26
  data
27
27
  );
28
28
  }
29
+ async function deleteEvaluator(idOrSlug) {
30
+ return makeRequest(
31
+ "DELETE",
32
+ `/api/evaluators/${encodeURIComponent(idOrSlug)}`
33
+ );
34
+ }
29
35
 
30
36
  export {
31
37
  getEvaluatorType,
32
38
  listEvaluators,
33
39
  getEvaluator,
34
40
  createEvaluator,
35
- updateEvaluator
41
+ updateEvaluator,
42
+ deleteEvaluator
36
43
  };
37
- //# sourceMappingURL=chunk-5UOPNRXW.js.map
44
+ //# sourceMappingURL=chunk-HDJDFKZR.js.map
@@ -0,0 +1,72 @@
1
+ // src/config.ts
2
+ import { AsyncLocalStorage } from "async_hooks";
3
+ var GLOBAL_KEY = "__langwatch_mcp_config";
4
+ var STORAGE_KEY = "__langwatch_mcp_config_storage";
5
+ function getGlobalState() {
6
+ const g = globalThis;
7
+ if (!g[GLOBAL_KEY]) {
8
+ g[GLOBAL_KEY] = void 0;
9
+ }
10
+ if (!g[STORAGE_KEY]) {
11
+ g[STORAGE_KEY] = new AsyncLocalStorage();
12
+ }
13
+ return {
14
+ get globalConfig() {
15
+ return g[GLOBAL_KEY];
16
+ },
17
+ set globalConfig(val) {
18
+ g[GLOBAL_KEY] = val;
19
+ },
20
+ get configStorage() {
21
+ return g[STORAGE_KEY];
22
+ }
23
+ };
24
+ }
25
+ function initConfig(args) {
26
+ const state = getGlobalState();
27
+ state.globalConfig = {
28
+ apiKey: args.apiKey || process.env.LANGWATCH_API_KEY,
29
+ endpoint: args.endpoint || process.env.LANGWATCH_ENDPOINT || "https://app.langwatch.ai",
30
+ projectId: process.env.LANGWATCH_PROJECT_ID
31
+ };
32
+ }
33
+ function getConfig() {
34
+ const state = getGlobalState();
35
+ const scoped = state.configStorage.getStore();
36
+ if (scoped) return scoped;
37
+ if (!state.globalConfig) {
38
+ console.error(
39
+ "[MCP config] getConfig() failed: globalConfig is null, no scoped config active. Was initConfig() called? Stack:",
40
+ new Error().stack
41
+ );
42
+ throw new Error("Config not initialized");
43
+ }
44
+ return state.globalConfig;
45
+ }
46
+ function requireApiKey() {
47
+ const config = getConfig();
48
+ if (!config.apiKey) {
49
+ const state = getGlobalState();
50
+ const hasScoped = !!state.configStorage.getStore();
51
+ console.error(
52
+ `[MCP config] requireApiKey() failed: apiKey is undefined. scopedConfig=${hasScoped}, endpoint=${config.endpoint}. In HTTP mode, the API key should be set per-session via runWithConfig(). Stack:`,
53
+ new Error().stack
54
+ );
55
+ throw new Error(
56
+ "LANGWATCH_API_KEY is required. Set it via --apiKey flag or LANGWATCH_API_KEY environment variable."
57
+ );
58
+ }
59
+ return config.apiKey;
60
+ }
61
+ function runWithConfig(config, fn) {
62
+ const state = getGlobalState();
63
+ return state.configStorage.run(config, fn);
64
+ }
65
+
66
+ export {
67
+ initConfig,
68
+ getConfig,
69
+ requireApiKey,
70
+ runWithConfig
71
+ };
72
+ //# sourceMappingURL=chunk-KOO5733S.js.map
@@ -0,0 +1,39 @@
1
+ import {
2
+ makeRequest
3
+ } from "./chunk-YH2IBTEL.js";
4
+
5
+ // src/langwatch-api-dashboards.ts
6
+ async function listDashboards() {
7
+ return makeRequest("GET", "/api/dashboards");
8
+ }
9
+ async function getDashboard(id) {
10
+ return makeRequest(
11
+ "GET",
12
+ `/api/dashboards/${encodeURIComponent(id)}`
13
+ );
14
+ }
15
+ async function createDashboard(data) {
16
+ return makeRequest("POST", "/api/dashboards", data);
17
+ }
18
+ async function renameDashboard(id, data) {
19
+ return makeRequest(
20
+ "PATCH",
21
+ `/api/dashboards/${encodeURIComponent(id)}`,
22
+ data
23
+ );
24
+ }
25
+ async function deleteDashboard(id) {
26
+ return makeRequest(
27
+ "DELETE",
28
+ `/api/dashboards/${encodeURIComponent(id)}`
29
+ );
30
+ }
31
+
32
+ export {
33
+ listDashboards,
34
+ getDashboard,
35
+ createDashboard,
36
+ renameDashboard,
37
+ deleteDashboard
38
+ };
39
+ //# sourceMappingURL=chunk-KZNBCKWG.js.map
@@ -0,0 +1,42 @@
1
+ import {
2
+ makeRequest
3
+ } from "./chunk-YH2IBTEL.js";
4
+
5
+ // src/langwatch-api-annotations.ts
6
+ async function listAnnotations() {
7
+ return makeRequest("GET", "/api/annotations");
8
+ }
9
+ async function getAnnotation(id) {
10
+ return makeRequest(
11
+ "GET",
12
+ `/api/annotations/${encodeURIComponent(id)}`
13
+ );
14
+ }
15
+ async function getAnnotationsByTrace(traceId) {
16
+ return makeRequest(
17
+ "GET",
18
+ `/api/annotations/trace/${encodeURIComponent(traceId)}`
19
+ );
20
+ }
21
+ async function createAnnotation(traceId, data) {
22
+ return makeRequest(
23
+ "POST",
24
+ `/api/annotations/trace/${encodeURIComponent(traceId)}`,
25
+ data
26
+ );
27
+ }
28
+ async function deleteAnnotation(id) {
29
+ return makeRequest(
30
+ "DELETE",
31
+ `/api/annotations/${encodeURIComponent(id)}`
32
+ );
33
+ }
34
+
35
+ export {
36
+ listAnnotations,
37
+ getAnnotation,
38
+ getAnnotationsByTrace,
39
+ createAnnotation,
40
+ deleteAnnotation
41
+ };
42
+ //# sourceMappingURL=chunk-L6QENXYA.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  makeRequest
3
- } from "./chunk-LLRQIF52.js";
3
+ } from "./chunk-YH2IBTEL.js";
4
4
 
5
5
  // src/langwatch-api-scenarios.ts
6
6
  async function listScenarios() {
@@ -37,4 +37,4 @@ export {
37
37
  updateScenario,
38
38
  archiveScenario
39
39
  };
40
- //# sourceMappingURL=chunk-6U4TCGFC.js.map
40
+ //# sourceMappingURL=chunk-NACSR6B7.js.map
@@ -0,0 +1,9 @@
1
+ // src/utils/escape-markdown.ts
2
+ function escapeMarkdown(value) {
3
+ return value.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\n/g, " ");
4
+ }
5
+
6
+ export {
7
+ escapeMarkdown
8
+ };
9
+ //# sourceMappingURL=chunk-NUFPTHKU.js.map
@@ -0,0 +1,86 @@
1
+ import {
2
+ makeRequest
3
+ } from "./chunk-YH2IBTEL.js";
4
+
5
+ // src/langwatch-api-datasets.ts
6
+ async function listDatasets(params) {
7
+ const query = new URLSearchParams();
8
+ if (params?.page != null) query.set("page", String(params.page));
9
+ if (params?.limit != null) query.set("limit", String(params.limit));
10
+ const qs = query.toString();
11
+ const path = qs ? `/api/dataset?${qs}` : "/api/dataset";
12
+ return makeRequest("GET", path);
13
+ }
14
+ async function getDataset(slugOrId) {
15
+ return makeRequest(
16
+ "GET",
17
+ `/api/dataset/${encodeURIComponent(slugOrId)}`
18
+ );
19
+ }
20
+ async function createDataset(data) {
21
+ return makeRequest(
22
+ "POST",
23
+ "/api/dataset",
24
+ data
25
+ );
26
+ }
27
+ async function updateDataset(params) {
28
+ const { slugOrId, ...data } = params;
29
+ return makeRequest(
30
+ "PATCH",
31
+ `/api/dataset/${encodeURIComponent(slugOrId)}`,
32
+ data
33
+ );
34
+ }
35
+ async function deleteDataset(slugOrId) {
36
+ return makeRequest(
37
+ "DELETE",
38
+ `/api/dataset/${encodeURIComponent(slugOrId)}`
39
+ );
40
+ }
41
+ async function createDatasetRecords(params) {
42
+ const { slugOrId, entries } = params;
43
+ return makeRequest(
44
+ "POST",
45
+ `/api/dataset/${encodeURIComponent(slugOrId)}/records`,
46
+ { entries }
47
+ );
48
+ }
49
+ async function updateDatasetRecord(params) {
50
+ const { slugOrId, recordId, entry } = params;
51
+ return makeRequest(
52
+ "PATCH",
53
+ `/api/dataset/${encodeURIComponent(slugOrId)}/records/${encodeURIComponent(recordId)}`,
54
+ { entry }
55
+ );
56
+ }
57
+ async function deleteDatasetRecords(params) {
58
+ const { slugOrId, recordIds } = params;
59
+ return makeRequest(
60
+ "DELETE",
61
+ `/api/dataset/${encodeURIComponent(slugOrId)}/records`,
62
+ { recordIds }
63
+ );
64
+ }
65
+ async function listDatasetRecords(params) {
66
+ const { slugOrId } = params;
67
+ const query = new URLSearchParams();
68
+ if (params.page != null) query.set("page", String(params.page));
69
+ if (params.limit != null) query.set("limit", String(params.limit));
70
+ const qs = query.toString();
71
+ const path = `/api/dataset/${encodeURIComponent(slugOrId)}/records${qs ? `?${qs}` : ""}`;
72
+ return makeRequest("GET", path);
73
+ }
74
+
75
+ export {
76
+ listDatasets,
77
+ getDataset,
78
+ createDataset,
79
+ updateDataset,
80
+ deleteDataset,
81
+ createDatasetRecords,
82
+ updateDatasetRecord,
83
+ deleteDatasetRecords,
84
+ listDatasetRecords
85
+ };
86
+ //# sourceMappingURL=chunk-OVQF3D5R.js.map
@@ -0,0 +1,35 @@
1
+ import {
2
+ makeRequest
3
+ } from "./chunk-YH2IBTEL.js";
4
+
5
+ // src/langwatch-api-workflows.ts
6
+ async function listWorkflows() {
7
+ return makeRequest("GET", "/api/workflows");
8
+ }
9
+ async function getWorkflow(id) {
10
+ return makeRequest(
11
+ "GET",
12
+ `/api/workflows/${encodeURIComponent(id)}`
13
+ );
14
+ }
15
+ async function runWorkflow(id, input) {
16
+ return makeRequest(
17
+ "POST",
18
+ `/api/workflows/${encodeURIComponent(id)}/run`,
19
+ input ?? {}
20
+ );
21
+ }
22
+ async function deleteWorkflow(id) {
23
+ return makeRequest(
24
+ "DELETE",
25
+ `/api/workflows/${encodeURIComponent(id)}`
26
+ );
27
+ }
28
+
29
+ export {
30
+ listWorkflows,
31
+ getWorkflow,
32
+ runWorkflow,
33
+ deleteWorkflow
34
+ };
35
+ //# sourceMappingURL=chunk-PO7FM7IX.js.map
@@ -0,0 +1,25 @@
1
+ import {
2
+ makeRequest
3
+ } from "./chunk-YH2IBTEL.js";
4
+
5
+ // src/langwatch-api-simulation-runs.ts
6
+ async function listSimulationRuns(params) {
7
+ const query = new URLSearchParams();
8
+ if (params?.scenarioSetId) query.set("scenarioSetId", params.scenarioSetId);
9
+ if (params?.batchRunId) query.set("batchRunId", params.batchRunId);
10
+ if (params?.limit) query.set("limit", String(params.limit));
11
+ const qs = query.toString() ? `?${query}` : "";
12
+ return makeRequest("GET", `/api/simulation-runs${qs}`);
13
+ }
14
+ async function getSimulationRun(scenarioRunId) {
15
+ return makeRequest(
16
+ "GET",
17
+ `/api/simulation-runs/${encodeURIComponent(scenarioRunId)}`
18
+ );
19
+ }
20
+
21
+ export {
22
+ listSimulationRuns,
23
+ getSimulationRun
24
+ };
25
+ //# sourceMappingURL=chunk-PZUWCWOS.js.map
@@ -0,0 +1,21 @@
1
+ import {
2
+ escapeMarkdown
3
+ } from "./chunk-NUFPTHKU.js";
4
+
5
+ // src/tools/format-dataset-mutation.ts
6
+ function formatDatasetMutationDetails(result) {
7
+ const lines = [];
8
+ lines.push(`**Name**: ${escapeMarkdown(result.name)}`);
9
+ lines.push(`**Slug**: ${escapeMarkdown(result.slug)}`);
10
+ lines.push(`**ID**: ${escapeMarkdown(result.id)}`);
11
+ if (Array.isArray(result.columnTypes) && result.columnTypes.length > 0) {
12
+ const colNames = result.columnTypes.map((c) => `${escapeMarkdown(c.name)} (${escapeMarkdown(c.type)})`).join(", ");
13
+ lines.push(`**Columns**: ${colNames}`);
14
+ }
15
+ return lines;
16
+ }
17
+
18
+ export {
19
+ formatDatasetMutationDetails
20
+ };
21
+ //# sourceMappingURL=chunk-WVI5CJ6S.js.map
@@ -1,14 +1,18 @@
1
1
  import {
2
2
  getConfig,
3
3
  requireApiKey
4
- } from "./chunk-AAQNA53E.js";
4
+ } from "./chunk-KOO5733S.js";
5
5
 
6
6
  // src/langwatch-api.ts
7
7
  async function makeRequest(method, path, body) {
8
- const url = getConfig().endpoint + path;
8
+ const config = getConfig();
9
+ const url = config.endpoint + path;
9
10
  const headers = {
10
11
  "X-Auth-Token": requireApiKey()
11
12
  };
13
+ if (config.projectId) {
14
+ headers["X-Project-Id"] = config.projectId;
15
+ }
12
16
  if (body !== void 0) {
13
17
  headers["Content-Type"] = "application/json";
14
18
  }
@@ -23,6 +27,9 @@ async function makeRequest(method, path, body) {
23
27
  `LangWatch API error ${response.status}: ${responseBody}`
24
28
  );
25
29
  }
30
+ if (response.status === 204 || response.headers?.get("content-length") === "0") {
31
+ return null;
32
+ }
26
33
  return response.json();
27
34
  }
28
35
  async function searchTraces(params) {
@@ -48,8 +55,11 @@ async function getAnalyticsTimeseries(params) {
48
55
  async function listPrompts() {
49
56
  return makeRequest("GET", "/api/prompts");
50
57
  }
51
- async function getPrompt(idOrHandle, version) {
52
- const query = version != null ? `?version=${version}` : "";
58
+ async function getPrompt(idOrHandle, options) {
59
+ const params = new URLSearchParams();
60
+ if (options?.version != null) params.set("version", String(options.version));
61
+ if (options?.tag) params.set("tag", options.tag);
62
+ const query = params.toString() ? `?${params}` : "";
53
63
  return makeRequest(
54
64
  "GET",
55
65
  `/api/prompts/${encodeURIComponent(idOrHandle)}${query}`
@@ -69,6 +79,39 @@ async function updatePrompt(idOrHandle, data) {
69
79
  data
70
80
  );
71
81
  }
82
+ async function assignPromptTag({
83
+ idOrHandle,
84
+ tag,
85
+ versionId
86
+ }) {
87
+ return makeRequest(
88
+ "PUT",
89
+ `/api/prompts/${encodeURIComponent(idOrHandle)}/tags/${encodeURIComponent(tag)}`,
90
+ { versionId }
91
+ );
92
+ }
93
+ async function listPromptTags() {
94
+ return makeRequest("GET", "/api/prompts/tags");
95
+ }
96
+ async function createPromptTag(name) {
97
+ return makeRequest("POST", "/api/prompts/tags", { name });
98
+ }
99
+ async function renamePromptTag({
100
+ tag,
101
+ name
102
+ }) {
103
+ return makeRequest(
104
+ "PUT",
105
+ `/api/prompts/tags/${encodeURIComponent(tag)}`,
106
+ { name }
107
+ );
108
+ }
109
+ async function deletePromptTag(tag) {
110
+ return makeRequest(
111
+ "DELETE",
112
+ `/api/prompts/tags/${encodeURIComponent(tag)}`
113
+ );
114
+ }
72
115
 
73
116
  export {
74
117
  makeRequest,
@@ -78,6 +121,11 @@ export {
78
121
  listPrompts,
79
122
  getPrompt,
80
123
  createPrompt,
81
- updatePrompt
124
+ updatePrompt,
125
+ assignPromptTag,
126
+ listPromptTags,
127
+ createPromptTag,
128
+ renamePromptTag,
129
+ deletePromptTag
82
130
  };
83
- //# sourceMappingURL=chunk-LLRQIF52.js.map
131
+ //# sourceMappingURL=chunk-YH2IBTEL.js.map
@@ -0,0 +1,71 @@
1
+ import {
2
+ makeRequest
3
+ } from "./chunk-YH2IBTEL.js";
4
+
5
+ // src/langwatch-api-agents.ts
6
+ async function listAgents(params) {
7
+ const query = new URLSearchParams();
8
+ if (params?.page) query.set("page", String(params.page));
9
+ if (params?.limit) query.set("limit", String(params.limit));
10
+ const qs = query.toString() ? `?${query}` : "";
11
+ return makeRequest("GET", `/api/agents${qs}`);
12
+ }
13
+ async function getAgent(id) {
14
+ return makeRequest(
15
+ "GET",
16
+ `/api/agents/${encodeURIComponent(id)}`
17
+ );
18
+ }
19
+ async function createAgent(data) {
20
+ return makeRequest("POST", "/api/agents", data);
21
+ }
22
+ async function updateAgent(params) {
23
+ const { id, ...data } = params;
24
+ return makeRequest(
25
+ "PATCH",
26
+ `/api/agents/${encodeURIComponent(id)}`,
27
+ data
28
+ );
29
+ }
30
+ async function runAgent(id, input) {
31
+ const agent = await getAgent(id);
32
+ const config = agent.config ?? {};
33
+ if (agent.type === "http") {
34
+ const url = config.url;
35
+ if (!url) {
36
+ throw new Error("HTTP agent has no URL configured");
37
+ }
38
+ const response = await fetch(url, {
39
+ method: "POST",
40
+ headers: { "Content-Type": "application/json" },
41
+ body: JSON.stringify(input ?? {})
42
+ });
43
+ const result2 = await response.json();
44
+ return { agentType: "http", result: result2 };
45
+ }
46
+ const workflowId = config.workflowId;
47
+ if (!workflowId) {
48
+ throw new Error(
49
+ `Agent "${agent.name}" (type: ${agent.type}) cannot be executed directly. Only HTTP agents and workflow-linked agents can be run.`
50
+ );
51
+ }
52
+ const { runWorkflow } = await import("./langwatch-api-workflows-4CJQAYP2.js");
53
+ const result = await runWorkflow(workflowId, input);
54
+ return { agentType: agent.type, result };
55
+ }
56
+ async function deleteAgent(id) {
57
+ return makeRequest(
58
+ "DELETE",
59
+ `/api/agents/${encodeURIComponent(id)}`
60
+ );
61
+ }
62
+
63
+ export {
64
+ listAgents,
65
+ getAgent,
66
+ createAgent,
67
+ updateAgent,
68
+ runAgent,
69
+ deleteAgent
70
+ };
71
+ //# sourceMappingURL=chunk-YI3OG4PI.js.map
@@ -0,0 +1,17 @@
1
+ interface McpConfig {
2
+ apiKey: string | undefined;
3
+ endpoint: string;
4
+ }
5
+
6
+ declare function initConfig(args: {
7
+ apiKey?: string;
8
+ endpoint?: string;
9
+ }): void;
10
+
11
+ declare function getConfig(): McpConfig;
12
+
13
+ declare function requireApiKey(): string;
14
+
15
+ declare function runWithConfig<T>(config: McpConfig, fn: () => T): T;
16
+
17
+ export { type McpConfig, getConfig, initConfig, requireApiKey, runWithConfig };
package/dist/config.js ADDED
@@ -0,0 +1,13 @@
1
+ import {
2
+ getConfig,
3
+ initConfig,
4
+ requireApiKey,
5
+ runWithConfig
6
+ } from "./chunk-KOO5733S.js";
7
+ export {
8
+ getConfig,
9
+ initConfig,
10
+ requireApiKey,
11
+ runWithConfig
12
+ };
13
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,23 @@
1
+ import {
2
+ createAgent
3
+ } from "./chunk-YI3OG4PI.js";
4
+ import "./chunk-YH2IBTEL.js";
5
+ import "./chunk-KOO5733S.js";
6
+
7
+ // src/tools/create-agent.ts
8
+ async function handleCreateAgent(params) {
9
+ const agent = await createAgent({
10
+ name: params.name,
11
+ type: params.type,
12
+ config: params.config ?? {}
13
+ });
14
+ return `Agent created successfully!
15
+
16
+ **Name**: ${agent.name}
17
+ **ID**: ${agent.id}
18
+ **Type**: ${agent.type}`;
19
+ }
20
+ export {
21
+ handleCreateAgent
22
+ };
23
+ //# sourceMappingURL=create-agent-YRSDH7P7.js.map
@@ -0,0 +1,24 @@
1
+ import {
2
+ createAnnotation
3
+ } from "./chunk-L6QENXYA.js";
4
+ import "./chunk-YH2IBTEL.js";
5
+ import "./chunk-KOO5733S.js";
6
+
7
+ // src/tools/create-annotation.ts
8
+ async function handleCreateAnnotation(params) {
9
+ const annotation = await createAnnotation(params.traceId, {
10
+ comment: params.comment,
11
+ isThumbsUp: params.isThumbsUp,
12
+ email: params.email
13
+ });
14
+ const rating = params.isThumbsUp === true ? " \u{1F44D}" : params.isThumbsUp === false ? " \u{1F44E}" : "";
15
+ return `Annotation created successfully!${rating}
16
+
17
+ **ID**: ${annotation.id ?? "\u2014"}
18
+ **Trace ID**: ${params.traceId}${params.comment ? `
19
+ **Comment**: ${params.comment}` : ""}`;
20
+ }
21
+ export {
22
+ handleCreateAnnotation
23
+ };
24
+ //# sourceMappingURL=create-annotation-FYQNKMVJ.js.map