mcp-jev 1.1.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -136
- package/dist/adapters/factory.d.ts +10 -0
- package/dist/adapters/factory.d.ts.map +1 -0
- package/dist/adapters/factory.js +34 -0
- package/dist/adapters/factory.js.map +1 -0
- package/dist/adapters/jev.d.ts +21 -0
- package/dist/adapters/jev.d.ts.map +1 -0
- package/dist/adapters/jev.js +88 -0
- package/dist/adapters/jev.js.map +1 -0
- package/dist/adapters/laya.d.ts +33 -0
- package/dist/adapters/laya.d.ts.map +1 -0
- package/dist/adapters/laya.js +125 -0
- package/dist/adapters/laya.js.map +1 -0
- package/dist/index.d.ts +10 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +155 -195
- package/dist/index.js.map +1 -1
- package/dist/lib.d.ts +101 -6
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +79 -12
- package/dist/lib.js.map +1 -1
- package/dist/presets.d.ts +15 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +198 -0
- package/dist/presets.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* MCP server for
|
|
3
|
+
* MCP server for System-1 decision models — provider-agnostic.
|
|
4
4
|
*
|
|
5
5
|
* Tools:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* decide_predict — typed questions → calibrated answers
|
|
7
|
+
* decide_preset — named workflow preset → answers
|
|
8
|
+
* decide_status — provider health + info
|
|
9
|
+
* decide_list_models — available models/checkpoints
|
|
8
10
|
*
|
|
9
11
|
* Env:
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* DECIDE_PROVIDER (optional, default: "jev") — "jev" | "laya"
|
|
13
|
+
* TYPESAFE_API_KEY (required when DECIDE_PROVIDER=jev)
|
|
14
|
+
* TYPESAFE_BASE_URL (optional) — override Jev base URL
|
|
15
|
+
* LAYA_BASE_URL (optional) — override Laya base URL (default: http://localhost:8000)
|
|
16
|
+
* LAYA_API_KEY (optional) — Laya bearer token
|
|
12
17
|
*/
|
|
13
18
|
export {};
|
|
14
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG"}
|
package/dist/index.js
CHANGED
|
@@ -1,226 +1,138 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* MCP server for
|
|
3
|
+
* MCP server for System-1 decision models — provider-agnostic.
|
|
4
4
|
*
|
|
5
5
|
* Tools:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* decide_predict — typed questions → calibrated answers
|
|
7
|
+
* decide_preset — named workflow preset → answers
|
|
8
|
+
* decide_status — provider health + info
|
|
9
|
+
* decide_list_models — available models/checkpoints
|
|
8
10
|
*
|
|
9
11
|
* Env:
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* DECIDE_PROVIDER (optional, default: "jev") — "jev" | "laya"
|
|
13
|
+
* TYPESAFE_API_KEY (required when DECIDE_PROVIDER=jev)
|
|
14
|
+
* TYPESAFE_BASE_URL (optional) — override Jev base URL
|
|
15
|
+
* LAYA_BASE_URL (optional) — override Laya base URL (default: http://localhost:8000)
|
|
16
|
+
* LAYA_API_KEY (optional) — Laya bearer token
|
|
12
17
|
*/
|
|
13
18
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
19
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
15
20
|
import { z } from "zod";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
process.exit(1);
|
|
21
|
+
import { ConfigurationError, MAX_STATE_STRING_CHARS, MAX_QUESTIONS, MAX_CHOICE_OPTIONS, MIN_SCORE_LEVELS, MAX_SCORE_LEVELS, } from "./lib.js";
|
|
22
|
+
import { createAdapter } from "./adapters/factory.js";
|
|
23
|
+
import { isValidPreset, expandPreset, PRESET_NAMES } from "./presets.js";
|
|
24
|
+
// ─── Startup: create adapter ─────────────────────────────────────────────────
|
|
25
|
+
let adapter;
|
|
26
|
+
try {
|
|
27
|
+
adapter = createAdapter();
|
|
24
28
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
async function throwApiError(resp, context) {
|
|
31
|
-
const raw = await resp.text().catch(() => "");
|
|
32
|
-
throw new Error(`Jev API error ${resp.status} (${context}): ${truncate(raw, ERROR_BODY_MAX_CHARS)}`);
|
|
33
|
-
}
|
|
34
|
-
async function callSystemOne(body) {
|
|
35
|
-
const resp = await fetchWithRetry(`${BASE_URL}/v1/systemone`, {
|
|
36
|
-
method: "POST",
|
|
37
|
-
headers: {
|
|
38
|
-
Authorization: `Bearer ${API_KEY}`,
|
|
39
|
-
"Content-Type": "application/json",
|
|
40
|
-
},
|
|
41
|
-
body: JSON.stringify(body),
|
|
42
|
-
});
|
|
43
|
-
if (!resp.ok) {
|
|
44
|
-
await throwApiError(resp, "systemone");
|
|
45
|
-
}
|
|
46
|
-
let raw;
|
|
47
|
-
try {
|
|
48
|
-
raw = await resp.json();
|
|
29
|
+
catch (e) {
|
|
30
|
+
if (e instanceof ConfigurationError) {
|
|
31
|
+
process.stderr.write(`[mcp-jev] FATAL: ${e.message}\n`);
|
|
32
|
+
process.exit(1);
|
|
49
33
|
}
|
|
50
|
-
|
|
51
|
-
throw new Error(`Failed to parse Jev API response as JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
52
|
-
}
|
|
53
|
-
// Runtime validation — catches API contract changes early (F01)
|
|
54
|
-
const parsed = JevResponseSchema.safeParse(raw);
|
|
55
|
-
if (!parsed.success) {
|
|
56
|
-
throw new Error(`Jev API response shape unexpected: ${parsed.error.message}`);
|
|
57
|
-
}
|
|
58
|
-
return parsed.data;
|
|
34
|
+
throw e;
|
|
59
35
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
catch (e) {
|
|
73
|
-
throw new Error(`Failed to parse Jev models response as JSON: ${e instanceof Error ? e.message : String(e)}`);
|
|
74
|
-
}
|
|
75
|
-
// Runtime shape validation (F01)
|
|
76
|
-
const envelope = JevModelsResponseSchema.safeParse(raw);
|
|
77
|
-
if (!envelope.success) {
|
|
78
|
-
throw new Error(`Unexpected Jev models response shape: ${envelope.error.message}`);
|
|
79
|
-
}
|
|
80
|
-
const entries = envelope.data.models ?? envelope.data.data ?? [];
|
|
81
|
-
if (!Array.isArray(entries)) {
|
|
82
|
-
throw new Error("Unexpected Jev models response shape — expected array");
|
|
83
|
-
}
|
|
84
|
-
// Filter and validate each model entry — skip entries missing id (F03)
|
|
85
|
-
return parseModelEntries(entries);
|
|
86
|
-
}
|
|
87
|
-
// ─── MCP server ─────────────────────────────────────────────────────────────
|
|
88
|
-
const server = new McpServer({
|
|
89
|
-
name: "mcp-jev",
|
|
90
|
-
version: "1.0.0",
|
|
91
|
-
});
|
|
92
|
-
// ── Tool 1: jev_decide ──────────────────────────────────────────────────────
|
|
93
|
-
const InstructionsSchema = z
|
|
94
|
-
.union([z.string(), z.record(z.unknown()), z.array(z.unknown())])
|
|
95
|
-
.describe([
|
|
96
|
-
"What the model should decide. Can be:",
|
|
97
|
-
" - A plain string: \"Is `message` urgent?\"",
|
|
98
|
-
" - An object: split the question and supporting data into named fields",
|
|
99
|
-
" - An array: ordered list of instruction parts",
|
|
100
|
-
"Reference state fields with backtick paths, e.g. `message` or `order.id`.",
|
|
101
|
-
].join("\n"));
|
|
102
|
-
const CriteriaValueSchema = z
|
|
103
|
-
.union([z.string(), z.record(z.unknown()), z.array(z.unknown()), z.null()])
|
|
104
|
-
.describe("Description for this option/level. Use null for options that need no extra detail.");
|
|
36
|
+
// ─── Shared Zod schemas ──────────────────────────────────────────────────────
|
|
37
|
+
const InstructionsSchema = z.union([
|
|
38
|
+
z.string(),
|
|
39
|
+
z.record(z.unknown()),
|
|
40
|
+
z.array(z.unknown()),
|
|
41
|
+
]);
|
|
42
|
+
const CriteriaValueSchema = z.union([
|
|
43
|
+
z.string(),
|
|
44
|
+
z.record(z.unknown()),
|
|
45
|
+
z.array(z.unknown()),
|
|
46
|
+
z.null(),
|
|
47
|
+
]);
|
|
105
48
|
const QuestionSchema = z.discriminatedUnion("type", [
|
|
106
49
|
z.object({
|
|
107
|
-
id: z.string().min(1)
|
|
108
|
-
type: z.literal("noul")
|
|
50
|
+
id: z.string().min(1),
|
|
51
|
+
type: z.literal("noul"),
|
|
109
52
|
instructions: InstructionsSchema,
|
|
110
|
-
criteria: z.string().optional()
|
|
53
|
+
criteria: z.string().optional(),
|
|
111
54
|
}),
|
|
112
55
|
z.object({
|
|
113
|
-
id: z.string().min(1)
|
|
114
|
-
type: z.literal("choice")
|
|
56
|
+
id: z.string().min(1),
|
|
57
|
+
type: z.literal("choice"),
|
|
115
58
|
instructions: InstructionsSchema,
|
|
116
59
|
criteria: z
|
|
117
60
|
.record(CriteriaValueSchema)
|
|
118
61
|
.refine((obj) => Object.keys(obj).length <= MAX_CHOICE_OPTIONS, {
|
|
119
62
|
message: `Choice criteria cannot exceed ${MAX_CHOICE_OPTIONS} options`,
|
|
120
|
-
})
|
|
121
|
-
.describe([
|
|
122
|
-
`Map of option key → description (max ${MAX_CHOICE_OPTIONS} options).`,
|
|
123
|
-
"Each value can be: string, object, array, or null.",
|
|
124
|
-
'Use null for options that need no extra detail, e.g. {"other": null}.',
|
|
125
|
-
].join("\n")),
|
|
63
|
+
}),
|
|
126
64
|
}),
|
|
127
65
|
z.object({
|
|
128
|
-
id: z.string().min(1)
|
|
129
|
-
type: z.literal("score")
|
|
66
|
+
id: z.string().min(1),
|
|
67
|
+
type: z.literal("score"),
|
|
130
68
|
instructions: InstructionsSchema,
|
|
131
|
-
criteria: z
|
|
132
|
-
.array(CriteriaValueSchema)
|
|
133
|
-
.min(MIN_SCORE_LEVELS)
|
|
134
|
-
.max(MAX_SCORE_LEVELS)
|
|
135
|
-
.describe([
|
|
136
|
-
`Ordered list of level descriptions from lowest to highest (${MIN_SCORE_LEVELS}–${MAX_SCORE_LEVELS} levels).`,
|
|
137
|
-
"Each level can be: string, object, or array.",
|
|
138
|
-
'e.g. ["calm", "frustrated", "very angry"]',
|
|
139
|
-
].join("\n")),
|
|
69
|
+
criteria: z.array(CriteriaValueSchema).min(MIN_SCORE_LEVELS).max(MAX_SCORE_LEVELS),
|
|
140
70
|
}),
|
|
141
71
|
]);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
72
|
+
const StateSchema = z.union([
|
|
73
|
+
z.string().max(MAX_STATE_STRING_CHARS),
|
|
74
|
+
z.record(z.unknown()).refine((obj) => JSON.stringify(obj).length <= MAX_STATE_STRING_CHARS, { message: `State object too large (max ~${MAX_STATE_STRING_CHARS} chars)` }),
|
|
75
|
+
z.array(z.unknown()).refine((arr) => JSON.stringify(arr).length <= MAX_STATE_STRING_CHARS, { message: `State array too large (max ~${MAX_STATE_STRING_CHARS} chars)` }),
|
|
76
|
+
]);
|
|
77
|
+
// ─── Helper ───────────────────────────────────────────────────────────────────
|
|
78
|
+
function toMcpError(e) {
|
|
79
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
80
|
+
return { content: [{ type: "text", text: `Error: ${message}` }], isError: true };
|
|
81
|
+
}
|
|
82
|
+
// ─── MCP server ─────────────────────────────────────────────────────────────
|
|
83
|
+
const server = new McpServer({
|
|
84
|
+
name: "mcp-jev",
|
|
85
|
+
version: "2.0.0",
|
|
86
|
+
});
|
|
87
|
+
// ── Tool 1: decide_predict ───────────────────────────────────────────────────
|
|
88
|
+
server.tool("decide_predict", [
|
|
89
|
+
"Evaluate typed questions against a state using a System-1 decision model.",
|
|
147
90
|
"",
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
" - Check a true/false condition with calibrated confidence (is_urgent, is_spam)",
|
|
151
|
-
" - Rate content on a rubric (severity, quality, sentiment)",
|
|
152
|
-
" - Run multiple of the above on the same content in one call",
|
|
91
|
+
"Sends state + questions to the configured provider (Jev or Laya) and returns",
|
|
92
|
+
"calibrated probabilities for each question — not generated text.",
|
|
153
93
|
"",
|
|
154
|
-
"Question types:",
|
|
155
|
-
" - noul: yes/no probability (0–1)",
|
|
156
|
-
" - choice: pick one of N options",
|
|
157
|
-
" - score: rate on ordered rubric (2–10 levels)",
|
|
94
|
+
"Question types: noul (yes/no probability), choice (pick one of N), score (rate on rubric).",
|
|
158
95
|
"",
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
"
|
|
163
|
-
" instructions: \"Does the user in `message` need urgent support?\" }",
|
|
164
|
-
" - { id: \"dept\", type: \"choice\",",
|
|
165
|
-
" instructions: \"Which department should handle `message`?\",",
|
|
166
|
-
" criteria: { billing: \"Payments/refunds\", technical: \"API errors\", general: null } }",
|
|
167
|
-
" - { id: \"frustration\", type: \"score\",",
|
|
168
|
-
" instructions: \"How frustrated is the user in `message`?\",",
|
|
169
|
-
" criteria: [\"calm\", \"annoyed\", \"very frustrated\"] }",
|
|
170
|
-
" → answers: { is_urgent: { noul: 0.95 },",
|
|
171
|
-
" dept: { choice: \"billing\", probabilities: {...}, confidence: 0.82 },",
|
|
172
|
-
" frustration: { score: 2.04, legend: {\"0\":\"calm\",\"2\":\"very frustrated\"}, ... } }",
|
|
96
|
+
"When to call:",
|
|
97
|
+
" - Classify or route text (intent, category)",
|
|
98
|
+
" - Check a true/false condition with calibrated confidence",
|
|
99
|
+
" - Rate content on a rubric",
|
|
173
100
|
"",
|
|
174
101
|
"Tip: send only the state fields each question needs. Extra context degrades accuracy.",
|
|
175
102
|
].join("\n"), {
|
|
176
|
-
state:
|
|
177
|
-
.union([
|
|
178
|
-
z.string().max(MAX_STATE_STRING_CHARS), // (F05) size limit for string state
|
|
179
|
-
z.record(z.unknown()).refine((obj) => JSON.stringify(obj).length <= MAX_STATE_STRING_CHARS, { message: `State object too large (max ~${MAX_STATE_STRING_CHARS} chars when serialized)` }),
|
|
180
|
-
z.array(z.unknown()).refine((arr) => JSON.stringify(arr).length <= MAX_STATE_STRING_CHARS, { message: `State array too large (max ~${MAX_STATE_STRING_CHARS} chars when serialized)` }),
|
|
181
|
-
])
|
|
182
|
-
.describe([
|
|
183
|
-
"The content Jev evaluates. Can be:",
|
|
184
|
-
` - A plain string (max ${MAX_STATE_STRING_CHARS.toLocaleString()} chars): \"My card was charged twice.\"`,
|
|
185
|
-
" - An object with named fields: {\"message\": \"...\", \"order_id\": \"A-104\"}",
|
|
186
|
-
" - An array of records (for batches or conversation turns)",
|
|
187
|
-
"Include only what the questions need — extra content lowers accuracy.",
|
|
188
|
-
].join("\n")),
|
|
103
|
+
state: StateSchema.describe("The content to evaluate (string, object, or array)"),
|
|
189
104
|
questions: z
|
|
190
105
|
.array(QuestionSchema)
|
|
191
106
|
.min(1)
|
|
192
|
-
.max(MAX_QUESTIONS)
|
|
193
|
-
.describe(
|
|
194
|
-
`List of questions to evaluate (max ${MAX_QUESTIONS}). Each has:`,
|
|
195
|
-
" id — key used in the response answers map",
|
|
196
|
-
" type — \"noul\" | \"choice\" | \"score\"",
|
|
197
|
-
" instructions — full question text, may reference state fields in backticks",
|
|
198
|
-
" criteria — required for choice (object) and score (array); optional for noul",
|
|
199
|
-
].join("\n")),
|
|
107
|
+
.max(MAX_QUESTIONS)
|
|
108
|
+
.describe("List of typed questions (noul/choice/score)"),
|
|
200
109
|
model: z
|
|
201
110
|
.string()
|
|
202
|
-
.
|
|
203
|
-
.describe(
|
|
111
|
+
.optional()
|
|
112
|
+
.describe('Model alias (default: "jev-latest"). Ignored for Laya (auto-routes).'),
|
|
204
113
|
}, async ({ state, questions, model }) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
114
|
+
// Validate no duplicate question IDs
|
|
115
|
+
const ids = questions.map((q) => q.id);
|
|
116
|
+
const seen = new Set();
|
|
117
|
+
for (const id of ids) {
|
|
118
|
+
if (seen.has(id)) {
|
|
208
119
|
return {
|
|
209
120
|
content: [
|
|
210
121
|
{
|
|
211
122
|
type: "text",
|
|
212
|
-
text: `Error: duplicate question id '${
|
|
123
|
+
text: `Error: duplicate question id '${id}' — each question must have a unique id.`,
|
|
213
124
|
},
|
|
214
125
|
],
|
|
215
126
|
isError: true,
|
|
216
127
|
};
|
|
217
128
|
}
|
|
129
|
+
seen.add(id);
|
|
130
|
+
}
|
|
131
|
+
// Build questions map for adapter
|
|
132
|
+
const questionsMap = {};
|
|
133
|
+
for (const q of questions) {
|
|
218
134
|
if (q.type === "noul") {
|
|
219
|
-
questionsMap[q.id] = {
|
|
220
|
-
type: "noul",
|
|
221
|
-
instructions: q.instructions,
|
|
222
|
-
...(q.criteria ? { criteria: q.criteria } : {}),
|
|
223
|
-
};
|
|
135
|
+
questionsMap[q.id] = { type: "noul", instructions: q.instructions, ...(q.criteria ? { criteria: q.criteria } : {}) };
|
|
224
136
|
}
|
|
225
137
|
else if (q.type === "choice") {
|
|
226
138
|
questionsMap[q.id] = { type: "choice", instructions: q.instructions, criteria: q.criteria };
|
|
@@ -230,45 +142,93 @@ server.tool("jev_decide", [
|
|
|
230
142
|
}
|
|
231
143
|
}
|
|
232
144
|
try {
|
|
233
|
-
const result = await
|
|
145
|
+
const result = await adapter.predict({ state, questions: questionsMap, model });
|
|
146
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
return toMcpError(e);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
// ── Tool 2: decide_preset ────────────────────────────────────────────────────
|
|
153
|
+
server.tool("decide_preset", [
|
|
154
|
+
"Run a named workflow preset — expands to a pre-defined set of questions and calls decide_predict.",
|
|
155
|
+
"",
|
|
156
|
+
"Available presets:",
|
|
157
|
+
" triage — support ticket intent, urgency, frustration, churn risk",
|
|
158
|
+
" guard — LLM input jailbreak, injection, sensitive data, harm, topic",
|
|
159
|
+
" moderation — content toxicity, harassment, threat, spam, severity",
|
|
160
|
+
" router — model routing by difficulty, domain, tool need, sensitivity",
|
|
161
|
+
" email — email category, spam, phishing, urgency, reply needed",
|
|
162
|
+
"",
|
|
163
|
+
"Tip: set state fields matching the preset (e.g., {message: ...} for triage, {prompt: ...} for guard).",
|
|
164
|
+
].join("\n"), {
|
|
165
|
+
preset: z
|
|
166
|
+
.string()
|
|
167
|
+
.describe(`Preset name: ${PRESET_NAMES.join(" | ")}`),
|
|
168
|
+
state: StateSchema.describe("The content to evaluate"),
|
|
169
|
+
model: z
|
|
170
|
+
.string()
|
|
171
|
+
.optional()
|
|
172
|
+
.describe("Model alias (optional)"),
|
|
173
|
+
}, async ({ preset, state, model }) => {
|
|
174
|
+
if (!isValidPreset(preset)) {
|
|
234
175
|
return {
|
|
235
176
|
content: [
|
|
236
177
|
{
|
|
237
178
|
type: "text",
|
|
238
|
-
text:
|
|
179
|
+
text: `Error: unknown preset "${preset}". Valid presets: ${PRESET_NAMES.join(", ")}.`,
|
|
239
180
|
},
|
|
240
181
|
],
|
|
182
|
+
isError: true,
|
|
241
183
|
};
|
|
242
184
|
}
|
|
185
|
+
const questions = expandPreset(preset);
|
|
186
|
+
try {
|
|
187
|
+
const result = await adapter.predict({ state, questions, model });
|
|
188
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
189
|
+
}
|
|
243
190
|
catch (e) {
|
|
244
|
-
|
|
245
|
-
return {
|
|
246
|
-
content: [{ type: "text", text: `Error calling Jev API: ${message}` }],
|
|
247
|
-
isError: true,
|
|
248
|
-
};
|
|
191
|
+
return toMcpError(e);
|
|
249
192
|
}
|
|
250
193
|
});
|
|
251
|
-
// ── Tool
|
|
252
|
-
server.tool("
|
|
253
|
-
"
|
|
194
|
+
// ── Tool 3: decide_status ────────────────────────────────────────────────────
|
|
195
|
+
server.tool("decide_status", [
|
|
196
|
+
"Get provider health and configuration info.",
|
|
197
|
+
"",
|
|
198
|
+
"Returns: { provider, base_url, model?, loaded?, device?, status?, error? }",
|
|
199
|
+
" - provider: 'jev' | 'laya'",
|
|
200
|
+
" - status: 'ok' | 'unreachable' | 'error' (Laya only)",
|
|
201
|
+
" - loaded: checkpoint names (Laya only)",
|
|
202
|
+
" - model: default model alias (Jev only)",
|
|
203
|
+
"",
|
|
204
|
+
"Note: Jev has no health endpoint — status is synthesized from env config.",
|
|
205
|
+
].join("\n"), {}, async () => {
|
|
206
|
+
try {
|
|
207
|
+
const result = await adapter.status();
|
|
208
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
return toMcpError(e);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
// ── Tool 4: decide_list_models ───────────────────────────────────────────────
|
|
215
|
+
server.tool("decide_list_models", [
|
|
216
|
+
"List available models or checkpoints for the active provider.",
|
|
217
|
+
"",
|
|
218
|
+
"Returns: [{ id, aliases?, description? }]",
|
|
219
|
+
" - Jev: model IDs and aliases from GET /v1/models",
|
|
220
|
+
" - Laya: loaded checkpoints from GET /health",
|
|
254
221
|
"",
|
|
255
222
|
"When to call:",
|
|
256
|
-
" - Before pinning a versioned model ID
|
|
257
|
-
" - To check
|
|
258
|
-
" - To confirm which model version is currently behind jev-latest",
|
|
223
|
+
" - Before pinning a versioned model ID in decide_predict",
|
|
224
|
+
" - To check which checkpoints are loaded in a local Laya instance",
|
|
259
225
|
].join("\n"), {}, async () => {
|
|
260
226
|
try {
|
|
261
|
-
const
|
|
262
|
-
return {
|
|
263
|
-
content: [{ type: "text", text: JSON.stringify(models, null, 2) }],
|
|
264
|
-
};
|
|
227
|
+
const result = await adapter.listModels();
|
|
228
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
265
229
|
}
|
|
266
230
|
catch (e) {
|
|
267
|
-
|
|
268
|
-
return {
|
|
269
|
-
content: [{ type: "text", text: `Error fetching models: ${message}` }],
|
|
270
|
-
isError: true,
|
|
271
|
-
};
|
|
231
|
+
return toMcpError(e);
|
|
272
232
|
}
|
|
273
233
|
});
|
|
274
234
|
// ─── Start ───────────────────────────────────────────────────────────────────
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,kBAAkB,EAGlB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GAEjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEzE,gFAAgF;AAEhF,IAAI,OAAwB,CAAC;AAC7B,IAAI,CAAC;IACH,OAAO,GAAG,aAAa,EAAE,CAAC;AAC5B,CAAC;AAAC,OAAO,CAAC,EAAE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