@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.
- package/.release-please-shim +1 -0
- package/CHANGELOG.md +89 -0
- package/README.md +51 -8
- package/dist/{archive-scenario-YFD5THOR.js → archive-scenario-YKGLJ4MZ.js} +4 -4
- package/dist/archive-suite-QFNDO3Y3.js +15 -0
- package/dist/assign-prompt-tag-Y2B4CBBT.js +19 -0
- package/dist/chunk-B57MZ4WI.js +1573 -0
- package/dist/{chunk-IX6QJKAD.js → chunk-CPUPGDNA.js} +2 -2
- package/dist/chunk-FBRKHHJV.js +48 -0
- package/dist/{chunk-5UOPNRXW.js → chunk-HDJDFKZR.js} +10 -3
- package/dist/chunk-KOO5733S.js +72 -0
- package/dist/chunk-KZNBCKWG.js +39 -0
- package/dist/chunk-L6QENXYA.js +42 -0
- package/dist/{chunk-6U4TCGFC.js → chunk-NACSR6B7.js} +2 -2
- package/dist/chunk-NUFPTHKU.js +9 -0
- package/dist/chunk-OVQF3D5R.js +86 -0
- package/dist/chunk-PO7FM7IX.js +35 -0
- package/dist/chunk-PZUWCWOS.js +25 -0
- package/dist/chunk-WVI5CJ6S.js +21 -0
- package/dist/{chunk-LLRQIF52.js → chunk-YH2IBTEL.js} +54 -6
- package/dist/chunk-YI3OG4PI.js +71 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +13 -0
- package/dist/create-agent-YRSDH7P7.js +23 -0
- package/dist/create-annotation-FYQNKMVJ.js +24 -0
- package/dist/create-dashboard-CORBR4YQ.js +18 -0
- package/dist/create-dataset-ZC63T6BB.js +22 -0
- package/dist/create-dataset-records-ILVNVKVR.js +22 -0
- package/dist/{create-evaluator-E5X5ZP3B.js → create-evaluator-2AU3PXFB.js} +4 -4
- package/dist/create-mcp-server.d.ts +8 -0
- package/dist/create-mcp-server.js +8 -0
- package/dist/{create-prompt-7Z35MIL6.js → create-prompt-NKRJ47YY.js} +7 -4
- package/dist/create-prompt-tag-S4JX3ULL.js +17 -0
- package/dist/{create-scenario-DIMPJRPY.js → create-scenario-BPRF75KF.js} +4 -4
- package/dist/create-suite-4YN7D6K2.js +38 -0
- package/dist/delete-agent-Y72R2YQA.js +18 -0
- package/dist/delete-annotation-UHWDMHSH.js +17 -0
- package/dist/delete-dashboard-LPWT36KN.js +18 -0
- package/dist/delete-dataset-GGPQRHKX.js +20 -0
- package/dist/delete-dataset-records-LTG5LT26.js +21 -0
- package/dist/delete-evaluator-F7QLXDHU.js +15 -0
- package/dist/delete-prompt-tag-B5UKZL45.js +17 -0
- package/dist/delete-workflow-4DGUDIDE.js +17 -0
- package/dist/get-agent-YEVICUX4.js +28 -0
- package/dist/{get-analytics-4YJW4S5L.js → get-analytics-3W5CMU3F.js} +22 -5
- package/dist/get-dashboard-NCQHN6MW.js +29 -0
- package/dist/get-dataset-KBK6PH36.js +48 -0
- package/dist/{get-evaluator-WDEH2F7M.js → get-evaluator-QDUL5LXR.js} +4 -4
- package/dist/{get-prompt-F6PDVC76.js → get-prompt-XCSSNRKR.js} +4 -4
- package/dist/{get-scenario-H24ZYNT5.js → get-scenario-FNRKOY7E.js} +4 -4
- package/dist/get-simulation-run-WOEKUF7K.js +56 -0
- package/dist/get-suite-U5AOD5TC.js +44 -0
- package/dist/{get-trace-27USKGO7.js → get-trace-MUWEJM2Z.js} +3 -3
- package/dist/get-workflow-SOA7MT7L.js +25 -0
- package/dist/http-server-7DMOCB75.js +224 -0
- package/dist/index.js +61640 -31868
- package/dist/langwatch-api-annotations-Q57NDUVR.js +17 -0
- package/dist/langwatch-api-dashboards-VBWWXV3Y.js +17 -0
- package/dist/langwatch-api-monitors-L3IY7FDT.js +52 -0
- package/dist/langwatch-api-secrets-S5HHF3XR.js +40 -0
- package/dist/langwatch-api-triggers-ME33QE26.js +30 -0
- package/dist/langwatch-api-workflows-4CJQAYP2.js +15 -0
- package/dist/list-agents-3HGIBJFM.js +32 -0
- package/dist/list-annotations-KWXYVEPI.js +33 -0
- package/dist/list-dashboards-VQ2LH666.js +32 -0
- package/dist/list-dataset-records-RNRGROJP.js +39 -0
- package/dist/list-datasets-I4A2LT2S.js +60 -0
- package/dist/{list-evaluators-KRGI72EH.js → list-evaluators-AKKRJ5MX.js} +4 -4
- package/dist/{list-model-providers-A5YCFTPI.js → list-model-providers-DVFEHFHZ.js} +4 -4
- package/dist/list-prompt-tags-PL5OISUA.js +23 -0
- package/dist/{list-prompts-LKJSE7XN.js → list-prompts-7VTFWE2Z.js} +3 -3
- package/dist/{list-scenarios-ZK5CMGC4.js → list-scenarios-5BZWZ6ZN.js} +4 -4
- package/dist/list-simulation-runs-WCZ6RLPE.js +43 -0
- package/dist/list-suites-RRQ2JX5Y.js +42 -0
- package/dist/list-workflows-UQB5FCX5.js +35 -0
- package/dist/rename-prompt-tag-TURD6KYU.js +18 -0
- package/dist/run-agent-BEJ4K4CM.js +36 -0
- package/dist/run-evaluation-AJ7WZNQD.js +64 -0
- package/dist/run-suite-U7V432G2.js +29 -0
- package/dist/run-workflow-5WX7DK5T.js +36 -0
- package/dist/{search-traces-SOKAAMAR.js → search-traces-ZCHNOMTX.js} +3 -3
- package/dist/{set-model-provider-7MGULZDH.js → set-model-provider-6CFHMCNE.js} +4 -4
- package/dist/update-agent-UE6UWLZP.js +20 -0
- package/dist/update-dataset-4XQZZE4S.js +22 -0
- package/dist/update-dataset-record-GNNM5TKM.js +19 -0
- package/dist/{update-evaluator-A3XINFLJ.js → update-evaluator-LHVDXIZD.js} +4 -4
- package/dist/{update-prompt-IW7X2UQM.js → update-prompt-3XEHECJ7.js} +5 -3
- package/dist/{update-scenario-ZT7TOBFR.js → update-scenario-DFPREYCD.js} +4 -4
- package/dist/update-suite-RATU5THO.js +39 -0
- package/package.json +22 -8
- package/src/__tests__/all-tools.integration.test.ts +353 -0
- package/src/__tests__/config.unit.test.ts +81 -1
- package/src/__tests__/datasets.integration.test.ts +620 -0
- package/src/__tests__/datasets.unit.test.ts +244 -0
- package/src/__tests__/docker.integration.test.ts +234 -0
- package/src/__tests__/http-transport.integration.test.ts +397 -0
- package/src/__tests__/langwatch-api.unit.test.ts +174 -0
- package/src/__tests__/scenario-tools.unit.test.ts +3 -0
- package/src/__tests__/tools.unit.test.ts +177 -0
- package/src/config.d.ts +15 -0
- package/src/config.ts +85 -7
- package/src/create-mcp-server.d.ts +6 -0
- package/src/create-mcp-server.ts +1799 -0
- package/src/http-server.ts +329 -0
- package/src/index.ts +22 -593
- package/src/langwatch-api-agents.ts +108 -0
- package/src/langwatch-api-annotations.ts +49 -0
- package/src/langwatch-api-dashboards.ts +48 -0
- package/src/langwatch-api-datasets.ts +191 -0
- package/src/langwatch-api-evaluators.ts +10 -0
- package/src/langwatch-api-monitors.ts +82 -0
- package/src/langwatch-api-secrets.ts +48 -0
- package/src/langwatch-api-simulation-runs.ts +51 -0
- package/src/langwatch-api-suites.ts +118 -0
- package/src/langwatch-api-triggers.ts +48 -0
- package/src/langwatch-api-workflows.ts +41 -0
- package/src/langwatch-api.ts +65 -3
- package/src/schemas/create-dataset.ts +48 -0
- package/src/schemas/index.ts +1 -0
- package/src/tools/archive-suite.ts +12 -0
- package/src/tools/assign-prompt-tag.ts +16 -0
- package/src/tools/create-agent.ts +15 -0
- package/src/tools/create-annotation.ts +18 -0
- package/src/tools/create-dashboard.ts +7 -0
- package/src/tools/create-dataset-records.ts +23 -0
- package/src/tools/create-dataset.ts +22 -0
- package/src/tools/create-prompt-tag.ts +12 -0
- package/src/tools/create-prompt.ts +4 -0
- package/src/tools/create-suite.ts +42 -0
- package/src/tools/delete-agent.ts +7 -0
- package/src/tools/delete-annotation.ts +7 -0
- package/src/tools/delete-dashboard.ts +7 -0
- package/src/tools/delete-dataset-records.ts +22 -0
- package/src/tools/delete-dataset.ts +20 -0
- package/src/tools/delete-evaluator.ts +12 -0
- package/src/tools/delete-prompt-tag.ts +12 -0
- package/src/tools/delete-workflow.ts +7 -0
- package/src/tools/format-dataset-mutation.ts +25 -0
- package/src/tools/get-agent.ts +21 -0
- package/src/tools/get-analytics.ts +30 -3
- package/src/tools/get-dashboard.ts +22 -0
- package/src/tools/get-dataset.ts +63 -0
- package/src/tools/get-prompt.ts +2 -1
- package/src/tools/get-simulation-run.ts +60 -0
- package/src/tools/get-suite.ts +47 -0
- package/src/tools/get-workflow.ts +17 -0
- package/src/tools/list-agents.ts +27 -0
- package/src/tools/list-annotations.ts +33 -0
- package/src/tools/list-dashboards.ts +27 -0
- package/src/tools/list-dataset-records.ts +46 -0
- package/src/tools/list-datasets.ts +80 -0
- package/src/tools/list-prompt-tags.ts +21 -0
- package/src/tools/list-simulation-runs.ts +49 -0
- package/src/tools/list-suites.ts +43 -0
- package/src/tools/list-workflows.ts +31 -0
- package/src/tools/rename-prompt-tag.ts +14 -0
- package/src/tools/run-agent.ts +36 -0
- package/src/tools/run-evaluation.ts +87 -0
- package/src/tools/run-suite.ts +28 -0
- package/src/tools/run-workflow.ts +36 -0
- package/src/tools/update-agent.ts +13 -0
- package/src/tools/update-dataset-record.ts +21 -0
- package/src/tools/update-dataset.ts +23 -0
- package/src/tools/update-prompt.ts +3 -0
- package/src/tools/update-suite.ts +44 -0
- package/src/utils/escape-markdown.ts +12 -0
- package/uv.lock +188 -530
- package/build.js +0 -12
- package/dist/archive-scenario-YFD5THOR.js.map +0 -1
- package/dist/chunk-5UOPNRXW.js.map +0 -1
- package/dist/chunk-6U4TCGFC.js.map +0 -1
- package/dist/chunk-AAQNA53E.js +0 -28
- package/dist/chunk-AAQNA53E.js.map +0 -1
- package/dist/chunk-IX6QJKAD.js.map +0 -1
- package/dist/chunk-LLRQIF52.js.map +0 -1
- package/dist/chunk-ZXKLPC2E.js.map +0 -1
- package/dist/config-FIQWQRUB.js +0 -11
- package/dist/config-FIQWQRUB.js.map +0 -1
- package/dist/create-evaluator-E5X5ZP3B.js.map +0 -1
- package/dist/create-prompt-7Z35MIL6.js.map +0 -1
- package/dist/create-scenario-DIMPJRPY.js.map +0 -1
- package/dist/discover-evaluator-schema-H23XCLNE.js.map +0 -1
- package/dist/discover-scenario-schema-MEEEVND7.js.map +0 -1
- package/dist/discover-schema-3T52ORPB.js.map +0 -1
- package/dist/get-analytics-4YJW4S5L.js.map +0 -1
- package/dist/get-evaluator-WDEH2F7M.js.map +0 -1
- package/dist/get-prompt-F6PDVC76.js.map +0 -1
- package/dist/get-scenario-H24ZYNT5.js.map +0 -1
- package/dist/get-trace-27USKGO7.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/list-evaluators-KRGI72EH.js.map +0 -1
- package/dist/list-model-providers-A5YCFTPI.js.map +0 -1
- package/dist/list-prompts-LKJSE7XN.js.map +0 -1
- package/dist/list-scenarios-ZK5CMGC4.js.map +0 -1
- package/dist/search-traces-SOKAAMAR.js.map +0 -1
- package/dist/set-model-provider-7MGULZDH.js.map +0 -1
- package/dist/update-evaluator-A3XINFLJ.js.map +0 -1
- package/dist/update-prompt-IW7X2UQM.js.map +0 -1
- package/dist/update-scenario-ZT7TOBFR.js.map +0 -1
- package/tests/evaluations.ipynb +0 -649
- package/tests/fixtures/azure/azure_openai_stream_bot_expected.py +0 -102
- package/tests/fixtures/azure/azure_openai_stream_bot_input.py +0 -78
- package/tests/fixtures/dspy/dspy_bot_expected.py +0 -61
- package/tests/fixtures/dspy/dspy_bot_input.py +0 -53
- package/tests/fixtures/fastapi/fastapi_app_expected.py +0 -68
- package/tests/fixtures/fastapi/fastapi_app_input.py +0 -60
- package/tests/fixtures/fastapi/prompt_management_fastapi_expected.py +0 -114
- package/tests/fixtures/fastapi/prompt_management_fastapi_input.py +0 -88
- package/tests/fixtures/haystack/haystack_bot_expected.py +0 -141
- package/tests/fixtures/haystack/haystack_bot_input.py +0 -69
- package/tests/fixtures/langchain/langchain_bot_expected.py +0 -53
- package/tests/fixtures/langchain/langchain_bot_input.py +0 -45
- package/tests/fixtures/langchain/langchain_bot_with_memory_expected.py +0 -69
- package/tests/fixtures/langchain/langchain_bot_with_memory_input.py +0 -61
- package/tests/fixtures/langchain/langchain_rag_bot_expected.py +0 -97
- package/tests/fixtures/langchain/langchain_rag_bot_input.py +0 -77
- package/tests/fixtures/langchain/langchain_rag_bot_vertex_ai_expected.py +0 -116
- package/tests/fixtures/langchain/langchain_rag_bot_vertex_ai_input.py +0 -81
- package/tests/fixtures/langchain/langgraph_rag_bot_with_threads_expected.py +0 -331
- package/tests/fixtures/langchain/langgraph_rag_bot_with_threads_input.py +0 -106
- package/tests/fixtures/litellm/litellm_bot_expected.py +0 -40
- package/tests/fixtures/litellm/litellm_bot_input.py +0 -35
- package/tests/fixtures/openai/openai_bot_expected.py +0 -43
- package/tests/fixtures/openai/openai_bot_function_call_expected.py +0 -91
- package/tests/fixtures/openai/openai_bot_function_call_input.py +0 -82
- package/tests/fixtures/openai/openai_bot_input.py +0 -36
- package/tests/fixtures/openai/openai_bot_rag_expected.py +0 -73
- package/tests/fixtures/openai/openai_bot_rag_input.py +0 -51
- package/tests/fixtures/opentelemetry/openinference_dspy_bot_expected.py +0 -63
- package/tests/fixtures/opentelemetry/openinference_dspy_bot_input.py +0 -58
- package/tests/fixtures/opentelemetry/openinference_langchain_bot_expected.py +0 -53
- package/tests/fixtures/opentelemetry/openinference_langchain_bot_input.py +0 -52
- package/tests/fixtures/opentelemetry/openinference_openai_bot_expected.py +0 -49
- package/tests/fixtures/opentelemetry/openinference_openai_bot_input.py +0 -41
- package/tests/fixtures/opentelemetry/openllmetry_openai_bot_expected.py +0 -44
- package/tests/fixtures/opentelemetry/openllmetry_openai_bot_input.py +0 -40
- package/tests/fixtures/strands/strands_bot_expected.py +0 -84
- package/tests/fixtures/strands/strands_bot_input.py +0 -52
- package/tests/scenario-openai.test.ts +0 -160
- package/tsup.config.ts +0 -10
- package/vitest.config.js +0 -7
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { listWorkflows as apiListWorkflows } from "../langwatch-api-workflows.js";
|
|
2
|
+
|
|
3
|
+
export async function handleListWorkflows(): Promise<string> {
|
|
4
|
+
const workflows = await apiListWorkflows();
|
|
5
|
+
|
|
6
|
+
if (!Array.isArray(workflows) || workflows.length === 0) {
|
|
7
|
+
return "No workflows found in this project.";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const lines: string[] = [];
|
|
11
|
+
lines.push(`# Workflows (${workflows.length} total)\n`);
|
|
12
|
+
|
|
13
|
+
for (const w of workflows) {
|
|
14
|
+
const tags: string[] = [];
|
|
15
|
+
if (w.isEvaluator) tags.push("evaluator");
|
|
16
|
+
if (w.isComponent) tags.push("component");
|
|
17
|
+
const tagStr = tags.length > 0 ? ` [${tags.join(", ")}]` : "";
|
|
18
|
+
|
|
19
|
+
lines.push(`## ${w.name}${tagStr}`);
|
|
20
|
+
lines.push(`**ID**: ${w.id}`);
|
|
21
|
+
if (w.description) lines.push(`**Description**: ${w.description}`);
|
|
22
|
+
lines.push(`**Updated**: ${w.updatedAt}`);
|
|
23
|
+
lines.push("");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
lines.push(
|
|
27
|
+
"> Use `platform_get_workflow` with the ID to see full workflow details.",
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return lines.join("\n");
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { renamePromptTag as apiRenamePromptTag } from "../langwatch-api.js";
|
|
2
|
+
|
|
3
|
+
export async function handleRenamePromptTag(params: {
|
|
4
|
+
tag: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}): Promise<string> {
|
|
7
|
+
await apiRenamePromptTag({ tag: params.tag, name: params.name });
|
|
8
|
+
|
|
9
|
+
const lines: string[] = [];
|
|
10
|
+
lines.push("Tag renamed successfully!\n");
|
|
11
|
+
lines.push(`**Old name**: ${params.tag}`);
|
|
12
|
+
lines.push(`**New name**: ${params.name}`);
|
|
13
|
+
return lines.join("\n");
|
|
14
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { runAgent as apiRunAgent } from "../langwatch-api-agents.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_run_agent MCP tool invocation.
|
|
5
|
+
*/
|
|
6
|
+
export async function handleRunAgent(params: {
|
|
7
|
+
id: string;
|
|
8
|
+
input?: string;
|
|
9
|
+
}): Promise<string> {
|
|
10
|
+
let parsedInput: Record<string, unknown> = {};
|
|
11
|
+
if (params.input) {
|
|
12
|
+
try {
|
|
13
|
+
parsedInput = JSON.parse(params.input) as Record<string, unknown>;
|
|
14
|
+
} catch {
|
|
15
|
+
return "Error: `input` must be a valid JSON object.";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { agentType, result } = await apiRunAgent(params.id, parsedInput);
|
|
20
|
+
|
|
21
|
+
const lines: string[] = [];
|
|
22
|
+
lines.push(`Agent executed successfully (type: ${agentType}).\n`);
|
|
23
|
+
|
|
24
|
+
if (typeof result === "object" && result !== null) {
|
|
25
|
+
const output = (result as Record<string, unknown>).output;
|
|
26
|
+
if (output !== undefined) {
|
|
27
|
+
lines.push("**Output:**");
|
|
28
|
+
lines.push(typeof output === "string" ? output : JSON.stringify(output, null, 2));
|
|
29
|
+
} else {
|
|
30
|
+
lines.push("**Result:**");
|
|
31
|
+
lines.push(JSON.stringify(result, null, 2));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return lines.join("\n");
|
|
36
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { makeRequest } from "../langwatch-api.js";
|
|
2
|
+
|
|
3
|
+
interface EvaluationRunResponse {
|
|
4
|
+
runId: string;
|
|
5
|
+
status: string;
|
|
6
|
+
total: number;
|
|
7
|
+
runUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface EvaluationStatusResponse {
|
|
11
|
+
runId: string;
|
|
12
|
+
status: string;
|
|
13
|
+
progress: number;
|
|
14
|
+
total: number;
|
|
15
|
+
startedAt?: number;
|
|
16
|
+
finishedAt?: number;
|
|
17
|
+
summary?: {
|
|
18
|
+
totalCells?: number;
|
|
19
|
+
completedCells?: number;
|
|
20
|
+
failedCells?: number;
|
|
21
|
+
duration?: number;
|
|
22
|
+
runUrl?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function handleRunEvaluation(params: {
|
|
27
|
+
slug: string;
|
|
28
|
+
}): Promise<string> {
|
|
29
|
+
const result = (await makeRequest(
|
|
30
|
+
"POST",
|
|
31
|
+
`/api/evaluations/v3/${encodeURIComponent(params.slug)}/run`,
|
|
32
|
+
)) as EvaluationRunResponse;
|
|
33
|
+
|
|
34
|
+
const lines: string[] = [];
|
|
35
|
+
lines.push(`Evaluation started!\n`);
|
|
36
|
+
lines.push(`**Run ID**: ${result.runId}`);
|
|
37
|
+
lines.push(`**Status**: ${result.status}`);
|
|
38
|
+
lines.push(`**Total cells**: ${result.total}`);
|
|
39
|
+
if (result.runUrl) lines.push(`**View at**: ${result.runUrl}`);
|
|
40
|
+
lines.push("");
|
|
41
|
+
lines.push(
|
|
42
|
+
`> Use \`platform_evaluation_status\` with run ID "${result.runId}" to check progress.`,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
return lines.join("\n");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function handleEvaluationStatus(params: {
|
|
49
|
+
runId: string;
|
|
50
|
+
}): Promise<string> {
|
|
51
|
+
const status = (await makeRequest(
|
|
52
|
+
"GET",
|
|
53
|
+
`/api/evaluations/v3/runs/${encodeURIComponent(params.runId)}`,
|
|
54
|
+
)) as EvaluationStatusResponse;
|
|
55
|
+
|
|
56
|
+
const lines: string[] = [];
|
|
57
|
+
lines.push(`# Evaluation Run ${status.runId}\n`);
|
|
58
|
+
lines.push(`**Status**: ${status.status}`);
|
|
59
|
+
lines.push(`**Progress**: ${status.progress}/${status.total} cells`);
|
|
60
|
+
|
|
61
|
+
if (status.startedAt) {
|
|
62
|
+
lines.push(`**Started**: ${new Date(status.startedAt).toISOString()}`);
|
|
63
|
+
}
|
|
64
|
+
if (status.finishedAt) {
|
|
65
|
+
lines.push(`**Finished**: ${new Date(status.finishedAt).toISOString()}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (status.summary) {
|
|
69
|
+
lines.push("\n## Summary\n");
|
|
70
|
+
if (status.summary.completedCells !== undefined) {
|
|
71
|
+
lines.push(`**Completed**: ${status.summary.completedCells}`);
|
|
72
|
+
}
|
|
73
|
+
if (status.summary.failedCells) {
|
|
74
|
+
lines.push(`**Failed**: ${status.summary.failedCells}`);
|
|
75
|
+
}
|
|
76
|
+
if (status.summary.duration) {
|
|
77
|
+
lines.push(
|
|
78
|
+
`**Duration**: ${(status.summary.duration / 1000).toFixed(1)}s`,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (status.summary.runUrl) {
|
|
82
|
+
lines.push(`**View results**: ${status.summary.runUrl}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return lines.join("\n");
|
|
87
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { runSuite as apiRunSuite } from "../langwatch-api-suites.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_run_suite MCP tool invocation.
|
|
5
|
+
*/
|
|
6
|
+
export async function handleRunSuite(params: {
|
|
7
|
+
id: string;
|
|
8
|
+
}): Promise<string> {
|
|
9
|
+
const result = await apiRunSuite(params.id);
|
|
10
|
+
|
|
11
|
+
const lines: string[] = [];
|
|
12
|
+
lines.push(`Suite run scheduled successfully.`);
|
|
13
|
+
lines.push("");
|
|
14
|
+
lines.push(`**Batch Run ID**: ${result.batchRunId}`);
|
|
15
|
+
lines.push(`**Jobs**: ${result.jobCount}`);
|
|
16
|
+
lines.push(`**Set ID**: ${result.setId}`);
|
|
17
|
+
|
|
18
|
+
if (result.skippedArchived.scenarios.length > 0) {
|
|
19
|
+
lines.push(`\n⚠️ Skipped archived scenarios: ${result.skippedArchived.scenarios.join(", ")}`);
|
|
20
|
+
}
|
|
21
|
+
if (result.skippedArchived.targets.length > 0) {
|
|
22
|
+
lines.push(`⚠️ Skipped archived targets: ${result.skippedArchived.targets.join(", ")}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
lines.push("\nView results in the LangWatch dashboard under Simulations.");
|
|
26
|
+
|
|
27
|
+
return lines.join("\n");
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { runWorkflow as apiRunWorkflow } from "../langwatch-api-workflows.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_run_workflow MCP tool invocation.
|
|
5
|
+
*/
|
|
6
|
+
export async function handleRunWorkflow(params: {
|
|
7
|
+
id: string;
|
|
8
|
+
input?: string;
|
|
9
|
+
}): Promise<string> {
|
|
10
|
+
let parsedInput: Record<string, unknown> = {};
|
|
11
|
+
if (params.input) {
|
|
12
|
+
try {
|
|
13
|
+
parsedInput = JSON.parse(params.input) as Record<string, unknown>;
|
|
14
|
+
} catch {
|
|
15
|
+
return "Error: `input` must be a valid JSON object.";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const result = await apiRunWorkflow(params.id, parsedInput);
|
|
20
|
+
|
|
21
|
+
const lines: string[] = [];
|
|
22
|
+
lines.push(`Workflow "${params.id}" executed successfully.\n`);
|
|
23
|
+
|
|
24
|
+
if (typeof result === "object" && result !== null) {
|
|
25
|
+
const output = (result as Record<string, unknown>).output;
|
|
26
|
+
if (output !== undefined) {
|
|
27
|
+
lines.push("**Output:**");
|
|
28
|
+
lines.push(typeof output === "string" ? output : JSON.stringify(output, null, 2));
|
|
29
|
+
} else {
|
|
30
|
+
lines.push("**Result:**");
|
|
31
|
+
lines.push(JSON.stringify(result, null, 2));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return lines.join("\n");
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { updateAgent as apiUpdateAgent } from "../langwatch-api-agents.js";
|
|
2
|
+
|
|
3
|
+
export async function handleUpdateAgent(params: {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
config?: Record<string, unknown>;
|
|
8
|
+
}): Promise<string> {
|
|
9
|
+
const { id, ...data } = params;
|
|
10
|
+
const agent = await apiUpdateAgent({ id, ...data });
|
|
11
|
+
|
|
12
|
+
return `Agent updated successfully!\n\n**Name**: ${agent.name}\n**ID**: ${agent.id}\n**Type**: ${agent.type}`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { updateDatasetRecord as apiUpdateDatasetRecord } from "../langwatch-api-datasets.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_update_dataset_record MCP tool invocation.
|
|
5
|
+
*
|
|
6
|
+
* Updates a single record in a dataset and returns confirmation.
|
|
7
|
+
*/
|
|
8
|
+
export async function handleUpdateDatasetRecord(params: {
|
|
9
|
+
slugOrId: string;
|
|
10
|
+
recordId: string;
|
|
11
|
+
entry: Record<string, unknown>;
|
|
12
|
+
}): Promise<string> {
|
|
13
|
+
const result = await apiUpdateDatasetRecord(params);
|
|
14
|
+
|
|
15
|
+
const lines: string[] = [];
|
|
16
|
+
lines.push("Record updated successfully!\n");
|
|
17
|
+
lines.push(`**Record ID**: ${result.id}`);
|
|
18
|
+
lines.push(`**Entry**: ${JSON.stringify(result.entry)}`);
|
|
19
|
+
|
|
20
|
+
return lines.join("\n");
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { updateDataset as apiUpdateDataset } from "../langwatch-api-datasets.js";
|
|
2
|
+
import type { DatasetColumnType } from "../langwatch-api-datasets.js";
|
|
3
|
+
import { formatDatasetMutationDetails } from "./format-dataset-mutation.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Handles the platform_update_dataset MCP tool invocation.
|
|
7
|
+
*
|
|
8
|
+
* Updates an existing dataset and returns a confirmation
|
|
9
|
+
* with the updated details.
|
|
10
|
+
*/
|
|
11
|
+
export async function handleUpdateDataset(params: {
|
|
12
|
+
slugOrId: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
columnTypes?: DatasetColumnType[];
|
|
15
|
+
}): Promise<string> {
|
|
16
|
+
const result = await apiUpdateDataset(params);
|
|
17
|
+
|
|
18
|
+
const lines: string[] = [];
|
|
19
|
+
lines.push("Dataset updated successfully!\n");
|
|
20
|
+
lines.push(...formatDatasetMutationDetails(result));
|
|
21
|
+
|
|
22
|
+
return lines.join("\n");
|
|
23
|
+
}
|
|
@@ -11,6 +11,7 @@ export async function handleUpdatePrompt(params: {
|
|
|
11
11
|
messages?: Array<{ role: string; content: string }>;
|
|
12
12
|
model?: string;
|
|
13
13
|
commitMessage: string;
|
|
14
|
+
tags?: string[];
|
|
14
15
|
}): Promise<string> {
|
|
15
16
|
const { idOrHandle, ...data } = params;
|
|
16
17
|
|
|
@@ -23,6 +24,8 @@ export async function handleUpdatePrompt(params: {
|
|
|
23
24
|
if (result.latestVersionNumber != null)
|
|
24
25
|
lines.push(`**Version**: v${result.latestVersionNumber}`);
|
|
25
26
|
lines.push(`**Commit**: ${params.commitMessage}`);
|
|
27
|
+
if (params.tags && params.tags.length > 0)
|
|
28
|
+
lines.push(`**Tags**: ${params.tags.join(", ")}`);
|
|
26
29
|
|
|
27
30
|
return lines.join("\n");
|
|
28
31
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { updateSuite as apiUpdateSuite } from "../langwatch-api-suites.js";
|
|
2
|
+
import type { SuiteTarget } from "../langwatch-api-suites.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Handles the platform_update_suite MCP tool invocation.
|
|
6
|
+
*/
|
|
7
|
+
export async function handleUpdateSuite(params: {
|
|
8
|
+
id: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
scenarioIds?: string[];
|
|
12
|
+
targets?: string;
|
|
13
|
+
repeatCount?: number;
|
|
14
|
+
labels?: string[];
|
|
15
|
+
}): Promise<string> {
|
|
16
|
+
let parsedTargets: SuiteTarget[] | undefined;
|
|
17
|
+
if (params.targets) {
|
|
18
|
+
try {
|
|
19
|
+
parsedTargets = JSON.parse(params.targets) as SuiteTarget[];
|
|
20
|
+
} catch {
|
|
21
|
+
return "Error: `targets` must be a valid JSON array.";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const suite = await apiUpdateSuite({
|
|
26
|
+
id: params.id,
|
|
27
|
+
name: params.name,
|
|
28
|
+
description: params.description,
|
|
29
|
+
scenarioIds: params.scenarioIds,
|
|
30
|
+
targets: parsedTargets,
|
|
31
|
+
repeatCount: params.repeatCount,
|
|
32
|
+
labels: params.labels,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return [
|
|
36
|
+
`Suite "${suite.name}" updated successfully.`,
|
|
37
|
+
"",
|
|
38
|
+
`**ID**: ${suite.id}`,
|
|
39
|
+
`**Slug**: ${suite.slug}`,
|
|
40
|
+
`**Scenarios**: ${suite.scenarioIds.length}`,
|
|
41
|
+
`**Targets**: ${suite.targets.length}`,
|
|
42
|
+
`**Repeat**: ${suite.repeatCount}x`,
|
|
43
|
+
].join("\n");
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escapes characters that would break markdown table formatting.
|
|
3
|
+
*
|
|
4
|
+
* Replaces pipe characters (`|`) with `\|` and newlines with spaces
|
|
5
|
+
* so that values can be safely embedded in markdown tables and headers.
|
|
6
|
+
*/
|
|
7
|
+
export function escapeMarkdown(value: string): string {
|
|
8
|
+
return value
|
|
9
|
+
.replace(/\\/g, "\\\\")
|
|
10
|
+
.replace(/\|/g, "\\|")
|
|
11
|
+
.replace(/\n/g, " ");
|
|
12
|
+
}
|