@mandujs/mcp 0.9.19 → 0.9.21

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 (122) hide show
  1. package/README.md +320 -0
  2. package/package.json +1 -1
  3. package/src/activity-monitor.ts +847 -231
  4. package/src/resources/handlers.ts +244 -0
  5. package/src/resources/skills/guides.ts +1136 -0
  6. package/src/resources/skills/index.ts +12 -0
  7. package/src/resources/skills/loader.ts +218 -0
  8. package/src/resources/skills/mandu-composition/SKILL.md +91 -0
  9. package/src/resources/skills/mandu-composition/metadata.json +13 -0
  10. package/src/resources/skills/mandu-composition/rules/_sections.md +26 -0
  11. package/src/resources/skills/mandu-composition/rules/_template.md +77 -0
  12. package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +146 -0
  13. package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +164 -0
  14. package/src/resources/skills/mandu-composition/rules/comp-island-event.md +161 -0
  15. package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +167 -0
  16. package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +149 -0
  17. package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +148 -0
  18. package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +150 -0
  19. package/src/resources/skills/mandu-deployment/SKILL.md +92 -0
  20. package/src/resources/skills/mandu-deployment/_sections.md +41 -0
  21. package/src/resources/skills/mandu-deployment/_template.md +38 -0
  22. package/src/resources/skills/mandu-deployment/metadata.json +13 -0
  23. package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +109 -0
  24. package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +115 -0
  25. package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +219 -0
  26. package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +150 -0
  27. package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +223 -0
  28. package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +152 -0
  29. package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +179 -0
  30. package/src/resources/skills/mandu-deployment/rules/deploy-platform-supabase.md +323 -0
  31. package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +140 -0
  32. package/src/resources/skills/mandu-fs-routes/SKILL.md +82 -0
  33. package/src/resources/skills/mandu-fs-routes/metadata.json +12 -0
  34. package/src/resources/skills/mandu-fs-routes/rules/_sections.md +36 -0
  35. package/src/resources/skills/mandu-fs-routes/rules/_template.md +69 -0
  36. package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +65 -0
  37. package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +93 -0
  38. package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +55 -0
  39. package/src/resources/skills/mandu-guard/SKILL.md +129 -0
  40. package/src/resources/skills/mandu-guard/metadata.json +12 -0
  41. package/src/resources/skills/mandu-guard/rules/_sections.md +36 -0
  42. package/src/resources/skills/mandu-guard/rules/_template.md +82 -0
  43. package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +100 -0
  44. package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +76 -0
  45. package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +81 -0
  46. package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +80 -0
  47. package/src/resources/skills/mandu-hydration/SKILL.md +91 -0
  48. package/src/resources/skills/mandu-hydration/metadata.json +12 -0
  49. package/src/resources/skills/mandu-hydration/rules/_sections.md +31 -0
  50. package/src/resources/skills/mandu-hydration/rules/_template.md +72 -0
  51. package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +109 -0
  52. package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +55 -0
  53. package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +113 -0
  54. package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +68 -0
  55. package/src/resources/skills/mandu-performance/SKILL.md +85 -0
  56. package/src/resources/skills/mandu-performance/metadata.json +14 -0
  57. package/src/resources/skills/mandu-performance/rules/_sections.md +31 -0
  58. package/src/resources/skills/mandu-performance/rules/_template.md +64 -0
  59. package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +103 -0
  60. package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +95 -0
  61. package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +124 -0
  62. package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +125 -0
  63. package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +80 -0
  64. package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +145 -0
  65. package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +98 -0
  66. package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +154 -0
  67. package/src/resources/skills/mandu-security/SKILL.md +87 -0
  68. package/src/resources/skills/mandu-security/metadata.json +13 -0
  69. package/src/resources/skills/mandu-security/rules/_sections.md +31 -0
  70. package/src/resources/skills/mandu-security/rules/_template.md +74 -0
  71. package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +127 -0
  72. package/src/resources/skills/mandu-security/rules/sec-env-management.md +133 -0
  73. package/src/resources/skills/mandu-security/rules/sec-input-validate.md +148 -0
  74. package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +146 -0
  75. package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +138 -0
  76. package/src/resources/skills/mandu-slot/SKILL.md +85 -0
  77. package/src/resources/skills/mandu-slot/metadata.json +12 -0
  78. package/src/resources/skills/mandu-slot/rules/_sections.md +36 -0
  79. package/src/resources/skills/mandu-slot/rules/_template.md +63 -0
  80. package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +38 -0
  81. package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +56 -0
  82. package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +59 -0
  83. package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +64 -0
  84. package/src/resources/skills/mandu-styling/SKILL.md +118 -0
  85. package/src/resources/skills/mandu-styling/_sections.md +36 -0
  86. package/src/resources/skills/mandu-styling/_template.md +32 -0
  87. package/src/resources/skills/mandu-styling/metadata.json +13 -0
  88. package/src/resources/skills/mandu-styling/rules/style-component-compound.md +235 -0
  89. package/src/resources/skills/mandu-styling/rules/style-component-slots.md +255 -0
  90. package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +205 -0
  91. package/src/resources/skills/mandu-styling/rules/style-island-animations.md +272 -0
  92. package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +167 -0
  93. package/src/resources/skills/mandu-styling/rules/style-island-variants.md +221 -0
  94. package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +209 -0
  95. package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +192 -0
  96. package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +162 -0
  97. package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +164 -0
  98. package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +161 -0
  99. package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +229 -0
  100. package/src/resources/skills/mandu-testing/SKILL.md +99 -0
  101. package/src/resources/skills/mandu-testing/metadata.json +13 -0
  102. package/src/resources/skills/mandu-testing/rules/_sections.md +26 -0
  103. package/src/resources/skills/mandu-testing/rules/_template.md +65 -0
  104. package/src/resources/skills/mandu-testing/rules/test-component-island.md +195 -0
  105. package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +196 -0
  106. package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +219 -0
  107. package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +192 -0
  108. package/src/resources/skills/mandu-ui/SKILL.md +117 -0
  109. package/src/resources/skills/mandu-ui/_sections.md +23 -0
  110. package/src/resources/skills/mandu-ui/_template.md +32 -0
  111. package/src/resources/skills/mandu-ui/metadata.json +13 -0
  112. package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +232 -0
  113. package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +238 -0
  114. package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +259 -0
  115. package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +258 -0
  116. package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +213 -0
  117. package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +209 -0
  118. package/src/resources/skills/recipes.ts +932 -0
  119. package/src/server.ts +3 -0
  120. package/src/tools/hydration.ts +8 -8
  121. package/src/tools/index.ts +1 -0
  122. package/src/tools/seo.ts +417 -0
