@lovable.dev/mcp-js 0.29.0-rc.1 → 0.29.0-rc.2
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.internal.md +22 -31
- package/README.md +23 -13
- package/dist/{authorize-BjNE3LPr.d.ts → authorize-Bpz8oxjF.d.ts} +2 -5
- package/dist/{authorize-BzZFS0zi.d.cts → authorize-Cqr7Jps0.d.cts} +2 -5
- package/dist/cli/extract-manifest.cjs +25 -3
- package/dist/cli/extract-manifest.js +24 -2
- package/dist/{cors-BDTQQJE2.js → cors-C_VffY86.js} +15 -21
- package/dist/{cors-BRv5KXKQ.cjs → cors-DNzLB6qa.cjs} +14 -26
- package/dist/{errors-DSe96Ffd.js → errors-Bwd1L0Rf.js} +23 -8
- package/dist/{errors-CN6Da8iz.cjs → errors-Cr95rSkB.cjs} +23 -8
- 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-BYUyNFdn.d.ts → io-Bh_WpbxU.d.cts} +1 -1
- package/dist/{io-B_YLNWDL.d.cts → io-DrHivYt0.d.ts} +1 -1
- package/dist/mcp-Bl7pQYdv.js +346 -0
- package/dist/mcp-CRdT2Fai.cjs +351 -0
- package/dist/{package-BI5r4uGM.js → package-CYA-5C24.js} +1 -1
- package/dist/{package-ClCIqol1.cjs → package-DNSwCau1.cjs} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.d.cts +36 -3
- package/dist/protocols/mcp/index.d.ts +36 -3
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +1 -1
- package/dist/protocols/oauth-metadata.d.cts +2 -2
- package/dist/protocols/oauth-metadata.d.ts +2 -2
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/stacks/supabase/index.cjs +6 -35
- package/dist/stacks/supabase/index.d.cts +1 -4
- package/dist/stacks/supabase/index.d.ts +1 -4
- package/dist/stacks/supabase/index.js +6 -35
- package/dist/stacks/supabase/vite.cjs +1 -1
- package/dist/stacks/supabase/vite.d.cts +1 -1
- package/dist/stacks/supabase/vite.d.ts +1 -1
- package/dist/stacks/supabase/vite.js +1 -1
- package/dist/stacks/tanstack/index.cjs +2 -23
- package/dist/stacks/tanstack/index.d.cts +3 -20
- package/dist/stacks/tanstack/index.d.ts +3 -20
- package/dist/stacks/tanstack/index.js +3 -22
- package/dist/stacks/tanstack/vite.cjs +5 -33
- package/dist/stacks/tanstack/vite.d.cts +5 -28
- package/dist/stacks/tanstack/vite.d.ts +5 -28
- package/dist/stacks/tanstack/vite.js +5 -33
- package/dist/{types-D1cgsnPu.d.cts → types-DnGEKnvI.d.cts} +43 -20
- package/dist/{types-D1cgsnPu.d.ts → types-DnGEKnvI.d.ts} +43 -20
- package/package.json +4 -11
- package/dist/base-C8osWdMU.d.cts +0 -35
- package/dist/base-C8osWdMU.d.ts +0 -35
- package/dist/gate-CAJSRt_t.cjs +0 -26
- package/dist/gate-uCVrbDBb.js +0 -21
- package/dist/list-tools-C1OiTDR9.js +0 -37
- package/dist/list-tools-C3AoI2Zw.d.cts +0 -8
- package/dist/list-tools-DES10avA.cjs +0 -48
- package/dist/list-tools-DXqSPvNY.d.ts +0 -8
- package/dist/mcp-C9B7o75m.cjs +0 -345
- package/dist/mcp-HDkUr85V.js +0 -340
- package/dist/protocols/rest/index.cjs +0 -5
- package/dist/protocols/rest/index.d.cts +0 -9
- package/dist/protocols/rest/index.d.ts +0 -9
- package/dist/protocols/rest/index.js +0 -3
- package/dist/rest-BBdfHMGh.cjs +0 -134
- package/dist/rest-Cr7NhxL3.js +0 -129
- package/dist/tool-result-CK6hXO43.cjs +0 -89
- package/dist/tool-result-DfCk445b.js +0 -78
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { s as trimTrailingSlash } from "../../logger-Ctv5xUSD.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as assertResourcePathShape, s as createRecorderForRuntime } from "../../cors-C_VffY86.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-Bl7pQYdv.js";
|
|
5
5
|
import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
|
|
6
|
-
import { n as createListToolsHandler } from "../../list-tools-C1OiTDR9.js";
|
|
7
|
-
import { t as createInvokeToolHandler } from "../../rest-Cr7NhxL3.js";
|
|
8
6
|
import { t as applyForwardedOrigin } from "../../forwarded-B3EBjHnA.js";
|
|
9
7
|
import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
|
|
10
8
|
//#region src/stacks/supabase/handler.ts
|
|
@@ -14,24 +12,8 @@ function deriveResourcePath(options) {
|
|
|
14
12
|
assertFunctionName(options.functionName);
|
|
15
13
|
return `${FUNCTIONS_MOUNT_PREFIX}${options.functionName}`;
|
|
16
14
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
if (path.endsWith("/.well-known/oauth-protected-resource")) return { kind: "metadata" };
|
|
20
|
-
if (path.endsWith("/.mcp/list-tools")) return { kind: "list-tools" };
|
|
21
|
-
const invokeMatch = /\/\.mcp\/invoke-tool\/([^/]+)$/.exec(path);
|
|
22
|
-
if (invokeMatch) {
|
|
23
|
-
let toolName;
|
|
24
|
-
try {
|
|
25
|
-
toolName = decodeURIComponent(invokeMatch[1]);
|
|
26
|
-
} catch {
|
|
27
|
-
return { kind: "mcp" };
|
|
28
|
-
}
|
|
29
|
-
return {
|
|
30
|
-
kind: "invoke-tool",
|
|
31
|
-
toolName
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
return { kind: "mcp" };
|
|
15
|
+
function isMetadataPath(pathname) {
|
|
16
|
+
return (pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname).endsWith(OAUTH_PROTECTED_RESOURCE_METADATA_PATH);
|
|
35
17
|
}
|
|
36
18
|
/**
|
|
37
19
|
* Build a single Web-Standard handler that serves the full MCP surface from
|
|
@@ -40,12 +22,9 @@ function dispatchFor(pathname) {
|
|
|
40
22
|
* | Suffix | Target |
|
|
41
23
|
* | --- | --- |
|
|
42
24
|
* | `/.well-known/oauth-protected-resource` | RFC 9728 metadata |
|
|
43
|
-
* | `/.mcp/list-tools` | REST tool catalog |
|
|
44
|
-
* | `/.mcp/invoke-tool/<tool>` | REST tool dispatcher |
|
|
45
25
|
* | (anything else) | MCP streamable-HTTP protocol |
|
|
46
26
|
*
|
|
47
27
|
* Pass the handler to `Deno.serve(...)` in the emitted function entry.
|
|
48
|
-
* The same OAuth bearer gate protects every dispatch target.
|
|
49
28
|
*/
|
|
50
29
|
function createSupabaseHandler(mcp, options = {}) {
|
|
51
30
|
const resourcePath = deriveResourcePath(options);
|
|
@@ -61,19 +40,11 @@ function createSupabaseHandler(mcp, options = {}) {
|
|
|
61
40
|
trustForwardedProto: true
|
|
62
41
|
};
|
|
63
42
|
const mcpHandler = createMcpProtocolHandler(mcp, runtimeOptions);
|
|
64
|
-
const listToolsHandler = createListToolsHandler(mcp, runtimeOptions);
|
|
65
|
-
const invokeToolHandler = createInvokeToolHandler(mcp, runtimeOptions);
|
|
66
43
|
const metadataHandler = createOAuthProtectedResourceMetadataHandler(mcp, runtimeOptions);
|
|
67
44
|
return async (request) => {
|
|
68
45
|
const req = applyForwardedOrigin(request, runtimeOptions);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
switch (target.kind) {
|
|
72
|
-
case "metadata": return metadataHandler(req);
|
|
73
|
-
case "list-tools": return listToolsHandler(req, recorder);
|
|
74
|
-
case "invoke-tool": return invokeToolHandler(req, target.toolName, recorder);
|
|
75
|
-
case "mcp": return mcpHandler(req, recorder);
|
|
76
|
-
}
|
|
46
|
+
if (isMetadataPath(new URL(req.url).pathname)) return metadataHandler(req);
|
|
47
|
+
return mcpHandler(req, createRecorderForRuntime(mcp, { stack: "supabase" }));
|
|
77
48
|
};
|
|
78
49
|
}
|
|
79
50
|
//#endregion
|
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_package = require("../../package-
|
|
5
|
+
const require_package = require("../../package-DNSwCau1.cjs");
|
|
6
6
|
const require_fs_errors = require("../../fs-errors-CWNzOV75.cjs");
|
|
7
7
|
const require_supabase_config = require("../../supabase-config-Dz7dnUv0.cjs");
|
|
8
8
|
const require_paths = require("../../paths-OP318a6c.cjs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as version } from "../../package-
|
|
1
|
+
import { t as version } from "../../package-CYA-5C24.js";
|
|
2
2
|
import { t as isFileMissing } from "../../fs-errors-PA2t1TIp.js";
|
|
3
3
|
import { t as readSupabaseProjectRef } from "../../supabase-config-CakTU8YF.js";
|
|
4
4
|
import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cors = require("../../cors-
|
|
3
|
-
const require_mcp = require("../../mcp-
|
|
2
|
+
const require_cors = require("../../cors-DNzLB6qa.cjs");
|
|
3
|
+
const require_mcp = require("../../mcp-CRdT2Fai.cjs");
|
|
4
4
|
const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
|
|
5
|
-
const require_list_tools = require("../../list-tools-DES10avA.cjs");
|
|
6
|
-
const require_rest = require("../../rest-BBdfHMGh.cjs");
|
|
7
5
|
const require_forwarded = require("../../forwarded-BC_RHnn5.cjs");
|
|
8
6
|
//#region src/stacks/tanstack/handlers.ts
|
|
9
7
|
const STACK = "tanstack";
|
|
@@ -16,23 +14,6 @@ function createTanStackMcpHandler(mcp, options = {}) {
|
|
|
16
14
|
return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, options), require_cors.createRecorderForRuntime(mcp, { stack: STACK }));
|
|
17
15
|
}
|
|
18
16
|
/**
|
|
19
|
-
* Build a TanStack Start handler for `GET /.mcp/list-tools`. Returns the
|
|
20
|
-
* tool catalog (name, description, annotations, JSON Schemas) as JSON.
|
|
21
|
-
*/
|
|
22
|
-
function createTanStackListToolsHandler(mcp, options = {}) {
|
|
23
|
-
const handler = require_list_tools.createListToolsHandler(mcp, options);
|
|
24
|
-
return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, options), require_cors.createRecorderForRuntime(mcp, { stack: STACK }));
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Build a TanStack Start handler for `POST /.mcp/invoke-tool/$tool`.
|
|
28
|
-
* Reads the tool name from `params.tool`, validates the JSON body, and
|
|
29
|
-
* dispatches to the matching `defineTool` handler.
|
|
30
|
-
*/
|
|
31
|
-
function createTanStackInvokeToolHandler(mcp, options = {}) {
|
|
32
|
-
const handler = require_rest.createInvokeToolHandler(mcp, options);
|
|
33
|
-
return ({ request, params }) => handler(require_forwarded.applyForwardedOrigin(request, options), params.tool, require_cors.createRecorderForRuntime(mcp, { stack: STACK }));
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
17
|
* Build a TanStack Start handler for `GET /.well-known/oauth-protected-resource`.
|
|
37
18
|
* When the MCP definition has no OAuth auth config the handler returns 404.
|
|
38
19
|
*/
|
|
@@ -41,7 +22,5 @@ function createTanStackOAuthProtectedResourceMetadataHandler(mcp, options = {})
|
|
|
41
22
|
return ({ request }) => handler(require_forwarded.applyForwardedOrigin(request, options));
|
|
42
23
|
}
|
|
43
24
|
//#endregion
|
|
44
|
-
exports.createTanStackInvokeToolHandler = createTanStackInvokeToolHandler;
|
|
45
|
-
exports.createTanStackListToolsHandler = createTanStackListToolsHandler;
|
|
46
25
|
exports.createTanStackMcpHandler = createTanStackMcpHandler;
|
|
47
26
|
exports.createTanStackOAuthProtectedResourceMetadataHandler = createTanStackOAuthProtectedResourceMetadataHandler;
|
|
@@ -1,37 +1,20 @@
|
|
|
1
|
-
import { u as McpDefinition } from "../../types-
|
|
2
|
-
import { t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { u as McpDefinition } from "../../types-DnGEKnvI.cjs";
|
|
2
|
+
import { t as McpRuntimeOptions } from "../../authorize-Cqr7Jps0.cjs";
|
|
3
3
|
//#region src/stacks/tanstack/handlers.d.ts
|
|
4
4
|
interface TanStackRouteCtx {
|
|
5
5
|
request: Request;
|
|
6
6
|
}
|
|
7
|
-
interface TanStackParamRouteCtx<TParam extends string> {
|
|
8
|
-
request: Request;
|
|
9
|
-
params: Record<TParam, string>;
|
|
10
|
-
}
|
|
11
7
|
type TanStackMcpHandler = (ctx: TanStackRouteCtx) => Promise<Response>;
|
|
12
|
-
type TanStackListToolsHandler = (ctx: TanStackRouteCtx) => Promise<Response>;
|
|
13
|
-
type TanStackInvokeToolHandler = (ctx: TanStackParamRouteCtx<"tool">) => Promise<Response>;
|
|
14
8
|
type TanStackOAuthProtectedResourceMetadataHandler = (ctx: TanStackRouteCtx) => Promise<Response>;
|
|
15
9
|
/**
|
|
16
10
|
* Build a TanStack Start handler for the MCP protocol endpoint
|
|
17
11
|
* (`POST /mcp`). Assignable directly to a route's `ANY` handler.
|
|
18
12
|
*/
|
|
19
13
|
declare function createTanStackMcpHandler(mcp: McpDefinition, options?: McpRuntimeOptions): TanStackMcpHandler;
|
|
20
|
-
/**
|
|
21
|
-
* Build a TanStack Start handler for `GET /.mcp/list-tools`. Returns the
|
|
22
|
-
* tool catalog (name, description, annotations, JSON Schemas) as JSON.
|
|
23
|
-
*/
|
|
24
|
-
declare function createTanStackListToolsHandler(mcp: McpDefinition, options?: McpRuntimeOptions): TanStackListToolsHandler;
|
|
25
|
-
/**
|
|
26
|
-
* Build a TanStack Start handler for `POST /.mcp/invoke-tool/$tool`.
|
|
27
|
-
* Reads the tool name from `params.tool`, validates the JSON body, and
|
|
28
|
-
* dispatches to the matching `defineTool` handler.
|
|
29
|
-
*/
|
|
30
|
-
declare function createTanStackInvokeToolHandler(mcp: McpDefinition, options?: McpRuntimeOptions): TanStackInvokeToolHandler;
|
|
31
14
|
/**
|
|
32
15
|
* Build a TanStack Start handler for `GET /.well-known/oauth-protected-resource`.
|
|
33
16
|
* When the MCP definition has no OAuth auth config the handler returns 404.
|
|
34
17
|
*/
|
|
35
18
|
declare function createTanStackOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): TanStackOAuthProtectedResourceMetadataHandler;
|
|
36
19
|
//#endregion
|
|
37
|
-
export { type
|
|
20
|
+
export { type TanStackMcpHandler, type TanStackOAuthProtectedResourceMetadataHandler, createTanStackMcpHandler, createTanStackOAuthProtectedResourceMetadataHandler };
|
|
@@ -1,37 +1,20 @@
|
|
|
1
|
-
import { u as McpDefinition } from "../../types-
|
|
2
|
-
import { t as McpRuntimeOptions } from "../../authorize-
|
|
1
|
+
import { u as McpDefinition } from "../../types-DnGEKnvI.js";
|
|
2
|
+
import { t as McpRuntimeOptions } from "../../authorize-Bpz8oxjF.js";
|
|
3
3
|
//#region src/stacks/tanstack/handlers.d.ts
|
|
4
4
|
interface TanStackRouteCtx {
|
|
5
5
|
request: Request;
|
|
6
6
|
}
|
|
7
|
-
interface TanStackParamRouteCtx<TParam extends string> {
|
|
8
|
-
request: Request;
|
|
9
|
-
params: Record<TParam, string>;
|
|
10
|
-
}
|
|
11
7
|
type TanStackMcpHandler = (ctx: TanStackRouteCtx) => Promise<Response>;
|
|
12
|
-
type TanStackListToolsHandler = (ctx: TanStackRouteCtx) => Promise<Response>;
|
|
13
|
-
type TanStackInvokeToolHandler = (ctx: TanStackParamRouteCtx<"tool">) => Promise<Response>;
|
|
14
8
|
type TanStackOAuthProtectedResourceMetadataHandler = (ctx: TanStackRouteCtx) => Promise<Response>;
|
|
15
9
|
/**
|
|
16
10
|
* Build a TanStack Start handler for the MCP protocol endpoint
|
|
17
11
|
* (`POST /mcp`). Assignable directly to a route's `ANY` handler.
|
|
18
12
|
*/
|
|
19
13
|
declare function createTanStackMcpHandler(mcp: McpDefinition, options?: McpRuntimeOptions): TanStackMcpHandler;
|
|
20
|
-
/**
|
|
21
|
-
* Build a TanStack Start handler for `GET /.mcp/list-tools`. Returns the
|
|
22
|
-
* tool catalog (name, description, annotations, JSON Schemas) as JSON.
|
|
23
|
-
*/
|
|
24
|
-
declare function createTanStackListToolsHandler(mcp: McpDefinition, options?: McpRuntimeOptions): TanStackListToolsHandler;
|
|
25
|
-
/**
|
|
26
|
-
* Build a TanStack Start handler for `POST /.mcp/invoke-tool/$tool`.
|
|
27
|
-
* Reads the tool name from `params.tool`, validates the JSON body, and
|
|
28
|
-
* dispatches to the matching `defineTool` handler.
|
|
29
|
-
*/
|
|
30
|
-
declare function createTanStackInvokeToolHandler(mcp: McpDefinition, options?: McpRuntimeOptions): TanStackInvokeToolHandler;
|
|
31
14
|
/**
|
|
32
15
|
* Build a TanStack Start handler for `GET /.well-known/oauth-protected-resource`.
|
|
33
16
|
* When the MCP definition has no OAuth auth config the handler returns 404.
|
|
34
17
|
*/
|
|
35
18
|
declare function createTanStackOAuthProtectedResourceMetadataHandler(mcp: McpDefinition, options?: McpRuntimeOptions): TanStackOAuthProtectedResourceMetadataHandler;
|
|
36
19
|
//#endregion
|
|
37
|
-
export { type
|
|
20
|
+
export { type TanStackMcpHandler, type TanStackOAuthProtectedResourceMetadataHandler, createTanStackMcpHandler, createTanStackOAuthProtectedResourceMetadataHandler };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { s as createRecorderForRuntime } from "../../cors-C_VffY86.js";
|
|
2
|
+
import { t as createMcpProtocolHandler } from "../../mcp-Bl7pQYdv.js";
|
|
3
3
|
import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
|
|
4
|
-
import { n as createListToolsHandler } from "../../list-tools-C1OiTDR9.js";
|
|
5
|
-
import { t as createInvokeToolHandler } from "../../rest-Cr7NhxL3.js";
|
|
6
4
|
import { t as applyForwardedOrigin } from "../../forwarded-B3EBjHnA.js";
|
|
7
5
|
//#region src/stacks/tanstack/handlers.ts
|
|
8
6
|
const STACK = "tanstack";
|
|
@@ -15,23 +13,6 @@ function createTanStackMcpHandler(mcp, options = {}) {
|
|
|
15
13
|
return ({ request }) => handler(applyForwardedOrigin(request, options), createRecorderForRuntime(mcp, { stack: STACK }));
|
|
16
14
|
}
|
|
17
15
|
/**
|
|
18
|
-
* Build a TanStack Start handler for `GET /.mcp/list-tools`. Returns the
|
|
19
|
-
* tool catalog (name, description, annotations, JSON Schemas) as JSON.
|
|
20
|
-
*/
|
|
21
|
-
function createTanStackListToolsHandler(mcp, options = {}) {
|
|
22
|
-
const handler = createListToolsHandler(mcp, options);
|
|
23
|
-
return ({ request }) => handler(applyForwardedOrigin(request, options), createRecorderForRuntime(mcp, { stack: STACK }));
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Build a TanStack Start handler for `POST /.mcp/invoke-tool/$tool`.
|
|
27
|
-
* Reads the tool name from `params.tool`, validates the JSON body, and
|
|
28
|
-
* dispatches to the matching `defineTool` handler.
|
|
29
|
-
*/
|
|
30
|
-
function createTanStackInvokeToolHandler(mcp, options = {}) {
|
|
31
|
-
const handler = createInvokeToolHandler(mcp, options);
|
|
32
|
-
return ({ request, params }) => handler(applyForwardedOrigin(request, options), params.tool, createRecorderForRuntime(mcp, { stack: STACK }));
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
16
|
* Build a TanStack Start handler for `GET /.well-known/oauth-protected-resource`.
|
|
36
17
|
* When the MCP definition has no OAuth auth config the handler returns 404.
|
|
37
18
|
*/
|
|
@@ -40,4 +21,4 @@ function createTanStackOAuthProtectedResourceMetadataHandler(mcp, options = {})
|
|
|
40
21
|
return ({ request }) => handler(applyForwardedOrigin(request, options));
|
|
41
22
|
}
|
|
42
23
|
//#endregion
|
|
43
|
-
export {
|
|
24
|
+
export { createTanStackMcpHandler, createTanStackOAuthProtectedResourceMetadataHandler };
|
|
@@ -25,32 +25,17 @@ function wellKnownRouteFile(routesDir, urlPath) {
|
|
|
25
25
|
return index === segments.length - 1 ? `${escaped}.ts` : escaped;
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const parentSegments = mcpUrlPath.replace(/^\/+/, "").replace(/\/+$/, "").split("/").slice(0, -1);
|
|
30
|
-
const restDir = (0, node_path.resolve)(routesDir, ...parentSegments, "[.mcp]");
|
|
31
|
-
const restUrlBase = `/${[...parentSegments, ".mcp"].join("/")}`;
|
|
32
|
-
return {
|
|
33
|
-
listToolsRouteFile: (0, node_path.resolve)(restDir, "list-tools.ts"),
|
|
34
|
-
invokeToolRouteFile: (0, node_path.resolve)(restDir, "invoke-tool", "$tool.ts"),
|
|
35
|
-
listToolsLiteral: `${restUrlBase}/list-tools`,
|
|
36
|
-
invokeToolLiteral: `${restUrlBase}/invoke-tool/$tool`
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function resolveAllRoutes(projectRoot, routesDirOption, routeFileName, mcpUrlPath, metadataUrlPath) {
|
|
28
|
+
function resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath) {
|
|
40
29
|
const routesDir = (0, node_path.resolve)(projectRoot, routesDirOption);
|
|
41
30
|
assertContains(projectRoot, routesDir, `routesDir "${routesDirOption}"`);
|
|
42
31
|
const mcpRouteFile = (0, node_path.resolve)(routesDir, routeFileName);
|
|
43
32
|
assertContains(routesDir, mcpRouteFile, `routeFileName "${routeFileName}"`);
|
|
44
33
|
const metadataRouteFile = wellKnownRouteFile(routesDir, metadataUrlPath);
|
|
45
34
|
assertContains(routesDir, metadataRouteFile, `metadataPath "${metadataUrlPath}"`);
|
|
46
|
-
const rest = resolveRestRoutes(routesDir, mcpUrlPath);
|
|
47
|
-
assertContains(routesDir, rest.listToolsRouteFile, `REST routes for path "${mcpUrlPath}"`);
|
|
48
|
-
assertContains(routesDir, rest.invokeToolRouteFile, `REST routes for path "${mcpUrlPath}"`);
|
|
49
35
|
return {
|
|
50
36
|
routesDir,
|
|
51
37
|
mcpRouteFile,
|
|
52
|
-
metadataRouteFile
|
|
53
|
-
...rest
|
|
38
|
+
metadataRouteFile
|
|
54
39
|
};
|
|
55
40
|
}
|
|
56
41
|
function assertUrlPathShape(urlPath) {
|
|
@@ -82,7 +67,6 @@ function relativeImportSpecifier(routeFile, target) {
|
|
|
82
67
|
function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot) {
|
|
83
68
|
const mcpImport = relativeImportSpecifier(route.file, mcpEntry);
|
|
84
69
|
const routeRel = normalizePath((0, node_path.relative)(projectRoot, route.file));
|
|
85
|
-
const note = route.spaFallbackNote ? " // ANY: TanStack returns SPA HTML for methods not in `handlers`; the SDK 405s instead.\n" : "";
|
|
86
70
|
const optionEntries = [`resourcePath: "${resourcePath}"`];
|
|
87
71
|
if (metadataPath !== void 0) optionEntries.push(`metadataPath: "${metadataPath}"`);
|
|
88
72
|
if (trustForwardedHost) if (route.attestsForwardedHost) {
|
|
@@ -106,7 +90,7 @@ import mcp from "${mcpImport}";
|
|
|
106
90
|
${routeOpen}
|
|
107
91
|
server: {
|
|
108
92
|
handlers: {
|
|
109
|
-
|
|
93
|
+
ANY: ${route.handlerFactory}(mcp, ${optionsObject}),
|
|
110
94
|
},
|
|
111
95
|
},
|
|
112
96
|
});
|
|
@@ -187,7 +171,6 @@ function mcpPlugin(options = {}) {
|
|
|
187
171
|
assertUrlPathShape(rawUrlPath);
|
|
188
172
|
const routeFileName = options.routeFileName ?? deriveRouteFileName(rawUrlPath);
|
|
189
173
|
const urlPath = canonicalUrlPath(rawUrlPath);
|
|
190
|
-
const emitRestRoutes = options.restRoutes !== false;
|
|
191
174
|
const emitProtectedResourceMetadataRoute = options.protectedResourceMetadataRoute !== false;
|
|
192
175
|
if (options.metadataPath !== void 0) {
|
|
193
176
|
if (!emitProtectedResourceMetadataRoute) throw new Error(`@lovable.dev/mcp-js: metadataPath sets where the protected-resource metadata route is served, so it can't be combined with protectedResourceMetadataRoute: false.`);
|
|
@@ -199,7 +182,7 @@ function mcpPlugin(options = {}) {
|
|
|
199
182
|
const trustForwardedProto = options.trustForwardedProto !== false;
|
|
200
183
|
let projectRoot = process.cwd();
|
|
201
184
|
let mcpEntry = (0, node_path.resolve)(projectRoot, mcpEntryOption);
|
|
202
|
-
let { routesDir, mcpRouteFile, metadataRouteFile
|
|
185
|
+
let { routesDir, mcpRouteFile, metadataRouteFile } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath);
|
|
203
186
|
const regenerate = () => {
|
|
204
187
|
let mcpEntryExists = true;
|
|
205
188
|
try {
|
|
@@ -221,17 +204,6 @@ function mcpPlugin(options = {}) {
|
|
|
221
204
|
handlerFactory: "createTanStackOAuthProtectedResourceMetadataHandler",
|
|
222
205
|
attestsForwardedHost: true
|
|
223
206
|
});
|
|
224
|
-
if (emitRestRoutes) routes.push({
|
|
225
|
-
file: listToolsRouteFile,
|
|
226
|
-
routeLiteral: listToolsLiteral,
|
|
227
|
-
handlerFactory: "createTanStackListToolsHandler",
|
|
228
|
-
spaFallbackNote: true
|
|
229
|
-
}, {
|
|
230
|
-
file: invokeToolRouteFile,
|
|
231
|
-
routeLiteral: invokeToolLiteral,
|
|
232
|
-
handlerFactory: "createTanStackInvokeToolHandler",
|
|
233
|
-
spaFallbackNote: true
|
|
234
|
-
});
|
|
235
207
|
for (const route of routes) {
|
|
236
208
|
expected.add(route.file);
|
|
237
209
|
writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot));
|
|
@@ -263,7 +235,7 @@ function mcpPlugin(options = {}) {
|
|
|
263
235
|
configResolved(config) {
|
|
264
236
|
projectRoot = config.root;
|
|
265
237
|
mcpEntry = (0, node_path.resolve)(projectRoot, mcpEntryOption);
|
|
266
|
-
({routesDir, mcpRouteFile, metadataRouteFile
|
|
238
|
+
({routesDir, mcpRouteFile, metadataRouteFile} = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath));
|
|
267
239
|
regenerate();
|
|
268
240
|
},
|
|
269
241
|
configureServer(server) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as McpPluginApi } from "../../io-
|
|
1
|
+
import { t as McpPluginApi } from "../../io-Bh_WpbxU.cjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
//#region src/stacks/tanstack/vite.d.ts
|
|
4
4
|
interface McpPluginOptions {
|
|
@@ -8,24 +8,12 @@ interface McpPluginOptions {
|
|
|
8
8
|
* @default "src/lib/mcp/index.ts"
|
|
9
9
|
*/
|
|
10
10
|
mcpEntry?: string;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* The plugin emits `<routesDir>/<routeFileName>` plus the REST companion
|
|
14
|
-
* routes here.
|
|
15
|
-
* @default "src/routes"
|
|
16
|
-
*/
|
|
11
|
+
/** Where TanStack route files live; the plugin emits `<routesDir>/<routeFileName>` here.
|
|
12
|
+
* @default "src/routes" */
|
|
17
13
|
routesDir?: string;
|
|
18
14
|
/**
|
|
19
15
|
* Public URL path for the MCP-protocol route.
|
|
20
16
|
*
|
|
21
|
-
* The REST companion routes co-locate with this path under a `.mcp`
|
|
22
|
-
* sub-segment of the same parent prefix: `/mcp` keeps them at
|
|
23
|
-
* `/.mcp/list-tools` and `/.mcp/invoke-tool/$tool`, while
|
|
24
|
-
* `/api/public/mcp` moves them to `/api/public/.mcp/*`. The `.mcp`
|
|
25
|
-
* namespace keeps them from colliding with user-defined URLs without
|
|
26
|
-
* anchoring them at the root. Set `restRoutes: false` to drop the
|
|
27
|
-
* companions entirely.
|
|
28
|
-
*
|
|
29
17
|
* Must start with `/` and use only `/mcp`-style segments; anything more
|
|
30
18
|
* exotic doesn't map cleanly to a TanStack file name.
|
|
31
19
|
* @default "/mcp"
|
|
@@ -37,14 +25,6 @@ interface McpPluginOptions {
|
|
|
37
25
|
* `/api/mcp` → `api/mcp.ts`).
|
|
38
26
|
*/
|
|
39
27
|
routeFileName?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Set to `false` to skip emitting the REST companion routes at
|
|
42
|
-
* `<path-parent>/.mcp/list-tools` and `<path-parent>/.mcp/<tool>`. Set
|
|
43
|
-
* `protectedResourceMetadataRoute: false` as well if you want the MCP
|
|
44
|
-
* protocol route to be the only emitted surface.
|
|
45
|
-
* @default true
|
|
46
|
-
*/
|
|
47
|
-
restRoutes?: boolean;
|
|
48
28
|
/**
|
|
49
29
|
* Set to `false` to skip emitting the OAuth protected-resource metadata
|
|
50
30
|
* route at `/.well-known/oauth-protected-resource`.
|
|
@@ -77,11 +57,8 @@ interface McpPluginOptions {
|
|
|
77
57
|
* @default true
|
|
78
58
|
*/
|
|
79
59
|
trustForwardedHost?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* from `X-Forwarded-Proto`. Safe only behind an overwriting proxy.
|
|
83
|
-
* @default true
|
|
84
|
-
*/
|
|
60
|
+
/** Derive the public scheme from `X-Forwarded-Proto`; safe only behind an
|
|
61
|
+
* overwriting proxy. @default true */
|
|
85
62
|
trustForwardedProto?: boolean;
|
|
86
63
|
}
|
|
87
64
|
declare function assertUrlPathShape(urlPath: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as McpPluginApi } from "../../io-
|
|
1
|
+
import { t as McpPluginApi } from "../../io-DrHivYt0.js";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
//#region src/stacks/tanstack/vite.d.ts
|
|
4
4
|
interface McpPluginOptions {
|
|
@@ -8,24 +8,12 @@ interface McpPluginOptions {
|
|
|
8
8
|
* @default "src/lib/mcp/index.ts"
|
|
9
9
|
*/
|
|
10
10
|
mcpEntry?: string;
|
|
11
|
-
/**
|
|
12
|
-
*
|
|
13
|
-
* The plugin emits `<routesDir>/<routeFileName>` plus the REST companion
|
|
14
|
-
* routes here.
|
|
15
|
-
* @default "src/routes"
|
|
16
|
-
*/
|
|
11
|
+
/** Where TanStack route files live; the plugin emits `<routesDir>/<routeFileName>` here.
|
|
12
|
+
* @default "src/routes" */
|
|
17
13
|
routesDir?: string;
|
|
18
14
|
/**
|
|
19
15
|
* Public URL path for the MCP-protocol route.
|
|
20
16
|
*
|
|
21
|
-
* The REST companion routes co-locate with this path under a `.mcp`
|
|
22
|
-
* sub-segment of the same parent prefix: `/mcp` keeps them at
|
|
23
|
-
* `/.mcp/list-tools` and `/.mcp/invoke-tool/$tool`, while
|
|
24
|
-
* `/api/public/mcp` moves them to `/api/public/.mcp/*`. The `.mcp`
|
|
25
|
-
* namespace keeps them from colliding with user-defined URLs without
|
|
26
|
-
* anchoring them at the root. Set `restRoutes: false` to drop the
|
|
27
|
-
* companions entirely.
|
|
28
|
-
*
|
|
29
17
|
* Must start with `/` and use only `/mcp`-style segments; anything more
|
|
30
18
|
* exotic doesn't map cleanly to a TanStack file name.
|
|
31
19
|
* @default "/mcp"
|
|
@@ -37,14 +25,6 @@ interface McpPluginOptions {
|
|
|
37
25
|
* `/api/mcp` → `api/mcp.ts`).
|
|
38
26
|
*/
|
|
39
27
|
routeFileName?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Set to `false` to skip emitting the REST companion routes at
|
|
42
|
-
* `<path-parent>/.mcp/list-tools` and `<path-parent>/.mcp/<tool>`. Set
|
|
43
|
-
* `protectedResourceMetadataRoute: false` as well if you want the MCP
|
|
44
|
-
* protocol route to be the only emitted surface.
|
|
45
|
-
* @default true
|
|
46
|
-
*/
|
|
47
|
-
restRoutes?: boolean;
|
|
48
28
|
/**
|
|
49
29
|
* Set to `false` to skip emitting the OAuth protected-resource metadata
|
|
50
30
|
* route at `/.well-known/oauth-protected-resource`.
|
|
@@ -77,11 +57,8 @@ interface McpPluginOptions {
|
|
|
77
57
|
* @default true
|
|
78
58
|
*/
|
|
79
59
|
trustForwardedHost?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* from `X-Forwarded-Proto`. Safe only behind an overwriting proxy.
|
|
83
|
-
* @default true
|
|
84
|
-
*/
|
|
60
|
+
/** Derive the public scheme from `X-Forwarded-Proto`; safe only behind an
|
|
61
|
+
* overwriting proxy. @default true */
|
|
85
62
|
trustForwardedProto?: boolean;
|
|
86
63
|
}
|
|
87
64
|
declare function assertUrlPathShape(urlPath: string): string;
|
|
@@ -21,32 +21,17 @@ function wellKnownRouteFile(routesDir, urlPath) {
|
|
|
21
21
|
return index === segments.length - 1 ? `${escaped}.ts` : escaped;
|
|
22
22
|
}));
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const parentSegments = mcpUrlPath.replace(/^\/+/, "").replace(/\/+$/, "").split("/").slice(0, -1);
|
|
26
|
-
const restDir = resolve(routesDir, ...parentSegments, "[.mcp]");
|
|
27
|
-
const restUrlBase = `/${[...parentSegments, ".mcp"].join("/")}`;
|
|
28
|
-
return {
|
|
29
|
-
listToolsRouteFile: resolve(restDir, "list-tools.ts"),
|
|
30
|
-
invokeToolRouteFile: resolve(restDir, "invoke-tool", "$tool.ts"),
|
|
31
|
-
listToolsLiteral: `${restUrlBase}/list-tools`,
|
|
32
|
-
invokeToolLiteral: `${restUrlBase}/invoke-tool/$tool`
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function resolveAllRoutes(projectRoot, routesDirOption, routeFileName, mcpUrlPath, metadataUrlPath) {
|
|
24
|
+
function resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath) {
|
|
36
25
|
const routesDir = resolve(projectRoot, routesDirOption);
|
|
37
26
|
assertContains(projectRoot, routesDir, `routesDir "${routesDirOption}"`);
|
|
38
27
|
const mcpRouteFile = resolve(routesDir, routeFileName);
|
|
39
28
|
assertContains(routesDir, mcpRouteFile, `routeFileName "${routeFileName}"`);
|
|
40
29
|
const metadataRouteFile = wellKnownRouteFile(routesDir, metadataUrlPath);
|
|
41
30
|
assertContains(routesDir, metadataRouteFile, `metadataPath "${metadataUrlPath}"`);
|
|
42
|
-
const rest = resolveRestRoutes(routesDir, mcpUrlPath);
|
|
43
|
-
assertContains(routesDir, rest.listToolsRouteFile, `REST routes for path "${mcpUrlPath}"`);
|
|
44
|
-
assertContains(routesDir, rest.invokeToolRouteFile, `REST routes for path "${mcpUrlPath}"`);
|
|
45
31
|
return {
|
|
46
32
|
routesDir,
|
|
47
33
|
mcpRouteFile,
|
|
48
|
-
metadataRouteFile
|
|
49
|
-
...rest
|
|
34
|
+
metadataRouteFile
|
|
50
35
|
};
|
|
51
36
|
}
|
|
52
37
|
function assertUrlPathShape(urlPath) {
|
|
@@ -78,7 +63,6 @@ function relativeImportSpecifier(routeFile, target) {
|
|
|
78
63
|
function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot) {
|
|
79
64
|
const mcpImport = relativeImportSpecifier(route.file, mcpEntry);
|
|
80
65
|
const routeRel = normalizePath(relative(projectRoot, route.file));
|
|
81
|
-
const note = route.spaFallbackNote ? " // ANY: TanStack returns SPA HTML for methods not in `handlers`; the SDK 405s instead.\n" : "";
|
|
82
66
|
const optionEntries = [`resourcePath: "${resourcePath}"`];
|
|
83
67
|
if (metadataPath !== void 0) optionEntries.push(`metadataPath: "${metadataPath}"`);
|
|
84
68
|
if (trustForwardedHost) if (route.attestsForwardedHost) {
|
|
@@ -102,7 +86,7 @@ import mcp from "${mcpImport}";
|
|
|
102
86
|
${routeOpen}
|
|
103
87
|
server: {
|
|
104
88
|
handlers: {
|
|
105
|
-
|
|
89
|
+
ANY: ${route.handlerFactory}(mcp, ${optionsObject}),
|
|
106
90
|
},
|
|
107
91
|
},
|
|
108
92
|
});
|
|
@@ -183,7 +167,6 @@ function mcpPlugin(options = {}) {
|
|
|
183
167
|
assertUrlPathShape(rawUrlPath);
|
|
184
168
|
const routeFileName = options.routeFileName ?? deriveRouteFileName(rawUrlPath);
|
|
185
169
|
const urlPath = canonicalUrlPath(rawUrlPath);
|
|
186
|
-
const emitRestRoutes = options.restRoutes !== false;
|
|
187
170
|
const emitProtectedResourceMetadataRoute = options.protectedResourceMetadataRoute !== false;
|
|
188
171
|
if (options.metadataPath !== void 0) {
|
|
189
172
|
if (!emitProtectedResourceMetadataRoute) throw new Error(`@lovable.dev/mcp-js: metadataPath sets where the protected-resource metadata route is served, so it can't be combined with protectedResourceMetadataRoute: false.`);
|
|
@@ -195,7 +178,7 @@ function mcpPlugin(options = {}) {
|
|
|
195
178
|
const trustForwardedProto = options.trustForwardedProto !== false;
|
|
196
179
|
let projectRoot = process.cwd();
|
|
197
180
|
let mcpEntry = resolve(projectRoot, mcpEntryOption);
|
|
198
|
-
let { routesDir, mcpRouteFile, metadataRouteFile
|
|
181
|
+
let { routesDir, mcpRouteFile, metadataRouteFile } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath);
|
|
199
182
|
const regenerate = () => {
|
|
200
183
|
let mcpEntryExists = true;
|
|
201
184
|
try {
|
|
@@ -217,17 +200,6 @@ function mcpPlugin(options = {}) {
|
|
|
217
200
|
handlerFactory: "createTanStackOAuthProtectedResourceMetadataHandler",
|
|
218
201
|
attestsForwardedHost: true
|
|
219
202
|
});
|
|
220
|
-
if (emitRestRoutes) routes.push({
|
|
221
|
-
file: listToolsRouteFile,
|
|
222
|
-
routeLiteral: listToolsLiteral,
|
|
223
|
-
handlerFactory: "createTanStackListToolsHandler",
|
|
224
|
-
spaFallbackNote: true
|
|
225
|
-
}, {
|
|
226
|
-
file: invokeToolRouteFile,
|
|
227
|
-
routeLiteral: invokeToolLiteral,
|
|
228
|
-
handlerFactory: "createTanStackInvokeToolHandler",
|
|
229
|
-
spaFallbackNote: true
|
|
230
|
-
});
|
|
231
203
|
for (const route of routes) {
|
|
232
204
|
expected.add(route.file);
|
|
233
205
|
writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot));
|
|
@@ -259,7 +231,7 @@ function mcpPlugin(options = {}) {
|
|
|
259
231
|
configResolved(config) {
|
|
260
232
|
projectRoot = config.root;
|
|
261
233
|
mcpEntry = resolve(projectRoot, mcpEntryOption);
|
|
262
|
-
({routesDir, mcpRouteFile, metadataRouteFile
|
|
234
|
+
({routesDir, mcpRouteFile, metadataRouteFile} = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath));
|
|
263
235
|
regenerate();
|
|
264
236
|
},
|
|
265
237
|
configureServer(server) {
|