Initial commit
This commit is contained in:
5
mcp-server/tools/project/index.js
Normal file
5
mcp-server/tools/project/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import { registerSaveProjectStylesTool } from "./saveStyles.js";
|
||||
|
||||
export function registerProjectTools(server) {
|
||||
registerSaveProjectStylesTool(server);
|
||||
}
|
||||
61
mcp-server/tools/project/saveStyles.js
Normal file
61
mcp-server/tools/project/saveStyles.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import { z } from "zod";
|
||||
import { withAuth } from "../../auth/index.js";
|
||||
import { handleToolError } from "../helpers/errorHandler.js";
|
||||
import { withAuthParams } from "../helpers/authSchema.js";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export function registerSaveProjectStylesTool(server) {
|
||||
server.tool(
|
||||
"save_project_styles",
|
||||
`Save the project's visual design styles summary to docs/project-styles.md. Call this after exploring existing modules to cache the style reference for future module creation. This avoids re-exploring modules every time a new module is created.
|
||||
|
||||
The content should include: color palette (hex values), typography, spacing patterns, Tailwind classes, button/card/section styles, and recurring design patterns.`,
|
||||
withAuthParams({
|
||||
content: z.string().describe("Markdown content with the project styles summary"),
|
||||
}),
|
||||
{ readOnlyHint: false, destructiveHint: false },
|
||||
withAuth(async ({ content }, extra) => {
|
||||
try {
|
||||
if (!content || !content.trim()) {
|
||||
return {
|
||||
content: [{ type: "text", text: "Error: content is required" }],
|
||||
isError: true,
|
||||
};
|
||||
}
|
||||
|
||||
// Get project directory from env
|
||||
const projectDir = process.env.ACAI_PROJECT_DIR || "";
|
||||
if (!projectDir) {
|
||||
return {
|
||||
content: [{ type: "text", text: "Error: ACAI_PROJECT_DIR not set" }],
|
||||
isError: true,
|
||||
};
|
||||
}
|
||||
|
||||
// Ensure docs/ directory exists
|
||||
const docsDir = path.join(projectDir, "docs");
|
||||
if (!fs.existsSync(docsDir)) {
|
||||
fs.mkdirSync(docsDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Write the file
|
||||
const filePath = path.join(docsDir, "project-styles.md");
|
||||
fs.writeFileSync(filePath, content.trim() + "\n", "utf-8");
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
text: JSON.stringify({
|
||||
success: true,
|
||||
message: "Project styles saved successfully",
|
||||
filePath: "docs/project-styles.md",
|
||||
})
|
||||
}],
|
||||
};
|
||||
} catch (error) {
|
||||
return handleToolError(error, "save_project_styles", {});
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user