@mapomodule/mcp 0.0.0-stage → 1.0.0-beta.2

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.
Files changed (166) hide show
  1. package/README.md +509 -2
  2. package/bin/mapo-mcp.mjs +3 -0
  3. package/dist/build.d.mts +18 -0
  4. package/dist/build.d.ts +18 -0
  5. package/dist/build.mjs +351 -0
  6. package/dist/cli.d.mts +7 -0
  7. package/dist/cli.d.ts +7 -0
  8. package/dist/cli.mjs +274 -0
  9. package/dist/index.d.mts +68 -0
  10. package/dist/index.d.ts +68 -0
  11. package/dist/index.mjs +1 -0
  12. package/dist/knowledge/api.json +1 -0
  13. package/dist/knowledge/docs.json +1 -0
  14. package/dist/module.d.mts +16 -0
  15. package/dist/module.d.ts +16 -0
  16. package/dist/module.json +9 -0
  17. package/dist/module.mjs +124 -0
  18. package/dist/runtime/core/doctor.d.ts +0 -0
  19. package/dist/runtime/core/doctor.js +128 -0
  20. package/dist/runtime/core/endpoint.d.ts +0 -0
  21. package/dist/runtime/core/endpoint.js +8 -0
  22. package/dist/runtime/core/indexer.d.ts +0 -0
  23. package/dist/runtime/core/indexer.js +194 -0
  24. package/dist/runtime/core/instructions.d.ts +0 -0
  25. package/dist/runtime/core/instructions.js +10 -0
  26. package/dist/runtime/core/knowledge.d.ts +0 -0
  27. package/dist/runtime/core/knowledge.js +76 -0
  28. package/dist/runtime/core/openapi.d.ts +0 -0
  29. package/dist/runtime/core/openapi.js +229 -0
  30. package/dist/runtime/core/overview.d.ts +0 -0
  31. package/dist/runtime/core/overview.js +15 -0
  32. package/dist/runtime/core/prompts.d.ts +0 -0
  33. package/dist/runtime/core/prompts.js +108 -0
  34. package/dist/runtime/core/recipes.d.ts +0 -0
  35. package/dist/runtime/core/recipes.js +496 -0
  36. package/dist/runtime/core/resources.d.ts +0 -0
  37. package/dist/runtime/core/resources.js +92 -0
  38. package/dist/runtime/core/scaffold/fields.d.ts +0 -0
  39. package/dist/runtime/core/scaffold/fields.js +64 -0
  40. package/dist/runtime/core/scaffold/index.d.ts +0 -0
  41. package/dist/runtime/core/scaffold/index.js +74 -0
  42. package/dist/runtime/core/scaffold/templates.d.ts +0 -0
  43. package/dist/runtime/core/scaffold/templates.js +349 -0
  44. package/dist/runtime/core/schema-source.d.ts +0 -0
  45. package/dist/runtime/core/schema-source.js +70 -0
  46. package/dist/runtime/core/search.d.ts +0 -0
  47. package/dist/runtime/core/search.js +173 -0
  48. package/dist/runtime/core/tokenize.d.ts +0 -0
  49. package/dist/runtime/core/tokenize.js +96 -0
  50. package/dist/runtime/core/tool-spec.d.ts +0 -0
  51. package/dist/runtime/core/tool-spec.js +3 -0
  52. package/dist/runtime/core/tools/api.d.ts +0 -0
  53. package/dist/runtime/core/tools/api.js +192 -0
  54. package/dist/runtime/core/tools/app.d.ts +0 -0
  55. package/dist/runtime/core/tools/app.js +141 -0
  56. package/dist/runtime/core/tools/backend.d.ts +0 -0
  57. package/dist/runtime/core/tools/backend.js +143 -0
  58. package/dist/runtime/core/tools/docs.d.ts +0 -0
  59. package/dist/runtime/core/tools/docs.js +154 -0
  60. package/dist/runtime/core/tools/scaffold.d.ts +0 -0
  61. package/dist/runtime/core/tools/scaffold.js +127 -0
  62. package/dist/runtime/core/types.d.ts +0 -0
  63. package/dist/runtime/core/types.js +0 -0
  64. package/dist/runtime/core/write.d.ts +0 -0
  65. package/dist/runtime/core/write.js +53 -0
  66. package/dist/runtime/mcp/handlers/mapo/index.js +7 -0
  67. package/dist/runtime/mcp/handlers/mapo/prompts/crud-page.js +3 -0
  68. package/dist/runtime/mcp/handlers/mapo/prompts/custom-field.js +3 -0
  69. package/dist/runtime/mcp/handlers/mapo/prompts/debug-form.js +3 -0
  70. package/dist/runtime/mcp/handlers/mapo/prompts/migrate-v1.js +3 -0
  71. package/dist/runtime/mcp/handlers/mapo/prompts/theme.js +3 -0
  72. package/dist/runtime/mcp/handlers/mapo/resources/app-manifest.js +19 -0
  73. package/dist/runtime/mcp/handlers/mapo/resources/docs.js +34 -0
  74. package/dist/runtime/mcp/handlers/mapo/resources/fields.js +34 -0
  75. package/dist/runtime/mcp/handlers/mapo/resources/knowledge-index.js +22 -0
  76. package/dist/runtime/mcp/handlers/mapo/resources/overview.js +20 -0
  77. package/dist/runtime/mcp/handlers/mapo/tools/backend-schema.js +3 -0
  78. package/dist/runtime/mcp/handlers/mapo/tools/component-api.js +3 -0
  79. package/dist/runtime/mcp/handlers/mapo/tools/composable-api.js +3 -0
  80. package/dist/runtime/mcp/handlers/mapo/tools/doctor.js +3 -0
  81. package/dist/runtime/mcp/handlers/mapo/tools/get-doc.js +3 -0
  82. package/dist/runtime/mcp/handlers/mapo/tools/inspect-app.js +3 -0
  83. package/dist/runtime/mcp/handlers/mapo/tools/list-field-types.js +3 -0
  84. package/dist/runtime/mcp/handlers/mapo/tools/list-recipes.js +3 -0
  85. package/dist/runtime/mcp/handlers/mapo/tools/scaffold.js +3 -0
  86. package/dist/runtime/mcp/handlers/mapo/tools/search-docs.js +3 -0
  87. package/dist/runtime/nitro/context.d.ts +0 -0
  88. package/dist/runtime/nitro/context.js +21 -0
  89. package/dist/runtime/nitro/to-mcp-prompt.d.ts +0 -0
  90. package/dist/runtime/nitro/to-mcp-prompt.js +23 -0
  91. package/dist/runtime/nitro/to-mcp-tool.d.ts +0 -0
  92. package/dist/runtime/nitro/to-mcp-tool.js +28 -0
  93. package/dist/runtime/types/virtual-modules.d.ts +6 -0
  94. package/dist/types.d.mts +9 -0
  95. package/package.json +73 -4
  96. package/src/__tests__/cli.test.ts +137 -0
  97. package/src/__tests__/doctor.test.ts +145 -0
  98. package/src/__tests__/endpoint.test.ts +31 -0
  99. package/src/__tests__/fixtures/drf-schema.json +142 -0
  100. package/src/__tests__/fixtures.ts +198 -0
  101. package/src/__tests__/indexer.test.ts +114 -0
  102. package/src/__tests__/knowledge.test.ts +225 -0
  103. package/src/__tests__/openapi.test.ts +256 -0
  104. package/src/__tests__/overview.test.ts +105 -0
  105. package/src/__tests__/recipes.test.ts +55 -0
  106. package/src/__tests__/resources.test.ts +69 -0
  107. package/src/__tests__/scaffold.test.ts +153 -0
  108. package/src/__tests__/search.test.ts +105 -0
  109. package/src/__tests__/tools.test.ts +226 -0
  110. package/src/__tests__/write.test.ts +134 -0
  111. package/src/build/extract-components.ts +135 -0
  112. package/src/build/extract-composables.ts +125 -0
  113. package/src/build/extract-fields.ts +250 -0
  114. package/src/build/index.ts +103 -0
  115. package/src/cli.ts +375 -0
  116. package/src/index.ts +65 -0
  117. package/src/module.ts +213 -0
  118. package/src/runtime/core/doctor.ts +204 -0
  119. package/src/runtime/core/endpoint.ts +27 -0
  120. package/src/runtime/core/indexer.ts +285 -0
  121. package/src/runtime/core/instructions.ts +18 -0
  122. package/src/runtime/core/knowledge.ts +121 -0
  123. package/src/runtime/core/openapi.ts +417 -0
  124. package/src/runtime/core/overview.ts +44 -0
  125. package/src/runtime/core/prompts.ts +150 -0
  126. package/src/runtime/core/recipes.ts +574 -0
  127. package/src/runtime/core/resources.ts +150 -0
  128. package/src/runtime/core/scaffold/fields.ts +127 -0
  129. package/src/runtime/core/scaffold/index.ts +120 -0
  130. package/src/runtime/core/scaffold/templates.ts +394 -0
  131. package/src/runtime/core/schema-source.ts +123 -0
  132. package/src/runtime/core/search.ts +282 -0
  133. package/src/runtime/core/tokenize.ts +146 -0
  134. package/src/runtime/core/tool-spec.ts +74 -0
  135. package/src/runtime/core/tools/api.ts +300 -0
  136. package/src/runtime/core/tools/app.ts +201 -0
  137. package/src/runtime/core/tools/backend.ts +197 -0
  138. package/src/runtime/core/tools/docs.ts +218 -0
  139. package/src/runtime/core/tools/scaffold.ts +176 -0
  140. package/src/runtime/core/types.ts +133 -0
  141. package/src/runtime/core/write.ts +119 -0
  142. package/src/runtime/mcp/handlers/mapo/index.ts +16 -0
  143. package/src/runtime/mcp/handlers/mapo/prompts/crud-page.ts +4 -0
  144. package/src/runtime/mcp/handlers/mapo/prompts/custom-field.ts +4 -0
  145. package/src/runtime/mcp/handlers/mapo/prompts/debug-form.ts +4 -0
  146. package/src/runtime/mcp/handlers/mapo/prompts/migrate-v1.ts +4 -0
  147. package/src/runtime/mcp/handlers/mapo/prompts/theme.ts +4 -0
  148. package/src/runtime/mcp/handlers/mapo/resources/app-manifest.ts +28 -0
  149. package/src/runtime/mcp/handlers/mapo/resources/docs.ts +41 -0
  150. package/src/runtime/mcp/handlers/mapo/resources/fields.ts +37 -0
  151. package/src/runtime/mcp/handlers/mapo/resources/knowledge-index.ts +24 -0
  152. package/src/runtime/mcp/handlers/mapo/resources/overview.ts +22 -0
  153. package/src/runtime/mcp/handlers/mapo/tools/backend-schema.ts +4 -0
  154. package/src/runtime/mcp/handlers/mapo/tools/component-api.ts +4 -0
  155. package/src/runtime/mcp/handlers/mapo/tools/composable-api.ts +4 -0
  156. package/src/runtime/mcp/handlers/mapo/tools/doctor.ts +4 -0
  157. package/src/runtime/mcp/handlers/mapo/tools/get-doc.ts +4 -0
  158. package/src/runtime/mcp/handlers/mapo/tools/inspect-app.ts +4 -0
  159. package/src/runtime/mcp/handlers/mapo/tools/list-field-types.ts +4 -0
  160. package/src/runtime/mcp/handlers/mapo/tools/list-recipes.ts +4 -0
  161. package/src/runtime/mcp/handlers/mapo/tools/scaffold.ts +4 -0
  162. package/src/runtime/mcp/handlers/mapo/tools/search-docs.ts +4 -0
  163. package/src/runtime/nitro/context.ts +41 -0
  164. package/src/runtime/nitro/to-mcp-prompt.ts +30 -0
  165. package/src/runtime/nitro/to-mcp-tool.ts +35 -0
  166. package/src/runtime/types/virtual-modules.d.ts +6 -0
