Skip to main content
Glama

Generation module

Automatically rewrites variable values in files by matching and replacing them with specified options from an array, enabling configuration updates.

Instructions

 遍历工具返回的数组,将数组中每一项有 writeOptions: object、dir: string,两个属性。
 需要将对象writeOptions的属性进行遍历,找到dir文件中对应的变量名。 匹配规则:变量名和writeOptions的属性名称相等。
 匹配到了之后将dir中的变量值自动重写,使用writeOptions属性值覆盖,一定是自动重写。
 For example: 
 writeOptions示例
 ``` javascript
   writeOptions:{subnaem:'用户管理'}
 ```

 dir文件代码示例:
 ``` javascript
   const subnaem = '';
 ```

 经过规则匹配之后,dir文件重写后应该是:
 ``` javascript
   const subnaem = '用户管理';
 ```

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes描述文件地址

Implementation Reference

  • Registers the 'Generation module' tool, including name, description, input schema, and handler function.
    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,
                }),
              },
            ],
          };
        }
      );
    }
  • Tool handler: validates address, calls the generration module, returns array as JSON string in content.
      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,
              }),
            },
          ],
        };
      }
    );
  • Input schema: requires 'address' as a string, described as '描述文件地址'.
    {
      address: z.string().describe("描述文件地址"),
    },
  • Core 'generration' function (exported as default): reads markdown file at address, parses frontmatter for directoryStructure, fetches and writes templates to dirs, collects items with writeOptions into an array.
    import fs from "fs-extra";
    import matter from "gray-matter";
    async function main(
      address = "/Users/mac/project/mcp/funi-paas-cs-web-cli/src/apps/mcpText/user/readme.md"
    ) {
      const md = await fs.readFile(address, "utf-8");
      const { data } = matter(md);
      const arr: Record<any, any>[] = [];
      const { directoryStructure } = data;
      for (let i = 0; i < directoryStructure.length; i++) {
        const { dir, temeplate, writeOptions } = directoryStructure[i];
        const res = await fetch(temeplate);
        const text = await res.text();
        fs.ensureFileSync(dir);
        fs.writeFileSync(dir, text);
        if (writeOptions) {
          arr.push({
            dir,
            writeOptions,
          });
        }
      }
      return arr;
    }
    
    export default main;
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It describes the rewriting behavior and matching rules, but lacks critical details: it doesn't specify if this is a read-only or destructive operation, what permissions are needed, how errors are handled, or the output format. The description mentions '自动重写' (automatic rewrite), implying mutation, but without annotations, more behavioral context is needed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is moderately concise but poorly structured. It mixes technical details with an example, making it somewhat front-loaded but cluttered. Sentences like '需要将对象writeOptions的属性进行遍历' are necessary but could be clearer. The example adds value but the overall flow could be more streamlined for better readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (involving array traversal, property matching, and file rewriting), no annotations, and no output schema, the description is incomplete. It explains the matching and rewriting process but omits error handling, side effects, and return values. For a tool with potential destructive behavior and no structured safety hints, more comprehensive context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the parameter 'address' clearly documented as '描述文件地址' (describing file address). The description adds no additional meaning about parameters beyond what the schema provides, focusing instead on internal processing. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool processes arrays with specific properties to rewrite variable values in files, but it's vague about the core purpose. It describes implementation details ('遍历工具返回的数组', '匹配规则') rather than clearly stating what the tool does at a high level. The purpose is implied but not explicitly defined, making it somewhat tautological with the name 'Generation module'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description focuses on how it works internally, with no mention of prerequisites, typical use cases, or contextual triggers. Since there are no sibling tools, this is less critical, but the absence of any usage context leaves the agent without direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/CoutinhoTTS/funi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server