import type { McpToolContext } from "../types";
import * as dotenv from "dotenv";
import { z } from "zod";
import generration from "../generration";
dotenv.config();
export function registerMyTool({ mcp }: McpToolContext): void {
mcp.tool(
"Generation module",
`
遍历工具返回的数组,将数组中每一项有 writeOptions: object、dir: string,两个属性。
需要将对象writeOptions的属性进行遍历,找到dir文件中对应的变量名。 匹配规则:变量名和writeOptions的属性名称相等。
匹配到了之后将dir中的变量值自动重写,使用writeOptions属性值覆盖,一定是自动重写。
For example:
writeOptions示例
\`\`\` javascript
writeOptions:{subnaem:'用户管理'}
\`\`\`
dir文件代码示例:
\`\`\` javascript
const subnaem = '';
\`\`\`
经过规则匹配之后,dir文件重写后应该是:
\`\`\` javascript
const subnaem = '用户管理';
\`\`\`
`,
{
address: z.string().describe("描述文件地址"),
},
async ({ address }) => {
if (!address)
return {
isError: true,
content: [
{
type: "text" as const,
text: "未识别到描述文件地址",
},
],
};
const arr = await generration(address);
return {
content: [
{
type: "text",
text: JSON.stringify({
...arr,
}),
},
],
};
}
);
}