@lovable.dev/mcp-js 3.1.1 → 3.2.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 +43 -0
- package/dist/{authorize-Dt7ll7Ur.d.ts → authorize-DUEaDXjU.d.ts} +1 -1
- package/dist/{authorize-BS_In2AW.d.cts → authorize-bDiUiJco.d.cts} +1 -1
- package/dist/{base-B7D0KqaY.d.ts → base-CLO7XsxC.d.ts} +1 -1
- package/dist/{base-D3TT1Wup.d.cts → base-D2d7lJY5.d.cts} +1 -1
- package/dist/cli/extract-manifest.cjs +1 -1
- package/dist/cli/extract-manifest.js +1 -1
- package/dist/{cors-CEF2VQQ4.cjs → cors-Dk0jvKYK.cjs} +1 -1
- package/dist/{cors-DbJgGIwT.js → cors-tLp9UO0k.js} +1 -1
- package/dist/{errors-CWxgUZH3.cjs → errors-CLfxIB-l.cjs} +3 -2
- package/dist/{errors-ZmYYVYKN.js → errors-CljrUVby.js} +3 -2
- package/dist/format-DDzvc92Z.cjs +41 -0
- package/dist/format-DKEuO8Tn.js +30 -0
- package/dist/hooks-BOdDe251.js +353 -0
- package/dist/hooks-xQl3EkDa.cjs +382 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{io-BvogiiQ1.d.ts → io-CFyHLyvs.d.ts} +1 -1
- package/dist/{io-Bn0ErYbG.d.cts → io-DfUvQ-SV.d.cts} +1 -1
- package/dist/{io-Cuzga3zO.js → io-U3Nv7y0k.js} +3 -2
- package/dist/{io-DvrElu4G.cjs → io-tWj7qb9q.cjs} +7 -6
- package/dist/{mcp-BClUdQ3O.cjs → mcp-BMNeCc_-.cjs} +160 -8
- package/dist/{mcp-cPwyvSCx.js → mcp-BYSubCtv.js} +161 -9
- package/dist/{package-CaoFQDOo.cjs → package-B4OsCEhG.cjs} +1 -1
- package/dist/{package-Dvpf79Jm.js → package-DXBX-HJu.js} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.d.cts +3 -3
- package/dist/protocols/mcp/index.d.ts +3 -3
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +1 -1
- package/dist/protocols/oauth-metadata.d.cts +3 -3
- package/dist/protocols/oauth-metadata.d.ts +3 -3
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/stacks/supabase/index.cjs +2 -2
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +2 -2
- package/dist/stacks/supabase/vite.cjs +40 -18
- package/dist/stacks/supabase/vite.d.cts +1 -1
- package/dist/stacks/supabase/vite.d.ts +1 -1
- package/dist/stacks/supabase/vite.js +34 -12
- package/dist/stacks/tanstack/index.cjs +2 -2
- package/dist/stacks/tanstack/index.d.cts +2 -2
- package/dist/stacks/tanstack/index.d.ts +2 -2
- package/dist/stacks/tanstack/index.js +2 -2
- package/dist/stacks/tanstack/vite.cjs +22 -22
- package/dist/stacks/tanstack/vite.d.cts +1 -1
- package/dist/stacks/tanstack/vite.d.ts +1 -1
- package/dist/stacks/tanstack/vite.js +14 -14
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/{types-BX8RawmT.d.ts → types-CAFCH0yK.d.cts} +7 -1
- package/dist/{types-BX8RawmT.d.cts → types-CAFCH0yK.d.ts} +7 -1
- package/package.json +16 -4
- package/skill-imports.d.cts +1 -0
- package/skill-imports.d.ts +9 -0
- package/dist/supabase-config-DITfH_bn.js +0 -30
- package/dist/supabase-config-Dz13d9ze.cjs +0 -41
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_schema = require("./schema-DNMsvJwE.cjs");
|
|
2
2
|
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
3
|
-
const require_errors = require("./errors-
|
|
4
|
-
const require_cors = require("./cors-
|
|
3
|
+
const require_errors = require("./errors-CLfxIB-l.cjs");
|
|
4
|
+
const require_cors = require("./cors-Dk0jvKYK.cjs");
|
|
5
5
|
const require_tool_result = require("./tool-result-rU-PpNNi.cjs");
|
|
6
6
|
let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
|
|
7
7
|
let _modelcontextprotocol_server = require("@modelcontextprotocol/server");
|
|
@@ -16,6 +16,68 @@ function extractTextContent(content) {
|
|
|
16
16
|
return text.length > 0 ? text : void 0;
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
|
+
//#region src/skills/runtime.ts
|
|
20
|
+
const SKILLS_EXTENSION_ID = "io.modelcontextprotocol/skills";
|
|
21
|
+
function indexLines(skills) {
|
|
22
|
+
return skills.map((skill) => `- name: ${JSON.stringify(skill.frontmatter.name)}; description: ${JSON.stringify(skill.frontmatter.description)}; uri: ${skill.uri}`);
|
|
23
|
+
}
|
|
24
|
+
function longestRun(text, char) {
|
|
25
|
+
let best = 0;
|
|
26
|
+
let current = 0;
|
|
27
|
+
for (const c of text) {
|
|
28
|
+
current = c === char ? current + 1 : 0;
|
|
29
|
+
if (current > best) best = current;
|
|
30
|
+
}
|
|
31
|
+
return best;
|
|
32
|
+
}
|
|
33
|
+
function prepareSkills(serverName, importedSkills) {
|
|
34
|
+
const skills = importedSkills;
|
|
35
|
+
const files = /* @__PURE__ */ new Map();
|
|
36
|
+
const skillsByUri = /* @__PURE__ */ new Map();
|
|
37
|
+
for (const skill of skills) {
|
|
38
|
+
skillsByUri.set(skill.uri, skill);
|
|
39
|
+
for (const file of skill.files) {
|
|
40
|
+
const existing = files.get(file.uri);
|
|
41
|
+
if (existing === void 0) files.set(file.uri, {
|
|
42
|
+
...file,
|
|
43
|
+
roots: [skill.rootUri]
|
|
44
|
+
});
|
|
45
|
+
else if (!existing.roots.includes(skill.rootUri)) files.set(file.uri, {
|
|
46
|
+
...existing,
|
|
47
|
+
roots: [...existing.roots, skill.rootUri]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const index = indexLines(skills);
|
|
52
|
+
const indexText = [
|
|
53
|
+
`## Agent Skills published by this server (${SKILLS_EXTENSION_ID})`,
|
|
54
|
+
"When a task matches, use the host's skill loader with this server and URI. Resolve references with skills/get; reading resources alone does not activate a skill.",
|
|
55
|
+
...index
|
|
56
|
+
].join("\n");
|
|
57
|
+
let delimiterLength = 8;
|
|
58
|
+
for (const file of files.values()) delimiterLength = Math.max(delimiterLength, longestRun(file.text, "@") + 1);
|
|
59
|
+
const delimiter = "@".repeat(delimiterLength);
|
|
60
|
+
const sections = [];
|
|
61
|
+
for (const file of files.values()) sections.push(`${delimiter} BEGIN FILE ${file.uri} (server: ${JSON.stringify(serverName)}; skill roots: ${file.roots.join(", ")})\n${file.text}\n${delimiter} END FILE ${file.uri}`);
|
|
62
|
+
return {
|
|
63
|
+
skills,
|
|
64
|
+
files,
|
|
65
|
+
skillsByUri,
|
|
66
|
+
indexText,
|
|
67
|
+
fallbackText: [
|
|
68
|
+
`## Agent Skills reference text from server ${JSON.stringify(serverName)}`,
|
|
69
|
+
"This is a text copy of the server's Agent Skills. It installs no files and grants no execution or frontmatter permissions; the host may separately provide native Skills support. Use a skill when its description matches the task. Relative paths inside a skill resolve against that skill's root URI; a skill:// URI names another section below.",
|
|
70
|
+
...index,
|
|
71
|
+
`Each file appears once between lines starting with "${delimiter} BEGIN FILE <uri>" and "${delimiter} END FILE <uri>".`,
|
|
72
|
+
...sections
|
|
73
|
+
].join("\n")
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function composeInstructions(authored, prepared, declared) {
|
|
77
|
+
const addition = declared ? prepared.indexText : prepared.fallbackText;
|
|
78
|
+
return authored.length > 0 ? `${authored}\n\n${addition}` : addition;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
19
81
|
//#region src/protocols/gate.ts
|
|
20
82
|
function createGatedHandler(gate) {
|
|
21
83
|
const allow = [...gate.methods, "OPTIONS"].join(", ");
|
|
@@ -140,6 +202,19 @@ function standardSchemaFromDefinition(definition, strict) {
|
|
|
140
202
|
function isPlainObject(value) {
|
|
141
203
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
142
204
|
}
|
|
205
|
+
function declaresSkillsSupport(parsedBody) {
|
|
206
|
+
if (Array.isArray(parsedBody)) {
|
|
207
|
+
const initializations = parsedBody.filter((value) => isPlainObject(value) && value.method === "initialize");
|
|
208
|
+
return initializations.length > 0 && initializations.every(declaresSkillsSupport);
|
|
209
|
+
}
|
|
210
|
+
if (!isPlainObject(parsedBody) || !isPlainObject(parsedBody.params)) return false;
|
|
211
|
+
const params = parsedBody.params;
|
|
212
|
+
let capabilities;
|
|
213
|
+
if (parsedBody.method === "initialize") capabilities = params.capabilities;
|
|
214
|
+
else if (isPlainObject(params._meta)) capabilities = params._meta[_modelcontextprotocol_server.CLIENT_CAPABILITIES_META_KEY];
|
|
215
|
+
if (!isPlainObject(capabilities) || !isPlainObject(capabilities.extensions)) return false;
|
|
216
|
+
return isPlainObject(capabilities.extensions[SKILLS_EXTENSION_ID]);
|
|
217
|
+
}
|
|
143
218
|
function toolRequestContext(sdkCtx, protocol) {
|
|
144
219
|
const mcpReq = sdkCtx?.mcpReq;
|
|
145
220
|
const client = { protocol };
|
|
@@ -250,7 +325,66 @@ function adaptToolCallback(tool, auth, recorder, protocol, appContext) {
|
|
|
250
325
|
};
|
|
251
326
|
};
|
|
252
327
|
}
|
|
253
|
-
|
|
328
|
+
const SKILL_CACHE = {
|
|
329
|
+
ttlMs: 0,
|
|
330
|
+
cacheScope: "private"
|
|
331
|
+
};
|
|
332
|
+
function paramsSchema(check) {
|
|
333
|
+
return { "~standard": {
|
|
334
|
+
version: 1,
|
|
335
|
+
vendor: "lovable-mcp-js",
|
|
336
|
+
validate: (value) => {
|
|
337
|
+
value ??= {};
|
|
338
|
+
if (!isPlainObject(value)) return { issues: [{ message: "params must be an object" }] };
|
|
339
|
+
const problem = check(value);
|
|
340
|
+
return problem ? { issues: [{ message: problem }] } : { value };
|
|
341
|
+
}
|
|
342
|
+
} };
|
|
343
|
+
}
|
|
344
|
+
const skillsListParams = paramsSchema((value) => value.cursor === void 0 ? void 0 : "This catalog has no continuation cursor");
|
|
345
|
+
const skillsGetParams = paramsSchema((value) => typeof value.uri === "string" ? void 0 : "uri must be a string");
|
|
346
|
+
function skillEntry(skill) {
|
|
347
|
+
return {
|
|
348
|
+
uri: skill.uri,
|
|
349
|
+
frontmatter: skill.frontmatter,
|
|
350
|
+
resources: skill.files.map((file) => ({
|
|
351
|
+
uri: file.uri,
|
|
352
|
+
digest: file.digest,
|
|
353
|
+
size: file.size
|
|
354
|
+
}))
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function registerSkills(server, skills, era) {
|
|
358
|
+
const resultMetadata = era === "modern" ? {
|
|
359
|
+
resultType: "complete",
|
|
360
|
+
...SKILL_CACHE
|
|
361
|
+
} : {};
|
|
362
|
+
for (const file of skills.files.values()) {
|
|
363
|
+
const owner = skills.skillsByUri.get(file.uri);
|
|
364
|
+
server.registerResource(owner ? owner.frontmatter.name : file.uri, file.uri, {
|
|
365
|
+
mimeType: file.mimeType,
|
|
366
|
+
...owner ? { description: owner.frontmatter.description } : {},
|
|
367
|
+
cacheHint: SKILL_CACHE
|
|
368
|
+
}, async () => ({ contents: [{
|
|
369
|
+
uri: file.uri,
|
|
370
|
+
mimeType: file.mimeType,
|
|
371
|
+
text: file.text
|
|
372
|
+
}] }));
|
|
373
|
+
}
|
|
374
|
+
server.server.setRequestHandler("skills/list", { params: skillsListParams }, async () => ({
|
|
375
|
+
skills: skills.skills.map(skillEntry),
|
|
376
|
+
...resultMetadata
|
|
377
|
+
}));
|
|
378
|
+
server.server.setRequestHandler("skills/get", { params: skillsGetParams }, async ({ uri }) => {
|
|
379
|
+
const skill = skills.skillsByUri.get(uri);
|
|
380
|
+
if (!skill) throw new _modelcontextprotocol_server.ProtocolError(_modelcontextprotocol_server.ProtocolErrorCode.InvalidParams, `No skill is served at ${uri}`);
|
|
381
|
+
return {
|
|
382
|
+
skill: skillEntry(skill),
|
|
383
|
+
...resultMetadata
|
|
384
|
+
};
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
async function buildServer(mcp, auth, recorder, era, signal, operations, skills) {
|
|
254
388
|
const calledTools = operations ? mcp.tools.filter((tool) => operations.calledTools.has(tool.name)) : mcp.tools;
|
|
255
389
|
const selectedTools = !operations || operations.listTools ? mcp.tools : calledTools;
|
|
256
390
|
const hasConditionalTools = mcp.tools.some((tool) => tool.enabled !== void 0);
|
|
@@ -266,8 +400,15 @@ async function buildServer(mcp, auth, recorder, era, signal, operations) {
|
|
|
266
400
|
version: mcp.version,
|
|
267
401
|
title: mcp.title
|
|
268
402
|
}, {
|
|
269
|
-
instructions: mcp.instructions,
|
|
270
|
-
capabilities:
|
|
403
|
+
instructions: skills ? skills.instructions : mcp.instructions,
|
|
404
|
+
capabilities: skills ? {
|
|
405
|
+
tools: { listChanged: false },
|
|
406
|
+
resources: {
|
|
407
|
+
listChanged: false,
|
|
408
|
+
subscribe: false
|
|
409
|
+
},
|
|
410
|
+
extensions: { [SKILLS_EXTENSION_ID]: {} }
|
|
411
|
+
} : { tools: { listChanged: false } },
|
|
271
412
|
cacheHints: {
|
|
272
413
|
"tools/list": {
|
|
273
414
|
ttlMs: 0,
|
|
@@ -276,9 +417,14 @@ async function buildServer(mcp, auth, recorder, era, signal, operations) {
|
|
|
276
417
|
"server/discover": {
|
|
277
418
|
ttlMs: 0,
|
|
278
419
|
cacheScope: "private"
|
|
279
|
-
}
|
|
420
|
+
},
|
|
421
|
+
...skills ? {
|
|
422
|
+
"resources/list": SKILL_CACHE,
|
|
423
|
+
"resources/read": SKILL_CACHE
|
|
424
|
+
} : {}
|
|
280
425
|
}
|
|
281
426
|
});
|
|
427
|
+
if (skills) registerSkills(server, skills.prepared, era);
|
|
282
428
|
for (const tool of selectedTools) {
|
|
283
429
|
if (tool.enabled) {
|
|
284
430
|
const { enabled } = tool;
|
|
@@ -312,6 +458,7 @@ async function buildServer(mcp, auth, recorder, era, signal, operations) {
|
|
|
312
458
|
*/
|
|
313
459
|
function createMcpProtocolHandler(mcp, options = {}) {
|
|
314
460
|
const authorizer = require_cors.createRequestAuthorizer(mcp, options);
|
|
461
|
+
const preparedSkills = mcp.skills && mcp.skills.length > 0 ? prepareSkills(mcp.name, mcp.skills) : void 0;
|
|
315
462
|
const handle = async (request, authResult, recorder) => {
|
|
316
463
|
let protocolError;
|
|
317
464
|
const reportTransportError = async (error) => {
|
|
@@ -329,8 +476,13 @@ function createMcpProtocolHandler(mcp, options = {}) {
|
|
|
329
476
|
});
|
|
330
477
|
};
|
|
331
478
|
try {
|
|
332
|
-
const classified = mcp.createAppContext ? await classifyRequest(request) : void 0;
|
|
333
|
-
const
|
|
479
|
+
const classified = mcp.createAppContext || preparedSkills ? await classifyRequest(request) : void 0;
|
|
480
|
+
const operations = mcp.createAppContext ? classified?.operations : void 0;
|
|
481
|
+
const skills = preparedSkills ? {
|
|
482
|
+
prepared: preparedSkills,
|
|
483
|
+
instructions: composeInstructions(mcp.instructions, preparedSkills, declaresSkillsSupport(classified?.parsedBody))
|
|
484
|
+
} : void 0;
|
|
485
|
+
const response = await (0, _modelcontextprotocol_server.createMcpHandler)(({ era, requestInfo }) => buildServer(mcp, authResult.auth, recorder, era, requestInfo?.signal ?? request.signal, operations, skills), {
|
|
334
486
|
legacy: "stateless",
|
|
335
487
|
maxSubscriptions: 0,
|
|
336
488
|
onerror: (error) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { i as log, r as describeError } from "./logger-CpLgYbCG.js";
|
|
2
2
|
import { n as schemaFromDefinition, t as jsonSchemaFromDefinition } from "./schema-JK_1KkOa.js";
|
|
3
|
-
import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-
|
|
4
|
-
import { d as nowMs, i as normalizeHttpMethod, l as emitBeforeResponse, n as createRequestAuthorizer, p as finalizeWireResponse, t as evaluateCors, u as createNoopRecorder } from "./cors-
|
|
3
|
+
import { a as ToolContext, c as toolRequiresAppContext, i as AuthContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-CljrUVby.js";
|
|
4
|
+
import { d as nowMs, i as normalizeHttpMethod, l as emitBeforeResponse, n as createRequestAuthorizer, p as finalizeWireResponse, t as evaluateCors, u as createNoopRecorder } from "./cors-tLp9UO0k.js";
|
|
5
5
|
import { t as finalizeToolResult } from "./tool-result-DcNioyiI.js";
|
|
6
6
|
import { safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
7
|
-
import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, McpServer, createMcpHandler } from "@modelcontextprotocol/server";
|
|
7
|
+
import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, McpServer, ProtocolError, ProtocolErrorCode, createMcpHandler } from "@modelcontextprotocol/server";
|
|
8
8
|
//#region src/core/content.ts
|
|
9
9
|
/** Join the text of a result's `type: "text"` blocks into one string, dropping
|
|
10
10
|
* binary/resource blocks. Used to surface a `tool_error` message in the local
|
|
@@ -16,6 +16,68 @@ function extractTextContent(content) {
|
|
|
16
16
|
return text.length > 0 ? text : void 0;
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
|
+
//#region src/skills/runtime.ts
|
|
20
|
+
const SKILLS_EXTENSION_ID = "io.modelcontextprotocol/skills";
|
|
21
|
+
function indexLines(skills) {
|
|
22
|
+
return skills.map((skill) => `- name: ${JSON.stringify(skill.frontmatter.name)}; description: ${JSON.stringify(skill.frontmatter.description)}; uri: ${skill.uri}`);
|
|
23
|
+
}
|
|
24
|
+
function longestRun(text, char) {
|
|
25
|
+
let best = 0;
|
|
26
|
+
let current = 0;
|
|
27
|
+
for (const c of text) {
|
|
28
|
+
current = c === char ? current + 1 : 0;
|
|
29
|
+
if (current > best) best = current;
|
|
30
|
+
}
|
|
31
|
+
return best;
|
|
32
|
+
}
|
|
33
|
+
function prepareSkills(serverName, importedSkills) {
|
|
34
|
+
const skills = importedSkills;
|
|
35
|
+
const files = /* @__PURE__ */ new Map();
|
|
36
|
+
const skillsByUri = /* @__PURE__ */ new Map();
|
|
37
|
+
for (const skill of skills) {
|
|
38
|
+
skillsByUri.set(skill.uri, skill);
|
|
39
|
+
for (const file of skill.files) {
|
|
40
|
+
const existing = files.get(file.uri);
|
|
41
|
+
if (existing === void 0) files.set(file.uri, {
|
|
42
|
+
...file,
|
|
43
|
+
roots: [skill.rootUri]
|
|
44
|
+
});
|
|
45
|
+
else if (!existing.roots.includes(skill.rootUri)) files.set(file.uri, {
|
|
46
|
+
...existing,
|
|
47
|
+
roots: [...existing.roots, skill.rootUri]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const index = indexLines(skills);
|
|
52
|
+
const indexText = [
|
|
53
|
+
`## Agent Skills published by this server (${SKILLS_EXTENSION_ID})`,
|
|
54
|
+
"When a task matches, use the host's skill loader with this server and URI. Resolve references with skills/get; reading resources alone does not activate a skill.",
|
|
55
|
+
...index
|
|
56
|
+
].join("\n");
|
|
57
|
+
let delimiterLength = 8;
|
|
58
|
+
for (const file of files.values()) delimiterLength = Math.max(delimiterLength, longestRun(file.text, "@") + 1);
|
|
59
|
+
const delimiter = "@".repeat(delimiterLength);
|
|
60
|
+
const sections = [];
|
|
61
|
+
for (const file of files.values()) sections.push(`${delimiter} BEGIN FILE ${file.uri} (server: ${JSON.stringify(serverName)}; skill roots: ${file.roots.join(", ")})\n${file.text}\n${delimiter} END FILE ${file.uri}`);
|
|
62
|
+
return {
|
|
63
|
+
skills,
|
|
64
|
+
files,
|
|
65
|
+
skillsByUri,
|
|
66
|
+
indexText,
|
|
67
|
+
fallbackText: [
|
|
68
|
+
`## Agent Skills reference text from server ${JSON.stringify(serverName)}`,
|
|
69
|
+
"This is a text copy of the server's Agent Skills. It installs no files and grants no execution or frontmatter permissions; the host may separately provide native Skills support. Use a skill when its description matches the task. Relative paths inside a skill resolve against that skill's root URI; a skill:// URI names another section below.",
|
|
70
|
+
...index,
|
|
71
|
+
`Each file appears once between lines starting with "${delimiter} BEGIN FILE <uri>" and "${delimiter} END FILE <uri>".`,
|
|
72
|
+
...sections
|
|
73
|
+
].join("\n")
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function composeInstructions(authored, prepared, declared) {
|
|
77
|
+
const addition = declared ? prepared.indexText : prepared.fallbackText;
|
|
78
|
+
return authored.length > 0 ? `${authored}\n\n${addition}` : addition;
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
19
81
|
//#region src/protocols/gate.ts
|
|
20
82
|
function createGatedHandler(gate) {
|
|
21
83
|
const allow = [...gate.methods, "OPTIONS"].join(", ");
|
|
@@ -140,6 +202,19 @@ function standardSchemaFromDefinition(definition, strict) {
|
|
|
140
202
|
function isPlainObject(value) {
|
|
141
203
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
142
204
|
}
|
|
205
|
+
function declaresSkillsSupport(parsedBody) {
|
|
206
|
+
if (Array.isArray(parsedBody)) {
|
|
207
|
+
const initializations = parsedBody.filter((value) => isPlainObject(value) && value.method === "initialize");
|
|
208
|
+
return initializations.length > 0 && initializations.every(declaresSkillsSupport);
|
|
209
|
+
}
|
|
210
|
+
if (!isPlainObject(parsedBody) || !isPlainObject(parsedBody.params)) return false;
|
|
211
|
+
const params = parsedBody.params;
|
|
212
|
+
let capabilities;
|
|
213
|
+
if (parsedBody.method === "initialize") capabilities = params.capabilities;
|
|
214
|
+
else if (isPlainObject(params._meta)) capabilities = params._meta[CLIENT_CAPABILITIES_META_KEY];
|
|
215
|
+
if (!isPlainObject(capabilities) || !isPlainObject(capabilities.extensions)) return false;
|
|
216
|
+
return isPlainObject(capabilities.extensions[SKILLS_EXTENSION_ID]);
|
|
217
|
+
}
|
|
143
218
|
function toolRequestContext(sdkCtx, protocol) {
|
|
144
219
|
const mcpReq = sdkCtx?.mcpReq;
|
|
145
220
|
const client = { protocol };
|
|
@@ -250,7 +325,66 @@ function adaptToolCallback(tool, auth, recorder, protocol, appContext) {
|
|
|
250
325
|
};
|
|
251
326
|
};
|
|
252
327
|
}
|
|
253
|
-
|
|
328
|
+
const SKILL_CACHE = {
|
|
329
|
+
ttlMs: 0,
|
|
330
|
+
cacheScope: "private"
|
|
331
|
+
};
|
|
332
|
+
function paramsSchema(check) {
|
|
333
|
+
return { "~standard": {
|
|
334
|
+
version: 1,
|
|
335
|
+
vendor: "lovable-mcp-js",
|
|
336
|
+
validate: (value) => {
|
|
337
|
+
value ??= {};
|
|
338
|
+
if (!isPlainObject(value)) return { issues: [{ message: "params must be an object" }] };
|
|
339
|
+
const problem = check(value);
|
|
340
|
+
return problem ? { issues: [{ message: problem }] } : { value };
|
|
341
|
+
}
|
|
342
|
+
} };
|
|
343
|
+
}
|
|
344
|
+
const skillsListParams = paramsSchema((value) => value.cursor === void 0 ? void 0 : "This catalog has no continuation cursor");
|
|
345
|
+
const skillsGetParams = paramsSchema((value) => typeof value.uri === "string" ? void 0 : "uri must be a string");
|
|
346
|
+
function skillEntry(skill) {
|
|
347
|
+
return {
|
|
348
|
+
uri: skill.uri,
|
|
349
|
+
frontmatter: skill.frontmatter,
|
|
350
|
+
resources: skill.files.map((file) => ({
|
|
351
|
+
uri: file.uri,
|
|
352
|
+
digest: file.digest,
|
|
353
|
+
size: file.size
|
|
354
|
+
}))
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
function registerSkills(server, skills, era) {
|
|
358
|
+
const resultMetadata = era === "modern" ? {
|
|
359
|
+
resultType: "complete",
|
|
360
|
+
...SKILL_CACHE
|
|
361
|
+
} : {};
|
|
362
|
+
for (const file of skills.files.values()) {
|
|
363
|
+
const owner = skills.skillsByUri.get(file.uri);
|
|
364
|
+
server.registerResource(owner ? owner.frontmatter.name : file.uri, file.uri, {
|
|
365
|
+
mimeType: file.mimeType,
|
|
366
|
+
...owner ? { description: owner.frontmatter.description } : {},
|
|
367
|
+
cacheHint: SKILL_CACHE
|
|
368
|
+
}, async () => ({ contents: [{
|
|
369
|
+
uri: file.uri,
|
|
370
|
+
mimeType: file.mimeType,
|
|
371
|
+
text: file.text
|
|
372
|
+
}] }));
|
|
373
|
+
}
|
|
374
|
+
server.server.setRequestHandler("skills/list", { params: skillsListParams }, async () => ({
|
|
375
|
+
skills: skills.skills.map(skillEntry),
|
|
376
|
+
...resultMetadata
|
|
377
|
+
}));
|
|
378
|
+
server.server.setRequestHandler("skills/get", { params: skillsGetParams }, async ({ uri }) => {
|
|
379
|
+
const skill = skills.skillsByUri.get(uri);
|
|
380
|
+
if (!skill) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `No skill is served at ${uri}`);
|
|
381
|
+
return {
|
|
382
|
+
skill: skillEntry(skill),
|
|
383
|
+
...resultMetadata
|
|
384
|
+
};
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
async function buildServer(mcp, auth, recorder, era, signal, operations, skills) {
|
|
254
388
|
const calledTools = operations ? mcp.tools.filter((tool) => operations.calledTools.has(tool.name)) : mcp.tools;
|
|
255
389
|
const selectedTools = !operations || operations.listTools ? mcp.tools : calledTools;
|
|
256
390
|
const hasConditionalTools = mcp.tools.some((tool) => tool.enabled !== void 0);
|
|
@@ -266,8 +400,15 @@ async function buildServer(mcp, auth, recorder, era, signal, operations) {
|
|
|
266
400
|
version: mcp.version,
|
|
267
401
|
title: mcp.title
|
|
268
402
|
}, {
|
|
269
|
-
instructions: mcp.instructions,
|
|
270
|
-
capabilities:
|
|
403
|
+
instructions: skills ? skills.instructions : mcp.instructions,
|
|
404
|
+
capabilities: skills ? {
|
|
405
|
+
tools: { listChanged: false },
|
|
406
|
+
resources: {
|
|
407
|
+
listChanged: false,
|
|
408
|
+
subscribe: false
|
|
409
|
+
},
|
|
410
|
+
extensions: { [SKILLS_EXTENSION_ID]: {} }
|
|
411
|
+
} : { tools: { listChanged: false } },
|
|
271
412
|
cacheHints: {
|
|
272
413
|
"tools/list": {
|
|
273
414
|
ttlMs: 0,
|
|
@@ -276,9 +417,14 @@ async function buildServer(mcp, auth, recorder, era, signal, operations) {
|
|
|
276
417
|
"server/discover": {
|
|
277
418
|
ttlMs: 0,
|
|
278
419
|
cacheScope: "private"
|
|
279
|
-
}
|
|
420
|
+
},
|
|
421
|
+
...skills ? {
|
|
422
|
+
"resources/list": SKILL_CACHE,
|
|
423
|
+
"resources/read": SKILL_CACHE
|
|
424
|
+
} : {}
|
|
280
425
|
}
|
|
281
426
|
});
|
|
427
|
+
if (skills) registerSkills(server, skills.prepared, era);
|
|
282
428
|
for (const tool of selectedTools) {
|
|
283
429
|
if (tool.enabled) {
|
|
284
430
|
const { enabled } = tool;
|
|
@@ -312,6 +458,7 @@ async function buildServer(mcp, auth, recorder, era, signal, operations) {
|
|
|
312
458
|
*/
|
|
313
459
|
function createMcpProtocolHandler(mcp, options = {}) {
|
|
314
460
|
const authorizer = createRequestAuthorizer(mcp, options);
|
|
461
|
+
const preparedSkills = mcp.skills && mcp.skills.length > 0 ? prepareSkills(mcp.name, mcp.skills) : void 0;
|
|
315
462
|
const handle = async (request, authResult, recorder) => {
|
|
316
463
|
let protocolError;
|
|
317
464
|
const reportTransportError = async (error) => {
|
|
@@ -329,8 +476,13 @@ function createMcpProtocolHandler(mcp, options = {}) {
|
|
|
329
476
|
});
|
|
330
477
|
};
|
|
331
478
|
try {
|
|
332
|
-
const classified = mcp.createAppContext ? await classifyRequest(request) : void 0;
|
|
333
|
-
const
|
|
479
|
+
const classified = mcp.createAppContext || preparedSkills ? await classifyRequest(request) : void 0;
|
|
480
|
+
const operations = mcp.createAppContext ? classified?.operations : void 0;
|
|
481
|
+
const skills = preparedSkills ? {
|
|
482
|
+
prepared: preparedSkills,
|
|
483
|
+
instructions: composeInstructions(mcp.instructions, preparedSkills, declaresSkillsSupport(classified?.parsedBody))
|
|
484
|
+
} : void 0;
|
|
485
|
+
const response = await createMcpHandler(({ era, requestInfo }) => buildServer(mcp, authResult.auth, recorder, era, requestInfo?.signal ?? request.signal, operations, skills), {
|
|
334
486
|
legacy: "stateless",
|
|
335
487
|
maxSubscriptions: 0,
|
|
336
488
|
onerror: (error) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as McpDefinition } from "../../types-
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CAFCH0yK.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-D2d7lJY5.cjs";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-bDiUiJco.cjs";
|
|
4
4
|
//#region src/protocols/mcp/protocol.d.ts
|
|
5
5
|
type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as McpDefinition } from "../../types-
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CAFCH0yK.js";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-CLO7XsxC.js";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../../authorize-DUEaDXjU.js";
|
|
4
4
|
//#region src/protocols/mcp/protocol.d.ts
|
|
5
5
|
type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { t as createMcpProtocolHandler } from "../../mcp-BYSubCtv.js";
|
|
2
2
|
export { createMcpProtocolHandler };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_logger = require("../logger-C-Hdu57K.cjs");
|
|
3
|
-
const require_cors = require("../cors-
|
|
3
|
+
const require_cors = require("../cors-Dk0jvKYK.cjs");
|
|
4
4
|
//#region src/protocols/oauth-metadata.ts
|
|
5
5
|
function notFound() {
|
|
6
6
|
return new Response(JSON.stringify({ error: "not found" }), {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as McpDefinition } from "../types-
|
|
2
|
-
import { t as MetricsRecorder } from "../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../types-CAFCH0yK.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "../base-D2d7lJY5.cjs";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-bDiUiJco.cjs";
|
|
4
4
|
//#region src/protocols/oauth-metadata.d.ts
|
|
5
5
|
type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { m as McpDefinition } from "../types-
|
|
2
|
-
import { t as MetricsRecorder } from "../base-
|
|
3
|
-
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-
|
|
1
|
+
import { m as McpDefinition } from "../types-CAFCH0yK.js";
|
|
2
|
+
import { t as MetricsRecorder } from "../base-CLO7XsxC.js";
|
|
3
|
+
import { n as ScheduleBackground, t as McpRuntimeOptions } from "../authorize-DUEaDXjU.js";
|
|
4
4
|
//#region src/protocols/oauth-metadata.d.ts
|
|
5
5
|
type OAuthProtectedResourceMetadataHandler = (request: Request, recorder?: MetricsRecorder, scheduleBackground?: ScheduleBackground) => Promise<Response>;
|
|
6
6
|
declare function createOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): OAuthProtectedResourceMetadataHandler;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as log, r as describeError } from "../logger-CpLgYbCG.js";
|
|
2
|
-
import { a as oauthConfigurationErrorResponse, f as JSON_HEADERS, i as normalizeHttpMethod, l as emitBeforeResponse, m as methodNotAllowed, p as finalizeWireResponse, r as getOAuthRuntime, s as resolveProtectedResource, t as evaluateCors, u as createNoopRecorder } from "../cors-
|
|
2
|
+
import { a as oauthConfigurationErrorResponse, f as JSON_HEADERS, i as normalizeHttpMethod, l as emitBeforeResponse, m as methodNotAllowed, p as finalizeWireResponse, r as getOAuthRuntime, s as resolveProtectedResource, t as evaluateCors, u as createNoopRecorder } from "../cors-tLp9UO0k.js";
|
|
3
3
|
//#region src/protocols/oauth-metadata.ts
|
|
4
4
|
function notFound() {
|
|
5
5
|
return new Response(JSON.stringify({ error: "not found" }), {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_logger = require("../../logger-C-Hdu57K.cjs");
|
|
3
|
-
const require_cors = require("../../cors-
|
|
3
|
+
const require_cors = require("../../cors-Dk0jvKYK.cjs");
|
|
4
4
|
const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
|
|
5
|
-
const require_mcp = require("../../mcp-
|
|
5
|
+
const require_mcp = require("../../mcp-BMNeCc_-.cjs");
|
|
6
6
|
const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
|
|
7
7
|
const require_forwarded = require("../../forwarded-B37IdmMX.cjs");
|
|
8
8
|
const require_paths = require("../../paths-OP318a6c.cjs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as McpDefinition } from "../../types-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CAFCH0yK.cjs";
|
|
2
2
|
//#region src/stacks/supabase/handler.d.ts
|
|
3
3
|
type SupabaseHandler = (request: Request) => Promise<Response>;
|
|
4
4
|
interface SupabaseHandlerOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as McpDefinition } from "../../types-
|
|
1
|
+
import { m as McpDefinition } from "../../types-CAFCH0yK.js";
|
|
2
2
|
//#region src/stacks/supabase/handler.d.ts
|
|
3
3
|
type SupabaseHandler = (request: Request) => Promise<Response>;
|
|
4
4
|
interface SupabaseHandlerOptions {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { s as trimTrailingSlash } from "../../logger-CpLgYbCG.js";
|
|
2
|
-
import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-
|
|
2
|
+
import { c as createRecorderForRuntime, o as assertResourcePathShape } from "../../cors-tLp9UO0k.js";
|
|
3
3
|
import { t as OAUTH_PROTECTED_RESOURCE_METADATA_PATH } from "../../metadata-path-CAkNcfyY.js";
|
|
4
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
4
|
+
import { t as createMcpProtocolHandler } from "../../mcp-BYSubCtv.js";
|
|
5
5
|
import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
|
|
6
6
|
import { t as applyForwardedOrigin } from "../../forwarded-BBXvFeh6.js";
|
|
7
7
|
import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
|