@lovable.dev/mcp-js 0.28.0 → 0.29.0-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/README.md +7 -1
- package/dist/{authorize-Cs1yyLrq.d.ts → authorize-BjNE3LPr.d.ts} +1 -1
- package/dist/{authorize-BcNuNPtP.d.cts → authorize-BzZFS0zi.d.cts} +1 -1
- package/dist/{base-CUkmyaXJ.d.cts → base-DSH8NnPj.d.cts} +4 -0
- package/dist/{base-CUkmyaXJ.d.ts → base-DSH8NnPj.d.ts} +4 -0
- package/dist/cli/extract-manifest.cjs +2 -2
- package/dist/cli/extract-manifest.js +2 -2
- package/dist/{authorize-ChY44o_1.cjs → cors-CmKzDN7k.cjs} +73 -29
- package/dist/{authorize--rUeMOGU.js → cors-D4YbODs-.js} +68 -24
- package/dist/{forwarded-BlLF3dfc.js → forwarded-B3EBjHnA.js} +3 -3
- package/dist/{forwarded-Bhwcj22u.cjs → forwarded-BC_RHnn5.cjs} +3 -3
- package/dist/{gate-CGZl0gjJ.cjs → gate-n_HX6eQ5.cjs} +6 -4
- package/dist/{gate-BiM6EBeA.js → gate-pGsVlY_4.js} +5 -3
- package/dist/index.cjs +37 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +37 -0
- package/dist/{io-VBHO8YH_.d.cts → io-BEwvgN8s.d.cts} +1 -1
- package/dist/{io-SMlD5WeX.d.ts → io-CvALf9NE.d.ts} +1 -1
- package/dist/list-tools-Dkyyje7j.cjs +48 -0
- package/dist/{list-tools-BLGr7mot.js → list-tools-ePP9tXND.js} +9 -13
- package/dist/{list-tools-BAqQVIHk.d.ts → list-tools-qIvVJeWZ.d.ts} +3 -3
- package/dist/{list-tools-BN97L2Yv.d.cts → list-tools-zagoI477.d.cts} +3 -3
- package/dist/mcp-Cs4zfvSi.js +336 -0
- package/dist/mcp-DQ1Vdv4v.cjs +341 -0
- package/dist/{package-CGLPZwz-.cjs → package-C3YVYgxp.cjs} +1 -1
- package/dist/{package-DgiA0xuY.js → package-DzB_5Hur.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 +11 -9
- package/dist/protocols/oauth-metadata.d.cts +2 -2
- package/dist/protocols/oauth-metadata.d.ts +2 -2
- package/dist/protocols/oauth-metadata.js +5 -3
- package/dist/protocols/rest/index.cjs +2 -2
- package/dist/protocols/rest/index.d.cts +4 -4
- package/dist/protocols/rest/index.d.ts +4 -4
- package/dist/protocols/rest/index.js +2 -2
- package/dist/{rest-BS7bBOd9.js → rest-DSclWpIt.js} +13 -12
- package/dist/{rest-BE05MUNS.cjs → rest-P6XZWP42.cjs} +28 -27
- package/dist/schema-CW1jKvio.js +65 -0
- package/dist/schema-D3vClxb7.cjs +76 -0
- package/dist/stacks/supabase/index.cjs +7 -7
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +5 -5
- 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 +8 -8
- package/dist/stacks/tanstack/index.d.cts +2 -2
- package/dist/stacks/tanstack/index.d.ts +2 -2
- package/dist/stacks/tanstack/index.js +5 -5
- package/dist/stacks/tanstack/vite.cjs +8 -4
- package/dist/stacks/tanstack/vite.d.cts +11 -1
- package/dist/stacks/tanstack/vite.d.ts +11 -1
- package/dist/stacks/tanstack/vite.js +8 -4
- package/dist/tool-result-CK6hXO43.cjs +89 -0
- package/dist/tool-result-DfCk445b.js +78 -0
- package/dist/{types-C0Wgm9zp.d.cts → types-D1cgsnPu.d.cts} +15 -7
- package/dist/{types-C0Wgm9zp.d.ts → types-D1cgsnPu.d.ts} +15 -7
- package/package.json +2 -1
- package/dist/content-D5LJAHyM.js +0 -12
- package/dist/content-NCYIGgOb.cjs +0 -17
- package/dist/list-tools-DCF6G4fn.cjs +0 -52
- package/dist/mcp-CUGwXkxb.cjs +0 -153
- package/dist/mcp-Czp-hHjN.js +0 -148
package/dist/mcp-Czp-hHjN.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { i as log, r as describeError } from "./logger-Ctv5xUSD.js";
|
|
2
|
-
import { i as ToolContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-DSe96Ffd.js";
|
|
3
|
-
import { l as nowMs, n as createRequestAuthorizer } from "./authorize--rUeMOGU.js";
|
|
4
|
-
import { t as extractTextContent } from "./content-D5LJAHyM.js";
|
|
5
|
-
import { t as createGatedHandler } from "./gate-BiM6EBeA.js";
|
|
6
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
-
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
8
|
-
//#region src/protocols/mcp/protocol.ts
|
|
9
|
-
function statelessMethodNotAllowed(allow) {
|
|
10
|
-
return Response.json({
|
|
11
|
-
jsonrpc: "2.0",
|
|
12
|
-
id: null,
|
|
13
|
-
error: {
|
|
14
|
-
code: -32e3,
|
|
15
|
-
message: "Method not allowed: stateless server offers no standalone SSE stream (GET) or session (DELETE)."
|
|
16
|
-
}
|
|
17
|
-
}, {
|
|
18
|
-
status: 405,
|
|
19
|
-
headers: { Allow: allow }
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Adapt a Lovable tool to the SDK's tool callback. The boundary cast bridges
|
|
24
|
-
* our SDK-decoupled content-block types to the SDK's; they match structurally.
|
|
25
|
-
*/
|
|
26
|
-
function adaptToolToSdkCallback(tool, auth, recorder) {
|
|
27
|
-
const endUserId = auth?.principal.sub;
|
|
28
|
-
return (async (first) => {
|
|
29
|
-
const args = tool.inputSchema ? first ?? {} : {};
|
|
30
|
-
const start = nowMs();
|
|
31
|
-
let result;
|
|
32
|
-
try {
|
|
33
|
-
result = await tool.handler(args, new ToolContext(auth));
|
|
34
|
-
} catch (err) {
|
|
35
|
-
const callerMessage = resolveToolErrorMessage(err);
|
|
36
|
-
if (callerMessage === void 0) {
|
|
37
|
-
await recorder.emit({
|
|
38
|
-
tool: tool.name,
|
|
39
|
-
method: "tools/call",
|
|
40
|
-
outcome: "handler_error",
|
|
41
|
-
durationMs: nowMs() - start,
|
|
42
|
-
errorText: errorSummary(err),
|
|
43
|
-
endUserId
|
|
44
|
-
});
|
|
45
|
-
return {
|
|
46
|
-
content: [{
|
|
47
|
-
type: "text",
|
|
48
|
-
text: "tool execution failed"
|
|
49
|
-
}],
|
|
50
|
-
isError: true
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
result = {
|
|
54
|
-
content: [{
|
|
55
|
-
type: "text",
|
|
56
|
-
text: callerMessage
|
|
57
|
-
}],
|
|
58
|
-
isError: true
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (result == null) {
|
|
62
|
-
await recorder.emit({
|
|
63
|
-
tool: tool.name,
|
|
64
|
-
method: "tools/call",
|
|
65
|
-
outcome: "handler_error",
|
|
66
|
-
durationMs: nowMs() - start,
|
|
67
|
-
endUserId
|
|
68
|
-
});
|
|
69
|
-
return {
|
|
70
|
-
content: [{
|
|
71
|
-
type: "text",
|
|
72
|
-
text: `tool "${tool.name}" returned no result`
|
|
73
|
-
}],
|
|
74
|
-
isError: true
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
await recorder.emit({
|
|
78
|
-
tool: tool.name,
|
|
79
|
-
method: "tools/call",
|
|
80
|
-
outcome: result.isError ? "tool_error" : "ok",
|
|
81
|
-
durationMs: nowMs() - start,
|
|
82
|
-
errorText: result.isError ? extractTextContent(result.content) : void 0,
|
|
83
|
-
endUserId
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
content: result.content ?? [],
|
|
87
|
-
structuredContent: result.structuredContent,
|
|
88
|
-
isError: result.isError
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Build a Web-Standard request handler that serves the MCP protocol over
|
|
94
|
-
* streamable HTTP. A fresh `McpServer` + transport is constructed per
|
|
95
|
-
* request — the transport is stateless, so this is cheap and there is no
|
|
96
|
-
* cross-request state to leak. The per-request `recorder` is supplied by the
|
|
97
|
-
* caller (the stack handler) so telemetry reads the runtime env in-flight.
|
|
98
|
-
*/
|
|
99
|
-
function createMcpProtocolHandler(mcp, options = {}) {
|
|
100
|
-
const authorizer = createRequestAuthorizer(mcp, options);
|
|
101
|
-
const handle = async (request, authResult, recorder) => {
|
|
102
|
-
try {
|
|
103
|
-
const server = new McpServer({
|
|
104
|
-
name: mcp.name,
|
|
105
|
-
version: mcp.version,
|
|
106
|
-
title: mcp.title
|
|
107
|
-
}, { instructions: mcp.instructions });
|
|
108
|
-
for (const tool of mcp.tools) server.registerTool(tool.name, {
|
|
109
|
-
title: tool.title,
|
|
110
|
-
description: tool.description,
|
|
111
|
-
inputSchema: tool.inputSchema,
|
|
112
|
-
outputSchema: tool.outputSchema,
|
|
113
|
-
annotations: tool.annotations
|
|
114
|
-
}, adaptToolToSdkCallback(tool, authResult.auth, recorder));
|
|
115
|
-
const transport = new WebStandardStreamableHTTPServerTransport({ sessionIdGenerator: void 0 });
|
|
116
|
-
await server.connect(transport);
|
|
117
|
-
return await transport.handleRequest(request);
|
|
118
|
-
} catch (err) {
|
|
119
|
-
await recorder.emit({
|
|
120
|
-
tool: null,
|
|
121
|
-
method: "transport",
|
|
122
|
-
outcome: "transport_error",
|
|
123
|
-
durationMs: 0,
|
|
124
|
-
endUserId: authResult.auth?.principal.sub
|
|
125
|
-
});
|
|
126
|
-
log.error("mcp.transport_error", {
|
|
127
|
-
...describeError(err),
|
|
128
|
-
outcome: "500 internal error"
|
|
129
|
-
});
|
|
130
|
-
return Response.json({
|
|
131
|
-
jsonrpc: "2.0",
|
|
132
|
-
id: null,
|
|
133
|
-
error: {
|
|
134
|
-
code: -32603,
|
|
135
|
-
message: "internal error"
|
|
136
|
-
}
|
|
137
|
-
}, { status: 500 });
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
return createGatedHandler({
|
|
141
|
-
authorizer,
|
|
142
|
-
methods: ["POST"],
|
|
143
|
-
methodNotAllowed: statelessMethodNotAllowed,
|
|
144
|
-
handle
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
|
-
export { createMcpProtocolHandler as t };
|