@lovable.dev/mcp-js 0.21.1-rc.0 → 0.21.1-rc.1

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.
Files changed (87) hide show
  1. package/dist/authorize-CumVyk7p.d.cts +27 -0
  2. package/dist/authorize-D6p4-9_D.d.ts +27 -0
  3. package/dist/base-CoIFvAmS.d.cts +26 -0
  4. package/dist/base-CoIFvAmS.d.ts +26 -0
  5. package/dist/cli/extract-manifest.cjs +116 -201
  6. package/dist/cli/extract-manifest.d.cts +1 -1
  7. package/dist/cli/extract-manifest.d.ts +1 -1
  8. package/dist/cli/extract-manifest.js +117 -156
  9. package/dist/content-D5LJAHyM.js +12 -0
  10. package/dist/content-NCYIGgOb.cjs +17 -0
  11. package/dist/context-BweeEcoA.cjs +56 -0
  12. package/dist/context-CIpPzN7P.js +51 -0
  13. package/dist/cors-B7CTXIHD.js +829 -0
  14. package/dist/cors-BebjKPrc.cjs +912 -0
  15. package/dist/forwarded--h4efJy-.js +43 -0
  16. package/dist/forwarded-Pi8Hs5Ps.cjs +48 -0
  17. package/dist/fs-errors-CWNzOV75.cjs +11 -0
  18. package/dist/fs-errors-PA2t1TIp.js +6 -0
  19. package/dist/index.cjs +129 -329
  20. package/dist/index.d.cts +26 -26
  21. package/dist/index.d.ts +26 -26
  22. package/dist/index.js +118 -177
  23. package/dist/{io-D4srzRKc.d.ts → io-CS4UL6_A.d.ts} +6 -4
  24. package/dist/io-CbbUbPY3.d.cts +15 -0
  25. package/dist/list-tools-CBCuS1Tv.cjs +57 -0
  26. package/dist/list-tools-CsWgiRy1.d.ts +8 -0
  27. package/dist/list-tools-CtZHOuPv.d.cts +8 -0
  28. package/dist/list-tools-D75RGtgs.js +46 -0
  29. package/dist/logger-2OXtfiIW.js +141 -0
  30. package/dist/logger-BqPOa_E1.cjs +194 -0
  31. package/dist/mcp-Cdj0AYst.cjs +123 -0
  32. package/dist/mcp-GngXbcqN.js +118 -0
  33. package/dist/metadata-path-CAkNcfyY.js +12 -0
  34. package/dist/metadata-path-zd7NSNoa.cjs +17 -0
  35. package/dist/package-7EUptuSJ.js +4 -0
  36. package/dist/package-BwCGVRcB.cjs +9 -0
  37. package/dist/paths-IS65L6TA.js +7 -0
  38. package/dist/paths-OP318a6c.cjs +18 -0
  39. package/dist/protocols/mcp/index.cjs +3 -750
  40. package/dist/protocols/mcp/index.d.cts +6 -7
  41. package/dist/protocols/mcp/index.d.ts +6 -7
  42. package/dist/protocols/mcp/index.js +2 -12
  43. package/dist/protocols/oauth-metadata.cjs +48 -539
  44. package/dist/protocols/oauth-metadata.d.cts +5 -6
  45. package/dist/protocols/oauth-metadata.d.ts +5 -6
  46. package/dist/protocols/oauth-metadata.js +52 -10
  47. package/dist/protocols/rest/index.cjs +5 -843
  48. package/dist/protocols/rest/index.d.cts +7 -10
  49. package/dist/protocols/rest/index.d.ts +7 -10
  50. package/dist/protocols/rest/index.js +3 -16
  51. package/dist/rest-CXH6-zv9.js +113 -0
  52. package/dist/rest-CyV8LHeB.cjs +118 -0
  53. package/dist/stacks/supabase/index.cjs +76 -1318
  54. package/dist/stacks/supabase/index.d.cts +29 -30
  55. package/dist/stacks/supabase/index.d.ts +29 -30
  56. package/dist/stacks/supabase/index.js +73 -89
  57. package/dist/stacks/supabase/vite.cjs +258 -287
  58. package/dist/stacks/supabase/vite.d.cts +24 -24
  59. package/dist/stacks/supabase/vite.d.ts +24 -24
  60. package/dist/stacks/supabase/vite.js +252 -252
  61. package/dist/stacks/tanstack/index.cjs +42 -1272
  62. package/dist/stacks/tanstack/index.d.cts +8 -9
  63. package/dist/stacks/tanstack/index.d.ts +8 -9
  64. package/dist/stacks/tanstack/index.js +36 -41
  65. package/dist/stacks/tanstack/vite.cjs +223 -312
  66. package/dist/stacks/tanstack/vite.d.cts +80 -81
  67. package/dist/stacks/tanstack/vite.d.ts +80 -81
  68. package/dist/stacks/tanstack/vite.js +216 -282
  69. package/dist/types-BYdYYTjk.d.cts +321 -0
  70. package/dist/types-BYdYYTjk.d.ts +321 -0
  71. package/package.json +71 -28
  72. package/dist/authorize-BMeXd_Sh.d.ts +0 -25
  73. package/dist/base-CM-KCpp6.d.ts +0 -28
  74. package/dist/chunk-4QNNVJBZ.js +0 -141
  75. package/dist/chunk-6DXGZZA4.js +0 -6
  76. package/dist/chunk-6QFZYYUV.js +0 -11
  77. package/dist/chunk-ACFNK34P.js +0 -114
  78. package/dist/chunk-BLY5L4KI.js +0 -79
  79. package/dist/chunk-H37EB22A.js +0 -125
  80. package/dist/chunk-L5ZOZKAL.js +0 -6
  81. package/dist/chunk-MA5H6PSF.js +0 -46
  82. package/dist/chunk-SJJDRA6X.js +0 -741
  83. package/dist/chunk-UQK5UO6C.js +0 -26
  84. package/dist/chunk-XQWJN6DC.js +0 -14
  85. package/dist/chunk-Y3ZFPEQH.js +0 -8
  86. package/dist/chunk-ZLWXDYOZ.js +0 -58
  87. package/dist/types-qqrmJ736.d.ts +0 -321
