@lovable.dev/mcp-js 4.0.0-rc.0 → 4.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -1
- package/dist/{authorize-Chb9Sb1f.d.ts → authorize-8crkySbp.d.ts} +1 -1
- package/dist/{authorize-Ba1deW5O.d.cts → authorize-BZdUmD37.d.cts} +1 -1
- package/dist/{base-D7ei8TjY.d.cts → base-CChLZaEN.d.cts} +1 -1
- package/dist/{base-D-lvtqSA.d.ts → base-DQPu0cno.d.ts} +1 -1
- package/dist/cli/check-server.cjs +61 -0
- package/dist/cli/check-server.d.cts +1 -0
- package/dist/cli/check-server.d.ts +1 -0
- package/dist/cli/check-server.js +62 -0
- package/dist/cli/extract-manifest.cjs +1 -1
- package/dist/cli/extract-manifest.js +1 -1
- package/dist/{cors-BuPvEjxu.cjs → cors-Ct-kdMcl.cjs} +1 -1
- package/dist/{cors-D9LajKfo.js → cors-Ct8SFh-_.js} +1 -1
- package/dist/diagnostic-ClI2_5MW.js +11 -0
- package/dist/diagnostic-DRKjgCsW.d.cts +12 -0
- package/dist/diagnostic-DRKjgCsW.d.ts +12 -0
- package/dist/diagnostic-ol9IE9Dl.cjs +16 -0
- package/dist/{errors-BEl2IOnx.js → errors-Cul5Uyfw.js} +3 -2
- package/dist/{errors-BlSu6Nrn.cjs → errors-ebgNFNvm.cjs} +3 -2
- package/dist/format-DDzvc92Z.cjs +41 -0
- package/dist/format-DKEuO8Tn.js +30 -0
- package/dist/hooks-BOdDe251.js +353 -0
- package/dist/hooks-xQl3EkDa.cjs +382 -0
- 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-B72X5KDG.d.ts → io-4N9Hcw0w.d.ts} +1 -1
- package/dist/{io-foChTR9t.d.cts → io-Be8y8E2V.d.cts} +1 -1
- package/dist/{io-BpxqVag8.cjs → io-Bf4Narx6.cjs} +17 -5
- package/dist/{io-DFsll31O.js → io-VMIaguRH.js} +14 -2
- package/dist/{mcp-DMMqfwKm.cjs → mcp-By6C2M4i.cjs} +156 -70
- package/dist/{mcp-B1wBn_X-.js → mcp-DWxIy07i.js} +154 -68
- package/dist/{package-Bt33FsvP.cjs → package-CBMX__7C.cjs} +1 -1
- package/dist/{package-BWLBCBmc.js → package-Ci4yKJUI.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 +1 -1
- package/dist/protocols/oauth-metadata.d.cts +3 -3
- package/dist/protocols/oauth-metadata.d.ts +3 -3
- package/dist/protocols/oauth-metadata.js +1 -1
- package/dist/stacks/supabase/index.cjs +2 -2
- package/dist/stacks/supabase/index.d.cts +1 -1
- package/dist/stacks/supabase/index.d.ts +1 -1
- package/dist/stacks/supabase/index.js +2 -2
- package/dist/stacks/supabase/vite.cjs +40 -19
- package/dist/stacks/supabase/vite.d.cts +1 -1
- package/dist/stacks/supabase/vite.d.ts +1 -1
- package/dist/stacks/supabase/vite.js +34 -13
- package/dist/stacks/tanstack/index.cjs +2 -2
- package/dist/stacks/tanstack/index.d.cts +2 -2
- package/dist/stacks/tanstack/index.d.ts +2 -2
- package/dist/stacks/tanstack/index.js +2 -2
- package/dist/stacks/tanstack/vite.cjs +33 -25
- package/dist/stacks/tanstack/vite.d.cts +1 -1
- package/dist/stacks/tanstack/vite.d.ts +1 -1
- package/dist/stacks/tanstack/vite.js +26 -18
- package/dist/testing/index.cjs +46 -0
- package/dist/testing/index.d.cts +10 -0
- package/dist/testing/index.d.ts +10 -0
- package/dist/testing/index.js +44 -0
- package/dist/testing/server.cjs +197 -0
- package/dist/testing/server.d.cts +31 -0
- package/dist/testing/server.d.ts +31 -0
- package/dist/testing/server.js +195 -0
- package/dist/tool-result-teeTDoM1.js +70 -0
- package/dist/tool-result-yqOfZUOP.cjs +87 -0
- package/dist/{types-srTXYLoX.d.cts → types-CyDJi9Jb.d.cts} +7 -1
- package/dist/{types-srTXYLoX.d.ts → types-CyDJi9Jb.d.ts} +7 -1
- package/package.json +40 -4
- package/skill-imports.d.cts +1 -0
- package/skill-imports.d.ts +11 -0
- package/dist/fs-errors-CWNzOV75.cjs +0 -11
- package/dist/fs-errors-PA2t1TIp.js +0 -6
- package/dist/supabase-config-CakTU8YF.js +0 -26
- package/dist/supabase-config-Dz7dnUv0.cjs +0 -31
package/README.md
CHANGED
|
@@ -44,6 +44,48 @@ Manifest extraction allows **512 tools** in the evaluated `defineMcp({ tools })`
|
|
|
44
44
|
|
|
45
45
|
`inputSchema` is closed: a `tools/call` carrying an argument key the schema does not declare fails in-band (`isError: true`, naming the key) instead of silently dropping it, and `tools/list` advertises `additionalProperties: false`. Set `strict: false` on a tool to accept and drop unknown keys instead.
|
|
46
46
|
|
|
47
|
+
## Task workflows as skills
|
|
48
|
+
|
|
49
|
+
**Experimental:** Skills support follows the developing [MCP Skills extension](https://modelcontextprotocol.io/extensions/skills). Client support varies, and the integration may change as the specification evolves.
|
|
50
|
+
|
|
51
|
+
Keep shared terminology and server-wide rules in `instructions`, individual tool contracts in tool descriptions, and task procedures in [Agent Skills](https://agentskills.io/specification). Import a dedicated skill directory and pass it in `defineMcp({ skills: [refunds] })`:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import refunds from "./skills/refunds?skill";
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Add `/// <reference types="@lovable.dev/mcp-js/skill-imports" />` to an included `.d.ts` file. Imports use relative or absolute directory paths, not aliases. Both stack plugins and the manifest extractor compile these imports; the deployed server needs no source directory or filesystem access. Imported values have the opaque `Skill` type: pass them to `defineMcp`, rather than constructing or inspecting compiled manifests. Each directory needs `SKILL.md` with valid YAML `name` and `description`; `name` must match its directory. All JSON-compatible frontmatter fields are preserved. Supporting files must be UTF-8 text. Binary content, ASCII controls other than tab/CR/LF (including DEL), symlinks, cycles and metadata that cannot survive JSON serialization fail the build. Text scripts can be included, but the SDK neither installs nor executes them.
|
|
58
|
+
|
|
59
|
+
**Every ordinary file beneath an imported directory is published recursively.** Hidden entries (a dot-prefixed path segment) fail the build unless each file is explicitly allowlisted on that import:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import refunds from "./skills/refunds?allowHidden=templates/.prettierrc&allowHidden=.config/example.json&skill";
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Repeat `allowHidden` for each exact, case-sensitive file path relative to the skill directory. Directory-wide grants, globs, traversal paths, duplicate entries and entries that do not name an existing file are rejected. A hidden directory is traversed only for listed descendants; every file beneath it needs its own entry. An empty hidden directory fails too. Allowed files still pass the text-only and symlink checks. Combine `allowHidden` with `path` in either order, keeping `skill` last; percent-encode reserved characters in values (for example `%26` for `&` and `%25` for `%`).
|
|
66
|
+
|
|
67
|
+
Use dedicated publication directories without credentials or private documents. The allowlist prevents accidental hidden-file publication, not secrets in ordinary or explicitly approved files. Files use the same server-level OAuth and origin policy as tools; conditional tool permissions do not hide skills or their contents.
|
|
68
|
+
|
|
69
|
+
By default, `./skills/refunds?skill` publishes `skill://refunds/SKILL.md` and its supporting files. Use root-relative file references such as `references/rules.md` inside a skill. Reference a different skill with its complete URI; the host resolves it through `skills/get` and its skill-loading path. Reading `SKILL.md` as an ordinary resource does not activate it.
|
|
70
|
+
|
|
71
|
+
An explicit path supports namespacing and nested skills:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import refunds from "./skills/refunds?path=acme/refunds&skill";
|
|
75
|
+
import escalation from "./skills/refunds/escalation?path=acme/refunds/escalation&skill";
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Register both imports to list both skills. Keep a nested import's path consistent with its enclosing skill so shared files have one URI. Nested directories remain supporting content unless separately registered. The last path segment must match the skill's name; duplicate names at distinct URIs are allowed. URI collisions with different content fail. Paths are encoded per segment, so Unicode supporting filenames are preserved.
|
|
79
|
+
|
|
80
|
+
The server advertises the [Skills extension](https://modelcontextprotocol.io/extensions/skills), implements `skills/list` and `skills/get`, and serves complete manifests and byte-exact files through MCP resources. Client support is evolving; consult the official page for current implementations.
|
|
81
|
+
|
|
82
|
+
| Client declaration | Server instructions |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| Declares `io.modelcontextprotocol/skills` | Authored instructions plus names, descriptions and URIs; the host loads skills on demand. |
|
|
85
|
+
| No declaration | Authored instructions plus a deterministic, URI-labelled copy of every included text file. |
|
|
86
|
+
|
|
87
|
+
Fallback is reference text, not installation, execution or a permission grant. It preserves source text rather than summarizing it or rewriting links. A capable client that omits the declaration can receive both representations, even if its native skill loader is disabled. Host context limits still apply: the SDK does not truncate instructions or guarantee that a host will retain them. Build output lists published file sizes; the standard recommends at most 512 files and 16 MiB per skill, and fallback instructions should be substantially smaller for practical model context. Omit `skills` to retain existing tools-only behavior.
|
|
88
|
+
|
|
47
89
|
## Upgrade to 4.x without migrating app forms
|
|
48
90
|
|
|
49
91
|
MCP schemas must use Zod 4 Classic (`zod/v4`) or Mini (`zod/v4-mini`). The peer
|
|
@@ -340,6 +382,64 @@ The request-derived `resource` default trusts the incoming `Host` to name this s
|
|
|
340
382
|
|
|
341
383
|
Use `auth.oauth.issuer(...)`, set `resource` or `acceptedAudiences` to anchor the accepted audience, and optionally set `jwksUri` and `requiredScopes`. For Supabase project auth, set `acceptedAudiences: "authenticated"`, keep app/business checks in app code, and forward `ctx.getToken()` to Supabase for RLS-backed data access.
|
|
342
384
|
|
|
385
|
+
## Testing
|
|
386
|
+
|
|
387
|
+
Test an MCP server in three layers:
|
|
388
|
+
|
|
389
|
+
1. **Business and persistence logic.** Keep it in ordinary functions and services and test it with your usual runner. No MCP is involved.
|
|
390
|
+
2. **Tool results.** Assert a result directly with `assertToolResult` from `@lovable.dev/mcp-js/testing`.
|
|
391
|
+
3. **The endpoint.** Connect a real MCP client to an in-process handler or a URL with `@lovable.dev/mcp-js/testing/server` or the `lovable-mcp-check` CLI.
|
|
392
|
+
|
|
393
|
+
Browser and UI testing are not covered.
|
|
394
|
+
|
|
395
|
+
```ts
|
|
396
|
+
import { assertToolResult } from "@lovable.dev/mcp-js/testing";
|
|
397
|
+
|
|
398
|
+
await assertToolResult(result, { outputSchema }); // expects success by default
|
|
399
|
+
await assertToolResult(failed, { isError: true });
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
A failed assertion throws `McpCheckError` with a fixed, value-free diagnostic. This assertion accepts package handler conveniences such as omitted content; it is not a raw-wire validator.
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
import assert from "node:assert/strict";
|
|
406
|
+
import { checkMcpServer, withMcpClient } from "@lovable.dev/mcp-js/testing/server";
|
|
407
|
+
|
|
408
|
+
// In process: the callback receives the official MCP SDK Client.
|
|
409
|
+
await withMcpClient({ endpoint: "http://localhost/mcp", handler }, async (client) => {
|
|
410
|
+
const result = await client.callTool({ name: "echo", arguments: { text: "hi" } });
|
|
411
|
+
assert.deepEqual(result.content, [{ type: "text", text: "hi" }]);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
// Discovery plus explicit calls; returns { checks, passed }.
|
|
415
|
+
const report = await checkMcpServer({
|
|
416
|
+
endpoint: "https://my-app.lovable.app/mcp",
|
|
417
|
+
headers: { authorization: `Bearer ${process.env.MCP_TOKEN}` },
|
|
418
|
+
calls: [{ name: "echo", arguments: { text: "hi" } }, { name: "echo", arguments: {}, isError: true }],
|
|
419
|
+
});
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
pnpm exec lovable-mcp-check --url https://my-app.lovable.app/mcp --bearer-env MCP_TOKEN --calls calls.json
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
`calls.json` holds the same `calls` array. Both entry points accept `protocolVersion` (`--protocol`): `2026-07-28` (default) or `2025-11-25`. `timeoutMs` (`--timeout`) bounds HTTP requests and checker operations, not the whole run, and defaults to 10 seconds. Inside `withMcpClient`, use the SDK's request options to bound long-running streaming operations. A timed-out handler must honor `request.signal` to stop its own work.
|
|
427
|
+
|
|
428
|
+
What a check does and does not prove:
|
|
429
|
+
|
|
430
|
+
- Discovery never calls a tool. Only the listed `calls` run, in order. After a failed or incomplete call, or a tool whose schema can't be checked, the remaining calls are skipped.
|
|
431
|
+
- `passed` means no failure was observed. A successful connection does not prove that auth is enforced or that business behavior is correct; assert those separately.
|
|
432
|
+
- Reports contain only fixed, value-free diagnostics with indexed locations. Exceptions from `withMcpClient` and its callback are **not** redacted.
|
|
433
|
+
- Credential headers are never sent across a redirect or to a different endpoint, and require HTTPS to a non-loopback host unless an in-process `handler` is supplied. The kit does not mint tokens or run a deployed OAuth flow; supply your own bearer.
|
|
434
|
+
|
|
435
|
+
Notes:
|
|
436
|
+
|
|
437
|
+
- `/testing/server` depends on the official MCP client, which adds install weight. The root `@lovable.dev/mcp-js` import never loads it.
|
|
438
|
+
- Both testing subpaths support ESM and CommonJS on Node 20 or later.
|
|
439
|
+
- Keep these tests isolated from production data. Tool schemas are not sandboxed: run checks against servers you don't trust in a separate, externally time-bounded process.
|
|
440
|
+
|
|
441
|
+
See [`example/testing`](./example/testing) for a runnable setup; `pnpm test:package:testing` runs it against the packed package.
|
|
442
|
+
|
|
343
443
|
## Security posture
|
|
344
444
|
|
|
345
445
|
For anyone evaluating an app that exposes an MCP server with this package:
|
|
@@ -455,11 +555,14 @@ Ownership: the emitted `index.ts` carries a `// AUTO-GENERATED by @lovable.dev/m
|
|
|
455
555
|
| Subpath | Contents |
|
|
456
556
|
| --------------------------------------- | ----------------------------------------------------------------------- |
|
|
457
557
|
| `@lovable.dev/mcp-js` | `defineTool`, `defineMcp`, public types |
|
|
558
|
+
| `@lovable.dev/mcp-js/skill-imports` | Type-only declarations for skill directory imports |
|
|
458
559
|
| `@lovable.dev/mcp-js/protocols/mcp` | `createMcpProtocolHandler` — Web-Standard MCP-over-HTTP |
|
|
459
560
|
| `@lovable.dev/mcp-js/protocols/oauth-metadata` | `createOAuthProtectedResourceMetadataHandler` (the `auth` namespace lives at the root) |
|
|
460
561
|
| `@lovable.dev/mcp-js/stacks/tanstack` | TanStack-route-ctx adapters (`createTanStack*Handler`) |
|
|
461
562
|
| `@lovable.dev/mcp-js/stacks/tanstack/vite` | The Vite plugin |
|
|
462
563
|
| `@lovable.dev/mcp-js/stacks/supabase` | `createSupabaseHandler` — Web-Standard Supabase Edge Function dispatcher |
|
|
463
564
|
| `@lovable.dev/mcp-js/stacks/supabase/vite` | `mcpPlugin` — the Vite plugin (Supabase variant; same name as TanStack's, picked by import path) |
|
|
565
|
+
| `@lovable.dev/mcp-js/testing` | Direct handler result assertion and redacted diagnostics |
|
|
566
|
+
| `@lovable.dev/mcp-js/testing/server` | Official-client lifecycle helper and endpoint checker (Node only) |
|
|
464
567
|
|
|
465
|
-
End users only need the root import (`@lovable.dev/mcp-js`). Generated route files import from `@lovable.dev/mcp-js/stacks/tanstack` (TanStack) or `@lovable.dev/mcp-js/stacks/supabase` (Supabase).
|
|
568
|
+
End users only need the root import (`@lovable.dev/mcp-js`). Generated route files import from `@lovable.dev/mcp-js/stacks/tanstack` (TanStack) or `@lovable.dev/mcp-js/stacks/supabase` (Supabase). Keep the testing subpaths in tests; the protocol subpaths are escape hatches for hand-wiring custom stacks.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as McpProtocolEra } from "./types-CyDJi9Jb.cjs";
|
|
2
2
|
//#region src/metrics/impl/base.d.ts
|
|
3
3
|
type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "app_context_error" | "auth_challenge" | "auth_token_expired" | "auth_token_invalid" | "auth_insufficient_scope" | "auth_unexpected_error" | "origin_rejected" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
|
|
4
4
|
/** One recorded MCP call. Carries no arguments or response payloads — only the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as McpProtocolEra } from "./types-CyDJi9Jb.js";
|
|
2
2
|
//#region src/metrics/impl/base.d.ts
|
|
3
3
|
type InvocationOutcome = "ok" | "tool_error" | "handler_error" | "transport_error" | "app_context_error" | "auth_challenge" | "auth_token_expired" | "auth_token_invalid" | "auth_insufficient_scope" | "auth_unexpected_error" | "origin_rejected" | "auth_discovery_config_error" | "auth_discovery_unreachable" | "auth_jwks_config_error" | "auth_jwks_unreachable";
|
|
4
4
|
/** One recorded MCP call. Carries no arguments or response payloads — only the
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const require_testing_server = require("../testing/server.cjs");
|
|
3
|
+
let node_fs_promises = require("node:fs/promises");
|
|
4
|
+
let node_util = require("node:util");
|
|
5
|
+
//#region src/cli/check-server.ts
|
|
6
|
+
async function main() {
|
|
7
|
+
let options;
|
|
8
|
+
try {
|
|
9
|
+
const { values } = (0, node_util.parseArgs)({ options: {
|
|
10
|
+
url: { type: "string" },
|
|
11
|
+
"bearer-env": { type: "string" },
|
|
12
|
+
protocol: {
|
|
13
|
+
type: "string",
|
|
14
|
+
default: "2026-07-28"
|
|
15
|
+
},
|
|
16
|
+
calls: { type: "string" },
|
|
17
|
+
timeout: { type: "string" },
|
|
18
|
+
help: { type: "boolean" }
|
|
19
|
+
} });
|
|
20
|
+
if (values.help) {
|
|
21
|
+
console.log("lovable-mcp-check --url <endpoint> [--bearer-env <NAME>] [--protocol 2025-11-25|2026-07-28] [--calls <json-file>] [--timeout <milliseconds>]\nDiscovery never calls tools. Only calls listed in the JSON array run. Supply credentials through a named environment variable, never command arguments. Timeout is per request (default 10000 ms), not the whole run. Exit 0 means no observed failures, not full coverage; 1 means a failed check, 2 invalid configuration.");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!values.url) throw new Error();
|
|
25
|
+
const bearer = values["bearer-env"] ? process.env[values["bearer-env"]] : void 0;
|
|
26
|
+
if (values["bearer-env"] && !bearer) throw new Error();
|
|
27
|
+
const calls = values.calls ? JSON.parse(await (0, node_fs_promises.readFile)(values.calls, "utf8")) : [];
|
|
28
|
+
if (!Array.isArray(calls) || calls.some((call) => !call || typeof call.name !== "string" || call.arguments !== void 0 && (!call.arguments || typeof call.arguments !== "object" || Array.isArray(call.arguments)) || call.isError !== void 0 && typeof call.isError !== "boolean" || Object.keys(call).some((key) => ![
|
|
29
|
+
"name",
|
|
30
|
+
"arguments",
|
|
31
|
+
"isError"
|
|
32
|
+
].includes(key)))) throw new Error();
|
|
33
|
+
options = {
|
|
34
|
+
endpoint: values.url,
|
|
35
|
+
protocolVersion: values.protocol,
|
|
36
|
+
headers: bearer ? { Authorization: `Bearer ${bearer}` } : void 0,
|
|
37
|
+
calls,
|
|
38
|
+
timeoutMs: values.timeout === void 0 ? void 0 : Number(values.timeout)
|
|
39
|
+
};
|
|
40
|
+
} catch {
|
|
41
|
+
console.error("Invalid check configuration. Use --help; check url, protocol, timeout, bearer-env and calls file. Values are omitted.");
|
|
42
|
+
process.exitCode = 2;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const report = await require_testing_server.checkMcpServer(options);
|
|
46
|
+
console.log(JSON.stringify(report, null, 2));
|
|
47
|
+
process.exitCode = report.checks.some((check) => check.code === "connection.options") ? 2 : report.passed ? 0 : 1;
|
|
48
|
+
}
|
|
49
|
+
main().catch(() => {
|
|
50
|
+
console.log(JSON.stringify({
|
|
51
|
+
passed: false,
|
|
52
|
+
checks: [{
|
|
53
|
+
code: "check.execution",
|
|
54
|
+
status: "failed",
|
|
55
|
+
basis: "package-guarantee",
|
|
56
|
+
message: "The check could not complete. Error details are omitted."
|
|
57
|
+
}]
|
|
58
|
+
}));
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
});
|
|
61
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { checkMcpServer } from "../testing/server.js";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { parseArgs } from "node:util";
|
|
5
|
+
//#region src/cli/check-server.ts
|
|
6
|
+
async function main() {
|
|
7
|
+
let options;
|
|
8
|
+
try {
|
|
9
|
+
const { values } = parseArgs({ options: {
|
|
10
|
+
url: { type: "string" },
|
|
11
|
+
"bearer-env": { type: "string" },
|
|
12
|
+
protocol: {
|
|
13
|
+
type: "string",
|
|
14
|
+
default: "2026-07-28"
|
|
15
|
+
},
|
|
16
|
+
calls: { type: "string" },
|
|
17
|
+
timeout: { type: "string" },
|
|
18
|
+
help: { type: "boolean" }
|
|
19
|
+
} });
|
|
20
|
+
if (values.help) {
|
|
21
|
+
console.log("lovable-mcp-check --url <endpoint> [--bearer-env <NAME>] [--protocol 2025-11-25|2026-07-28] [--calls <json-file>] [--timeout <milliseconds>]\nDiscovery never calls tools. Only calls listed in the JSON array run. Supply credentials through a named environment variable, never command arguments. Timeout is per request (default 10000 ms), not the whole run. Exit 0 means no observed failures, not full coverage; 1 means a failed check, 2 invalid configuration.");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!values.url) throw new Error();
|
|
25
|
+
const bearer = values["bearer-env"] ? process.env[values["bearer-env"]] : void 0;
|
|
26
|
+
if (values["bearer-env"] && !bearer) throw new Error();
|
|
27
|
+
const calls = values.calls ? JSON.parse(await readFile(values.calls, "utf8")) : [];
|
|
28
|
+
if (!Array.isArray(calls) || calls.some((call) => !call || typeof call.name !== "string" || call.arguments !== void 0 && (!call.arguments || typeof call.arguments !== "object" || Array.isArray(call.arguments)) || call.isError !== void 0 && typeof call.isError !== "boolean" || Object.keys(call).some((key) => ![
|
|
29
|
+
"name",
|
|
30
|
+
"arguments",
|
|
31
|
+
"isError"
|
|
32
|
+
].includes(key)))) throw new Error();
|
|
33
|
+
options = {
|
|
34
|
+
endpoint: values.url,
|
|
35
|
+
protocolVersion: values.protocol,
|
|
36
|
+
headers: bearer ? { Authorization: `Bearer ${bearer}` } : void 0,
|
|
37
|
+
calls,
|
|
38
|
+
timeoutMs: values.timeout === void 0 ? void 0 : Number(values.timeout)
|
|
39
|
+
};
|
|
40
|
+
} catch {
|
|
41
|
+
console.error("Invalid check configuration. Use --help; check url, protocol, timeout, bearer-env and calls file. Values are omitted.");
|
|
42
|
+
process.exitCode = 2;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const report = await checkMcpServer(options);
|
|
46
|
+
console.log(JSON.stringify(report, null, 2));
|
|
47
|
+
process.exitCode = report.checks.some((check) => check.code === "connection.options") ? 2 : report.passed ? 0 : 1;
|
|
48
|
+
}
|
|
49
|
+
main().catch(() => {
|
|
50
|
+
console.log(JSON.stringify({
|
|
51
|
+
passed: false,
|
|
52
|
+
checks: [{
|
|
53
|
+
code: "check.execution",
|
|
54
|
+
status: "failed",
|
|
55
|
+
basis: "package-guarantee",
|
|
56
|
+
message: "The check could not complete. Error details are omitted."
|
|
57
|
+
}]
|
|
58
|
+
}));
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
});
|
|
61
|
+
//#endregion
|
|
62
|
+
export {};
|
|
@@ -4,7 +4,7 @@ const projectRoot = process.argv[2] ?? process.cwd();
|
|
|
4
4
|
import("zod/v4/core").catch((err) => {
|
|
5
5
|
const message = err instanceof Error ? err.message : String(err);
|
|
6
6
|
throw new Error(`@lovable.dev/mcp-js requires zod ^3.25.76 or ^4.0.0 to extract MCP schemas. Import MCP schemas from "zod/v4"; existing app forms can keep importing from "zod". Verify the project's zod dependency and package resolution, then try again. Underlying error: ${message}`);
|
|
7
|
-
}).then(() => Promise.resolve().then(() => require("../io-
|
|
7
|
+
}).then(() => Promise.resolve().then(() => require("../io-Bf4Narx6.cjs"))).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
|
|
8
8
|
console.error(err instanceof Error ? err.message : String(err));
|
|
9
9
|
process.exit(1);
|
|
10
10
|
});
|
|
@@ -4,7 +4,7 @@ const projectRoot = process.argv[2] ?? process.cwd();
|
|
|
4
4
|
import("zod/v4/core").catch((err) => {
|
|
5
5
|
const message = err instanceof Error ? err.message : String(err);
|
|
6
6
|
throw new Error(`@lovable.dev/mcp-js requires zod ^3.25.76 or ^4.0.0 to extract MCP schemas. Import MCP schemas from "zod/v4"; existing app forms can keep importing from "zod". Verify the project's zod dependency and package resolution, then try again. Underlying error: ${message}`);
|
|
7
|
-
}).then(() => import("../io-
|
|
7
|
+
}).then(() => import("../io-VMIaguRH.js")).then(({ runExtract }) => runExtract(projectRoot)).catch((err) => {
|
|
8
8
|
console.error(err instanceof Error ? err.message : String(err));
|
|
9
9
|
process.exit(1);
|
|
10
10
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
2
|
-
const require_package = require("./package-
|
|
2
|
+
const require_package = require("./package-CBMX__7C.cjs");
|
|
3
3
|
require("./metadata-path-zd7NSNoa.cjs");
|
|
4
4
|
let jose = require("jose");
|
|
5
5
|
//#region src/core/http.ts
|
|
@@ -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-CpLgYbCG.js";
|
|
2
|
-
import { t as version } from "./package-
|
|
2
|
+
import { t as version } from "./package-Ci4yKJUI.js";
|
|
3
3
|
import "./metadata-path-CAkNcfyY.js";
|
|
4
4
|
import { createLocalJWKSet, decodeProtectedHeader, errors, jwtVerify } from "jose";
|
|
5
5
|
//#region src/core/http.ts
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/testing/diagnostic.ts
|
|
2
|
+
var McpCheckError = class extends Error {
|
|
3
|
+
diagnostic;
|
|
4
|
+
constructor(diagnostic) {
|
|
5
|
+
super(`${diagnostic.code}: ${diagnostic.message}`);
|
|
6
|
+
this.diagnostic = diagnostic;
|
|
7
|
+
this.name = "McpCheckError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { McpCheckError as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/testing/diagnostic.d.ts
|
|
2
|
+
interface Diagnostic {
|
|
3
|
+
code: string;
|
|
4
|
+
basis: "protocol-requirement" | "package-guarantee" | "app-expectation";
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
declare class McpCheckError extends Error {
|
|
8
|
+
readonly diagnostic: Diagnostic;
|
|
9
|
+
constructor(diagnostic: Diagnostic);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { McpCheckError as n, Diagnostic as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/testing/diagnostic.d.ts
|
|
2
|
+
interface Diagnostic {
|
|
3
|
+
code: string;
|
|
4
|
+
basis: "protocol-requirement" | "package-guarantee" | "app-expectation";
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
declare class McpCheckError extends Error {
|
|
8
|
+
readonly diagnostic: Diagnostic;
|
|
9
|
+
constructor(diagnostic: Diagnostic);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { McpCheckError as n, Diagnostic as t };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/testing/diagnostic.ts
|
|
2
|
+
var McpCheckError = class extends Error {
|
|
3
|
+
diagnostic;
|
|
4
|
+
constructor(diagnostic) {
|
|
5
|
+
super(`${diagnostic.code}: ${diagnostic.message}`);
|
|
6
|
+
this.diagnostic = diagnostic;
|
|
7
|
+
this.name = "McpCheckError";
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
Object.defineProperty(exports, "McpCheckError", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return McpCheckError;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { o as parseSafeUrl, s as trimTrailingSlash, u as resolveMetricsConfig } from "./logger-CpLgYbCG.js";
|
|
2
|
+
import { n as validateSkills } from "./format-DKEuO8Tn.js";
|
|
2
3
|
import { t as jsonSchemaFromDefinition } from "./schema-DBTR1XbM.js";
|
|
3
4
|
//#region src/core/define.ts
|
|
4
5
|
function toolRequiresAppContext(tool) {
|
|
@@ -146,11 +147,11 @@ function defineMcp(def) {
|
|
|
146
147
|
if (Array.isArray(def.allowedOrigins)) Object.freeze(def.allowedOrigins);
|
|
147
148
|
Object.freeze(def.tools);
|
|
148
149
|
for (const tool of def.tools) Object.freeze(tool);
|
|
150
|
+
if (def.skills !== void 0) validateSkills(def.skills);
|
|
149
151
|
return def;
|
|
150
152
|
}
|
|
151
153
|
//#endregion
|
|
152
154
|
//#region src/auth/context.ts
|
|
153
|
-
const NEVER_ABORTED = new AbortController().signal;
|
|
154
155
|
/** Verified caller identity exposed to the app-context factory.
|
|
155
156
|
* `getToken()` is the sole bearer escape hatch. */
|
|
156
157
|
var AuthContext = class {
|
|
@@ -203,7 +204,7 @@ var ToolContext = class extends AuthContext {
|
|
|
203
204
|
constructor(auth, request = {}, appContext) {
|
|
204
205
|
super(auth);
|
|
205
206
|
this.#appContext = appContext;
|
|
206
|
-
this.#signal = request.signal ??
|
|
207
|
+
this.#signal = request.signal ?? new AbortController().signal;
|
|
207
208
|
this.#client = request.client ?? { protocol: "legacy" };
|
|
208
209
|
this.#sendProgress = request.sendProgress;
|
|
209
210
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_logger = require("./logger-C-Hdu57K.cjs");
|
|
2
|
+
const require_format = require("./format-DDzvc92Z.cjs");
|
|
2
3
|
const require_schema = require("./schema-CjFpqCEP.cjs");
|
|
3
4
|
//#region src/core/define.ts
|
|
4
5
|
function toolRequiresAppContext(tool) {
|
|
@@ -146,11 +147,11 @@ function defineMcp(def) {
|
|
|
146
147
|
if (Array.isArray(def.allowedOrigins)) Object.freeze(def.allowedOrigins);
|
|
147
148
|
Object.freeze(def.tools);
|
|
148
149
|
for (const tool of def.tools) Object.freeze(tool);
|
|
150
|
+
if (def.skills !== void 0) require_format.validateSkills(def.skills);
|
|
149
151
|
return def;
|
|
150
152
|
}
|
|
151
153
|
//#endregion
|
|
152
154
|
//#region src/auth/context.ts
|
|
153
|
-
const NEVER_ABORTED = new AbortController().signal;
|
|
154
155
|
/** Verified caller identity exposed to the app-context factory.
|
|
155
156
|
* `getToken()` is the sole bearer escape hatch. */
|
|
156
157
|
var AuthContext = class {
|
|
@@ -203,7 +204,7 @@ var ToolContext = class extends AuthContext {
|
|
|
203
204
|
constructor(auth, request = {}, appContext) {
|
|
204
205
|
super(auth);
|
|
205
206
|
this.#appContext = appContext;
|
|
206
|
-
this.#signal = request.signal ??
|
|
207
|
+
this.#signal = request.signal ?? new AbortController().signal;
|
|
207
208
|
this.#client = request.client ?? { protocol: "legacy" };
|
|
208
209
|
this.#sendProgress = request.sendProgress;
|
|
209
210
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/skills/format.ts
|
|
2
|
+
const COMPILED_SKILL_KIND = "lovable-mcp-compiled-skill";
|
|
3
|
+
function freezeTree(value) {
|
|
4
|
+
if (typeof value !== "object" || value === null) return;
|
|
5
|
+
Object.freeze(value);
|
|
6
|
+
for (const child of Object.values(value)) freezeTree(child);
|
|
7
|
+
}
|
|
8
|
+
function validateSkills(skills) {
|
|
9
|
+
if (!Array.isArray(skills)) throw new TypeError("@lovable.dev/mcp-js: skills must be an array of ?skill imports");
|
|
10
|
+
const uris = /* @__PURE__ */ new Set();
|
|
11
|
+
const files = /* @__PURE__ */ new Map();
|
|
12
|
+
for (const skill of skills) {
|
|
13
|
+
if (!skill || skill.kind !== "lovable-mcp-compiled-skill" || !Array.isArray(skill.files) || !skill.frontmatter || typeof skill.frontmatter.name !== "string" || typeof skill.frontmatter.description !== "string" || typeof skill.rootUri !== "string" || skill.uri !== `${skill.rootUri}/SKILL.md` || !skill.rootUri.startsWith("skill://") || decodeURIComponent(skill.rootUri.split("/").at(-1) ?? "") !== skill.frontmatter.name) throw new TypeError("@lovable.dev/mcp-js: skills entries must come from a ?skill import");
|
|
14
|
+
if (uris.has(skill.uri)) throw new Error(`@lovable.dev/mcp-js: duplicate skill URI ${skill.uri}`);
|
|
15
|
+
uris.add(skill.uri);
|
|
16
|
+
const paths = /* @__PURE__ */ new Set();
|
|
17
|
+
for (const file of skill.files) {
|
|
18
|
+
if (!file || typeof file.path !== "string" || file.path.split("/").some((part) => !part || part === "." || part === "..") || file.uri !== `${skill.rootUri}/${file.path.split("/").map(encodeURIComponent).join("/")}` || typeof file.text !== "string" || typeof file.mimeType !== "string" || !/^sha256:[a-f0-9]{64}$/.test(file.digest) || file.size !== new TextEncoder().encode(file.text).length || paths.has(file.path)) throw new TypeError(`@lovable.dev/mcp-js: invalid compiled skill file in ${skill.uri}`);
|
|
19
|
+
paths.add(file.path);
|
|
20
|
+
const existing = files.get(file.uri);
|
|
21
|
+
if (existing && (existing.text !== file.text || existing.digest !== file.digest || existing.mimeType !== file.mimeType)) throw new Error(`@lovable.dev/mcp-js: skill file URI collision with different content: ${file.uri}`);
|
|
22
|
+
files.set(file.uri, file);
|
|
23
|
+
}
|
|
24
|
+
if (!paths.has("SKILL.md")) throw new Error(`@lovable.dev/mcp-js: missing SKILL.md in ${skill.uri}`);
|
|
25
|
+
freezeTree(skill);
|
|
26
|
+
}
|
|
27
|
+
Object.freeze(skills);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
Object.defineProperty(exports, "COMPILED_SKILL_KIND", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function() {
|
|
33
|
+
return COMPILED_SKILL_KIND;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "validateSkills", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function() {
|
|
39
|
+
return validateSkills;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/skills/format.ts
|
|
2
|
+
const COMPILED_SKILL_KIND = "lovable-mcp-compiled-skill";
|
|
3
|
+
function freezeTree(value) {
|
|
4
|
+
if (typeof value !== "object" || value === null) return;
|
|
5
|
+
Object.freeze(value);
|
|
6
|
+
for (const child of Object.values(value)) freezeTree(child);
|
|
7
|
+
}
|
|
8
|
+
function validateSkills(skills) {
|
|
9
|
+
if (!Array.isArray(skills)) throw new TypeError("@lovable.dev/mcp-js: skills must be an array of ?skill imports");
|
|
10
|
+
const uris = /* @__PURE__ */ new Set();
|
|
11
|
+
const files = /* @__PURE__ */ new Map();
|
|
12
|
+
for (const skill of skills) {
|
|
13
|
+
if (!skill || skill.kind !== "lovable-mcp-compiled-skill" || !Array.isArray(skill.files) || !skill.frontmatter || typeof skill.frontmatter.name !== "string" || typeof skill.frontmatter.description !== "string" || typeof skill.rootUri !== "string" || skill.uri !== `${skill.rootUri}/SKILL.md` || !skill.rootUri.startsWith("skill://") || decodeURIComponent(skill.rootUri.split("/").at(-1) ?? "") !== skill.frontmatter.name) throw new TypeError("@lovable.dev/mcp-js: skills entries must come from a ?skill import");
|
|
14
|
+
if (uris.has(skill.uri)) throw new Error(`@lovable.dev/mcp-js: duplicate skill URI ${skill.uri}`);
|
|
15
|
+
uris.add(skill.uri);
|
|
16
|
+
const paths = /* @__PURE__ */ new Set();
|
|
17
|
+
for (const file of skill.files) {
|
|
18
|
+
if (!file || typeof file.path !== "string" || file.path.split("/").some((part) => !part || part === "." || part === "..") || file.uri !== `${skill.rootUri}/${file.path.split("/").map(encodeURIComponent).join("/")}` || typeof file.text !== "string" || typeof file.mimeType !== "string" || !/^sha256:[a-f0-9]{64}$/.test(file.digest) || file.size !== new TextEncoder().encode(file.text).length || paths.has(file.path)) throw new TypeError(`@lovable.dev/mcp-js: invalid compiled skill file in ${skill.uri}`);
|
|
19
|
+
paths.add(file.path);
|
|
20
|
+
const existing = files.get(file.uri);
|
|
21
|
+
if (existing && (existing.text !== file.text || existing.digest !== file.digest || existing.mimeType !== file.mimeType)) throw new Error(`@lovable.dev/mcp-js: skill file URI collision with different content: ${file.uri}`);
|
|
22
|
+
files.set(file.uri, file);
|
|
23
|
+
}
|
|
24
|
+
if (!paths.has("SKILL.md")) throw new Error(`@lovable.dev/mcp-js: missing SKILL.md in ${skill.uri}`);
|
|
25
|
+
freezeTree(skill);
|
|
26
|
+
}
|
|
27
|
+
Object.freeze(skills);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { validateSkills as n, COMPILED_SKILL_KIND as t };
|