@lovable.dev/mcp-js 0.22.1 → 0.22.2-rc.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/dist/authorize-CumVyk7p.d.cts +27 -0
- package/dist/authorize-D6p4-9_D.d.ts +27 -0
- package/dist/base-DCe0kP79.d.cts +29 -0
- package/dist/base-DCe0kP79.d.ts +29 -0
- package/dist/cli/extract-manifest.cjs +116 -201
- package/dist/cli/extract-manifest.d.cts +1 -1
- package/dist/cli/extract-manifest.d.ts +1 -1
- package/dist/cli/extract-manifest.js +117 -156
- package/dist/content-D5LJAHyM.js +12 -0
- package/dist/content-NCYIGgOb.cjs +17 -0
- package/dist/context-BweeEcoA.cjs +56 -0
- package/dist/context-CIpPzN7P.js +51 -0
- package/dist/cors-CSDhBjFd.cjs +913 -0
- package/dist/cors-rWp_tbLZ.js +830 -0
- package/dist/forwarded--h4efJy-.js +43 -0
- package/dist/forwarded-Pi8Hs5Ps.cjs +48 -0
- package/dist/fs-errors-CWNzOV75.cjs +11 -0
- package/dist/fs-errors-PA2t1TIp.js +6 -0
- package/dist/index.cjs +129 -329
- package/dist/index.d.cts +26 -26
- package/dist/index.d.ts +26 -26
- package/dist/index.js +118 -177
- package/dist/{io-D4srzRKc.d.ts → io-CfSPxeBN.d.ts} +6 -4
- package/dist/io-DPYvBqET.d.cts +15 -0
- package/dist/list-tools-B4TTPEl1.d.cts +8 -0
- package/dist/list-tools-CFUX-uo-.cjs +57 -0
- package/dist/list-tools-DVJrjtmH.js +46 -0
- package/dist/list-tools-bh6-eqZM.d.ts +8 -0
- package/dist/logger-2OXtfiIW.js +141 -0
- package/dist/logger-BqPOa_E1.cjs +194 -0
- package/dist/mcp-BNcpj8o7.cjs +128 -0
- package/dist/mcp-Bx3bJHzH.js +123 -0
- package/dist/metadata-path-CAkNcfyY.js +12 -0
- package/dist/metadata-path-zd7NSNoa.cjs +17 -0
- package/dist/package-CgwD4Ywz.js +4 -0
- package/dist/package-DzstF8Ih.cjs +9 -0
- package/dist/paths-IS65L6TA.js +7 -0
- package/dist/paths-OP318a6c.cjs +18 -0
- package/dist/protocols/mcp/index.cjs +3 -750
- package/dist/protocols/mcp/index.d.cts +6 -7
- package/dist/protocols/mcp/index.d.ts +6 -7
- package/dist/protocols/mcp/index.js +2 -12
- package/dist/protocols/oauth-metadata.cjs +48 -539
- package/dist/protocols/oauth-metadata.d.cts +5 -6
- package/dist/protocols/oauth-metadata.d.ts +5 -6
- package/dist/protocols/oauth-metadata.js +52 -10
- package/dist/protocols/rest/index.cjs +5 -843
- package/dist/protocols/rest/index.d.cts +7 -10
- package/dist/protocols/rest/index.d.ts +7 -10
- package/dist/protocols/rest/index.js +3 -16
- package/dist/rest-BRshnow2.js +117 -0
- package/dist/rest-C4ZEGSIV.cjs +122 -0
- package/dist/stacks/supabase/index.cjs +76 -1318
- package/dist/stacks/supabase/index.d.cts +29 -30
- package/dist/stacks/supabase/index.d.ts +29 -30
- package/dist/stacks/supabase/index.js +73 -89
- package/dist/stacks/supabase/vite.cjs +258 -287
- package/dist/stacks/supabase/vite.d.cts +24 -24
- package/dist/stacks/supabase/vite.d.ts +24 -24
- package/dist/stacks/supabase/vite.js +252 -252
- package/dist/stacks/tanstack/index.cjs +42 -1272
- package/dist/stacks/tanstack/index.d.cts +8 -9
- package/dist/stacks/tanstack/index.d.ts +8 -9
- package/dist/stacks/tanstack/index.js +36 -41
- package/dist/stacks/tanstack/vite.cjs +223 -312
- package/dist/stacks/tanstack/vite.d.cts +80 -81
- package/dist/stacks/tanstack/vite.d.ts +80 -81
- package/dist/stacks/tanstack/vite.js +216 -282
- package/dist/types-BYdYYTjk.d.cts +321 -0
- package/dist/types-BYdYYTjk.d.ts +321 -0
- package/package.json +4 -4
- package/dist/authorize-BMeXd_Sh.d.ts +0 -25
- package/dist/base-CM-KCpp6.d.ts +0 -28
- package/dist/chunk-5HVSJCKE.js +0 -114
- package/dist/chunk-6DXGZZA4.js +0 -6
- package/dist/chunk-6QFZYYUV.js +0 -11
- package/dist/chunk-6SZOFKGH.js +0 -58
- package/dist/chunk-H37EB22A.js +0 -125
- package/dist/chunk-IFDWUM7L.js +0 -741
- package/dist/chunk-IXZIFYO6.js +0 -79
- package/dist/chunk-MA5H6PSF.js +0 -46
- package/dist/chunk-TJN33K5U.js +0 -141
- package/dist/chunk-UQK5UO6C.js +0 -26
- package/dist/chunk-XQWJN6DC.js +0 -14
- package/dist/chunk-Y3ZFPEQH.js +0 -8
- package/dist/chunk-ZQXSWTPU.js +0 -6
- package/dist/types-qqrmJ736.d.ts +0 -321
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
type RestListToolsHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
7
|
-
declare function createListToolsHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestListToolsHandler;
|
|
8
|
-
|
|
1
|
+
import { c as McpDefinition } from "../../types-BYdYYTjk.cjs";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-DCe0kP79.cjs";
|
|
3
|
+
import { t as McpRuntimeOptions } from "../../authorize-CumVyk7p.cjs";
|
|
4
|
+
import { n as createListToolsHandler, t as RestListToolsHandler } from "../../list-tools-B4TTPEl1.cjs";
|
|
5
|
+
//#region src/protocols/rest/invoke-tool.d.ts
|
|
9
6
|
type RestInvokeToolHandler = (request: Request, toolName: string, recorder?: MetricsRecorder) => Promise<Response>;
|
|
10
7
|
declare function createInvokeToolHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestInvokeToolHandler;
|
|
11
|
-
|
|
12
|
-
export { type RestInvokeToolHandler, type RestListToolsHandler, createInvokeToolHandler, createListToolsHandler };
|
|
8
|
+
//#endregion
|
|
9
|
+
export { type RestInvokeToolHandler, type RestListToolsHandler, createInvokeToolHandler, createListToolsHandler };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
type RestListToolsHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
7
|
-
declare function createListToolsHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestListToolsHandler;
|
|
8
|
-
|
|
1
|
+
import { c as McpDefinition } from "../../types-BYdYYTjk.js";
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-DCe0kP79.js";
|
|
3
|
+
import { t as McpRuntimeOptions } from "../../authorize-D6p4-9_D.js";
|
|
4
|
+
import { n as createListToolsHandler, t as RestListToolsHandler } from "../../list-tools-bh6-eqZM.js";
|
|
5
|
+
//#region src/protocols/rest/invoke-tool.d.ts
|
|
9
6
|
type RestInvokeToolHandler = (request: Request, toolName: string, recorder?: MetricsRecorder) => Promise<Response>;
|
|
10
7
|
declare function createInvokeToolHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestInvokeToolHandler;
|
|
11
|
-
|
|
12
|
-
export { type RestInvokeToolHandler, type RestListToolsHandler, createInvokeToolHandler, createListToolsHandler };
|
|
8
|
+
//#endregion
|
|
9
|
+
export { type RestInvokeToolHandler, type RestListToolsHandler, createInvokeToolHandler, createListToolsHandler };
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
createListToolsHandler
|
|
6
|
-
} from "../../chunk-6SZOFKGH.js";
|
|
7
|
-
import "../../chunk-6QFZYYUV.js";
|
|
8
|
-
import "../../chunk-MA5H6PSF.js";
|
|
9
|
-
import "../../chunk-IFDWUM7L.js";
|
|
10
|
-
import "../../chunk-H37EB22A.js";
|
|
11
|
-
import "../../chunk-6DXGZZA4.js";
|
|
12
|
-
import "../../chunk-ZQXSWTPU.js";
|
|
13
|
-
export {
|
|
14
|
-
createInvokeToolHandler,
|
|
15
|
-
createListToolsHandler
|
|
16
|
-
};
|
|
1
|
+
import { n as createListToolsHandler } from "../../list-tools-DVJrjtmH.js";
|
|
2
|
+
import { t as createInvokeToolHandler } from "../../rest-BRshnow2.js";
|
|
3
|
+
export { createInvokeToolHandler, createListToolsHandler };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { t as ToolContext } from "./context-CIpPzN7P.js";
|
|
2
|
+
import { d as nowMs, f as JSON_HEADERS, i as createRequestAuthorizer, m as methodNotAllowed, n as withCors, r as assertRestResourceBinding, t as corsPreflightResponse, u as createNoopRecorder } from "./cors-rWp_tbLZ.js";
|
|
3
|
+
import { t as extractTextContent } from "./content-D5LJAHyM.js";
|
|
4
|
+
import "./list-tools-DVJrjtmH.js";
|
|
5
|
+
import { getParseErrorMessage, objectFromShape, safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
6
|
+
//#region src/protocols/rest/invoke-tool.ts
|
|
7
|
+
const MAX_REFLECTED_TOOL_NAME = 256;
|
|
8
|
+
function safeReflectName(name) {
|
|
9
|
+
const text = String(name);
|
|
10
|
+
return text.length > MAX_REFLECTED_TOOL_NAME ? `${text.slice(0, MAX_REFLECTED_TOOL_NAME)}…` : text;
|
|
11
|
+
}
|
|
12
|
+
function isEmptyArgs(value) {
|
|
13
|
+
if (value == null) return true;
|
|
14
|
+
if (typeof value !== "object" || Array.isArray(value)) return false;
|
|
15
|
+
return Object.keys(value).length === 0;
|
|
16
|
+
}
|
|
17
|
+
function createInvokeToolHandler(mcp, options = {}) {
|
|
18
|
+
assertRestResourceBinding(mcp, options);
|
|
19
|
+
const authorizer = createRequestAuthorizer(mcp, options);
|
|
20
|
+
const handle = async (request, toolName, recorder) => {
|
|
21
|
+
const authResult = await authorizer.authorize(request, recorder);
|
|
22
|
+
if (!authResult.ok) return authResult.response;
|
|
23
|
+
const endUserId = authResult.auth?.principal.sub;
|
|
24
|
+
if (request.method !== "POST") return methodNotAllowed("POST, OPTIONS");
|
|
25
|
+
const tool = mcp.tools.find((t) => t.name === toolName);
|
|
26
|
+
if (!tool) return new Response(JSON.stringify({ error: `unknown tool: ${safeReflectName(toolName)}` }), {
|
|
27
|
+
status: 404,
|
|
28
|
+
headers: JSON_HEADERS
|
|
29
|
+
});
|
|
30
|
+
let rawArgs = {};
|
|
31
|
+
const text = await request.text();
|
|
32
|
+
if (text) try {
|
|
33
|
+
rawArgs = JSON.parse(text);
|
|
34
|
+
} catch {
|
|
35
|
+
return new Response(JSON.stringify({ error: "invalid JSON body" }), {
|
|
36
|
+
status: 400,
|
|
37
|
+
headers: JSON_HEADERS
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
let args = rawArgs;
|
|
41
|
+
if (tool.inputSchema) try {
|
|
42
|
+
const parsed = await safeParseAsync(objectFromShape(tool.inputSchema), rawArgs);
|
|
43
|
+
if (!parsed.success) return new Response(JSON.stringify({
|
|
44
|
+
error: "validation failed",
|
|
45
|
+
details: getParseErrorMessage(parsed.error)
|
|
46
|
+
}), {
|
|
47
|
+
status: 400,
|
|
48
|
+
headers: JSON_HEADERS
|
|
49
|
+
});
|
|
50
|
+
args = parsed.data;
|
|
51
|
+
} catch {
|
|
52
|
+
return new Response(JSON.stringify({
|
|
53
|
+
error: "schema error",
|
|
54
|
+
tool: toolName
|
|
55
|
+
}), {
|
|
56
|
+
status: 500,
|
|
57
|
+
headers: JSON_HEADERS
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else if (!isEmptyArgs(rawArgs)) return new Response(JSON.stringify({ error: "tool has no inputSchema; expected empty body" }), {
|
|
61
|
+
status: 400,
|
|
62
|
+
headers: JSON_HEADERS
|
|
63
|
+
});
|
|
64
|
+
let result;
|
|
65
|
+
const start = nowMs();
|
|
66
|
+
try {
|
|
67
|
+
result = await tool.handler(args, new ToolContext(authResult.auth));
|
|
68
|
+
} catch {
|
|
69
|
+
await recorder.emit({
|
|
70
|
+
tool: tool.name,
|
|
71
|
+
method: "tools/call",
|
|
72
|
+
outcome: "handler_error",
|
|
73
|
+
durationMs: nowMs() - start,
|
|
74
|
+
endUserId
|
|
75
|
+
});
|
|
76
|
+
return new Response(JSON.stringify({
|
|
77
|
+
error: "handler threw",
|
|
78
|
+
tool: toolName
|
|
79
|
+
}), {
|
|
80
|
+
status: 500,
|
|
81
|
+
headers: JSON_HEADERS
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (result == null) {
|
|
85
|
+
await recorder.emit({
|
|
86
|
+
tool: tool.name,
|
|
87
|
+
method: "tools/call",
|
|
88
|
+
outcome: "handler_error",
|
|
89
|
+
durationMs: nowMs() - start,
|
|
90
|
+
endUserId
|
|
91
|
+
});
|
|
92
|
+
return new Response(JSON.stringify({ error: `tool "${toolName}" returned no result` }), {
|
|
93
|
+
status: 500,
|
|
94
|
+
headers: JSON_HEADERS
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
await recorder.emit({
|
|
98
|
+
tool: tool.name,
|
|
99
|
+
method: "tools/call",
|
|
100
|
+
outcome: result.isError ? "tool_error" : "ok",
|
|
101
|
+
durationMs: nowMs() - start,
|
|
102
|
+
errorText: result.isError ? extractTextContent(result.content) : void 0,
|
|
103
|
+
endUserId
|
|
104
|
+
});
|
|
105
|
+
return Response.json({
|
|
106
|
+
content: result.content ?? [],
|
|
107
|
+
structuredContent: result.structuredContent,
|
|
108
|
+
isError: result.isError
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return async (request, toolName, recorder = createNoopRecorder()) => {
|
|
112
|
+
if (request.method === "OPTIONS") return corsPreflightResponse("POST, OPTIONS");
|
|
113
|
+
return withCors(await handle(request, toolName, recorder));
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { createInvokeToolHandler as t };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const require_context = require("./context-BweeEcoA.cjs");
|
|
2
|
+
const require_cors = require("./cors-CSDhBjFd.cjs");
|
|
3
|
+
const require_content = require("./content-NCYIGgOb.cjs");
|
|
4
|
+
require("./list-tools-CFUX-uo-.cjs");
|
|
5
|
+
let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
|
|
6
|
+
//#region src/protocols/rest/invoke-tool.ts
|
|
7
|
+
const MAX_REFLECTED_TOOL_NAME = 256;
|
|
8
|
+
function safeReflectName(name) {
|
|
9
|
+
const text = String(name);
|
|
10
|
+
return text.length > MAX_REFLECTED_TOOL_NAME ? `${text.slice(0, MAX_REFLECTED_TOOL_NAME)}…` : text;
|
|
11
|
+
}
|
|
12
|
+
function isEmptyArgs(value) {
|
|
13
|
+
if (value == null) return true;
|
|
14
|
+
if (typeof value !== "object" || Array.isArray(value)) return false;
|
|
15
|
+
return Object.keys(value).length === 0;
|
|
16
|
+
}
|
|
17
|
+
function createInvokeToolHandler(mcp, options = {}) {
|
|
18
|
+
require_cors.assertRestResourceBinding(mcp, options);
|
|
19
|
+
const authorizer = require_cors.createRequestAuthorizer(mcp, options);
|
|
20
|
+
const handle = async (request, toolName, recorder) => {
|
|
21
|
+
const authResult = await authorizer.authorize(request, recorder);
|
|
22
|
+
if (!authResult.ok) return authResult.response;
|
|
23
|
+
const endUserId = authResult.auth?.principal.sub;
|
|
24
|
+
if (request.method !== "POST") return require_cors.methodNotAllowed("POST, OPTIONS");
|
|
25
|
+
const tool = mcp.tools.find((t) => t.name === toolName);
|
|
26
|
+
if (!tool) return new Response(JSON.stringify({ error: `unknown tool: ${safeReflectName(toolName)}` }), {
|
|
27
|
+
status: 404,
|
|
28
|
+
headers: require_cors.JSON_HEADERS
|
|
29
|
+
});
|
|
30
|
+
let rawArgs = {};
|
|
31
|
+
const text = await request.text();
|
|
32
|
+
if (text) try {
|
|
33
|
+
rawArgs = JSON.parse(text);
|
|
34
|
+
} catch {
|
|
35
|
+
return new Response(JSON.stringify({ error: "invalid JSON body" }), {
|
|
36
|
+
status: 400,
|
|
37
|
+
headers: require_cors.JSON_HEADERS
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
let args = rawArgs;
|
|
41
|
+
if (tool.inputSchema) try {
|
|
42
|
+
const parsed = await (0, _modelcontextprotocol_sdk_server_zod_compat_js.safeParseAsync)((0, _modelcontextprotocol_sdk_server_zod_compat_js.objectFromShape)(tool.inputSchema), rawArgs);
|
|
43
|
+
if (!parsed.success) return new Response(JSON.stringify({
|
|
44
|
+
error: "validation failed",
|
|
45
|
+
details: (0, _modelcontextprotocol_sdk_server_zod_compat_js.getParseErrorMessage)(parsed.error)
|
|
46
|
+
}), {
|
|
47
|
+
status: 400,
|
|
48
|
+
headers: require_cors.JSON_HEADERS
|
|
49
|
+
});
|
|
50
|
+
args = parsed.data;
|
|
51
|
+
} catch {
|
|
52
|
+
return new Response(JSON.stringify({
|
|
53
|
+
error: "schema error",
|
|
54
|
+
tool: toolName
|
|
55
|
+
}), {
|
|
56
|
+
status: 500,
|
|
57
|
+
headers: require_cors.JSON_HEADERS
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else if (!isEmptyArgs(rawArgs)) return new Response(JSON.stringify({ error: "tool has no inputSchema; expected empty body" }), {
|
|
61
|
+
status: 400,
|
|
62
|
+
headers: require_cors.JSON_HEADERS
|
|
63
|
+
});
|
|
64
|
+
let result;
|
|
65
|
+
const start = require_cors.nowMs();
|
|
66
|
+
try {
|
|
67
|
+
result = await tool.handler(args, new require_context.ToolContext(authResult.auth));
|
|
68
|
+
} catch {
|
|
69
|
+
await recorder.emit({
|
|
70
|
+
tool: tool.name,
|
|
71
|
+
method: "tools/call",
|
|
72
|
+
outcome: "handler_error",
|
|
73
|
+
durationMs: require_cors.nowMs() - start,
|
|
74
|
+
endUserId
|
|
75
|
+
});
|
|
76
|
+
return new Response(JSON.stringify({
|
|
77
|
+
error: "handler threw",
|
|
78
|
+
tool: toolName
|
|
79
|
+
}), {
|
|
80
|
+
status: 500,
|
|
81
|
+
headers: require_cors.JSON_HEADERS
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (result == null) {
|
|
85
|
+
await recorder.emit({
|
|
86
|
+
tool: tool.name,
|
|
87
|
+
method: "tools/call",
|
|
88
|
+
outcome: "handler_error",
|
|
89
|
+
durationMs: require_cors.nowMs() - start,
|
|
90
|
+
endUserId
|
|
91
|
+
});
|
|
92
|
+
return new Response(JSON.stringify({ error: `tool "${toolName}" returned no result` }), {
|
|
93
|
+
status: 500,
|
|
94
|
+
headers: require_cors.JSON_HEADERS
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
await recorder.emit({
|
|
98
|
+
tool: tool.name,
|
|
99
|
+
method: "tools/call",
|
|
100
|
+
outcome: result.isError ? "tool_error" : "ok",
|
|
101
|
+
durationMs: require_cors.nowMs() - start,
|
|
102
|
+
errorText: result.isError ? require_content.extractTextContent(result.content) : void 0,
|
|
103
|
+
endUserId
|
|
104
|
+
});
|
|
105
|
+
return Response.json({
|
|
106
|
+
content: result.content ?? [],
|
|
107
|
+
structuredContent: result.structuredContent,
|
|
108
|
+
isError: result.isError
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return async (request, toolName, recorder = require_cors.createNoopRecorder()) => {
|
|
112
|
+
if (request.method === "OPTIONS") return require_cors.corsPreflightResponse("POST, OPTIONS");
|
|
113
|
+
return require_cors.withCors(await handle(request, toolName, recorder));
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
Object.defineProperty(exports, "createInvokeToolHandler", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function() {
|
|
120
|
+
return createInvokeToolHandler;
|
|
121
|
+
}
|
|
122
|
+
});
|