@langwatch/mcp-server 0.4.0 → 0.6.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/CHANGELOG.md +44 -0
- package/dist/archive-scenario-YFD5THOR.js +19 -0
- package/dist/archive-scenario-YFD5THOR.js.map +1 -0
- package/dist/chunk-5UOPNRXW.js +37 -0
- package/dist/chunk-5UOPNRXW.js.map +1 -0
- package/dist/chunk-6U4TCGFC.js +40 -0
- package/dist/chunk-6U4TCGFC.js.map +1 -0
- package/dist/chunk-IX6QJKAD.js +22 -0
- package/dist/chunk-IX6QJKAD.js.map +1 -0
- package/dist/{chunk-HOPTUDCZ.js → chunk-LLRQIF52.js} +5 -12
- package/dist/chunk-LLRQIF52.js.map +1 -0
- package/dist/create-evaluator-E5X5ZP3B.js +27 -0
- package/dist/create-evaluator-E5X5ZP3B.js.map +1 -0
- package/dist/create-prompt-7Z35MIL6.js +36 -0
- package/dist/create-prompt-7Z35MIL6.js.map +1 -0
- package/dist/create-scenario-DIMPJRPY.js +26 -0
- package/dist/create-scenario-DIMPJRPY.js.map +1 -0
- package/dist/discover-evaluator-schema-H23XCLNE.js +1402 -0
- package/dist/discover-evaluator-schema-H23XCLNE.js.map +1 -0
- package/dist/discover-scenario-schema-MEEEVND7.js +65 -0
- package/dist/discover-scenario-schema-MEEEVND7.js.map +1 -0
- package/dist/{get-analytics-3IFTN6MY.js → get-analytics-4YJW4S5L.js} +2 -2
- package/dist/get-evaluator-WDEH2F7M.js +47 -0
- package/dist/get-evaluator-WDEH2F7M.js.map +1 -0
- package/dist/{get-prompt-2ZB5B3QC.js → get-prompt-F6PDVC76.js} +2 -5
- package/dist/get-prompt-F6PDVC76.js.map +1 -0
- package/dist/get-scenario-H24ZYNT5.js +33 -0
- package/dist/get-scenario-H24ZYNT5.js.map +1 -0
- package/dist/{get-trace-7IXKKCJJ.js → get-trace-27USKGO7.js} +2 -2
- package/dist/index.js +27066 -8845
- package/dist/index.js.map +1 -1
- package/dist/list-evaluators-KRGI72EH.js +34 -0
- package/dist/list-evaluators-KRGI72EH.js.map +1 -0
- package/dist/list-model-providers-A5YCFTPI.js +35 -0
- package/dist/list-model-providers-A5YCFTPI.js.map +1 -0
- package/dist/{list-prompts-J72LTP7Z.js → list-prompts-LKJSE7XN.js} +6 -7
- package/dist/list-prompts-LKJSE7XN.js.map +1 -0
- package/dist/list-scenarios-ZK5CMGC4.js +40 -0
- package/dist/list-scenarios-ZK5CMGC4.js.map +1 -0
- package/dist/{search-traces-RW2NDHN5.js → search-traces-SOKAAMAR.js} +2 -2
- package/dist/set-model-provider-7MGULZDH.js +33 -0
- package/dist/set-model-provider-7MGULZDH.js.map +1 -0
- package/dist/update-evaluator-A3XINFLJ.js +24 -0
- package/dist/update-evaluator-A3XINFLJ.js.map +1 -0
- package/dist/update-prompt-IW7X2UQM.js +22 -0
- package/dist/update-prompt-IW7X2UQM.js.map +1 -0
- package/dist/update-scenario-ZT7TOBFR.js +27 -0
- package/dist/update-scenario-ZT7TOBFR.js.map +1 -0
- package/package.json +11 -11
- package/src/__tests__/all-tools.integration.test.ts +1337 -0
- package/src/__tests__/discover-evaluator-schema.unit.test.ts +89 -0
- package/src/__tests__/evaluator-tools.unit.test.ts +262 -0
- package/src/__tests__/integration.integration.test.ts +9 -34
- package/src/__tests__/langwatch-api.unit.test.ts +4 -32
- package/src/__tests__/model-provider-tools.unit.test.ts +190 -0
- package/src/__tests__/scenario-tools.integration.test.ts +286 -0
- package/src/__tests__/scenario-tools.unit.test.ts +185 -0
- package/src/__tests__/tools.unit.test.ts +59 -65
- package/src/index.ts +338 -48
- package/src/langwatch-api-evaluators.ts +70 -0
- package/src/langwatch-api-model-providers.ts +41 -0
- package/src/langwatch-api-scenarios.ts +67 -0
- package/src/langwatch-api.ts +6 -30
- package/src/tools/archive-scenario.ts +19 -0
- package/src/tools/create-evaluator.ts +33 -0
- package/src/tools/create-prompt.ts +30 -5
- package/src/tools/create-scenario.ts +30 -0
- package/src/tools/discover-evaluator-schema.ts +143 -0
- package/src/tools/discover-scenario-schema.ts +71 -0
- package/src/tools/get-evaluator.ts +53 -0
- package/src/tools/get-prompt.ts +1 -4
- package/src/tools/get-scenario.ts +36 -0
- package/src/tools/list-evaluators.ts +37 -0
- package/src/tools/list-model-providers.ts +40 -0
- package/src/tools/list-prompts.ts +5 -6
- package/src/tools/list-scenarios.ts +47 -0
- package/src/tools/set-model-provider.ts +46 -0
- package/src/tools/update-evaluator.ts +30 -0
- package/src/tools/update-prompt.ts +9 -25
- package/src/tools/update-scenario.ts +32 -0
- package/uv.lock +1788 -1322
- package/dist/chunk-HOPTUDCZ.js.map +0 -1
- package/dist/create-prompt-UBC537BJ.js +0 -22
- package/dist/create-prompt-UBC537BJ.js.map +0 -1
- package/dist/get-prompt-2ZB5B3QC.js.map +0 -1
- package/dist/list-prompts-J72LTP7Z.js.map +0 -1
- package/dist/update-prompt-G6HHZSUM.js +0 -31
- package/dist/update-prompt-G6HHZSUM.js.map +0 -1
- /package/dist/{get-analytics-3IFTN6MY.js.map → get-analytics-4YJW4S5L.js.map} +0 -0
- /package/dist/{get-trace-7IXKKCJJ.js.map → get-trace-27USKGO7.js.map} +0 -0
- /package/dist/{search-traces-RW2NDHN5.js.map → search-traces-SOKAAMAR.js.map} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { listScenarios as apiListScenarios } from "../langwatch-api-scenarios.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_list_scenarios MCP tool invocation.
|
|
5
|
+
*
|
|
6
|
+
* Lists all scenarios in the LangWatch project, formatted as an
|
|
7
|
+
* AI-readable digest or raw JSON.
|
|
8
|
+
*/
|
|
9
|
+
export async function handleListScenarios(params: {
|
|
10
|
+
format?: "digest" | "json";
|
|
11
|
+
}): Promise<string> {
|
|
12
|
+
const scenarios = await apiListScenarios();
|
|
13
|
+
|
|
14
|
+
if (params.format === "json") {
|
|
15
|
+
return JSON.stringify(scenarios, null, 2);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!Array.isArray(scenarios) || scenarios.length === 0) {
|
|
19
|
+
return "No scenarios found in this project.\n\n> Tip: Use `platform_create_scenario` to create your first scenario.";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const lines: string[] = [];
|
|
23
|
+
lines.push(`# Scenarios (${scenarios.length} total)\n`);
|
|
24
|
+
|
|
25
|
+
for (const s of scenarios) {
|
|
26
|
+
lines.push(`## ${s.name}`);
|
|
27
|
+
lines.push(`**ID**: ${s.id}`);
|
|
28
|
+
const preview =
|
|
29
|
+
s.situation && s.situation.length > 60
|
|
30
|
+
? s.situation.slice(0, 60) + "..."
|
|
31
|
+
: s.situation;
|
|
32
|
+
lines.push(`**Situation**: ${preview}`);
|
|
33
|
+
lines.push(
|
|
34
|
+
`**Criteria**: ${Array.isArray(s.criteria) ? s.criteria.length : 0} criteria`,
|
|
35
|
+
);
|
|
36
|
+
if (Array.isArray(s.labels) && s.labels.length > 0) {
|
|
37
|
+
lines.push(`**Labels**: ${s.labels.join(", ")}`);
|
|
38
|
+
}
|
|
39
|
+
lines.push("");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
lines.push(
|
|
43
|
+
"> Use `platform_get_scenario` with the ID to see full scenario details.",
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return lines.join("\n");
|
|
47
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { setModelProvider as apiSetModelProvider } from "../langwatch-api-model-providers.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_set_model_provider MCP tool invocation.
|
|
5
|
+
*
|
|
6
|
+
* Creates or updates a model provider configuration, including API keys.
|
|
7
|
+
* Returns confirmation with the updated provider status.
|
|
8
|
+
*/
|
|
9
|
+
export async function handleSetModelProvider(params: {
|
|
10
|
+
provider: string;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
customKeys?: Record<string, unknown>;
|
|
13
|
+
defaultModel?: string;
|
|
14
|
+
}): Promise<string> {
|
|
15
|
+
const providers = await apiSetModelProvider(params);
|
|
16
|
+
|
|
17
|
+
const updated = providers[params.provider];
|
|
18
|
+
|
|
19
|
+
if (!updated) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Model provider "${params.provider}" was not found in the response. The provider name may be invalid.`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const lines: string[] = [];
|
|
26
|
+
lines.push("Model provider updated successfully!\n");
|
|
27
|
+
lines.push(`**Provider**: ${params.provider}`);
|
|
28
|
+
lines.push(`**Status**: ${updated?.enabled ? "enabled" : "disabled"}`);
|
|
29
|
+
|
|
30
|
+
if (updated?.customKeys) {
|
|
31
|
+
const keyFields = Object.entries(updated.customKeys)
|
|
32
|
+
.map(([k, v]) => `${k}: ${v ? "set" : "not set"}`)
|
|
33
|
+
.join(", ");
|
|
34
|
+
lines.push(`**Keys**: ${keyFields}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (params.defaultModel) {
|
|
38
|
+
// Show the normalized model name (with provider prefix)
|
|
39
|
+
const normalizedModel = params.defaultModel.includes("/")
|
|
40
|
+
? params.defaultModel
|
|
41
|
+
: `${params.provider}/${params.defaultModel}`;
|
|
42
|
+
lines.push(`**Default Model**: ${normalizedModel}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return lines.join("\n");
|
|
46
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
updateEvaluator as apiUpdateEvaluator,
|
|
3
|
+
getEvaluatorType,
|
|
4
|
+
} from "../langwatch-api-evaluators.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Handles the platform_update_evaluator MCP tool invocation.
|
|
8
|
+
*
|
|
9
|
+
* Updates an existing evaluator and returns a confirmation
|
|
10
|
+
* with the updated details.
|
|
11
|
+
*/
|
|
12
|
+
export async function handleUpdateEvaluator(params: {
|
|
13
|
+
evaluatorId: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
config?: Record<string, unknown>;
|
|
16
|
+
}): Promise<string> {
|
|
17
|
+
const { evaluatorId, ...data } = params;
|
|
18
|
+
const result = await apiUpdateEvaluator({ id: evaluatorId, ...data });
|
|
19
|
+
|
|
20
|
+
const evaluatorType = getEvaluatorType(result);
|
|
21
|
+
|
|
22
|
+
const lines: string[] = [];
|
|
23
|
+
lines.push("Evaluator updated successfully!\n");
|
|
24
|
+
lines.push(`**ID**: ${result.id}`);
|
|
25
|
+
if (result.slug) lines.push(`**Slug**: ${result.slug}`);
|
|
26
|
+
lines.push(`**Name**: ${result.name}`);
|
|
27
|
+
if (evaluatorType) lines.push(`**Evaluator Type**: ${evaluatorType}`);
|
|
28
|
+
|
|
29
|
+
return lines.join("\n");
|
|
30
|
+
}
|
|
@@ -1,44 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
updatePrompt as apiUpdatePrompt,
|
|
3
|
-
createPromptVersion as apiCreateVersion,
|
|
4
|
-
} from "../langwatch-api.js";
|
|
5
|
-
import type { PromptMutationResponse } from "../langwatch-api.js";
|
|
1
|
+
import { updatePrompt as apiUpdatePrompt } from "../langwatch-api.js";
|
|
6
2
|
|
|
7
3
|
/**
|
|
8
|
-
* Handles the
|
|
4
|
+
* Handles the platform_update_prompt MCP tool invocation.
|
|
9
5
|
*
|
|
10
|
-
* Updates an existing prompt
|
|
11
|
-
*
|
|
6
|
+
* Updates an existing prompt via the PUT endpoint.
|
|
7
|
+
* Every update with a commitMessage creates a new version automatically.
|
|
12
8
|
*/
|
|
13
9
|
export async function handleUpdatePrompt(params: {
|
|
14
10
|
idOrHandle: string;
|
|
15
11
|
messages?: Array<{ role: string; content: string }>;
|
|
16
12
|
model?: string;
|
|
17
|
-
|
|
18
|
-
commitMessage?: string;
|
|
19
|
-
createVersion?: boolean;
|
|
13
|
+
commitMessage: string;
|
|
20
14
|
}): Promise<string> {
|
|
21
|
-
const { idOrHandle,
|
|
15
|
+
const { idOrHandle, ...data } = params;
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
if (createVersion) {
|
|
25
|
-
result = await apiCreateVersion(idOrHandle, data);
|
|
26
|
-
} else {
|
|
27
|
-
result = await apiUpdatePrompt(idOrHandle, data);
|
|
28
|
-
}
|
|
17
|
+
const result = await apiUpdatePrompt(idOrHandle, data);
|
|
29
18
|
|
|
30
19
|
const lines: string[] = [];
|
|
31
|
-
lines.push(
|
|
32
|
-
createVersion
|
|
33
|
-
? "New version created successfully!\n"
|
|
34
|
-
: "Prompt updated successfully!\n"
|
|
35
|
-
);
|
|
20
|
+
lines.push("Prompt updated successfully!\n");
|
|
36
21
|
if (result.id) lines.push(`**ID**: ${result.id}`);
|
|
37
22
|
if (result.handle) lines.push(`**Handle**: ${result.handle}`);
|
|
38
23
|
if (result.latestVersionNumber != null)
|
|
39
24
|
lines.push(`**Version**: v${result.latestVersionNumber}`);
|
|
40
|
-
|
|
41
|
-
lines.push(`**Commit**: ${params.commitMessage}`);
|
|
25
|
+
lines.push(`**Commit**: ${params.commitMessage}`);
|
|
42
26
|
|
|
43
27
|
return lines.join("\n");
|
|
44
28
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { updateScenario as apiUpdateScenario } from "../langwatch-api-scenarios.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Handles the platform_update_scenario MCP tool invocation.
|
|
5
|
+
*
|
|
6
|
+
* Updates an existing scenario and returns a confirmation
|
|
7
|
+
* with the updated details.
|
|
8
|
+
*/
|
|
9
|
+
export async function handleUpdateScenario(params: {
|
|
10
|
+
scenarioId: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
situation?: string;
|
|
13
|
+
criteria?: string[];
|
|
14
|
+
labels?: string[];
|
|
15
|
+
}): Promise<string> {
|
|
16
|
+
const { scenarioId, ...data } = params;
|
|
17
|
+
const result = await apiUpdateScenario({ id: scenarioId, ...data });
|
|
18
|
+
|
|
19
|
+
const lines: string[] = [];
|
|
20
|
+
lines.push("Scenario updated successfully!\n");
|
|
21
|
+
lines.push(`**ID**: ${result.id}`);
|
|
22
|
+
lines.push(`**Name**: ${result.name}`);
|
|
23
|
+
if (result.situation) lines.push(`**Situation**: ${result.situation}`);
|
|
24
|
+
if (Array.isArray(result.criteria) && result.criteria.length > 0) {
|
|
25
|
+
lines.push(`**Criteria**: ${result.criteria.length} criteria`);
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(result.labels) && result.labels.length > 0) {
|
|
28
|
+
lines.push(`**Labels**: ${result.labels.join(", ")}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return lines.join("\n");
|
|
32
|
+
}
|