@lovable.dev/mcp-js 0.21.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 (86) 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-CFy5vZ5Z.d.ts → base-CoIFvAmS.d.cts} +15 -14
  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 -740
  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 -839
  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 -1302
  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 -1256
  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/chunk-6DXGZZA4.js +0 -6
  74. package/dist/chunk-6QFZYYUV.js +0 -11
  75. package/dist/chunk-CI7JYLV3.js +0 -104
  76. package/dist/chunk-E3Q3FRKQ.js +0 -6
  77. package/dist/chunk-ENJDNFEB.js +0 -79
  78. package/dist/chunk-H37EB22A.js +0 -125
  79. package/dist/chunk-LFXK3FNF.js +0 -58
  80. package/dist/chunk-MA5H6PSF.js +0 -46
  81. package/dist/chunk-QPKPYDPB.js +0 -137
  82. package/dist/chunk-UQK5UO6C.js +0 -26
  83. package/dist/chunk-XQWJN6DC.js +0 -14
  84. package/dist/chunk-Y3ZFPEQH.js +0 -8
  85. package/dist/chunk-YLU2JTHL.js +0 -739
  86. package/dist/types-qqrmJ736.d.ts +0 -321
@@ -1,137 +0,0 @@
1
- import {
2
- extractTextContent
3
- } from "./chunk-6QFZYYUV.js";
4
- import {
5
- ToolContext
6
- } from "./chunk-MA5H6PSF.js";
7
- import {
8
- JSON_HEADERS,
9
- assertRestResourceBinding,
10
- corsPreflightResponse,
11
- createNoopRecorder,
12
- createRequestAuthorizer,
13
- methodNotAllowed,
14
- nowMs,
15
- withCors
16
- } from "./chunk-YLU2JTHL.js";
17
-
18
- // src/protocols/rest/invoke-tool.ts
19
- import { getParseErrorMessage, objectFromShape, safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
20
- var MAX_REFLECTED_TOOL_NAME = 256;
21
- function safeReflectName(name) {
22
- const text = String(name);
23
- return text.length > MAX_REFLECTED_TOOL_NAME ? `${text.slice(0, MAX_REFLECTED_TOOL_NAME)}\u2026` : text;
24
- }
25
- function isEmptyArgs(value) {
26
- if (value == null)
27
- return true;
28
- if (typeof value !== "object" || Array.isArray(value))
29
- return false;
30
- return Object.keys(value).length === 0;
31
- }
32
- function createInvokeToolHandler(mcp, options = {}) {
33
- assertRestResourceBinding(mcp, options);
34
- const authorizer = createRequestAuthorizer(mcp, options);
35
- const handle = async (request, toolName, recorder) => {
36
- const authResult = await authorizer.authorize(request, recorder);
37
- if (!authResult.ok)
38
- return authResult.response;
39
- if (request.method !== "POST")
40
- return methodNotAllowed("POST, OPTIONS");
41
- const tool = mcp.tools.find((t) => t.name === toolName);
42
- if (!tool) {
43
- return new Response(JSON.stringify({ error: `unknown tool: ${safeReflectName(toolName)}` }), {
44
- status: 404,
45
- headers: JSON_HEADERS
46
- });
47
- }
48
- let rawArgs = {};
49
- const text = await request.text();
50
- if (text) {
51
- try {
52
- rawArgs = JSON.parse(text);
53
- } catch {
54
- return new Response(JSON.stringify({ error: "invalid JSON body" }), {
55
- status: 400,
56
- headers: JSON_HEADERS
57
- });
58
- }
59
- }
60
- let args = rawArgs;
61
- if (tool.inputSchema) {
62
- try {
63
- const schema = objectFromShape(tool.inputSchema);
64
- const parsed = await safeParseAsync(schema, rawArgs);
65
- if (!parsed.success) {
66
- return new Response(
67
- JSON.stringify({
68
- error: "validation failed",
69
- details: getParseErrorMessage(parsed.error)
70
- }),
71
- { status: 400, headers: JSON_HEADERS }
72
- );
73
- }
74
- args = parsed.data;
75
- } catch {
76
- return new Response(JSON.stringify({ error: "schema error", tool: toolName }), {
77
- status: 500,
78
- headers: JSON_HEADERS
79
- });
80
- }
81
- } else if (!isEmptyArgs(rawArgs)) {
82
- return new Response(JSON.stringify({ error: "tool has no inputSchema; expected empty body" }), {
83
- status: 400,
84
- headers: JSON_HEADERS
85
- });
86
- }
87
- let result;
88
- const start = nowMs();
89
- try {
90
- result = await tool.handler(args, new ToolContext(authResult.auth));
91
- } catch {
92
- await recorder.emit({
93
- tool: tool.name,
94
- method: "tools/call",
95
- outcome: "handler_error",
96
- durationMs: nowMs() - start
97
- });
98
- return new Response(JSON.stringify({ error: "handler threw", tool: toolName }), {
99
- status: 500,
100
- headers: JSON_HEADERS
101
- });
102
- }
103
- if (result == null) {
104
- await recorder.emit({
105
- tool: tool.name,
106
- method: "tools/call",
107
- outcome: "handler_error",
108
- durationMs: nowMs() - start
109
- });
110
- return new Response(JSON.stringify({ error: `tool "${toolName}" returned no result` }), {
111
- status: 500,
112
- headers: JSON_HEADERS
113
- });
114
- }
115
- await recorder.emit({
116
- tool: tool.name,
117
- method: "tools/call",
118
- outcome: result.isError ? "tool_error" : "ok",
119
- durationMs: nowMs() - start,
120
- errorText: result.isError ? extractTextContent(result.content) : void 0
121
- });
122
- return Response.json({
123
- content: result.content ?? [],
124
- structuredContent: result.structuredContent,
125
- isError: result.isError
126
- });
127
- };
128
- return async (request, toolName, recorder = createNoopRecorder()) => {
129
- if (request.method === "OPTIONS")
130
- return corsPreflightResponse("POST, OPTIONS");
131
- return withCors(await handle(request, toolName, recorder));
132
- };
133
- }
134
-
135
- export {
136
- createInvokeToolHandler
137
- };
@@ -1,26 +0,0 @@
1
- // src/core/forwarded.ts
2
- function applyForwardedOrigin(request, options) {
3
- const proto = options.trustForwardedProto ? firstForwardedValue(request, "x-forwarded-proto") : void 0;
4
- const host = options.trustForwardedHost ? firstForwardedValue(request, "x-forwarded-host") : void 0;
5
- if (proto === void 0 && host === void 0)
6
- return request;
7
- const url = new URL(request.url);
8
- let changed = false;
9
- if (proto !== void 0 && `${proto}:` !== url.protocol) {
10
- url.protocol = `${proto}:`;
11
- changed = true;
12
- }
13
- if (host !== void 0 && host !== url.host) {
14
- url.host = host;
15
- changed = true;
16
- }
17
- return changed ? new Request(url.href, request) : request;
18
- }
19
- function firstForwardedValue(request, header) {
20
- const value = request.headers.get(header)?.split(",")[0]?.trim();
21
- return value ? value : void 0;
22
- }
23
-
24
- export {
25
- applyForwardedOrigin
26
- };
@@ -1,14 +0,0 @@
1
- // src/stacks/supabase/paths.ts
2
- var FUNCTIONS_MOUNT_PREFIX = "/functions/v1/";
3
- function assertFunctionName(value, label = "functionName") {
4
- if (!/^[a-zA-Z0-9_-]+$/.test(value)) {
5
- throw new Error(
6
- `@lovable.dev/mcp-js: ${label} must be a single path segment matching [A-Za-z0-9_-], got ${JSON.stringify(value)}`
7
- );
8
- }
9
- }
10
-
11
- export {
12
- FUNCTIONS_MOUNT_PREFIX,
13
- assertFunctionName
14
- };
@@ -1,8 +0,0 @@
1
- // src/core/fs-errors.ts
2
- function isFileMissing(err) {
3
- return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
4
- }
5
-
6
- export {
7
- isFileMissing
8
- };