@lovable.dev/mcp-js 0.25.0 → 0.26.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.internal.md +3 -2
- package/README.md +12 -0
- package/dist/{base-D-dYxK8t.d.cts → base-CReh7d3E.d.cts} +2 -2
- package/dist/{base-D-dYxK8t.d.ts → base-CReh7d3E.d.ts} +2 -2
- package/dist/cli/extract-manifest.cjs +2 -2
- package/dist/cli/extract-manifest.js +2 -2
- package/dist/{cors-DW1p9Uzw.cjs → cors-B79id9hu.cjs} +3 -2
- package/dist/{cors-1Iz86PSf.js → cors-DlHHW20_.js} +3 -2
- package/dist/errors-CN6Da8iz.cjs +108 -0
- package/dist/{context-BweeEcoA.cjs → errors-DSe96Ffd.js} +34 -5
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +2 -2
- package/dist/{io-CSsqm26s.d.ts → io-B-fV6rsM.d.ts} +1 -1
- package/dist/{io-BlJ298VF.d.cts → io-Bd58IeVb.d.cts} +1 -1
- package/dist/{list-tools-DKz6nJQ6.d.ts → list-tools-C6u8G4iq.d.ts} +1 -1
- package/dist/{list-tools-DBidJV3L.cjs → list-tools-Ct6yJ_bo.cjs} +1 -1
- package/dist/{list-tools-Dk-QKfqy.d.cts → list-tools-DOBMd4AE.d.cts} +1 -1
- package/dist/{list-tools-DjzEigXr.js → list-tools-S2xzLisA.js} +1 -1
- package/dist/{mcp-CoVt8EO9.js → mcp-BUR5KIhL.js} +23 -12
- package/dist/{mcp-DSo7xlpz.cjs → mcp-DNz7KIy4.cjs} +24 -13
- package/dist/{package-CUrmd7C5.js → package-Aux8_a4B.js} +1 -1
- package/dist/{package-Wvf1u2OZ.cjs → package-C1uEtkqq.cjs} +1 -1
- package/dist/protocols/mcp/index.cjs +1 -1
- package/dist/protocols/mcp/index.d.cts +1 -1
- package/dist/protocols/mcp/index.d.ts +1 -1
- package/dist/protocols/mcp/index.js +1 -1
- package/dist/protocols/oauth-metadata.cjs +1 -1
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/protocols/rest/index.cjs +2 -2
- package/dist/protocols/rest/index.d.cts +2 -2
- package/dist/protocols/rest/index.d.ts +2 -2
- package/dist/protocols/rest/index.js +2 -2
- package/dist/{rest-CvdOnTsb.cjs → rest-DWrrqgYf.cjs} +30 -19
- package/dist/{rest-DdQMWvF4.js → rest-xOYdRom7.js} +29 -18
- package/dist/stacks/supabase/index.cjs +4 -4
- package/dist/stacks/supabase/index.js +4 -4
- 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 +4 -4
- package/dist/stacks/tanstack/index.js +4 -4
- package/dist/stacks/tanstack/vite.d.cts +1 -1
- package/dist/stacks/tanstack/vite.d.ts +1 -1
- package/package.json +1 -1
- package/dist/context-CIpPzN7P.js +0 -51
package/README.internal.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @lovable.dev/mcp-js — internal notes
|
|
2
2
|
|
|
3
|
-
Architecture rationale, source layout, and dev scripts for contributors. The user-facing docs are in [`README.md`](README.md); release rules and build-system constraints are in [`AGENTS.md`](AGENTS.md).
|
|
3
|
+
Architecture rationale, source layout, and dev scripts for contributors. The user-facing docs are in [`README.md`](README.md); release rules and build-system constraints are in [`AGENTS.md`](AGENTS.md). The tarball carries `dist`, `package.json`, `LICENSE`, `CHANGELOG.md`, and every root `README*` (npm force-includes them, this file included) — no source, tests, or examples.
|
|
4
4
|
|
|
5
5
|
## Folder meaning
|
|
6
6
|
|
|
@@ -159,6 +159,7 @@ tests/
|
|
|
159
159
|
stacks/
|
|
160
160
|
tanstack/{handlers,vite}.test.ts
|
|
161
161
|
supabase/{handler,emit,vite}.test.ts
|
|
162
|
+
supabase/authoring-template.test.ts # executes the App MCP authoring guides' factory (reads go/api/**, needs a monorepo checkout)
|
|
162
163
|
integration/ # boots an example app, hits live HTTP
|
|
163
164
|
global-setup.ts # spawns example/tanstack on :8080
|
|
164
165
|
tools.test.ts # non-OAuth example
|
|
@@ -173,7 +174,7 @@ pnpm format:check # oxfmt --check src/ tests/
|
|
|
173
174
|
pnpm lint # format:check + oxlint (one command, both surfaces)
|
|
174
175
|
pnpm lint:fix # format + oxlint --fix
|
|
175
176
|
pnpm typecheck # tsgo --noEmit
|
|
176
|
-
pnpm test # vitest run --project unit (fast
|
|
177
|
+
pnpm test # vitest run --project unit (fast; needs the monorepo checkout — authoring-template.test.ts reads go/api/**)
|
|
177
178
|
pnpm test:watch # vitest --project unit
|
|
178
179
|
pnpm test:integration:tanstack # build + install tanstack example + vitest --project integration
|
|
179
180
|
pnpm test:integration:tanstack:oauth # build + install OAuth example + vitest --project integration-oauth
|
package/README.md
CHANGED
|
@@ -171,6 +171,18 @@ construction (e.g. calling Supabase on the user's behalf); never return it from
|
|
|
171
171
|
tool or write it to logs. A leaked token stays valid at the authorization server
|
|
172
172
|
until it expires.
|
|
173
173
|
|
|
174
|
+
**Caller-visible errors.** Throwing `ToolError` from a handler returns an `isError` result carrying exactly its message, on both the MCP and REST surfaces — the same shape as returning `{ isError: true, content: [...] }`. Any other exception is redacted to a generic failure on the wire; its name and message appear only in the server's local `tool.invoked` log line (`errorText`), never in telemetry.
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
import { ToolError } from "@lovable.dev/mcp-js";
|
|
178
|
+
|
|
179
|
+
handler: async ({ id }, ctx) => {
|
|
180
|
+
const row = await findBook(ctx, id);
|
|
181
|
+
if (!row) throw new ToolError(`book ${id} not found`);
|
|
182
|
+
return { content: [{ type: "text", text: JSON.stringify(row) }] };
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
174
186
|
Use an OAuth access token from the configured authorization server for MCP calls. Plain app-session JWTs, such as Supabase tokens from `signInWithPassword`, carry neither `client_id` nor `azp`; the SDK rejects them by default so copied browser sessions do not pass as delegated OAuth client tokens. Set `requireOAuthClientClaim: false` only when intentionally accepting those session tokens and relying on app checks plus downstream RLS via the forwarded bearer token.
|
|
175
187
|
|
|
176
188
|
`auth.oauth.issuer(...)` fields:
|
|
@@ -16,8 +16,8 @@ interface InvocationRecord {
|
|
|
16
16
|
/** The app end-user that made the call (the access token `sub`), or
|
|
17
17
|
* `undefined` when the request is unauthenticated. Not a Lovable identity. */
|
|
18
18
|
endUserId?: string;
|
|
19
|
-
/**
|
|
20
|
-
* only — never sent to the collector
|
|
19
|
+
/** Caller-visible `isError` text (`tool_error`) or a bounded internal-exception
|
|
20
|
+
* summary (`handler_error`). Local log only — never sent to the collector. */
|
|
21
21
|
errorText?: string;
|
|
22
22
|
}
|
|
23
23
|
/** A per-request telemetry recorder. `emit` logs the invocation and sends it as a
|
|
@@ -16,8 +16,8 @@ interface InvocationRecord {
|
|
|
16
16
|
/** The app end-user that made the call (the access token `sub`), or
|
|
17
17
|
* `undefined` when the request is unauthenticated. Not a Lovable identity. */
|
|
18
18
|
endUserId?: string;
|
|
19
|
-
/**
|
|
20
|
-
* only — never sent to the collector
|
|
19
|
+
/** Caller-visible `isError` text (`tool_error`) or a bounded internal-exception
|
|
20
|
+
* summary (`handler_error`). Local log only — never sent to the collector. */
|
|
21
21
|
errorText?: string;
|
|
22
22
|
}
|
|
23
23
|
/** A per-request telemetry recorder. `emit` logs the invocation and sends it as a
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_package = require("../package-
|
|
3
|
-
const require_list_tools = require("../list-tools-
|
|
2
|
+
const require_package = require("../package-C1uEtkqq.cjs");
|
|
3
|
+
const require_list_tools = require("../list-tools-Ct6yJ_bo.cjs");
|
|
4
4
|
const require_fs_errors = require("../fs-errors-CWNzOV75.cjs");
|
|
5
5
|
let node_fs = require("node:fs");
|
|
6
6
|
let node_path = require("node:path");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as version } from "../package-
|
|
3
|
-
import { t as buildMcpListing } from "../list-tools-
|
|
2
|
+
import { t as version } from "../package-Aux8_a4B.js";
|
|
3
|
+
import { t as buildMcpListing } from "../list-tools-S2xzLisA.js";
|
|
4
4
|
import { t as isFileMissing } from "../fs-errors-PA2t1TIp.js";
|
|
5
5
|
import { lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, resolve } from "node:path";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_logger = require("./logger-BSKbuM66.cjs");
|
|
2
|
-
const require_package = require("./package-
|
|
2
|
+
const require_package = require("./package-C1uEtkqq.cjs");
|
|
3
3
|
require("./metadata-path-zd7NSNoa.cjs");
|
|
4
4
|
let jose = require("jose");
|
|
5
5
|
//#region src/core/http.ts
|
|
@@ -168,8 +168,9 @@ var BaseMetricRecorder = class {
|
|
|
168
168
|
}
|
|
169
169
|
headers.authorization = `Bearer ${key}`;
|
|
170
170
|
}
|
|
171
|
+
const { errorText: _localOnly, ...wireEvent } = ev;
|
|
171
172
|
const body = buildLogsPayload([{
|
|
172
|
-
...
|
|
173
|
+
...wireEvent,
|
|
173
174
|
timeUnixNano: nowUnixNano(),
|
|
174
175
|
stack: this.stack
|
|
175
176
|
}], this.server);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as log, n as applyLogLevelFromEnv, o as parseSafeUrl, r as describeError, s as trimTrailingSlash, t as LOG_LEVEL_ENV_VAR, u as resolveMetricsConfig } from "./logger-3-kwsF-5.js";
|
|
2
|
-
import { t as version } from "./package-
|
|
2
|
+
import { t as version } from "./package-Aux8_a4B.js";
|
|
3
3
|
import "./metadata-path-CAkNcfyY.js";
|
|
4
4
|
import { createLocalJWKSet, decodeProtectedHeader, jwtVerify } from "jose";
|
|
5
5
|
//#region src/core/http.ts
|
|
@@ -168,8 +168,9 @@ var BaseMetricRecorder = class {
|
|
|
168
168
|
}
|
|
169
169
|
headers.authorization = `Bearer ${key}`;
|
|
170
170
|
}
|
|
171
|
+
const { errorText: _localOnly, ...wireEvent } = ev;
|
|
171
172
|
const body = buildLogsPayload([{
|
|
172
|
-
...
|
|
173
|
+
...wireEvent,
|
|
173
174
|
timeUnixNano: nowUnixNano(),
|
|
174
175
|
stack: this.stack
|
|
175
176
|
}], this.server);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
//#region src/auth/context.ts
|
|
2
|
+
/**
|
|
3
|
+
* The auth surface passed to every tool handler as its second argument. It wraps
|
|
4
|
+
* the verified per-request auth context in a private field, so the context — and
|
|
5
|
+
* the bearer token inside it — can't be read, enumerated, spread, or
|
|
6
|
+
* `JSON.stringify`'d off the instance; the accessors below are the only way out.
|
|
7
|
+
* `getToken()` is the single intentional escape hatch for the raw bearer.
|
|
8
|
+
*/
|
|
9
|
+
var ToolContext = class {
|
|
10
|
+
#auth;
|
|
11
|
+
constructor(auth) {
|
|
12
|
+
this.#auth = auth;
|
|
13
|
+
}
|
|
14
|
+
/** Whether the in-flight tool call carries a verified auth context. */
|
|
15
|
+
isAuthenticated() {
|
|
16
|
+
return this.#auth !== void 0;
|
|
17
|
+
}
|
|
18
|
+
/** The verified bearer token, or `undefined` when unauthenticated. Pass it to downstream APIs; never return or log it. */
|
|
19
|
+
getToken() {
|
|
20
|
+
return this.#auth?.bearer.token;
|
|
21
|
+
}
|
|
22
|
+
/** The verified user id (the token `sub`), or `undefined`. */
|
|
23
|
+
getUserId() {
|
|
24
|
+
return this.#auth?.principal.sub;
|
|
25
|
+
}
|
|
26
|
+
/** The verified user email, or `undefined` when absent. */
|
|
27
|
+
getUserEmail() {
|
|
28
|
+
return this.#auth?.principal.email;
|
|
29
|
+
}
|
|
30
|
+
/** The verified OAuth `client_id`, or `undefined`. */
|
|
31
|
+
getClientId() {
|
|
32
|
+
return this.#auth?.principal.clientId;
|
|
33
|
+
}
|
|
34
|
+
/** The verified OAuth scopes, or `undefined` when unauthenticated. */
|
|
35
|
+
getScopes() {
|
|
36
|
+
return this.#auth?.principal.scopes;
|
|
37
|
+
}
|
|
38
|
+
/** The verified token issuer, or `undefined`. */
|
|
39
|
+
getIssuer() {
|
|
40
|
+
return this.#auth?.principal.issuer;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The full verified JWT claims, or `undefined`. Use this for app/business
|
|
44
|
+
* authorization on issuer-specific claims that have no dedicated accessor.
|
|
45
|
+
*/
|
|
46
|
+
getClaims() {
|
|
47
|
+
return this.#auth?.principal.claims;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/core/errors.ts
|
|
52
|
+
const TOOL_ERROR_BRAND = Symbol.for("@lovable.dev/mcp-js/tool-error");
|
|
53
|
+
/** Error whose message is meant for the remote MCP caller; thrown from a handler
|
|
54
|
+
* it becomes an `isError` result carrying exactly `message`. */
|
|
55
|
+
var ToolError = class extends Error {
|
|
56
|
+
constructor(message, options) {
|
|
57
|
+
super(message, options);
|
|
58
|
+
this.name = "ToolError";
|
|
59
|
+
Object.defineProperty(this, TOOL_ERROR_BRAND, { value: true });
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function isToolError(err) {
|
|
63
|
+
return err instanceof Error && Object.getOwnPropertyDescriptor(err, TOOL_ERROR_BRAND)?.value === true;
|
|
64
|
+
}
|
|
65
|
+
/** The caller-visible message of a thrown ToolError, or undefined for anything
|
|
66
|
+
* else — including when inspecting the value itself throws (fail closed). */
|
|
67
|
+
function resolveToolErrorMessage(err) {
|
|
68
|
+
try {
|
|
69
|
+
return isToolError(err) ? String(err.message) : void 0;
|
|
70
|
+
} catch {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const MAX_ERROR_SUMMARY = 500;
|
|
75
|
+
/** Bounded name+message line for local logs; never for wire responses. */
|
|
76
|
+
function errorSummary(err) {
|
|
77
|
+
try {
|
|
78
|
+
const text = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
|
|
79
|
+
return text.length > MAX_ERROR_SUMMARY ? `${text.slice(0, MAX_ERROR_SUMMARY)}…` : text;
|
|
80
|
+
} catch {
|
|
81
|
+
return "unprintable error";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
Object.defineProperty(exports, "ToolContext", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function() {
|
|
88
|
+
return ToolContext;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(exports, "ToolError", {
|
|
92
|
+
enumerable: true,
|
|
93
|
+
get: function() {
|
|
94
|
+
return ToolError;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, "errorSummary", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function() {
|
|
100
|
+
return errorSummary;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(exports, "resolveToolErrorMessage", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function() {
|
|
106
|
+
return resolveToolErrorMessage;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
@@ -48,9 +48,38 @@ var ToolContext = class {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
//#endregion
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
//#region src/core/errors.ts
|
|
52
|
+
const TOOL_ERROR_BRAND = Symbol.for("@lovable.dev/mcp-js/tool-error");
|
|
53
|
+
/** Error whose message is meant for the remote MCP caller; thrown from a handler
|
|
54
|
+
* it becomes an `isError` result carrying exactly `message`. */
|
|
55
|
+
var ToolError = class extends Error {
|
|
56
|
+
constructor(message, options) {
|
|
57
|
+
super(message, options);
|
|
58
|
+
this.name = "ToolError";
|
|
59
|
+
Object.defineProperty(this, TOOL_ERROR_BRAND, { value: true });
|
|
55
60
|
}
|
|
56
|
-
}
|
|
61
|
+
};
|
|
62
|
+
function isToolError(err) {
|
|
63
|
+
return err instanceof Error && Object.getOwnPropertyDescriptor(err, TOOL_ERROR_BRAND)?.value === true;
|
|
64
|
+
}
|
|
65
|
+
/** The caller-visible message of a thrown ToolError, or undefined for anything
|
|
66
|
+
* else — including when inspecting the value itself throws (fail closed). */
|
|
67
|
+
function resolveToolErrorMessage(err) {
|
|
68
|
+
try {
|
|
69
|
+
return isToolError(err) ? String(err.message) : void 0;
|
|
70
|
+
} catch {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const MAX_ERROR_SUMMARY = 500;
|
|
75
|
+
/** Bounded name+message line for local logs; never for wire responses. */
|
|
76
|
+
function errorSummary(err) {
|
|
77
|
+
try {
|
|
78
|
+
const text = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
|
|
79
|
+
return text.length > MAX_ERROR_SUMMARY ? `${text.slice(0, MAX_ERROR_SUMMARY)}…` : text;
|
|
80
|
+
} catch {
|
|
81
|
+
return "unprintable error";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { ToolContext as i, errorSummary as n, resolveToolErrorMessage as r, ToolError as t };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_logger = require("./logger-BSKbuM66.cjs");
|
|
3
|
-
const
|
|
3
|
+
const require_errors = require("./errors-CN6Da8iz.cjs");
|
|
4
4
|
//#region src/core/define.ts
|
|
5
5
|
function assertUniqueNames(mcp) {
|
|
6
6
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -142,7 +142,8 @@ function issuer(options) {
|
|
|
142
142
|
const oauth = Object.freeze({ issuer });
|
|
143
143
|
const auth = Object.freeze({ oauth });
|
|
144
144
|
//#endregion
|
|
145
|
-
exports.ToolContext =
|
|
145
|
+
exports.ToolContext = require_errors.ToolContext;
|
|
146
|
+
exports.ToolError = require_errors.ToolError;
|
|
146
147
|
exports.auth = auth;
|
|
147
148
|
exports.defineMcp = defineMcp;
|
|
148
149
|
exports.defineTool = defineTool;
|
package/dist/index.d.cts
CHANGED
|
@@ -54,6 +54,13 @@ declare const auth: Readonly<{
|
|
|
54
54
|
}>;
|
|
55
55
|
}>;
|
|
56
56
|
//#endregion
|
|
57
|
+
//#region src/core/errors.d.ts
|
|
58
|
+
/** Error whose message is meant for the remote MCP caller; thrown from a handler
|
|
59
|
+
* it becomes an `isError` result carrying exactly `message`. */
|
|
60
|
+
declare class ToolError extends Error {
|
|
61
|
+
constructor(message: string, options?: ErrorOptions);
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
57
64
|
//#region src/core/logger.d.ts
|
|
58
65
|
type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
59
66
|
/**
|
|
@@ -63,4 +70,4 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
|
63
70
|
*/
|
|
64
71
|
declare function setLogLevel(level: LogLevel): void;
|
|
65
72
|
//#endregion
|
|
66
|
-
export { type AudioContent, type ContentAnnotations, type ContentBlock, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JwtClaims, type LogLevel, type McpDefinitionInput, type MetricsConfig, type MetricsOptions, type ResourceLink, type ResourceLinkIcon, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, type ToolHandlerResult, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
|
|
73
|
+
export { type AudioContent, type ContentAnnotations, type ContentBlock, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JwtClaims, type LogLevel, type McpDefinitionInput, type MetricsConfig, type MetricsOptions, type ResourceLink, type ResourceLinkIcon, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,13 @@ declare const auth: Readonly<{
|
|
|
54
54
|
}>;
|
|
55
55
|
}>;
|
|
56
56
|
//#endregion
|
|
57
|
+
//#region src/core/errors.d.ts
|
|
58
|
+
/** Error whose message is meant for the remote MCP caller; thrown from a handler
|
|
59
|
+
* it becomes an `isError` result carrying exactly `message`. */
|
|
60
|
+
declare class ToolError extends Error {
|
|
61
|
+
constructor(message: string, options?: ErrorOptions);
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
57
64
|
//#region src/core/logger.d.ts
|
|
58
65
|
type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
59
66
|
/**
|
|
@@ -63,4 +70,4 @@ type LogLevel = "silent" | "error" | "warn" | "info" | "debug";
|
|
|
63
70
|
*/
|
|
64
71
|
declare function setLogLevel(level: LogLevel): void;
|
|
65
72
|
//#endregion
|
|
66
|
-
export { type AudioContent, type ContentAnnotations, type ContentBlock, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JwtClaims, type LogLevel, type McpDefinitionInput, type MetricsConfig, type MetricsOptions, type ResourceLink, type ResourceLinkIcon, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, type ToolHandlerResult, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
|
|
73
|
+
export { type AudioContent, type ContentAnnotations, type ContentBlock, type EmbeddedBlobResource, type EmbeddedResource, type EmbeddedTextResource, type ImageContent, type IssuerOAuthOptions, type JwtClaims, type LogLevel, type McpDefinitionInput, type MetricsConfig, type MetricsOptions, type ResourceLink, type ResourceLinkIcon, type TextContent, type ToolAnnotations, type ToolContent, ToolContext, type ToolDefinition, ToolError, type ToolHandlerResult, type ZodRawShape, type ZodSchema, auth, defineMcp, defineTool, setLogLevel };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as setLogLevel, o as parseSafeUrl, s as trimTrailingSlash, u as resolveMetricsConfig } from "./logger-3-kwsF-5.js";
|
|
2
|
-
import {
|
|
2
|
+
import { i as ToolContext, t as ToolError } from "./errors-DSe96Ffd.js";
|
|
3
3
|
//#region src/core/define.ts
|
|
4
4
|
function assertUniqueNames(mcp) {
|
|
5
5
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -141,4 +141,4 @@ function issuer(options) {
|
|
|
141
141
|
const oauth = Object.freeze({ issuer });
|
|
142
142
|
const auth = Object.freeze({ oauth });
|
|
143
143
|
//#endregion
|
|
144
|
-
export { ToolContext, auth, defineMcp, defineTool, setLogLevel };
|
|
144
|
+
export { ToolContext, ToolError, auth, defineMcp, defineTool, setLogLevel };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as McpDefinition } from "./types-C0Wgm9zp.js";
|
|
2
|
-
import { t as MetricsRecorder } from "./base-
|
|
2
|
+
import { t as MetricsRecorder } from "./base-CReh7d3E.js";
|
|
3
3
|
import { t as McpRuntimeOptions } from "./authorize-Y6Jm8GhR.js";
|
|
4
4
|
//#region src/protocols/rest/list-tools.d.ts
|
|
5
5
|
type RestListToolsHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_cors = require("./cors-
|
|
1
|
+
const require_cors = require("./cors-B79id9hu.cjs");
|
|
2
2
|
let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
|
|
3
3
|
let _modelcontextprotocol_sdk_server_zod_json_schema_compat_js = require("@modelcontextprotocol/sdk/server/zod-json-schema-compat.js");
|
|
4
4
|
//#region src/protocols/rest/list-tools.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as McpDefinition } from "./types-C0Wgm9zp.cjs";
|
|
2
|
-
import { t as MetricsRecorder } from "./base-
|
|
2
|
+
import { t as MetricsRecorder } from "./base-CReh7d3E.cjs";
|
|
3
3
|
import { t as McpRuntimeOptions } from "./authorize-D3zzoTAG.cjs";
|
|
4
4
|
//#region src/protocols/rest/list-tools.d.ts
|
|
5
5
|
type RestListToolsHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as createRequestAuthorizer, m as methodNotAllowed, n as withCors, p as headResponse, r as assertRestResourceBinding, t as corsPreflightResponse, u as createNoopRecorder } from "./cors-
|
|
1
|
+
import { i as createRequestAuthorizer, m as methodNotAllowed, n as withCors, p as headResponse, r as assertRestResourceBinding, t as corsPreflightResponse, u as createNoopRecorder } from "./cors-DlHHW20_.js";
|
|
2
2
|
import { objectFromShape } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
3
3
|
import { toJsonSchemaCompat } from "@modelcontextprotocol/sdk/server/zod-json-schema-compat.js";
|
|
4
4
|
//#region src/protocols/rest/list-tools.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as log, r as describeError } from "./logger-3-kwsF-5.js";
|
|
2
|
-
import {
|
|
3
|
-
import { d as nowMs, i as createRequestAuthorizer, n as withCors, t as corsPreflightResponse, u as createNoopRecorder } from "./cors-
|
|
2
|
+
import { i as ToolContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-DSe96Ffd.js";
|
|
3
|
+
import { d as nowMs, i as createRequestAuthorizer, n as withCors, t as corsPreflightResponse, u as createNoopRecorder } from "./cors-DlHHW20_.js";
|
|
4
4
|
import { t as extractTextContent } from "./content-D5LJAHyM.js";
|
|
5
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
6
|
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
|
|
@@ -17,18 +17,29 @@ function adaptToolToSdkCallback(tool, auth, recorder) {
|
|
|
17
17
|
let result;
|
|
18
18
|
try {
|
|
19
19
|
result = await tool.handler(args, new ToolContext(auth));
|
|
20
|
-
} catch {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
} catch (err) {
|
|
21
|
+
const callerMessage = resolveToolErrorMessage(err);
|
|
22
|
+
if (callerMessage === void 0) {
|
|
23
|
+
await recorder.emit({
|
|
24
|
+
tool: tool.name,
|
|
25
|
+
method: "tools/call",
|
|
26
|
+
outcome: "handler_error",
|
|
27
|
+
durationMs: nowMs() - start,
|
|
28
|
+
errorText: errorSummary(err),
|
|
29
|
+
endUserId
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
content: [{
|
|
33
|
+
type: "text",
|
|
34
|
+
text: "tool execution failed"
|
|
35
|
+
}],
|
|
36
|
+
isError: true
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
result = {
|
|
29
40
|
content: [{
|
|
30
41
|
type: "text",
|
|
31
|
-
text:
|
|
42
|
+
text: callerMessage
|
|
32
43
|
}],
|
|
33
44
|
isError: true
|
|
34
45
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_logger = require("./logger-BSKbuM66.cjs");
|
|
2
|
-
const
|
|
3
|
-
const require_cors = require("./cors-
|
|
2
|
+
const require_errors = require("./errors-CN6Da8iz.cjs");
|
|
3
|
+
const require_cors = require("./cors-B79id9hu.cjs");
|
|
4
4
|
const require_content = require("./content-NCYIGgOb.cjs");
|
|
5
5
|
let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
6
6
|
let _modelcontextprotocol_sdk_server_webStandardStreamableHttp_js = require("@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js");
|
|
@@ -16,19 +16,30 @@ function adaptToolToSdkCallback(tool, auth, recorder) {
|
|
|
16
16
|
const start = require_cors.nowMs();
|
|
17
17
|
let result;
|
|
18
18
|
try {
|
|
19
|
-
result = await tool.handler(args, new
|
|
20
|
-
} catch {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
result = await tool.handler(args, new require_errors.ToolContext(auth));
|
|
20
|
+
} catch (err) {
|
|
21
|
+
const callerMessage = require_errors.resolveToolErrorMessage(err);
|
|
22
|
+
if (callerMessage === void 0) {
|
|
23
|
+
await recorder.emit({
|
|
24
|
+
tool: tool.name,
|
|
25
|
+
method: "tools/call",
|
|
26
|
+
outcome: "handler_error",
|
|
27
|
+
durationMs: require_cors.nowMs() - start,
|
|
28
|
+
errorText: require_errors.errorSummary(err),
|
|
29
|
+
endUserId
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
content: [{
|
|
33
|
+
type: "text",
|
|
34
|
+
text: "tool execution failed"
|
|
35
|
+
}],
|
|
36
|
+
isError: true
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
result = {
|
|
29
40
|
content: [{
|
|
30
41
|
type: "text",
|
|
31
|
-
text:
|
|
42
|
+
text: callerMessage
|
|
32
43
|
}],
|
|
33
44
|
isError: true
|
|
34
45
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as McpDefinition } from "../../types-C0Wgm9zp.cjs";
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-CReh7d3E.cjs";
|
|
3
3
|
import { t as McpRuntimeOptions } from "../../authorize-D3zzoTAG.cjs";
|
|
4
4
|
//#region src/protocols/mcp/protocol.d.ts
|
|
5
5
|
type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as McpDefinition } from "../../types-C0Wgm9zp.js";
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-CReh7d3E.js";
|
|
3
3
|
import { t as McpRuntimeOptions } from "../../authorize-Y6Jm8GhR.js";
|
|
4
4
|
//#region src/protocols/mcp/protocol.d.ts
|
|
5
5
|
type McpProtocolHandler = (request: Request, recorder?: MetricsRecorder) => Promise<Response>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { t as createMcpProtocolHandler } from "../../mcp-BUR5KIhL.js";
|
|
2
2
|
export { createMcpProtocolHandler };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_logger = require("../logger-BSKbuM66.cjs");
|
|
3
|
-
const require_cors = require("../cors-
|
|
3
|
+
const require_cors = require("../cors-B79id9hu.cjs");
|
|
4
4
|
//#region src/protocols/oauth-metadata.ts
|
|
5
5
|
function notFound() {
|
|
6
6
|
return require_cors.withCors(new Response(JSON.stringify({ error: "not found" }), {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as log, r as describeError } from "../logger-3-kwsF-5.js";
|
|
2
|
-
import { a as getOAuthRuntime, c as resolveProtectedResource, f as JSON_HEADERS, m as methodNotAllowed, n as withCors, o as oauthConfigurationErrorResponse, p as headResponse, t as corsPreflightResponse } from "../cors-
|
|
2
|
+
import { a as getOAuthRuntime, c as resolveProtectedResource, f as JSON_HEADERS, m as methodNotAllowed, n as withCors, o as oauthConfigurationErrorResponse, p as headResponse, t as corsPreflightResponse } from "../cors-DlHHW20_.js";
|
|
3
3
|
//#region src/protocols/oauth-metadata.ts
|
|
4
4
|
function notFound() {
|
|
5
5
|
return withCors(new Response(JSON.stringify({ error: "not found" }), {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_list_tools = require("../../list-tools-
|
|
3
|
-
const require_rest = require("../../rest-
|
|
2
|
+
const require_list_tools = require("../../list-tools-Ct6yJ_bo.cjs");
|
|
3
|
+
const require_rest = require("../../rest-DWrrqgYf.cjs");
|
|
4
4
|
exports.createInvokeToolHandler = require_rest.createInvokeToolHandler;
|
|
5
5
|
exports.createListToolsHandler = require_list_tools.createListToolsHandler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as McpDefinition } from "../../types-C0Wgm9zp.cjs";
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-CReh7d3E.cjs";
|
|
3
3
|
import { t as McpRuntimeOptions } from "../../authorize-D3zzoTAG.cjs";
|
|
4
|
-
import { n as createListToolsHandler, t as RestListToolsHandler } from "../../list-tools-
|
|
4
|
+
import { n as createListToolsHandler, t as RestListToolsHandler } from "../../list-tools-DOBMd4AE.cjs";
|
|
5
5
|
//#region src/protocols/rest/invoke-tool.d.ts
|
|
6
6
|
type RestInvokeToolHandler = (request: Request, toolName: string, recorder?: MetricsRecorder) => Promise<Response>;
|
|
7
7
|
declare function createInvokeToolHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestInvokeToolHandler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as McpDefinition } from "../../types-C0Wgm9zp.js";
|
|
2
|
-
import { t as MetricsRecorder } from "../../base-
|
|
2
|
+
import { t as MetricsRecorder } from "../../base-CReh7d3E.js";
|
|
3
3
|
import { t as McpRuntimeOptions } from "../../authorize-Y6Jm8GhR.js";
|
|
4
|
-
import { n as createListToolsHandler, t as RestListToolsHandler } from "../../list-tools-
|
|
4
|
+
import { n as createListToolsHandler, t as RestListToolsHandler } from "../../list-tools-C6u8G4iq.js";
|
|
5
5
|
//#region src/protocols/rest/invoke-tool.d.ts
|
|
6
6
|
type RestInvokeToolHandler = (request: Request, toolName: string, recorder?: MetricsRecorder) => Promise<Response>;
|
|
7
7
|
declare function createInvokeToolHandler(mcp: McpDefinition, options?: McpRuntimeOptions): RestInvokeToolHandler;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as createListToolsHandler } from "../../list-tools-
|
|
2
|
-
import { t as createInvokeToolHandler } from "../../rest-
|
|
1
|
+
import { n as createListToolsHandler } from "../../list-tools-S2xzLisA.js";
|
|
2
|
+
import { t as createInvokeToolHandler } from "../../rest-xOYdRom7.js";
|
|
3
3
|
export { createInvokeToolHandler, createListToolsHandler };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_cors = require("./cors-
|
|
1
|
+
const require_errors = require("./errors-CN6Da8iz.cjs");
|
|
2
|
+
const require_cors = require("./cors-B79id9hu.cjs");
|
|
3
3
|
const require_content = require("./content-NCYIGgOb.cjs");
|
|
4
|
-
require("./list-tools-
|
|
4
|
+
require("./list-tools-Ct6yJ_bo.cjs");
|
|
5
5
|
let _modelcontextprotocol_sdk_server_zod_compat_js = require("@modelcontextprotocol/sdk/server/zod-compat.js");
|
|
6
6
|
//#region src/protocols/rest/invoke-tool.ts
|
|
7
7
|
const MAX_REFLECTED_TOOL_NAME = 256;
|
|
@@ -64,22 +64,33 @@ function createInvokeToolHandler(mcp, options = {}) {
|
|
|
64
64
|
let result;
|
|
65
65
|
const start = require_cors.nowMs();
|
|
66
66
|
try {
|
|
67
|
-
result = await tool.handler(args, new
|
|
68
|
-
} catch {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
67
|
+
result = await tool.handler(args, new require_errors.ToolContext(authResult.auth));
|
|
68
|
+
} catch (err) {
|
|
69
|
+
const callerMessage = require_errors.resolveToolErrorMessage(err);
|
|
70
|
+
if (callerMessage === void 0) {
|
|
71
|
+
await recorder.emit({
|
|
72
|
+
tool: tool.name,
|
|
73
|
+
method: "tools/call",
|
|
74
|
+
outcome: "handler_error",
|
|
75
|
+
durationMs: require_cors.nowMs() - start,
|
|
76
|
+
errorText: require_errors.errorSummary(err),
|
|
77
|
+
endUserId
|
|
78
|
+
});
|
|
79
|
+
return new Response(JSON.stringify({
|
|
80
|
+
error: "handler threw",
|
|
81
|
+
tool: toolName
|
|
82
|
+
}), {
|
|
83
|
+
status: 500,
|
|
84
|
+
headers: require_cors.JSON_HEADERS
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
result = {
|
|
88
|
+
content: [{
|
|
89
|
+
type: "text",
|
|
90
|
+
text: callerMessage
|
|
91
|
+
}],
|
|
92
|
+
isError: true
|
|
93
|
+
};
|
|
83
94
|
}
|
|
84
95
|
if (result == null) {
|
|
85
96
|
await recorder.emit({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
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-
|
|
1
|
+
import { i as ToolContext, n as errorSummary, r as resolveToolErrorMessage } from "./errors-DSe96Ffd.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-DlHHW20_.js";
|
|
3
3
|
import { t as extractTextContent } from "./content-D5LJAHyM.js";
|
|
4
|
-
import "./list-tools-
|
|
4
|
+
import "./list-tools-S2xzLisA.js";
|
|
5
5
|
import { getParseErrorMessage, objectFromShape, safeParseAsync } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
6
6
|
//#region src/protocols/rest/invoke-tool.ts
|
|
7
7
|
const MAX_REFLECTED_TOOL_NAME = 256;
|
|
@@ -65,21 +65,32 @@ function createInvokeToolHandler(mcp, options = {}) {
|
|
|
65
65
|
const start = nowMs();
|
|
66
66
|
try {
|
|
67
67
|
result = await tool.handler(args, new ToolContext(authResult.auth));
|
|
68
|
-
} catch {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
} catch (err) {
|
|
69
|
+
const callerMessage = resolveToolErrorMessage(err);
|
|
70
|
+
if (callerMessage === void 0) {
|
|
71
|
+
await recorder.emit({
|
|
72
|
+
tool: tool.name,
|
|
73
|
+
method: "tools/call",
|
|
74
|
+
outcome: "handler_error",
|
|
75
|
+
durationMs: nowMs() - start,
|
|
76
|
+
errorText: errorSummary(err),
|
|
77
|
+
endUserId
|
|
78
|
+
});
|
|
79
|
+
return new Response(JSON.stringify({
|
|
80
|
+
error: "handler threw",
|
|
81
|
+
tool: toolName
|
|
82
|
+
}), {
|
|
83
|
+
status: 500,
|
|
84
|
+
headers: JSON_HEADERS
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
result = {
|
|
88
|
+
content: [{
|
|
89
|
+
type: "text",
|
|
90
|
+
text: callerMessage
|
|
91
|
+
}],
|
|
92
|
+
isError: true
|
|
93
|
+
};
|
|
83
94
|
}
|
|
84
95
|
if (result == null) {
|
|
85
96
|
await recorder.emit({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_logger = require("../../logger-BSKbuM66.cjs");
|
|
3
|
-
const require_cors = require("../../cors-
|
|
3
|
+
const require_cors = require("../../cors-B79id9hu.cjs");
|
|
4
4
|
const require_metadata_path = require("../../metadata-path-zd7NSNoa.cjs");
|
|
5
|
-
const require_mcp = require("../../mcp-
|
|
5
|
+
const require_mcp = require("../../mcp-DNz7KIy4.cjs");
|
|
6
6
|
const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
|
|
7
|
-
const require_list_tools = require("../../list-tools-
|
|
8
|
-
const require_rest = require("../../rest-
|
|
7
|
+
const require_list_tools = require("../../list-tools-Ct6yJ_bo.cjs");
|
|
8
|
+
const require_rest = require("../../rest-DWrrqgYf.cjs");
|
|
9
9
|
const require_forwarded = require("../../forwarded-Pi8Hs5Ps.cjs");
|
|
10
10
|
const require_paths = require("../../paths-OP318a6c.cjs");
|
|
11
11
|
//#region src/stacks/supabase/handler.ts
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { s as trimTrailingSlash } from "../../logger-3-kwsF-5.js";
|
|
2
|
-
import { l as createRecorderForRuntime, s as assertResourcePathShape } from "../../cors-
|
|
2
|
+
import { l as createRecorderForRuntime, s as assertResourcePathShape } from "../../cors-DlHHW20_.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-BUR5KIhL.js";
|
|
5
5
|
import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
|
|
6
|
-
import { n as createListToolsHandler } from "../../list-tools-
|
|
7
|
-
import { t as createInvokeToolHandler } from "../../rest-
|
|
6
|
+
import { n as createListToolsHandler } from "../../list-tools-S2xzLisA.js";
|
|
7
|
+
import { t as createInvokeToolHandler } from "../../rest-xOYdRom7.js";
|
|
8
8
|
import { t as applyForwardedOrigin } from "../../forwarded--h4efJy-.js";
|
|
9
9
|
import { n as assertFunctionName, t as FUNCTIONS_MOUNT_PREFIX } from "../../paths-IS65L6TA.js";
|
|
10
10
|
//#region src/stacks/supabase/handler.ts
|
|
@@ -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-C1uEtkqq.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-Aux8_a4B.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,9 @@
|
|
|
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-B79id9hu.cjs");
|
|
3
|
+
const require_mcp = require("../../mcp-DNz7KIy4.cjs");
|
|
4
4
|
const require_protocols_oauth_metadata = require("../../protocols/oauth-metadata.cjs");
|
|
5
|
-
const require_list_tools = require("../../list-tools-
|
|
6
|
-
const require_rest = require("../../rest-
|
|
5
|
+
const require_list_tools = require("../../list-tools-Ct6yJ_bo.cjs");
|
|
6
|
+
const require_rest = require("../../rest-DWrrqgYf.cjs");
|
|
7
7
|
const require_forwarded = require("../../forwarded-Pi8Hs5Ps.cjs");
|
|
8
8
|
//#region src/stacks/tanstack/handlers.ts
|
|
9
9
|
const STACK = "tanstack";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { l as createRecorderForRuntime } from "../../cors-
|
|
2
|
-
import { t as createMcpProtocolHandler } from "../../mcp-
|
|
1
|
+
import { l as createRecorderForRuntime } from "../../cors-DlHHW20_.js";
|
|
2
|
+
import { t as createMcpProtocolHandler } from "../../mcp-BUR5KIhL.js";
|
|
3
3
|
import { createOAuthProtectedResourceMetadataHandler } from "../../protocols/oauth-metadata.js";
|
|
4
|
-
import { n as createListToolsHandler } from "../../list-tools-
|
|
5
|
-
import { t as createInvokeToolHandler } from "../../rest-
|
|
4
|
+
import { n as createListToolsHandler } from "../../list-tools-S2xzLisA.js";
|
|
5
|
+
import { t as createInvokeToolHandler } from "../../rest-xOYdRom7.js";
|
|
6
6
|
import { t as applyForwardedOrigin } from "../../forwarded--h4efJy-.js";
|
|
7
7
|
//#region src/stacks/tanstack/handlers.ts
|
|
8
8
|
const STACK = "tanstack";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovable.dev/mcp-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Author MCP servers for Lovable apps. Declare tools with defineTool, register them in defineMcp, and a framework adapter (TanStack or Supabase Edge Functions) emits the route(s) at build time.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
package/dist/context-CIpPzN7P.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//#region src/auth/context.ts
|
|
2
|
-
/**
|
|
3
|
-
* The auth surface passed to every tool handler as its second argument. It wraps
|
|
4
|
-
* the verified per-request auth context in a private field, so the context — and
|
|
5
|
-
* the bearer token inside it — can't be read, enumerated, spread, or
|
|
6
|
-
* `JSON.stringify`'d off the instance; the accessors below are the only way out.
|
|
7
|
-
* `getToken()` is the single intentional escape hatch for the raw bearer.
|
|
8
|
-
*/
|
|
9
|
-
var ToolContext = class {
|
|
10
|
-
#auth;
|
|
11
|
-
constructor(auth) {
|
|
12
|
-
this.#auth = auth;
|
|
13
|
-
}
|
|
14
|
-
/** Whether the in-flight tool call carries a verified auth context. */
|
|
15
|
-
isAuthenticated() {
|
|
16
|
-
return this.#auth !== void 0;
|
|
17
|
-
}
|
|
18
|
-
/** The verified bearer token, or `undefined` when unauthenticated. Pass it to downstream APIs; never return or log it. */
|
|
19
|
-
getToken() {
|
|
20
|
-
return this.#auth?.bearer.token;
|
|
21
|
-
}
|
|
22
|
-
/** The verified user id (the token `sub`), or `undefined`. */
|
|
23
|
-
getUserId() {
|
|
24
|
-
return this.#auth?.principal.sub;
|
|
25
|
-
}
|
|
26
|
-
/** The verified user email, or `undefined` when absent. */
|
|
27
|
-
getUserEmail() {
|
|
28
|
-
return this.#auth?.principal.email;
|
|
29
|
-
}
|
|
30
|
-
/** The verified OAuth `client_id`, or `undefined`. */
|
|
31
|
-
getClientId() {
|
|
32
|
-
return this.#auth?.principal.clientId;
|
|
33
|
-
}
|
|
34
|
-
/** The verified OAuth scopes, or `undefined` when unauthenticated. */
|
|
35
|
-
getScopes() {
|
|
36
|
-
return this.#auth?.principal.scopes;
|
|
37
|
-
}
|
|
38
|
-
/** The verified token issuer, or `undefined`. */
|
|
39
|
-
getIssuer() {
|
|
40
|
-
return this.#auth?.principal.issuer;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The full verified JWT claims, or `undefined`. Use this for app/business
|
|
44
|
-
* authorization on issuer-specific claims that have no dedicated accessor.
|
|
45
|
-
*/
|
|
46
|
-
getClaims() {
|
|
47
|
-
return this.#auth?.principal.claims;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
51
|
-
export { ToolContext as t };
|