@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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "../../metadata-path-CAkNcfyY.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as readSupabaseProjectRef } from "../../supabase-config-CakTU8YF.js";
|
|
2
|
+
import { a as isFileMissing, i as readSupabaseProjectRef, r as skillImportVitePlugin } from "../../hooks-BOdDe251.js";
|
|
4
3
|
import { lstatSync, mkdirSync, readFileSync, readdirSync, unlinkSync, writeFileSync } from "node:fs";
|
|
5
4
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
6
5
|
import { loadEnv } from "vite";
|
|
@@ -60,7 +59,7 @@ function relativeImportSpecifier(routeFile, target) {
|
|
|
60
59
|
const withoutExt = normalizePath(relative(dirname(routeFile), target)).replace(/\.ts$/, "");
|
|
61
60
|
return withoutExt.startsWith(".") ? withoutExt : `./${withoutExt}`;
|
|
62
61
|
}
|
|
63
|
-
function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot) {
|
|
62
|
+
function buildRouteSource(route, resourcePath, metadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot, hasSitemapInventory) {
|
|
64
63
|
const mcpImport = relativeImportSpecifier(route.file, mcpEntry);
|
|
65
64
|
const routeRel = normalizePath(relative(projectRoot, route.file));
|
|
66
65
|
const optionEntries = [`resourcePath: "${resourcePath}"`];
|
|
@@ -84,7 +83,7 @@ import { ${route.handlerFactory} } from "@lovable.dev/mcp-js/stacks/tanstack";
|
|
|
84
83
|
import mcp from "${mcpImport}";
|
|
85
84
|
|
|
86
85
|
${routeOpen}
|
|
87
|
-
server: {
|
|
86
|
+
${hasSitemapInventory ? " staticData: { sitemap: false },\n" : ""} server: {
|
|
88
87
|
handlers: {
|
|
89
88
|
ANY: ${route.handlerFactory}(mcp, ${optionsObject}),
|
|
90
89
|
},
|
|
@@ -178,6 +177,7 @@ function mcpPlugin(options = {}) {
|
|
|
178
177
|
const trustForwardedProto = options.trustForwardedProto !== false;
|
|
179
178
|
let projectRoot = process.cwd();
|
|
180
179
|
let mcpEntry = resolve(projectRoot, mcpEntryOption);
|
|
180
|
+
let sitemapFile = resolve(projectRoot, "src/lib/sitemap.ts");
|
|
181
181
|
let { routesDir, mcpRouteFile, metadataRouteFile } = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath);
|
|
182
182
|
const regenerate = () => {
|
|
183
183
|
let mcpEntryExists = true;
|
|
@@ -189,6 +189,13 @@ function mcpPlugin(options = {}) {
|
|
|
189
189
|
}
|
|
190
190
|
const expected = /* @__PURE__ */ new Set();
|
|
191
191
|
if (mcpEntryExists) {
|
|
192
|
+
let sitemapSource = "";
|
|
193
|
+
try {
|
|
194
|
+
sitemapSource = readFileSync(sitemapFile, "utf8");
|
|
195
|
+
} catch (err) {
|
|
196
|
+
if (!isFileMissing(err)) throw err;
|
|
197
|
+
}
|
|
198
|
+
const hasSitemapInventory = /^\s*export\s+const\s+sitemapRouteInventoryVersion\s*=\s*1\s*(?:;|$)/m.test(sitemapSource);
|
|
192
199
|
const routes = [{
|
|
193
200
|
file: mcpRouteFile,
|
|
194
201
|
routeLiteral: urlPath,
|
|
@@ -202,7 +209,7 @@ function mcpPlugin(options = {}) {
|
|
|
202
209
|
});
|
|
203
210
|
for (const route of routes) {
|
|
204
211
|
expected.add(route.file);
|
|
205
|
-
writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot));
|
|
212
|
+
writeIfChanged(route.file, buildRouteSource(route, urlPath, injectedMetadataPath, trustForwardedHost, trustForwardedProto, mcpEntry, projectRoot, hasSitemapInventory));
|
|
206
213
|
}
|
|
207
214
|
}
|
|
208
215
|
for (const file of findAdoptedFiles(routesDir)) if (!expected.has(file)) try {
|
|
@@ -212,6 +219,19 @@ function mcpPlugin(options = {}) {
|
|
|
212
219
|
}
|
|
213
220
|
};
|
|
214
221
|
return {
|
|
222
|
+
...skillImportVitePlugin({ onServer(server) {
|
|
223
|
+
const onChange = (file) => {
|
|
224
|
+
if (normalizePath(file) === normalizePath(mcpEntry) || normalizePath(file) === normalizePath(sitemapFile)) regenerate();
|
|
225
|
+
};
|
|
226
|
+
server.watcher.on("add", onChange);
|
|
227
|
+
server.watcher.on("change", onChange);
|
|
228
|
+
server.watcher.on("unlink", onChange);
|
|
229
|
+
server.watcher.once("close", () => {
|
|
230
|
+
server.watcher.off("add", onChange);
|
|
231
|
+
server.watcher.off("change", onChange);
|
|
232
|
+
server.watcher.off("unlink", onChange);
|
|
233
|
+
});
|
|
234
|
+
} }),
|
|
215
235
|
name: "@lovable.dev/mcp-js",
|
|
216
236
|
api: {
|
|
217
237
|
get mcpEntry() {
|
|
@@ -231,22 +251,10 @@ function mcpPlugin(options = {}) {
|
|
|
231
251
|
configResolved(config) {
|
|
232
252
|
projectRoot = config.root;
|
|
233
253
|
mcpEntry = resolve(projectRoot, mcpEntryOption);
|
|
254
|
+
sitemapFile = resolve(projectRoot, "src/lib/sitemap.ts");
|
|
234
255
|
({routesDir, mcpRouteFile, metadataRouteFile} = resolveAllRoutes(projectRoot, routesDirOption, routeFileName, metadataUrlPath));
|
|
235
256
|
regenerate();
|
|
236
257
|
},
|
|
237
|
-
configureServer(server) {
|
|
238
|
-
const onChange = (file) => {
|
|
239
|
-
if (normalizePath(file) === normalizePath(mcpEntry)) regenerate();
|
|
240
|
-
};
|
|
241
|
-
server.watcher.on("add", onChange);
|
|
242
|
-
server.watcher.on("change", onChange);
|
|
243
|
-
server.watcher.on("unlink", onChange);
|
|
244
|
-
server.watcher.once("close", () => {
|
|
245
|
-
server.watcher.off("add", onChange);
|
|
246
|
-
server.watcher.off("change", onChange);
|
|
247
|
-
server.watcher.off("unlink", onChange);
|
|
248
|
-
});
|
|
249
|
-
},
|
|
250
258
|
buildStart() {
|
|
251
259
|
regenerate();
|
|
252
260
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_schema = require("../schema-CjFpqCEP.cjs");
|
|
3
|
+
const require_tool_result = require("../tool-result-yqOfZUOP.cjs");
|
|
4
|
+
const require_diagnostic = require("../diagnostic-ol9IE9Dl.cjs");
|
|
5
|
+
let zod_v4_core = require("zod/v4/core");
|
|
6
|
+
let _modelcontextprotocol_core = require("@modelcontextprotocol/core");
|
|
7
|
+
//#region src/testing/result.ts
|
|
8
|
+
async function assertToolResult(result, expected = {}) {
|
|
9
|
+
const fail = (code, message, basis = "package-guarantee") => {
|
|
10
|
+
throw new require_diagnostic.McpCheckError({
|
|
11
|
+
code,
|
|
12
|
+
message,
|
|
13
|
+
basis
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
let json = false;
|
|
17
|
+
try {
|
|
18
|
+
json = require_tool_result.isJsonValue(result);
|
|
19
|
+
} catch {}
|
|
20
|
+
if (!json) fail("result.json", "Return JSON data without cycles, class instances or non-finite numbers.");
|
|
21
|
+
let parsed;
|
|
22
|
+
let value;
|
|
23
|
+
try {
|
|
24
|
+
if (!result || typeof result !== "object" || Array.isArray(result)) throw new Error();
|
|
25
|
+
value = { ...result };
|
|
26
|
+
if (value.content !== void 0 && !Array.isArray(value.content)) throw new Error();
|
|
27
|
+
parsed = _modelcontextprotocol_core.CallToolResultSchema.safeParse({
|
|
28
|
+
...value,
|
|
29
|
+
content: require_tool_result.normalizeToolContent(value.content)
|
|
30
|
+
});
|
|
31
|
+
} catch {
|
|
32
|
+
return fail("result.shape", "Return a plain MCP result with valid content blocks and object _meta.");
|
|
33
|
+
}
|
|
34
|
+
if (!parsed.success) fail("result.shape", "Return a plain MCP result with valid content blocks and object _meta.");
|
|
35
|
+
if (value.isError === true !== (expected.isError === true)) fail("result.expected-error", expected.isError ? "Expected an error result." : "Expected a successful result.", "app-expectation");
|
|
36
|
+
if (expected.outputSchema && !value.isError) {
|
|
37
|
+
let valid = false;
|
|
38
|
+
try {
|
|
39
|
+
valid = value.structuredContent !== void 0 && (await (0, zod_v4_core.safeParseAsync)(require_schema.schemaFromDefinition(expected.outputSchema, false), value.structuredContent)).success;
|
|
40
|
+
} catch {}
|
|
41
|
+
if (!valid) fail("result.output-schema", "Successful structuredContent must be present and match the declared outputSchema.");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
exports.McpCheckError = require_diagnostic.McpCheckError;
|
|
46
|
+
exports.assertToolResult = assertToolResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { w as ZodOutputSchema } from "../types-CyDJi9Jb.cjs";
|
|
2
|
+
import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.cjs";
|
|
3
|
+
//#region src/testing/result.d.ts
|
|
4
|
+
interface ToolResultExpectation {
|
|
5
|
+
outputSchema?: ZodOutputSchema;
|
|
6
|
+
isError?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function assertToolResult(result: unknown, expected?: ToolResultExpectation): Promise<void>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type Diagnostic, McpCheckError, type ToolResultExpectation, assertToolResult };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { w as ZodOutputSchema } from "../types-CyDJi9Jb.js";
|
|
2
|
+
import { n as McpCheckError, t as Diagnostic } from "../diagnostic-DRKjgCsW.js";
|
|
3
|
+
//#region src/testing/result.d.ts
|
|
4
|
+
interface ToolResultExpectation {
|
|
5
|
+
outputSchema?: ZodOutputSchema;
|
|
6
|
+
isError?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function assertToolResult(result: unknown, expected?: ToolResultExpectation): Promise<void>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { type Diagnostic, McpCheckError, type ToolResultExpectation, assertToolResult };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { n as schemaFromDefinition } from "../schema-DBTR1XbM.js";
|
|
2
|
+
import { n as isJsonValue, r as normalizeToolContent } from "../tool-result-teeTDoM1.js";
|
|
3
|
+
import { t as McpCheckError } from "../diagnostic-ClI2_5MW.js";
|
|
4
|
+
import { safeParseAsync } from "zod/v4/core";
|
|
5
|
+
import { CallToolResultSchema } from "@modelcontextprotocol/core";
|
|
6
|
+
//#region src/testing/result.ts
|
|
7
|
+
async function assertToolResult(result, expected = {}) {
|
|
8
|
+
const fail = (code, message, basis = "package-guarantee") => {
|
|
9
|
+
throw new McpCheckError({
|
|
10
|
+
code,
|
|
11
|
+
message,
|
|
12
|
+
basis
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
let json = false;
|
|
16
|
+
try {
|
|
17
|
+
json = isJsonValue(result);
|
|
18
|
+
} catch {}
|
|
19
|
+
if (!json) fail("result.json", "Return JSON data without cycles, class instances or non-finite numbers.");
|
|
20
|
+
let parsed;
|
|
21
|
+
let value;
|
|
22
|
+
try {
|
|
23
|
+
if (!result || typeof result !== "object" || Array.isArray(result)) throw new Error();
|
|
24
|
+
value = { ...result };
|
|
25
|
+
if (value.content !== void 0 && !Array.isArray(value.content)) throw new Error();
|
|
26
|
+
parsed = CallToolResultSchema.safeParse({
|
|
27
|
+
...value,
|
|
28
|
+
content: normalizeToolContent(value.content)
|
|
29
|
+
});
|
|
30
|
+
} catch {
|
|
31
|
+
return fail("result.shape", "Return a plain MCP result with valid content blocks and object _meta.");
|
|
32
|
+
}
|
|
33
|
+
if (!parsed.success) fail("result.shape", "Return a plain MCP result with valid content blocks and object _meta.");
|
|
34
|
+
if (value.isError === true !== (expected.isError === true)) fail("result.expected-error", expected.isError ? "Expected an error result." : "Expected a successful result.", "app-expectation");
|
|
35
|
+
if (expected.outputSchema && !value.isError) {
|
|
36
|
+
let valid = false;
|
|
37
|
+
try {
|
|
38
|
+
valid = value.structuredContent !== void 0 && (await safeParseAsync(schemaFromDefinition(expected.outputSchema, false), value.structuredContent)).success;
|
|
39
|
+
} catch {}
|
|
40
|
+
if (!valid) fail("result.output-schema", "Successful structuredContent must be present and match the declared outputSchema.");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { McpCheckError, assertToolResult };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_diagnostic = require("../diagnostic-ol9IE9Dl.cjs");
|
|
3
|
+
let _modelcontextprotocol_client = require("@modelcontextprotocol/client");
|
|
4
|
+
let _modelcontextprotocol_client_validators_ajv = require("@modelcontextprotocol/client/validators/ajv");
|
|
5
|
+
let node_net = require("node:net");
|
|
6
|
+
//#region src/testing/server.ts
|
|
7
|
+
async function withMcpClient(options, run) {
|
|
8
|
+
let endpoint;
|
|
9
|
+
let headers;
|
|
10
|
+
const version = options.protocolVersion ?? "2026-07-28";
|
|
11
|
+
const timeoutMs = options.timeoutMs ?? 1e4;
|
|
12
|
+
try {
|
|
13
|
+
endpoint = new URL(options.endpoint);
|
|
14
|
+
headers = new Headers(options.headers);
|
|
15
|
+
const host = endpoint.hostname;
|
|
16
|
+
const loopback = host === "localhost" || host === "[::1]" || (0, node_net.isIP)(host) === 4 && host.startsWith("127.");
|
|
17
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 2147483647 || !["2025-11-25", "2026-07-28"].includes(version) || !["http:", "https:"].includes(endpoint.protocol) || endpoint.username || endpoint.password || endpoint.hash || endpoint.protocol === "http:" && !loopback && !options.handler && [...headers].length > 0) throw new Error();
|
|
18
|
+
} catch {
|
|
19
|
+
throw new require_diagnostic.McpCheckError({
|
|
20
|
+
code: "connection.options",
|
|
21
|
+
basis: "package-guarantee",
|
|
22
|
+
message: "Use a valid HTTP(S) endpoint without URL credentials or fragment, a supported protocol and a positive timeout. Remote HTTP with supplied headers is refused."
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const client = new _modelcontextprotocol_client.Client({
|
|
26
|
+
name: "mcp-js-tests",
|
|
27
|
+
version: "1"
|
|
28
|
+
}, {
|
|
29
|
+
supportedProtocolVersions: [version],
|
|
30
|
+
versionNegotiation: { mode: version === "2025-11-25" ? "legacy" : { pin: version } },
|
|
31
|
+
capabilities: options.capabilities ?? {},
|
|
32
|
+
inputRequired: { autoFulfill: false },
|
|
33
|
+
listMaxPages: 16
|
|
34
|
+
});
|
|
35
|
+
const transport = new _modelcontextprotocol_client.StreamableHTTPClientTransport(endpoint, {
|
|
36
|
+
requestInit: { headers },
|
|
37
|
+
fetch: async (url, init) => {
|
|
38
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
39
|
+
const request = new Request(url, {
|
|
40
|
+
...init,
|
|
41
|
+
redirect: "manual",
|
|
42
|
+
signal: init?.signal ? AbortSignal.any([timeout, init.signal]) : timeout
|
|
43
|
+
});
|
|
44
|
+
if (request.url !== endpoint.href) throw new Error("Test transport refused a different endpoint.");
|
|
45
|
+
let onAbort = () => {};
|
|
46
|
+
let response;
|
|
47
|
+
try {
|
|
48
|
+
response = await Promise.race([options.handler ? options.handler(request) : fetch(request), new Promise((_resolve, reject) => {
|
|
49
|
+
onAbort = () => reject(request.signal.reason);
|
|
50
|
+
if (request.signal.aborted) onAbort();
|
|
51
|
+
else request.signal.addEventListener("abort", onAbort, { once: true });
|
|
52
|
+
})]);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (timeout.aborted && error === timeout.reason) throw new _modelcontextprotocol_client.SdkError(_modelcontextprotocol_client.SdkErrorCode.RequestTimeout, "Request timed out");
|
|
55
|
+
throw error;
|
|
56
|
+
} finally {
|
|
57
|
+
request.signal.removeEventListener("abort", onAbort);
|
|
58
|
+
}
|
|
59
|
+
if (response.status >= 300 && response.status < 400) {
|
|
60
|
+
await response.body?.cancel();
|
|
61
|
+
throw new Error("Test transport refused a redirect. Configure the final endpoint explicitly.");
|
|
62
|
+
}
|
|
63
|
+
return response;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
try {
|
|
67
|
+
await client.connect(transport, { timeout: timeoutMs });
|
|
68
|
+
return await run(client);
|
|
69
|
+
} finally {
|
|
70
|
+
await client.close();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function checkMcpServer(options) {
|
|
74
|
+
const checks = [];
|
|
75
|
+
const calls = options.calls ?? [];
|
|
76
|
+
const timeout = options.timeoutMs ?? 1e4;
|
|
77
|
+
let nextCall = 0;
|
|
78
|
+
let stage = "server.connect";
|
|
79
|
+
let location;
|
|
80
|
+
const record = (code, message, status = "passed", basis = "protocol-requirement") => {
|
|
81
|
+
checks.push({
|
|
82
|
+
code,
|
|
83
|
+
message,
|
|
84
|
+
status,
|
|
85
|
+
basis,
|
|
86
|
+
location
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
try {
|
|
90
|
+
await withMcpClient(options, async (client) => {
|
|
91
|
+
record(stage, "The official client connected with the configured protocol and caller headers.");
|
|
92
|
+
stage = "server.tools";
|
|
93
|
+
const { tools } = client.getServerCapabilities()?.tools ? await client.listTools(void 0, {
|
|
94
|
+
cacheMode: "bypass",
|
|
95
|
+
timeout
|
|
96
|
+
}) : { tools: [] };
|
|
97
|
+
record(stage, "The official client decoded the tool catalog; the tools capability is optional.");
|
|
98
|
+
const unsupported = /* @__PURE__ */ new Set();
|
|
99
|
+
for (const [index, tool] of tools.entries()) {
|
|
100
|
+
location = `tools[${index}]`;
|
|
101
|
+
stage = "server.schemas";
|
|
102
|
+
for (const schema of [tool.inputSchema, tool.outputSchema]) {
|
|
103
|
+
if (!schema) continue;
|
|
104
|
+
if (typeof schema.$schema === "string" && !/^https?:\/\/json-schema\.org\/(?:draft\/(?:2020-12|2019-09)|draft-0[67])\/schema#?$/.test(schema.$schema)) {
|
|
105
|
+
unsupported.add(tool.name);
|
|
106
|
+
record(stage, "This helper cannot validate the declared schema dialect. Selected calls to this tool and subsequent calls will not run.", "not-tested", "package-guarantee");
|
|
107
|
+
} else new _modelcontextprotocol_client_validators_ajv.AjvJsonSchemaValidator().getValidator(schema);
|
|
108
|
+
}
|
|
109
|
+
if (!unsupported.has(tool.name)) record(stage, "Advertised schemas compile with the SDK validator.");
|
|
110
|
+
}
|
|
111
|
+
for (; nextCall < calls.length; nextCall++) {
|
|
112
|
+
const call = calls[nextCall];
|
|
113
|
+
location = `calls[${nextCall}]`;
|
|
114
|
+
stage = "tool.call";
|
|
115
|
+
if (unsupported.has(call.name)) break;
|
|
116
|
+
const tool = tools.find((entry) => entry.name === call.name);
|
|
117
|
+
if (!tool) throw new require_diagnostic.McpCheckError({
|
|
118
|
+
code: "tool.not-found",
|
|
119
|
+
basis: "app-expectation",
|
|
120
|
+
message: "Selected tool was not advertised to this caller. No call was made."
|
|
121
|
+
});
|
|
122
|
+
const { outputSchema, ...definition } = tool;
|
|
123
|
+
const result = await client.callTool({
|
|
124
|
+
name: call.name,
|
|
125
|
+
arguments: call.arguments
|
|
126
|
+
}, {
|
|
127
|
+
toolDefinition: definition,
|
|
128
|
+
timeout
|
|
129
|
+
});
|
|
130
|
+
if (result.isError === true !== (call.isError === true)) throw new require_diagnostic.McpCheckError({
|
|
131
|
+
code: "result.expected-error",
|
|
132
|
+
basis: "app-expectation",
|
|
133
|
+
message: call.isError ? "Expected an error result." : "Expected a successful result."
|
|
134
|
+
});
|
|
135
|
+
if (!result.isError && outputSchema && (result.structuredContent === void 0 || !new _modelcontextprotocol_client_validators_ajv.AjvJsonSchemaValidator().getValidator(outputSchema)(result.structuredContent).valid)) throw new require_diagnostic.McpCheckError({
|
|
136
|
+
code: "result.output-schema",
|
|
137
|
+
basis: "protocol-requirement",
|
|
138
|
+
message: "Successful structuredContent must match the advertised outputSchema."
|
|
139
|
+
});
|
|
140
|
+
record(stage, "The selected call returned the expected success/error result and matched its advertised output schema, if any.");
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
} catch (error) {
|
|
144
|
+
const status = _modelcontextprotocol_client.SdkError.isInstance(error) && typeof error.data === "object" && error.data !== null && "status" in error.data ? error.data.status : void 0;
|
|
145
|
+
const sdkCode = status === 401 ? _modelcontextprotocol_client.SdkErrorCode.ClientHttpAuthentication : status === 403 ? _modelcontextprotocol_client.SdkErrorCode.ClientHttpForbidden : _modelcontextprotocol_client.SdkError.isInstance(error) ? error.code : void 0;
|
|
146
|
+
const incomplete = _modelcontextprotocol_client.SdkError.isInstance(error) && sdkCode === _modelcontextprotocol_client.SdkErrorCode.UnsupportedResultType && error.data !== null && typeof error.data === "object" && "resultType" in error.data && error.data.resultType === "input_required";
|
|
147
|
+
const typed = {
|
|
148
|
+
[_modelcontextprotocol_client.SdkErrorCode.ClientHttpAuthentication]: {
|
|
149
|
+
code: "server.unauthorized",
|
|
150
|
+
message: "The endpoint rejected authentication. Check the supplied credentials and audience."
|
|
151
|
+
},
|
|
152
|
+
[_modelcontextprotocol_client.SdkErrorCode.ClientHttpForbidden]: {
|
|
153
|
+
code: "server.forbidden",
|
|
154
|
+
message: "The endpoint refused access for this caller."
|
|
155
|
+
},
|
|
156
|
+
[_modelcontextprotocol_client.SdkErrorCode.RequestTimeout]: {
|
|
157
|
+
code: "server.timeout",
|
|
158
|
+
message: "The request timed out. Check endpoint availability and the configured timeout."
|
|
159
|
+
},
|
|
160
|
+
[_modelcontextprotocol_client.SdkErrorCode.InvalidResult]: {
|
|
161
|
+
code: "result.shape",
|
|
162
|
+
message: "The official client rejected the response shape."
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const known = sdkCode === void 0 ? void 0 : typed[sdkCode];
|
|
166
|
+
const diagnostic = incomplete ? {
|
|
167
|
+
code: "tool.input-required",
|
|
168
|
+
basis: "package-guarantee",
|
|
169
|
+
message: "The selected call requires additional input. No input was supplied and later calls will not run."
|
|
170
|
+
} : error instanceof require_diagnostic.McpCheckError ? error.diagnostic : {
|
|
171
|
+
code: stage,
|
|
172
|
+
basis: "package-guarantee",
|
|
173
|
+
message: stage === "server.connect" ? "Connection failed. Check endpoint, credentials and protocol support; response details are omitted." : stage === "server.schemas" ? "Schema compilation failed. Check dialect, references and syntax; remote references are not fetched." : "The check could not complete. Inspect this contract in an app test; response details are omitted.",
|
|
174
|
+
...known
|
|
175
|
+
};
|
|
176
|
+
checks.push({
|
|
177
|
+
...diagnostic,
|
|
178
|
+
location,
|
|
179
|
+
status: incomplete ? "not-tested" : "failed"
|
|
180
|
+
});
|
|
181
|
+
if (location === `calls[${nextCall}]`) nextCall++;
|
|
182
|
+
}
|
|
183
|
+
for (; nextCall < calls.length; nextCall++) {
|
|
184
|
+
location = `calls[${nextCall}]`;
|
|
185
|
+
record("tool.call", "Call not run because a prerequisite check or selected call did not complete.", "not-tested", "app-expectation");
|
|
186
|
+
}
|
|
187
|
+
location = void 0;
|
|
188
|
+
record("app.behavior", "Authentication enforcement, business behavior, browser interactions and deployed OAuth require app-owned tests. This is not full MCP conformance.", "not-tested", "app-expectation");
|
|
189
|
+
if (calls.length === 0) record("tool.calls", "No calls selected; input enforcement and result mapping were not exercised.", "not-tested", "app-expectation");
|
|
190
|
+
return {
|
|
191
|
+
checks,
|
|
192
|
+
passed: checks.every((check) => check.status !== "failed")
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
exports.checkMcpServer = checkMcpServer;
|
|
197
|
+
exports.withMcpClient = withMcpClient;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { t as Diagnostic } from "../diagnostic-DRKjgCsW.cjs";
|
|
2
|
+
import { Client, ClientCapabilities } from "@modelcontextprotocol/client";
|
|
3
|
+
//#region src/testing/server.d.ts
|
|
4
|
+
type ProtocolVersion = "2025-11-25" | "2026-07-28";
|
|
5
|
+
interface McpTestConnection {
|
|
6
|
+
endpoint: string | URL;
|
|
7
|
+
protocolVersion?: ProtocolVersion;
|
|
8
|
+
headers?: ConstructorParameters<typeof Headers>[0];
|
|
9
|
+
handler?: (request: Request) => Promise<Response>;
|
|
10
|
+
capabilities?: ClientCapabilities;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
declare function withMcpClient<T>(options: McpTestConnection, run: (client: Client) => Promise<T>): Promise<T>;
|
|
14
|
+
interface ServerCheck extends Diagnostic {
|
|
15
|
+
status: "passed" | "failed" | "not-tested";
|
|
16
|
+
location?: string;
|
|
17
|
+
}
|
|
18
|
+
interface ServerCheckReport {
|
|
19
|
+
checks: ServerCheck[];
|
|
20
|
+
passed: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface ServerCheckOptions extends McpTestConnection {
|
|
23
|
+
calls?: {
|
|
24
|
+
name: string;
|
|
25
|
+
arguments?: Record<string, unknown>;
|
|
26
|
+
isError?: boolean;
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
declare function checkMcpServer(options: ServerCheckOptions): Promise<ServerCheckReport>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { McpTestConnection, ProtocolVersion, ServerCheck, ServerCheckOptions, ServerCheckReport, checkMcpServer, withMcpClient };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { t as Diagnostic } from "../diagnostic-DRKjgCsW.js";
|
|
2
|
+
import { Client, ClientCapabilities } from "@modelcontextprotocol/client";
|
|
3
|
+
//#region src/testing/server.d.ts
|
|
4
|
+
type ProtocolVersion = "2025-11-25" | "2026-07-28";
|
|
5
|
+
interface McpTestConnection {
|
|
6
|
+
endpoint: string | URL;
|
|
7
|
+
protocolVersion?: ProtocolVersion;
|
|
8
|
+
headers?: ConstructorParameters<typeof Headers>[0];
|
|
9
|
+
handler?: (request: Request) => Promise<Response>;
|
|
10
|
+
capabilities?: ClientCapabilities;
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
declare function withMcpClient<T>(options: McpTestConnection, run: (client: Client) => Promise<T>): Promise<T>;
|
|
14
|
+
interface ServerCheck extends Diagnostic {
|
|
15
|
+
status: "passed" | "failed" | "not-tested";
|
|
16
|
+
location?: string;
|
|
17
|
+
}
|
|
18
|
+
interface ServerCheckReport {
|
|
19
|
+
checks: ServerCheck[];
|
|
20
|
+
passed: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface ServerCheckOptions extends McpTestConnection {
|
|
23
|
+
calls?: {
|
|
24
|
+
name: string;
|
|
25
|
+
arguments?: Record<string, unknown>;
|
|
26
|
+
isError?: boolean;
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
declare function checkMcpServer(options: ServerCheckOptions): Promise<ServerCheckReport>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { McpTestConnection, ProtocolVersion, ServerCheck, ServerCheckOptions, ServerCheckReport, checkMcpServer, withMcpClient };
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { t as McpCheckError } from "../diagnostic-ClI2_5MW.js";
|
|
2
|
+
import { Client, SdkError, SdkErrorCode, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
|
|
3
|
+
import { AjvJsonSchemaValidator } from "@modelcontextprotocol/client/validators/ajv";
|
|
4
|
+
import { isIP } from "node:net";
|
|
5
|
+
//#region src/testing/server.ts
|
|
6
|
+
async function withMcpClient(options, run) {
|
|
7
|
+
let endpoint;
|
|
8
|
+
let headers;
|
|
9
|
+
const version = options.protocolVersion ?? "2026-07-28";
|
|
10
|
+
const timeoutMs = options.timeoutMs ?? 1e4;
|
|
11
|
+
try {
|
|
12
|
+
endpoint = new URL(options.endpoint);
|
|
13
|
+
headers = new Headers(options.headers);
|
|
14
|
+
const host = endpoint.hostname;
|
|
15
|
+
const loopback = host === "localhost" || host === "[::1]" || isIP(host) === 4 && host.startsWith("127.");
|
|
16
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 2147483647 || !["2025-11-25", "2026-07-28"].includes(version) || !["http:", "https:"].includes(endpoint.protocol) || endpoint.username || endpoint.password || endpoint.hash || endpoint.protocol === "http:" && !loopback && !options.handler && [...headers].length > 0) throw new Error();
|
|
17
|
+
} catch {
|
|
18
|
+
throw new McpCheckError({
|
|
19
|
+
code: "connection.options",
|
|
20
|
+
basis: "package-guarantee",
|
|
21
|
+
message: "Use a valid HTTP(S) endpoint without URL credentials or fragment, a supported protocol and a positive timeout. Remote HTTP with supplied headers is refused."
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const client = new Client({
|
|
25
|
+
name: "mcp-js-tests",
|
|
26
|
+
version: "1"
|
|
27
|
+
}, {
|
|
28
|
+
supportedProtocolVersions: [version],
|
|
29
|
+
versionNegotiation: { mode: version === "2025-11-25" ? "legacy" : { pin: version } },
|
|
30
|
+
capabilities: options.capabilities ?? {},
|
|
31
|
+
inputRequired: { autoFulfill: false },
|
|
32
|
+
listMaxPages: 16
|
|
33
|
+
});
|
|
34
|
+
const transport = new StreamableHTTPClientTransport(endpoint, {
|
|
35
|
+
requestInit: { headers },
|
|
36
|
+
fetch: async (url, init) => {
|
|
37
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
38
|
+
const request = new Request(url, {
|
|
39
|
+
...init,
|
|
40
|
+
redirect: "manual",
|
|
41
|
+
signal: init?.signal ? AbortSignal.any([timeout, init.signal]) : timeout
|
|
42
|
+
});
|
|
43
|
+
if (request.url !== endpoint.href) throw new Error("Test transport refused a different endpoint.");
|
|
44
|
+
let onAbort = () => {};
|
|
45
|
+
let response;
|
|
46
|
+
try {
|
|
47
|
+
response = await Promise.race([options.handler ? options.handler(request) : fetch(request), new Promise((_resolve, reject) => {
|
|
48
|
+
onAbort = () => reject(request.signal.reason);
|
|
49
|
+
if (request.signal.aborted) onAbort();
|
|
50
|
+
else request.signal.addEventListener("abort", onAbort, { once: true });
|
|
51
|
+
})]);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (timeout.aborted && error === timeout.reason) throw new SdkError(SdkErrorCode.RequestTimeout, "Request timed out");
|
|
54
|
+
throw error;
|
|
55
|
+
} finally {
|
|
56
|
+
request.signal.removeEventListener("abort", onAbort);
|
|
57
|
+
}
|
|
58
|
+
if (response.status >= 300 && response.status < 400) {
|
|
59
|
+
await response.body?.cancel();
|
|
60
|
+
throw new Error("Test transport refused a redirect. Configure the final endpoint explicitly.");
|
|
61
|
+
}
|
|
62
|
+
return response;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
try {
|
|
66
|
+
await client.connect(transport, { timeout: timeoutMs });
|
|
67
|
+
return await run(client);
|
|
68
|
+
} finally {
|
|
69
|
+
await client.close();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function checkMcpServer(options) {
|
|
73
|
+
const checks = [];
|
|
74
|
+
const calls = options.calls ?? [];
|
|
75
|
+
const timeout = options.timeoutMs ?? 1e4;
|
|
76
|
+
let nextCall = 0;
|
|
77
|
+
let stage = "server.connect";
|
|
78
|
+
let location;
|
|
79
|
+
const record = (code, message, status = "passed", basis = "protocol-requirement") => {
|
|
80
|
+
checks.push({
|
|
81
|
+
code,
|
|
82
|
+
message,
|
|
83
|
+
status,
|
|
84
|
+
basis,
|
|
85
|
+
location
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
try {
|
|
89
|
+
await withMcpClient(options, async (client) => {
|
|
90
|
+
record(stage, "The official client connected with the configured protocol and caller headers.");
|
|
91
|
+
stage = "server.tools";
|
|
92
|
+
const { tools } = client.getServerCapabilities()?.tools ? await client.listTools(void 0, {
|
|
93
|
+
cacheMode: "bypass",
|
|
94
|
+
timeout
|
|
95
|
+
}) : { tools: [] };
|
|
96
|
+
record(stage, "The official client decoded the tool catalog; the tools capability is optional.");
|
|
97
|
+
const unsupported = /* @__PURE__ */ new Set();
|
|
98
|
+
for (const [index, tool] of tools.entries()) {
|
|
99
|
+
location = `tools[${index}]`;
|
|
100
|
+
stage = "server.schemas";
|
|
101
|
+
for (const schema of [tool.inputSchema, tool.outputSchema]) {
|
|
102
|
+
if (!schema) continue;
|
|
103
|
+
if (typeof schema.$schema === "string" && !/^https?:\/\/json-schema\.org\/(?:draft\/(?:2020-12|2019-09)|draft-0[67])\/schema#?$/.test(schema.$schema)) {
|
|
104
|
+
unsupported.add(tool.name);
|
|
105
|
+
record(stage, "This helper cannot validate the declared schema dialect. Selected calls to this tool and subsequent calls will not run.", "not-tested", "package-guarantee");
|
|
106
|
+
} else new AjvJsonSchemaValidator().getValidator(schema);
|
|
107
|
+
}
|
|
108
|
+
if (!unsupported.has(tool.name)) record(stage, "Advertised schemas compile with the SDK validator.");
|
|
109
|
+
}
|
|
110
|
+
for (; nextCall < calls.length; nextCall++) {
|
|
111
|
+
const call = calls[nextCall];
|
|
112
|
+
location = `calls[${nextCall}]`;
|
|
113
|
+
stage = "tool.call";
|
|
114
|
+
if (unsupported.has(call.name)) break;
|
|
115
|
+
const tool = tools.find((entry) => entry.name === call.name);
|
|
116
|
+
if (!tool) throw new McpCheckError({
|
|
117
|
+
code: "tool.not-found",
|
|
118
|
+
basis: "app-expectation",
|
|
119
|
+
message: "Selected tool was not advertised to this caller. No call was made."
|
|
120
|
+
});
|
|
121
|
+
const { outputSchema, ...definition } = tool;
|
|
122
|
+
const result = await client.callTool({
|
|
123
|
+
name: call.name,
|
|
124
|
+
arguments: call.arguments
|
|
125
|
+
}, {
|
|
126
|
+
toolDefinition: definition,
|
|
127
|
+
timeout
|
|
128
|
+
});
|
|
129
|
+
if (result.isError === true !== (call.isError === true)) throw new McpCheckError({
|
|
130
|
+
code: "result.expected-error",
|
|
131
|
+
basis: "app-expectation",
|
|
132
|
+
message: call.isError ? "Expected an error result." : "Expected a successful result."
|
|
133
|
+
});
|
|
134
|
+
if (!result.isError && outputSchema && (result.structuredContent === void 0 || !new AjvJsonSchemaValidator().getValidator(outputSchema)(result.structuredContent).valid)) throw new McpCheckError({
|
|
135
|
+
code: "result.output-schema",
|
|
136
|
+
basis: "protocol-requirement",
|
|
137
|
+
message: "Successful structuredContent must match the advertised outputSchema."
|
|
138
|
+
});
|
|
139
|
+
record(stage, "The selected call returned the expected success/error result and matched its advertised output schema, if any.");
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
} catch (error) {
|
|
143
|
+
const status = SdkError.isInstance(error) && typeof error.data === "object" && error.data !== null && "status" in error.data ? error.data.status : void 0;
|
|
144
|
+
const sdkCode = status === 401 ? SdkErrorCode.ClientHttpAuthentication : status === 403 ? SdkErrorCode.ClientHttpForbidden : SdkError.isInstance(error) ? error.code : void 0;
|
|
145
|
+
const incomplete = SdkError.isInstance(error) && sdkCode === SdkErrorCode.UnsupportedResultType && error.data !== null && typeof error.data === "object" && "resultType" in error.data && error.data.resultType === "input_required";
|
|
146
|
+
const typed = {
|
|
147
|
+
[SdkErrorCode.ClientHttpAuthentication]: {
|
|
148
|
+
code: "server.unauthorized",
|
|
149
|
+
message: "The endpoint rejected authentication. Check the supplied credentials and audience."
|
|
150
|
+
},
|
|
151
|
+
[SdkErrorCode.ClientHttpForbidden]: {
|
|
152
|
+
code: "server.forbidden",
|
|
153
|
+
message: "The endpoint refused access for this caller."
|
|
154
|
+
},
|
|
155
|
+
[SdkErrorCode.RequestTimeout]: {
|
|
156
|
+
code: "server.timeout",
|
|
157
|
+
message: "The request timed out. Check endpoint availability and the configured timeout."
|
|
158
|
+
},
|
|
159
|
+
[SdkErrorCode.InvalidResult]: {
|
|
160
|
+
code: "result.shape",
|
|
161
|
+
message: "The official client rejected the response shape."
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const known = sdkCode === void 0 ? void 0 : typed[sdkCode];
|
|
165
|
+
const diagnostic = incomplete ? {
|
|
166
|
+
code: "tool.input-required",
|
|
167
|
+
basis: "package-guarantee",
|
|
168
|
+
message: "The selected call requires additional input. No input was supplied and later calls will not run."
|
|
169
|
+
} : error instanceof McpCheckError ? error.diagnostic : {
|
|
170
|
+
code: stage,
|
|
171
|
+
basis: "package-guarantee",
|
|
172
|
+
message: stage === "server.connect" ? "Connection failed. Check endpoint, credentials and protocol support; response details are omitted." : stage === "server.schemas" ? "Schema compilation failed. Check dialect, references and syntax; remote references are not fetched." : "The check could not complete. Inspect this contract in an app test; response details are omitted.",
|
|
173
|
+
...known
|
|
174
|
+
};
|
|
175
|
+
checks.push({
|
|
176
|
+
...diagnostic,
|
|
177
|
+
location,
|
|
178
|
+
status: incomplete ? "not-tested" : "failed"
|
|
179
|
+
});
|
|
180
|
+
if (location === `calls[${nextCall}]`) nextCall++;
|
|
181
|
+
}
|
|
182
|
+
for (; nextCall < calls.length; nextCall++) {
|
|
183
|
+
location = `calls[${nextCall}]`;
|
|
184
|
+
record("tool.call", "Call not run because a prerequisite check or selected call did not complete.", "not-tested", "app-expectation");
|
|
185
|
+
}
|
|
186
|
+
location = void 0;
|
|
187
|
+
record("app.behavior", "Authentication enforcement, business behavior, browser interactions and deployed OAuth require app-owned tests. This is not full MCP conformance.", "not-tested", "app-expectation");
|
|
188
|
+
if (calls.length === 0) record("tool.calls", "No calls selected; input enforcement and result mapping were not exercised.", "not-tested", "app-expectation");
|
|
189
|
+
return {
|
|
190
|
+
checks,
|
|
191
|
+
passed: checks.every((check) => check.status !== "failed")
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
export { checkMcpServer, withMcpClient };
|