package/src/server.ts CHANGED
@@ -19,6 +19,7 @@ import { hydrationTools, hydrationToolDefinitions } from "./tools/hydration.js";
19
19
  import { contractTools, contractToolDefinitions } from "./tools/contract.js";
20
20
  import { brainTools, brainToolDefinitions } from "./tools/brain.js";
21
21
  import { runtimeTools, runtimeToolDefinitions } from "./tools/runtime.js";
22
+ import { seoTools, seoToolDefinitions } from "./tools/seo.js";
22
23
  import { resourceHandlers, resourceDefinitions } from "./resources/handlers.js";
23
24
  import { findProjectRoot } from "./utils/project.js";
24
25
  import { applyWarningInjection } from "./utils/withWarnings.js";
@@ -63,6 +64,7 @@ export class ManduMcpServer {
63
64
  ...contractToolDefinitions,
64
65
  ...brainToolDefinitions,
65
66
  ...runtimeToolDefinitions,
67
+ ...seoToolDefinitions,
66
68
  ];
67
69
  }
68
70
 
@@ -78,6 +80,7 @@ export class ManduMcpServer {
78
80
  ...contractTools(this.projectRoot),
79
81
  ...brainTools(this.projectRoot, this.server, this.monitor),
80
82
  ...runtimeTools(this.projectRoot),
83
+ ...seoTools(this.projectRoot),
81
84
  };
82
85
 
83
86
  return applyWarningInjection(handlers);
@@ -378,19 +378,19 @@ function generateClientSlotTemplate(routeId: string, slotModule?: string): strin
378
378
  .map((s) => s.charAt(0).toUpperCase() + s.slice(1))
