@lovable.dev/mcp-js 0.27.1 → 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 +13 -7
- 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-CReh7d3E.d.cts → base-DSH8NnPj.d.cts} +10 -3
- package/dist/{base-CReh7d3E.d.ts → base-DSH8NnPj.d.ts} +10 -3
- package/dist/cli/extract-manifest.cjs +2 -2
- package/dist/cli/extract-manifest.js +2 -2
- package/dist/{authorize-CB35c3Wg.cjs → cors-CmKzDN7k.cjs} +154 -59
- package/dist/{authorize-FOlzhxrM.js → cors-D4YbODs-.js} +150 -55
- package/dist/{forwarded-BlLF3dfc.js → forwarded-B3EBjHnA.js} +3 -3
- package/dist/{forwarded-Bhwcj22u.cjs → forwarded-BC_RHnn5.cjs} +3 -3
- package/dist/{gate-B9RSzvoI.cjs → gate-n_HX6eQ5.cjs} +6 -4
- package/dist/{gate-BeHmyGxk.js → gate-pGsVlY_4.js} +5 -3
- package/dist/index.cjs +38 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +38 -1
- package/dist/{io-BzTGjG_c.d.cts → io-BEwvgN8s.d.cts} +1 -1
- package/dist/{io--MeYrWG7.d.ts → io-CvALf9NE.d.ts} +1 -1
- package/dist/list-tools-Dkyyje7j.cjs +48 -0
- package/dist/{list-tools-Dt-mhh52.js → list-tools-ePP9tXND.js} +9 -13
- package/dist/{list-tools-Bku6XkVc.d.ts → list-tools-qIvVJeWZ.d.ts} +3 -3
- package/dist/{list-tools-Cn7tpE0V.d.cts → list-tools-zagoI477.d.cts} +3 -3
- package/dist/{logger-BkMMCFTv.cjs → logger-CN1q-KNn.cjs} +6 -6
- package/dist/{logger-rGakBvJ1.js → logger-Ctv5xUSD.js} +6 -6
- package/dist/mcp-Cs4zfvSi.js +336 -0
- package/dist/mcp-DQ1Vdv4v.cjs +341 -0
- package/dist/{package-BdaLbzEh.cjs → package-C3YVYgxp.cjs} +1 -1
- package/dist/{package-dtiombMt.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 +12 -10
- package/dist/protocols/oauth-metadata.d.cts +2 -2
- package/dist/protocols/oauth-metadata.d.ts +2 -2
- package/dist/protocols/oauth-metadata.js +6 -4
- 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-Cit2862S.js → rest-DSclWpIt.js} +13 -12
- package/dist/{rest-1Pf9sYNU.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 +8 -8
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +6 -6
- 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-DiMCRunS.cjs +0 -52
- package/dist/mcp-DiVQhHIw.js +0 -148
- package/dist/mcp-ECo1Ixk8.cjs +0 -153
package/dist/mcp-ECo1Ixk8.cjs
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
const require_logger = require("./logger-BkMMCFTv.cjs");
|
|
2
|
-
const require_errors = require("./errors-CN6Da8iz.cjs");
|
|
3
|
-
const require_authorize = require("./authorize-CB35c3Wg.cjs");
|
|
4
|
-
const require_content = require("./content-NCYIGgOb.cjs");
|
|
5
|
-
const require_gate = require("./gate-B9RSzvoI.cjs");
|
|
6
|
-
let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
7
|
-
let _modelcontextprotocol_sdk_server_webStandardStreamableHttp_js = require("@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 = require_authorize.nowMs();
|
|
31
|
-
let result;
|
|
32
|
-
try {
|
|
33
|
-
result = await tool.handler(args, new require_errors.ToolContext(auth));
|
|
34
|
-
} catch (err) {
|
|
35
|
-
const callerMessage = require_errors.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: require_authorize.nowMs() - start,
|
|
42
|
-
errorText: require_errors.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: require_authorize.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: require_authorize.nowMs() - start,
|
|
82
|
-
errorText: result.isError ? require_content.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 = require_authorize.createRequestAuthorizer(mcp, options);
|
|
101
|
-
const handle = async (request, authResult, recorder) => {
|
|
102
|
-
try {
|
|
103
|
-
const server = new _modelcontextprotocol_sdk_server_mcp_js.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 _modelcontextprotocol_sdk_server_webStandardStreamableHttp_js.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
|
-
require_logger.log.error("mcp.transport_error", {
|
|
127
|
-
...require_logger.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 require_gate.createGatedHandler({
|
|
141
|
-
authorizer,
|
|
142
|
-
methods: ["POST"],
|
|
143
|
-
methodNotAllowed: statelessMethodNotAllowed,
|
|
144
|
-
handle
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
|
-
Object.defineProperty(exports, "createMcpProtocolHandler", {
|
|
149
|
-
enumerable: true,
|
|
150
|
-
get: function() {
|
|
151
|
-
return createMcpProtocolHandler;
|
|
152
|
-
}
|
|
153
|
-
});
|