@@ -0,0 +1,9 @@
1
+ import type { NuxtModule } from '@nuxt/schema'
2
+
3
+ import type { default as Module } from './module.mjs'
4
+
5
+ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
+
7
+ export { type MapoAppManifest, type MapoMcpContext } from './index.mjs'
8
+
9
+ export { type MapoMcpOptions, default } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,75 @@
1
1
  {
2
2
  "name": "@mapomodule/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0-beta.2",
4
+ "description": "Mapo MCP server: grounded docs, component and field APIs, live app introspection and scaffolding for AI assistants",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Lotrek Agency (https://lotrek.it)",
8
+ "homepage": "https://lotrekagency.github.io/mapo-new/",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/lotrekagency/mapo-new.git",
12
+ "directory": "packages/@mapomodule/mcp"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/lotrekagency/mapo-new/issues"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "tag": "next"
20
+ },
21
+ "bin": {
22
+ "mapo-mcp": "bin/mapo-mcp.mjs"
23
+ },
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/module.d.mts",
27
+ "import": "./dist/module.mjs"
28
+ },
29
+ "./types": {
30
+ "types": "./dist/index.d.mts",
31
+ "import": "./dist/index.mjs"
32
+ },
33
+ "./runtime/*": {
34
+ "types": "./src/runtime/*.ts",
35
+ "import": "./dist/runtime/*.js",
36
+ "default": "./src/runtime/*"
37
+ }
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "src",
42
+ "bin"
43
+ ],
44
+ "scripts": {
45
+ "build": "nuxt-module-build build && node scripts/clean-handler-dts.mjs && node scripts/build-knowledge.mjs",
46
+ "dev": "nuxt-module-build build --stub --watch",
47
+ "dev:prepare": "nuxt-module-build build --stub && node scripts/build-knowledge.mjs",
48
+ "knowledge": "node scripts/build-knowledge.mjs",
49
+ "typecheck": "tsc --noEmit",
50
+ "lint": "eslint src",
51
+ "test": "vitest run --passWithNoTests"
52
+ },
53
+ "dependencies": {
54
+ "@modelcontextprotocol/sdk": "^1.29.0",
55
+ "@nuxtjs/mcp-toolkit": "^0.18.0",
56
+ "citty": "^0.1.6",
57
+ "consola": "^3.4.2",
58
+ "zod": "^4.1.13"
59
+ },
60
+ "peerDependencies": {
61
+ "nuxt": ">=4.0.0"
62
+ },
63
+ "devDependencies": {
64
+ "@nuxt/kit": "4.4.2",
65
+ "@nuxt/module-builder": "^1.0.2",
66
+ "@nuxt/schema": "4.4.2",
67
+ "@types/node": "^25.6.0",
68
+ "jiti": "^2.7.0",
69
+ "nuxt": "^4.4.2",
70
+ "typescript": "^6.0.3",
71
+ "vitest": "^4.1.5",
72
+ "vue": "^3.5.32",
73
+ "vue-component-meta": "^3.3.4"
74
+ }
75
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * End-to-end check of the stdio transport: spawns the published bin and talks
3
+ * to it with a real MCP client. Skipped until the package is built.
4
+ */
5
+ import { existsSync } from "node:fs";
6
+ import { fileURLToPath } from "node:url";
7
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
8
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
9
+ import { afterAll, beforeAll, describe, expect, it } from "vitest";
10
+
11
+ /** `contents` is a text/blob union; every resource this server serves is text. */
12
+ interface TextResourceContent {
13
+ uri: string;
14
+ text: string;
15
+ mimeType?: string;
16
+ }
17
+
18
+ const binPath = fileURLToPath(
19
+ new URL("../../bin/mapo-mcp.mjs", import.meta.url),
20
+ );
21
+ const cliBuilt = existsSync(
22
+ fileURLToPath(new URL("../../dist/cli.mjs", import.meta.url)),
23
+ );
24
+ const describeBuilt = cliBuilt ? describe : describe.skip;
25
+
26
+ describeBuilt("mapo-mcp stdio server", () => {
27
+ let client: Client;
28
+
29
+ beforeAll(async () => {
30
+ client = new Client({ name: "mapo-mcp-test", version: "0.0.0" });
31
+ await client.connect(
32
+ new StdioClientTransport({
33
+ command: process.execPath,
34
+ // Port 9 (discard) is always refused: the live tools must degrade
35
+ // predictably instead of hitting a dev server that may be running.
36
+ args: [binPath, "serve", "--app", "http://127.0.0.1:9/mcp/mapo"],
37
+ }),
38
+ );
39
+ });
40
+
41
+ afterAll(async () => {
42
+ await client?.close();
43
+ });
44
+
45
+ it("advertises every tool that works without the dev server", async () => {
46
+ const { tools } = await client.listTools();
47
+ expect(tools.map((tool) => tool.name).sort()).toEqual([
48
+ "mapo_backend_schema",
49
+ "mapo_component_api",
50
+ "mapo_composable_api",
51
+ "mapo_doctor",
52
+ "mapo_get_doc",
53
+ "mapo_inspect_app",
54
+ "mapo_list_field_types",
55
+ "mapo_list_recipes",
56
+ "mapo_scaffold",
57
+ "mapo_search_docs",
58
+ ]);
59
+ });
60
+
61
+ it("exposes the knowledge resources, including the templated ones", async () => {
62
+ const { resources } = await client.listResources();
63
+ const uris = resources.map((resource) => resource.uri);
64
+
65
+ expect(uris).toContain("mapo://knowledge/index");
66
+ expect(uris).toContain("mapo://overview");
67
+ expect(uris.some((uri) => uri.startsWith("mapo://docs/"))).toBe(true);
68
+ expect(uris.some((uri) => uri.startsWith("mapo://fields/"))).toBe(true);
69
+ });
70
+
71
+ it("sends the shared instructions on initialize", () => {
72
+ const instructions = client.getInstructions() ?? "";
73
+
74
+ expect(instructions).toContain("mapo_list_recipes");
75
+ expect(instructions).toContain("mapo://overview");
76
+ });
77
+
78
+ it("serves the overview page as a resource", async () => {
79
+ const result = await client.readResource({ uri: "mapo://overview" });
80
+ const content = result.contents[0] as TextResourceContent;
81
+
82
+ expect(content.mimeType).toBe("text/markdown");
83
+ expect(content.text).toContain("# Concepts");
84
+ });
85
+
86
+ it("reads a documentation page through its resource URI", async () => {
87
+ const result = await client.readResource({
88
+ uri: "mapo://docs/howto/crud-list.md",
89
+ });
90
+ const content = result.contents[0] as TextResourceContent;
91
+
92
+ expect(content.mimeType).toBe("text/markdown");
93
+ expect(content.text).toContain("MapoList");
94
+ });
95
+
96
+ it("reads a field type contract through its resource URI", async () => {
97
+ const result = await client.readResource({ uri: "mapo://fields/select" });
98
+ const content = result.contents[0] as TextResourceContent;
99
+
100
+ expect(content.text).toContain("Field type `select`");
101
+ });
102
+
103
+ it("answers a docs search", async () => {
104
+ const result = (await client.callTool({
105
+ name: "mapo_search_docs",
106
+ arguments: { query: "CRUD list pagination", limit: 2 },
107
+ })) as { content: Array<{ text: string }>; isError?: boolean };
108
+
109
+ expect(result.isError).toBeFalsy();
110
+ expect(result.content[0]!.text).toContain("howto/");
111
+ });
112
+
113
+ it("degrades gracefully when the app endpoint is unreachable", async () => {
114
+ const result = (await client.callTool({
115
+ name: "mapo_inspect_app",
116
+ arguments: {},
117
+ })) as { content: Array<{ text: string }>; isError?: boolean };
118
+
119
+ const text = result.content[0]!.text;
120
+ expect(text).toContain("mapo_inspect_app");
121
+ expect(text).toContain("dev server");
122
+ expect(text).toContain("127.0.0.1:9");
123
+ });
124
+
125
+ it("reports invalid input instead of crashing", async () => {
126
+ const result = (await client
127
+ .callTool({
128
+ name: "mapo_get_doc",
129
+ arguments: { path: "does-not-exist.md" },
130
+ })
131
+ .catch((error: Error) => ({ content: [{ text: error.message }] }))) as {
132
+ content: Array<{ text: string }>;
133
+ };
134
+
135
+ expect(result.content[0]!.text).toContain("mapo_search_docs");
136
+ });
137
+ });
@@ -0,0 +1,145 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { runDoctor } from "../runtime/core/doctor.js";
3
+ import { makeManifest } from "./fixtures.js";
4
+
5
+ /** Convenience: the rule ids reported for a manifest. */
6
+ function rulesFor(
7
+ overrides: Parameters<typeof makeManifest>[0] = {},
8
+ ): string[] {
9
+ return runDoctor(makeManifest(overrides)).map((finding) => finding.rule);
10
+ }
11
+
12
+ describe("runDoctor", () => {
13
+ it("stays silent on a healthy app", () => {
14
+ expect(runDoctor(makeManifest())).toEqual([]);
15
+ });
16
+
17
+ it("flags @nuxt/ui declared after Mapo", () => {
18
+ const findings = runDoctor(
19
+ makeManifest({ moduleOrder: ["mapomodule", "@nuxt/ui"] }),
20
+ );
21
+
22
+ expect(findings[0]!.rule).toBe("nuxt-ui-order");
23
+ expect(findings[0]!.severity).toBe("error");
24
+ expect(findings[0]!.fix).toContain("before");
25
+ });
26
+
27
+ it("flags @nuxt/ui missing entirely", () => {
28
+ expect(rulesFor({ moduleOrder: ["mapomodule"] })).toContain(
29
+ "nuxt-ui-missing",
30
+ );
31
+ });
32
+
33
+ it("ignores module order when Mapo is not registered by name", () => {
34
+ // An app may register the modules through a layer or an inline function.
35
+ expect(rulesFor({ moduleOrder: ["@nuxt/ui"] })).not.toContain(
36
+ "nuxt-ui-order",
37
+ );
38
+ });
39
+
40
+ it("flags a missing login route against the configured loginUrl", () => {
41
+ const findings = runDoctor(
42
+ makeManifest({ routes: [{ path: "/articles" }] }),
43
+ );
44
+ const login = findings.find(
45
+ (finding) => finding.rule === "login-route-missing",
46
+ )!;
47
+
48
+ expect(login.severity).toBe("error");
49
+ expect(login.message).toContain("/login");
50
+ expect(login.fix).toContain("MapoLogin");
51
+ });
52
+
53
+ it("honours a custom loginUrl", () => {
54
+ const manifest = makeManifest({
55
+ config: { mapoCore: { loginUrl: "/admin/signin" } },
56
+ routes: [{ path: "/admin/signin" }, { path: "/articles" }],
57
+ });
58
+
59
+ expect(runDoctor(manifest).map((f) => f.rule)).not.toContain(
60
+ "login-route-missing",
61
+ );
62
+ });
63
+
64
+ it("reports untouched auth endpoints as info, not as an error", () => {
65
+ const findings = runDoctor(
66
+ makeManifest({ config: { mapoCore: { loginUrl: "/login" } } }),
67
+ );
68
+ const auth = findings.find(
69
+ (finding) => finding.rule === "auth-endpoints-default",
70
+ )!;
71
+
72
+ expect(auth.severity).toBe("info");
73
+ });
74
+
75
+ it("notices an app with no admin page yet", () => {
76
+ expect(rulesFor({ routes: [{ path: "/login" }] })).toContain(
77
+ "no-admin-pages",
78
+ );
79
+ });
80
+
81
+ it("warns about locales Mapo has no catalog for", () => {
82
+ const findings = runDoctor(makeManifest({ locales: ["en", "fr", "de"] }));
83
+ const locale = findings.find((f) => f.rule === "locale-without-catalog")!;
84
+
85
+ expect(locale.message).toContain("fr, de");
86
+ expect(locale.message).not.toContain("en,");
87
+ });
88
+
89
+ it("flags media fields left on the default endpoints", () => {
90
+ const rules = rulesFor({
91
+ fieldTypes: [{ type: "enhanced-media", source: "default" }],
92
+ });
93
+ expect(rules).toContain("media-endpoints-default");
94
+ });
95
+
96
+ it("stays silent when the media endpoints are configured", () => {
97
+ const rules = rulesFor({
98
+ fieldTypes: [{ type: "media", source: "default" }],
99
+ config: {
100
+ mapoCore: makeManifest().config.mapoCore,
101
+ mapoMedia: {
102
+ endpoints: { media: "/api/cms/media", folders: "/api/cms/folders" },
103
+ },
104
+ },
105
+ });
106
+ expect(rules).not.toContain("media-endpoints-default");
107
+ });
108
+
109
+ it("stays silent when an integration provides the media endpoints", () => {
110
+ const rules = rulesFor({
111
+ fieldTypes: [{ type: "media", source: "default" }],
112
+ modules: [
113
+ ...makeManifest().modules,
114
+ { name: "mapo-integrations-camomilla", version: "0.0.0" },
115
+ ],
116
+ });
117
+ expect(rules).not.toContain("media-endpoints-default");
118
+ });
119
+
120
+ it("detects a broken install", () => {
121
+ const rules = rulesFor({ modules: [{ name: "@mapomodule/uikit" }] });
122
+ expect(rules).toContain("core-missing");
123
+ });
124
+
125
+ it("sorts errors before warnings and warnings before info", () => {
126
+ const findings = runDoctor(
127
+ makeManifest({
128
+ moduleOrder: ["mapomodule", "@nuxt/ui"],
129
+ routes: [],
130
+ locales: ["fr"],
131
+ config: { mapoCore: {} },
132
+ }),
133
+ );
134
+ const severities = findings.map((finding) => finding.severity);
135
+
136
+ expect(severities).toEqual(
137
+ [...severities].sort(
138
+ (a, b) =>
139
+ ({ error: 0, warning: 1, info: 2 })[a] -
140
+ { error: 0, warning: 1, info: 2 }[b],
141
+ ),
142
+ );
143
+ expect(severities[0]).toBe("error");
144
+ });
145
+ });
@@ -0,0 +1,31 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { mcpEndpointPath, mcpEndpointUrl } from "../runtime/core/endpoint.js";
3
+
4
+ describe("mcpEndpointPath", () => {
5
+ it("is /mcp/mapo for an app served from the root", () => {
6
+ expect(mcpEndpointPath()).toBe("/mcp/mapo");
7
+ expect(mcpEndpointPath("/")).toBe("/mcp/mapo");
8
+ expect(mcpEndpointPath("./")).toBe("/mcp/mapo");
9
+ });
10
+
11
+ // Regression: the startup log used to print /mcp/mapo for an app under a
12
+ // base URL, where that path redirects and the handler answers below the base.
13
+ it("sits under app.baseURL, which Nitro puts in front of every server route", () => {
14
+ expect(mcpEndpointPath("/backoffice/")).toBe("/backoffice/mcp/mapo");
15
+ expect(mcpEndpointPath("/backoffice")).toBe("/backoffice/mcp/mapo");
16
+ expect(mcpEndpointPath("backoffice/admin/")).toBe(
17
+ "/backoffice/admin/mcp/mapo",
18
+ );
19
+ });
20
+ });
21
+
22
+ describe("mcpEndpointUrl", () => {
23
+ it("joins the origin and the path without doubling slashes", () => {
24
+ expect(mcpEndpointUrl("http://localhost:3000")).toBe(
25
+ "http://localhost:3000/mcp/mapo",
26
+ );
27
+ expect(mcpEndpointUrl("http://localhost:3000/", "/backoffice/")).toBe(
28
+ "http://localhost:3000/backoffice/mcp/mapo",
29
+ );
30
+ });
31
+ });
@@ -0,0 +1,142 @@
1
+ {
2
+ "openapi": "3.0.3",
3
+ "info": { "title": "Example CMS API", "version": "1.0.0" },
4
+ "paths": {
5
+ "/api/articles/": {
6
+ "get": {
7
+ "responses": {
8
+ "200": {
9
+ "content": {
10
+ "application/json": {
11
+ "schema": {
12
+ "type": "object",
13
+ "properties": {
14
+ "count": { "type": "integer" },
15
+ "results": {
16
+ "type": "array",
17
+ "items": { "$ref": "#/components/schemas/Article" }
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
26
+ },
27
+ "/api/articles/{id}/": {
28
+ "get": {
29
+ "responses": {
30
+ "200": {
31
+ "content": {
32
+ "application/json": {
33
+ "schema": { "$ref": "#/components/schemas/Article" }
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ },
40
+ "/api/authors/": {
41
+ "get": {
42
+ "responses": {
43
+ "200": {
44
+ "content": {
45
+ "application/json": {
46
+ "schema": {
47
+ "type": "array",
48
+ "items": { "$ref": "#/components/schemas/Author" }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ },
56
+ "/api/tags/": {
57
+ "get": {
58
+ "responses": {
59
+ "200": {
60
+ "content": {
61
+ "application/json": {
62
+ "schema": {
63
+ "type": "object",
64
+ "properties": {
65
+ "results": {
66
+ "type": "array",
67
+ "items": { "$ref": "#/components/schemas/Tag" }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ },
78
+ "components": {
79
+ "schemas": {
80
+ "Article": {
81
+ "type": "object",
82
+ "description": "A published article.",
83
+ "required": ["title", "status"],
84
+ "properties": {
85
+ "id": { "type": "integer", "readOnly": true },
86
+ "title": { "type": "string", "maxLength": 200 },
87
+ "body": { "type": "string" },
88
+ "summary": { "type": "string", "maxLength": 900 },
89
+ "status": {
90
+ "type": "string",
91
+ "enum": ["draft", "published", "archived"],
92
+ "title": "Publication status"
93
+ },
94
+ "published_at": {
95
+ "type": "string",
96
+ "format": "date-time",
97
+ "nullable": true
98
+ },
99
+ "release_date": { "type": "string", "format": "date" },
100
+ "is_featured": { "type": "boolean" },
101
+ "priority": { "type": "integer", "minimum": 1, "maximum": 10 },
102
+ "contact_email": { "type": "string", "format": "email" },
103
+ "canonical_url": { "type": "string", "format": "uri" },
104
+ "cover": { "type": "string", "format": "binary" },
105
+ "author": {
106
+ "allOf": [{ "$ref": "#/components/schemas/Author" }],
107
+ "nullable": true
108
+ },
109
+ "tags": {
110
+ "type": "array",
111
+ "items": { "$ref": "#/components/schemas/Tag" }
112
+ },
113
+ "keywords": { "type": "array", "items": { "type": "string" } },
114
+ "editor": { "allOf": [{ "$ref": "#/components/schemas/Editor" }] },
115
+ "created_at": {
116
+ "type": "string",
117
+ "format": "date-time",
118
+ "readOnly": true
119
+ }
120
+ }
121
+ },
122
+ "Author": {
123
+ "type": "object",
124
+ "properties": {
125
+ "id": { "type": "integer", "readOnly": true },
126
+ "name": { "type": "string", "maxLength": 120 }
127
+ }
128
+ },
129
+ "Tag": {
130
+ "type": "object",
131
+ "properties": {
132
+ "id": { "type": "integer", "readOnly": true },
133
+ "label": { "type": "string", "maxLength": 40 }
134
+ }
135
+ },
136
+ "Editor": {
137
+ "type": "object",
138
+ "properties": { "id": { "type": "integer" } }
139
+ }
140
+ }
141
+ }
142
+ }