379
379
  .join("");
380
380
 
381
- const typeImport = slotModule
382
- ? `// Import types from server slot if needed
383
- // import type { LoaderData } from "./${routeId}.slot";
384
-
385
- `
386
- : "";
381
+ const typeImport = slotModule
382
+ ? `// Import types from server slot if needed (adjust path to your project)
383
+ // import type { LoaderData } from "../../../spec/slots/${routeId}.slot";
384
+
385
+ `
386
+ : "";
387
387
 
388
388
  return `/**
389
389
  * ${pascalCase} Client Slot
390
390
  * 브라우저에서 실행되는 클라이언트 로직
391
391
  */
392
392
 
393
- import { Mandu } from "@mandujs/core/client";
393
+ import { ManduClient } from "@mandujs/core/client";
394
394
  import { useState, useCallback } from "react";
395
395
 
396
396
  ${typeImport}// 서버에서 전달받는 데이터 타입
@@ -399,7 +399,7 @@ interface ServerData {
399
399
  [key: string]: unknown;
400
400
  }
401
401
 
402
- export default Mandu.island<ServerData>({
402
+ export default ManduClient.island<ServerData>({
403
403
  /**
404
404
  * Setup Phase
405
405
  * - 서버 데이터를 받아 클라이언트 상태 초기화
@@ -8,3 +8,4 @@ export { hydrationTools, hydrationToolDefinitions } from "./hydration.js";
8
8
  export { contractTools, contractToolDefinitions } from "./contract.js";
9
9
  export { brainTools, brainToolDefinitions } from "./brain.js";
10
10
  export { runtimeTools, runtimeToolDefinitions } from "./runtime.js";
11
+ export { seoTools, seoToolDefinitions } from "./seo.js";
@@ -0,0 +1,417 @@
1
+ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import {
3
+ renderMetadata,
4
+ createDefaultMetadata,
5
+ resolveMetadata,
6
+ renderSitemap,
7
+ renderRobots,
8
+ createDefaultRobots,
9
+ createArticleJsonLd,
10
+ createBreadcrumbJsonLd,
11
+ createFAQJsonLd,
12
+ createProductJsonLd,
13
+ createWebSiteJsonLd,
14
+ createOrganizationJsonLd,
15
+ createLocalBusinessJsonLd,
16
+ createVideoJsonLd,
17
+ createEventJsonLd,
18
+ type Metadata,
19
+ type Sitemap,
20
+ type RobotsFile,
21
+ type JsonLd,
22
+ } from "@mandujs/core";
23
+ import { getProjectPaths, readJsonFile, writeJsonFile } from "../utils/project.js";
24
+ import * as fs from "fs";
25
+ import * as path from "path";
26
+
27
+ export const seoToolDefinitions: Tool[] = [
28
+ {
29
+ name: "mandu_preview_seo",
30
+ description: "Preview rendered SEO HTML for given metadata. Useful for testing metadata before applying.",
31
+ inputSchema: {
32
+ type: "object",
33
+ properties: {
34
+ metadata: {
35
+ type: "object",
36
+ description: "Metadata object to render (title, description, openGraph, twitter, etc.)",
37
+ },
38
+ },
39
+ required: ["metadata"],
40
+ },
41
+ },
42
+ {
43
+ name: "mandu_generate_sitemap_preview",
44
+ description: "Generate sitemap.xml preview from entries",
45
+ inputSchema: {
46
+ type: "object",
47
+ properties: {
48
+ entries: {
49
+ type: "array",
50
+ description: "Array of sitemap entries with url, lastModified, changeFrequency, priority",
51
+ items: {
52
+ type: "object",
53
+ properties: {
54
+ url: { type: "string", description: "Page URL" },
55
+ lastModified: { type: "string", description: "Last modified date (ISO string)" },
56
+ changeFrequency: {
57
+ type: "string",
58
+ enum: ["always", "hourly", "daily", "weekly", "monthly", "yearly", "never"],
59
+ },
60
+ priority: { type: "number", description: "Priority 0.0 to 1.0" },
61
+ images: {
62
+ type: "array",
63
+ items: { type: "string" },
64
+ description: "Image URLs for this page",
65
+ },
66
+ },
67
+ required: ["url"],
68
+ },
69
+ },
70
+ },
71
+ required: ["entries"],
72
+ },
73
+ },
74
+ {
75
+ name: "mandu_generate_robots_preview",
76
+ description: "Generate robots.txt preview from configuration",
77
+ inputSchema: {
78
+ type: "object",
79
+ properties: {
80
+ rules: {
81
+ type: "object",
82
+ description: "Robots rules (userAgent, allow, disallow, crawlDelay)",
83
+ },
84
+ sitemap: {
85
+ type: "string",
86
+ description: "Sitemap URL",
87
+ },
88
+ },
89
+ required: [],
90
+ },
91
+ },
92
+ {
93
+ name: "mandu_create_jsonld",
94
+ description: "Create JSON-LD structured data for SEO. Supports Article, WebSite, Organization, Breadcrumb, FAQ, Product, LocalBusiness, Video, Event types.",
95
+ inputSchema: {
96
+ type: "object",
97
+ properties: {
98
+ type: {
99
+ type: "string",
100
+ enum: ["Article", "WebSite", "Organization", "Breadcrumb", "FAQ", "Product", "LocalBusiness", "Video", "Event"],
101
+ description: "Type of JSON-LD to create",
102
+ },
103
+ data: {
104
+ type: "object",
105
+ description: "Data for the JSON-LD (varies by type)",
106
+ },
107
+ },
108
+ required: ["type", "data"],
109
+ },
110
+ },
111
+ {
112
+ name: "mandu_write_seo_file",
113
+ description: "Write SEO configuration file (sitemap.ts or robots.ts) to app directory",
114
+ inputSchema: {
115
+ type: "object",
116
+ properties: {
117
+ fileType: {
118
+ type: "string",
119
+ enum: ["sitemap", "robots"],
120
+ description: "Type of SEO file to create",
121
+ },
122
+ config: {
123
+ type: "object",
124
+ description: "Configuration object for the file",
125
+ },
126
+ },
127
+ required: ["fileType"],
128
+ },
129
+ },
130
+ {
131
+ name: "mandu_seo_analyze",
132
+ description: "Analyze SEO metadata for common issues and provide recommendations",
133
+ inputSchema: {
134
+ type: "object",
135
+ properties: {
136
+ metadata: {
137
+ type: "object",
138
+ description: "Metadata object to analyze",
139
+ },
140
+ url: {
141
+ type: "string",
142
+ description: "Page URL for context",
143
+ },
144
+ },
145
+ required: ["metadata"],
146
+ },
147
+ },
148
+ ];
149
+
150
+ export function seoTools(projectRoot: string) {
151
+ const paths = getProjectPaths(projectRoot);
152
+
153
+ return {
154
+ mandu_preview_seo: async (args: Record<string, unknown>) => {
155
+ const { metadata } = args as { metadata: Metadata };
156
+
157
+ try {
158
+ // Create resolved metadata from input
159
+ const resolved = await resolveMetadata([metadata]);
160
+ const html = renderMetadata(resolved);
161
+
162
+ return {
163
+ success: true,
164
+ html,
165
+ resolved: {
166
+ title: resolved.title?.absolute,
167
+ description: resolved.description,
168
+ hasOpenGraph: !!resolved.openGraph,
169
+ hasTwitter: !!resolved.twitter,
170
+ hasJsonLd: !!resolved.jsonLd && resolved.jsonLd.length > 0,
171
+ },
172
+ };
173
+ } catch (error) {
174
+ return {
175
+ success: false,
176
+ error: error instanceof Error ? error.message : String(error),
177
+ };
178
+ }
179
+ },
180
+
181
+ mandu_generate_sitemap_preview: async (args: Record<string, unknown>) => {
182
+ const { entries } = args as { entries: Sitemap };
183
+
184
+ try {
185
+ // Convert date strings to Date objects
186
+ const processedEntries = entries.map((entry) => ({
187
+ ...entry,
188
+ lastModified: entry.lastModified
189
+ ? new Date(entry.lastModified as string)
190
+ : undefined,
191
+ }));
192
+
193
+ const xml = renderSitemap(processedEntries);
194
+
195
+ return {
196
+ success: true,
197
+ xml,
198
+ entryCount: entries.length,
199
+ };
200
+ } catch (error) {
201
+ return {
202
+ success: false,
203
+ error: error instanceof Error ? error.message : String(error),
204
+ };
205
+ }
206
+ },
207
+
208
+ mandu_generate_robots_preview: async (args: Record<string, unknown>) => {
209
+ const { rules, sitemap } = args as {
210
+ rules?: RobotsFile["rules"];
211
+ sitemap?: string;
212
+ };
213
+
214
+ try {
215
+ const robotsConfig: RobotsFile = rules
216
+ ? { rules, sitemap }
217
+ : createDefaultRobots(sitemap || "");
218
+
219
+ const txt = renderRobots(robotsConfig);
220
+
221
+ return {
222
+ success: true,
223
+ txt,
224
+ };
225
+ } catch (error) {
226
+ return {
227
+ success: false,
228
+ error: error instanceof Error ? error.message : String(error),
229
+ };
230
+ }
231
+ },
232
+
233
+ mandu_create_jsonld: async (args: Record<string, unknown>) => {
234
+ const { type, data } = args as { type: string; data: Record<string, unknown> };
235
+
236
+ try {
237
+ let jsonLd: JsonLd;
238
+
239
+ switch (type) {
240
+ case "Article":
241
+ jsonLd = createArticleJsonLd(data as Parameters<typeof createArticleJsonLd>[0]);
242
+ break;
243
+ case "WebSite":
244
+ jsonLd = createWebSiteJsonLd(data as Parameters<typeof createWebSiteJsonLd>[0]);
245
+ break;
246
+ case "Organization":
247
+ jsonLd = createOrganizationJsonLd(data as Parameters<typeof createOrganizationJsonLd>[0]);
248
+ break;
249
+ case "Breadcrumb":
250
+ jsonLd = createBreadcrumbJsonLd(data as Array<{ name: string; url: string }>);
251
+ break;
252
+ case "FAQ":
253
+ jsonLd = createFAQJsonLd(data as Array<{ question: string; answer: string }>);
254
+ break;
255
+ case "Product":
256
+ jsonLd = createProductJsonLd(data as Parameters<typeof createProductJsonLd>[0]);
257
+ break;
258
+ case "LocalBusiness":
259
+ jsonLd = createLocalBusinessJsonLd(data as Parameters<typeof createLocalBusinessJsonLd>[0]);
260
+ break;
261
+ case "Video":
262
+ jsonLd = createVideoJsonLd(data as Parameters<typeof createVideoJsonLd>[0]);
263
+ break;
264
+ case "Event":
265
+ jsonLd = createEventJsonLd(data as Parameters<typeof createEventJsonLd>[0]);
266
+ break;
267
+ default:
268
+ return {
269
+ success: false,
270
+ error: `Unknown JSON-LD type: ${type}`,
271
+ };
272
+ }
273
+
274
+ return {
275
+ success: true,
276
+ jsonLd,
277
+ script: `<script type="application/ld+json">${JSON.stringify(jsonLd, null, 2)}</script>`,
278
+ };
279
+ } catch (error) {
280
+ return {
281
+ success: false,
282
+ error: error instanceof Error ? error.message : String(error),
283
+ };
284
+ }
285
+ },
286
+
287
+ mandu_write_seo_file: async (args: Record<string, unknown>) => {
288
+ const { fileType, config } = args as {
289
+ fileType: "sitemap" | "robots";
290
+ config?: Record<string, unknown>;
291
+ };
292
+
293
+ try {
294
+ const appDir = path.join(projectRoot, "app");
295
+
296
+ // Ensure app directory exists
297
+ if (!fs.existsSync(appDir)) {
298
+ fs.mkdirSync(appDir, { recursive: true });
299
+ }
300
+
301
+ let filePath: string;
302
+ let content: string;
303
+
304
+ if (fileType === "sitemap") {
305
+ filePath = path.join(appDir, "sitemap.ts");
306
+ content = `import type { Sitemap } from '@mandujs/core'
307
+
308
+ export default function sitemap(): Sitemap {
309
+ return [
310
+ {
311
+ url: 'https://example.com',
312
+ lastModified: new Date(),
313
+ changeFrequency: 'daily',
314
+ priority: 1.0,
315
+ },
316
+ // Add more entries here
317
+ ]
318
+ }
319
+ `;
320
+ } else {
321
+ filePath = path.join(appDir, "robots.ts");
322
+ content = `import type { RobotsFile } from '@mandujs/core'
323
+
324
+ export default function robots(): RobotsFile {
325
+ return {
326
+ rules: {
327
+ userAgent: '*',
328
+ allow: '/',
329
+ disallow: ['/admin', '/private'],
330
+ },
331
+ sitemap: 'https://example.com/sitemap.xml',
332
+ }
333
+ }
334
+ `;
335
+ }
336
+
337
+ fs.writeFileSync(filePath, content, "utf-8");
338
+
339
+ return {
340
+ success: true,
341
+ filePath,
342
+ message: `Created ${fileType}.ts at ${filePath}`,
343
+ };
344
+ } catch (error) {
345
+ return {
346
+ success: false,
347
+ error: error instanceof Error ? error.message : String(error),
348
+ };
349
+ }
350
+ },
351
+
352
+ mandu_seo_analyze: async (args: Record<string, unknown>) => {
353
+ const { metadata, url } = args as { metadata: Metadata; url?: string };
354
+
355
+ const issues: Array<{ severity: "error" | "warning" | "info"; message: string }> = [];
356
+ const recommendations: string[] = [];
357
+
358
+ // Title checks
359
+ if (!metadata.title) {
360
+ issues.push({ severity: "error", message: "Missing title" });
361
+ } else if (typeof metadata.title === "string") {
362
+ if (metadata.title.length < 10) {
363
+ issues.push({ severity: "warning", message: "Title is too short (< 10 chars)" });
364
+ } else if (metadata.title.length > 60) {
365
+ issues.push({ severity: "warning", message: "Title is too long (> 60 chars)" });
366
+ }
367
+ }
368
+
369
+ // Description checks
370
+ if (!metadata.description) {
371
+ issues.push({ severity: "error", message: "Missing description" });
372
+ } else if (metadata.description.length < 50) {
373
+ issues.push({ severity: "warning", message: "Description is too short (< 50 chars)" });
374
+ } else if (metadata.description.length > 160) {
375
+ issues.push({ severity: "warning", message: "Description is too long (> 160 chars)" });
376
+ }
377
+
378
+ // Open Graph checks
379
+ if (!metadata.openGraph) {
380
+ issues.push({ severity: "warning", message: "Missing Open Graph metadata" });
381
+ recommendations.push("Add openGraph with title, description, and images for better social sharing");
382
+ } else {
383
+ if (!metadata.openGraph.images) {
384
+ issues.push({ severity: "warning", message: "Missing Open Graph image" });
385
+ }
386
+ }
387
+
388
+ // Twitter checks
389
+ if (!metadata.twitter) {
390
+ issues.push({ severity: "info", message: "Missing Twitter Card metadata" });
391
+ recommendations.push("Add twitter card metadata for Twitter sharing");
392
+ }
393
+
394
+ // JSON-LD checks
395
+ if (!metadata.jsonLd) {
396
+ recommendations.push("Add JSON-LD structured data for rich search results");
397
+ }
398
+
399
+ // Viewport check
400
+ if (!metadata.viewport) {
401
+ recommendations.push("Add viewport meta for mobile optimization");
402
+ }
403
+
404
+ // Calculate score
405
+ const errorCount = issues.filter((i) => i.severity === "error").length;
406
+ const warningCount = issues.filter((i) => i.severity === "warning").length;
407
+ const score = Math.max(0, 100 - errorCount * 20 - warningCount * 10);
408
+
409
+ return {
410
+ score,
411
+ issues,
412
+ recommendations,
413
+ summary: `SEO Score: ${score}/100 (${errorCount} errors, ${warningCount} warnings)`,
414
+ };
415
+ },
416
+ };
417
+ }