@@ -1,12 +1,9 @@
1
- import { M as McpRuntimeOptions } from '../../authorize-BMeXd_Sh.js';
2
- import { d as McpDefinition } from '../../types-qqrmJ736.js';
3
- import { M as MetricsRecorder } from '../../base-CM-KCpp6.js';
4
- import 'zod';
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-CoIFvAmS.cjs";
3
+ import { t as McpRuntimeOptions } from "../../authorize-CumVyk7p.cjs";
4
+ import { n as createListToolsHandler, t as RestListToolsHandler } from "../../list-tools-CtZHOuPv.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 { M as McpRuntimeOptions } from '../../authorize-BMeXd_Sh.js';
2
- import { d as McpDefinition } from '../../types-qqrmJ736.js';
3
- import { M as MetricsRecorder } from '../../base-CM-KCpp6.js';
4
- import 'zod';
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-CoIFvAmS.js";
3
+ import { t as McpRuntimeOptions } from "../../authorize-D6p4-9_D.js";
4
+ import { n as createListToolsHandler, t as RestListToolsHandler } from "../../list-tools-CsWgiRy1.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
- createInvokeToolHandler
3
- } from "../../chunk-4QNNVJBZ.js";
4
- import {
5
- createListToolsHandler
6
- } from "../../chunk-ZLWXDYOZ.js";
7
- import "../../chunk-6QFZYYUV.js";
8
- import "../../chunk-MA5H6PSF.js";
9
- import "../../chunk-SJJDRA6X.js";
10
- import "../../chunk-H37EB22A.js";
11
- import "../../chunk-6DXGZZA4.js";
12
- import "../../chunk-L5ZOZKAL.js";
13
- export {
14
- createInvokeToolHandler,
15
- createListToolsHandler
16
- };
1
+ import { n as createListToolsHandler } from "../../list-tools-D75RGtgs.js";
2
+ import { t as createInvokeToolHandler } from "../../rest-CXH6-zv9.js";
3
+ export { createInvokeToolHandler, createListToolsHandler };
@@ -0,0 +1,113 @@
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-B7CTXIHD.js";
3
+ import { t as extractTextContent } from "./content-D5LJAHyM.js";
4
+ import "./list-tools-D75RGtgs.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
+ if (request.method !== "POST") return methodNotAllowed("POST, OPTIONS");
24
+ const tool = mcp.tools.find((t) => t.name === toolName);
25
+ if (!tool) return new Response(JSON.stringify({ error: `unknown tool: ${safeReflectName(toolName)}` }), {
26
+ status: 404,
27
+ headers: JSON_HEADERS
28
+ });
29
+ let rawArgs = {};
30
+ const text = await request.text();
31
+ if (text) try {
32
+ rawArgs = JSON.parse(text);
33
+ } catch {
34
+ return new Response(JSON.stringify({ error: "invalid JSON body" }), {
35
+ status: 400,
36
+ headers: JSON_HEADERS
37
+ });
38
+ }
39
+ let args = rawArgs;
40
+ if (tool.inputSchema) try {
41
+ const parsed = await safeParseAsync(objectFromShape(tool.inputSchema), rawArgs);
42
+ if (!parsed.success) return new Response(JSON.stringify({
43
+ error: "validation failed",
44
+ details: getParseErrorMessage(parsed.error)
45
+ }), {
46
+ status: 400,
47
+ headers: JSON_HEADERS
48
+ });
49
+ args = parsed.data;
50
+ } catch {
51
+ return new Response(JSON.stringify({
52
+ error: "schema error",
53
+ tool: toolName
54
+ }), {
55
+ status: 500,
56
+ headers: JSON_HEADERS
57
+ });
58
+ }
59
+ else if (!isEmptyArgs(rawArgs)) return new Response(JSON.stringify({ error: "tool has no inputSchema; expected empty body" }), {
60
+ status: 400,
61
+ headers: JSON_HEADERS
62
+ });
63
+ let result;
64
+ const start = nowMs();
65
+ try {
66
+ result = await tool.handler(args, new ToolContext(authResult.auth));
67
+ } catch {
68
+ await recorder.emit({
69
+ tool: tool.name,
70
+ method: "tools/call",
71
+ outcome: "handler_error",
72
+ durationMs: nowMs() - start
73
+ });
74
+ return new Response(JSON.stringify({
75
+ error: "handler threw",
76
+ tool: toolName
77
+ }), {
78
+ status: 500,
79
+ headers: JSON_HEADERS
80
+ });
81
+ }
82
+ if (result == null) {
83
+ await recorder.emit({
84
+ tool: tool.name,
85
+ method: "tools/call",
86
+ outcome: "handler_error",
87
+ durationMs: nowMs() - start
88
+ });
89
+ return new Response(JSON.stringify({ error: `tool "${toolName}" returned no result` }), {
90
+ status: 500,
91
+ headers: JSON_HEADERS
92
+ });
93
+ }
94
+ await recorder.emit({
95
+ tool: tool.name,
96
+ method: "tools/call",
97
+ outcome: result.isError ? "tool_error" : "ok",
98
+ durationMs: nowMs() - start,
99
+ errorText: result.isError ? extractTextContent(result.content) : void 0
100
+ });
101
+ return Response.json({
102
+ content: result.content ?? [],
103
+ structuredContent: result.structuredContent,
104
+ isError: result.isError
105
+ });
106
+ };
107
+ return async (request, toolName, recorder = createNoopRecorder()) => {
108
+ if (request.method === "OPTIONS") return corsPreflightResponse("POST, OPTIONS");
109
+ return withCors(await handle(request, toolName, recorder));
110
+ };
111
+ }
112
+ //#endregion
113
+ export { createInvokeToolHandler as t };
@@ -0,0 +1,118 @@
1
+ const require_context = require("./context-BweeEcoA.cjs");
2
+ const require_cors = require("./cors-BebjKPrc.cjs");
3
+ const require_content = require("./content-NCYIGgOb.cjs");
4
+ require("./list-tools-CBCuS1Tv.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
+ if (request.method !== "POST") return require_cors.methodNotAllowed("POST, OPTIONS");
24
+ const tool = mcp.tools.find((t) => t.name === toolName);
25
+ if (!tool) return new Response(JSON.stringify({ error: `unknown tool: ${safeReflectName(toolName)}` }), {
26
+ status: 404,
27
+ headers: require_cors.JSON_HEADERS
28
+ });
29
+ let rawArgs = {};
30
+ const text = await request.text();
31
+ if (text) try {
32
+ rawArgs = JSON.parse(text);
33
+ } catch {
34
+ return new Response(JSON.stringify({ error: "invalid JSON body" }), {
35
+ status: 400,
36
+ headers: require_cors.JSON_HEADERS
37
+ });
38
+ }
39
+ let args = rawArgs;
40
+ if (tool.inputSchema) try {
41
+ const parsed = await (0, _modelcontextprotocol_sdk_server_zod_compat_js.safeParseAsync)((0, _modelcontextprotocol_sdk_server_zod_compat_js.objectFromShape)(tool.inputSchema), rawArgs);
42
+ if (!parsed.success) return new Response(JSON.stringify({
43
+ error: "validation failed",
44
+ details: (0, _modelcontextprotocol_sdk_server_zod_compat_js.getParseErrorMessage)(parsed.error)
45
+ }), {
46
+ status: 400,
47
+ headers: require_cors.JSON_HEADERS
48
+ });
49
+ args = parsed.data;
50
+ } catch {
51
+ return new Response(JSON.stringify({
52
+ error: "schema error",
53
+ tool: toolName
54
+ }), {
55
+ status: 500,
56
+ headers: require_cors.JSON_HEADERS
57
+ });
58
+ }
59
+ else if (!isEmptyArgs(rawArgs)) return new Response(JSON.stringify({ error: "tool has no inputSchema; expected empty body" }), {
60
+ status: 400,
61
+ headers: require_cors.JSON_HEADERS
62
+ });
63
+ let result;
64
+ const start = require_cors.nowMs();
65
+ try {
66
+ result = await tool.handler(args, new require_context.ToolContext(authResult.auth));
67
+ } catch {
68
+ await recorder.emit({
69
+ tool: tool.name,
70
+ method: "tools/call",
71
+ outcome: "handler_error",
72
+ durationMs: require_cors.nowMs() - start
73
+ });
74
+ return new Response(JSON.stringify({
75
+ error: "handler threw",
76
+ tool: toolName
77
+ }), {
78
+ status: 500,
79
+ headers: require_cors.JSON_HEADERS
80
+ });
81
+ }
82
+ if (result == null) {
83
+ await recorder.emit({
84
+ tool: tool.name,
85
+ method: "tools/call",
86
+ outcome: "handler_error",
87
+ durationMs: require_cors.nowMs() - start
88
+ });
89
+ return new Response(JSON.stringify({ error: `tool "${toolName}" returned no result` }), {
90
+ status: 500,
91
+ headers: require_cors.JSON_HEADERS
92
+ });
93
+ }
94
+ await recorder.emit({
95
+ tool: tool.name,
96
+ method: "tools/call",
97
+ outcome: result.isError ? "tool_error" : "ok",
98
+ durationMs: require_cors.nowMs() - start,
99
+ errorText: result.isError ? require_content.extractTextContent(result.content) : void 0
100
+ });
101
+ return Response.json({
102
+ content: result.content ?? [],
103
+ structuredContent: result.structuredContent,
104
+ isError: result.isError
105
+ });
106
+ };
107
+ return async (request, toolName, recorder = require_cors.createNoopRecorder()) => {
108
+ if (request.method === "OPTIONS") return require_cors.corsPreflightResponse("POST, OPTIONS");
109
+ return require_cors.withCors(await handle(request, toolName, recorder));
110
+ };
111
+ }
112
+ //#endregion
113
+ Object.defineProperty(exports, "createInvokeToolHandler", {
114
+ enumerable: true,
115
+ get: function() {
116
+ return createInvokeToolHandler;
117
+ }
118
+ });