Skip to main content
Glama
thana0623

prompts-mcp-server

by thana0623

log_module

Record a module modification with change description, files, and decisions. Use after modifying code to log the update for the module.

Instructions

【模块记录】按模块记录一次修改(目录式)。修改功能前先 read_module,修改后调用此工具。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
moduleNameYes模块名称(如 auth、rag-upload、frontend)
changeYes变更内容描述
filesNo涉及的文件列表
decisionsNo本次决策

Implementation Reference

  • The handleLogModule method is the tool handler for 'log_module'. It extracts moduleName, change, files, and decisions from args, validates required params (moduleName, change), then calls appendModuleLog from module-logger.ts to write the module modification record to disk.
    private async handleLogModule(args: any) {
      const moduleName = typeof args?.moduleName === 'string' ? args.moduleName : '';
      const change = typeof args?.change === 'string' ? args.change : '';
      const files: string[] = Array.isArray(args?.files) ? args.files : [];
      const decisions: string[] = Array.isArray(args?.decisions) ? args.decisions : [];
    
      if (!moduleName || !change) {
        return {
          content: [{ type: 'text', text: '❌ "moduleName" 和 "change" 是必填参数。' }],
          isError: true,
        };
      }
    
      const projectRoot = getProjectRoot();
      const today = new Date().toISOString().slice(0, 10);
    
      const result = appendModuleLog(projectRoot, moduleName, {
        date: today,
        change,
        files,
        decisions,
      });
    
      if (result.success) {
        return {
          content: [{ type: 'text', text: `✅ 模块记录已更新: ${moduleName}\n\n变更: ${change}\n日期: ${today}` }],
        };
      } else {
        return {
          content: [{ type: 'text', text: `❌ 更新模块记录失败: ${result.error}` }],
          isError: true,
        };
      }
    }
  • Registration/input schema for the 'log_module' tool. Defines the tool name, description, and input parameters: moduleName (string, required), change (string, required), files (array of strings), decisions (array of strings).
    name: 'log_module',
    description: '【模块记录】按模块记录一次修改(目录式)。修改功能前先 read_module,修改后调用此工具。',
    inputSchema: {
      type: 'object',
      properties: {
        moduleName: {
          type: 'string',
          description: '模块名称(如 auth、rag-upload、frontend)',
        },
        change: {
          type: 'string',
          description: '变更内容描述',
        },
        files: {
          type: 'array',
          items: { type: 'string' },
          description: '涉及的文件列表',
        },
        decisions: {
          type: 'array',
          items: { type: 'string' },
          description: '本次决策',
        },
      },
      required: ['moduleName', 'change'],
    },
  • src/index.ts:248-249 (registration)
    Registration of 'log_module' in the CallToolRequestSchema handler. Maps the tool name 'log_module' to handleLogModule method via a switch-case statement.
    case 'log_module':
      return this.handleLogModule(args);
  • The appendModuleLog function is the core helper that writes the module modification entry to disk. It appends a new row to the markdown table in the module's record file under .github/prompts/modules/<moduleName>.md. If the file doesn't exist, it creates a new one with a header table.
    // ─── 写入模块记录 ────────────────────────────────────────────────────
    
    /**
     * 追加一条模块修改记录
     */
    export function appendModuleLog(
      projectRoot: string,
      moduleName: string,
      entry: ModuleEntry
    ): { success: boolean; error?: string } {
      try {
        const modulesDir = getModulesDir(projectRoot);
        if (!fs.existsSync(modulesDir)) {
          fs.mkdirSync(modulesDir, { recursive: true });
        }
    
        const filePath = getModulePath(projectRoot, moduleName);
        let existing = '';
        if (fs.existsSync(filePath)) {
          existing = fs.readFileSync(filePath, 'utf-8');
        }
    
        // 构建新条目行
        const filesStr = entry.files.join(', ') || '-';
        const decisionsStr = entry.decisions.join('; ') || '-';
        const newRow = `| ${entry.date} | ${entry.change} | ${filesStr} | ${decisionsStr} |\n`;
    
        if (!existing) {
          // 新文件
          const content = `# 模块记录: ${moduleName}
    
    > 按模块记录每一项修改,修改前先读取此文件了解历史。
    
    ## 修改历史
    
    | 日期 | 变更内容 | 涉及文件 | 决策 |
    |------|---------|---------|------|
    ${newRow}
    ## 当前状态
    
    - 待补充
    
    ## 待办
    
    - [ ] 补充模块说明
    `;
          fs.writeFileSync(filePath, content, 'utf-8');
        } else {
          // 追加到表格中(在表头之后插入)
          const tableMarker = '|------|---------|---------|------|';
          const idx = existing.indexOf(tableMarker);
          if (idx !== -1) {
            const insertPos = idx + tableMarker.length;
            const updated = existing.slice(0, insertPos) + '\n' + newRow + existing.slice(insertPos);
            fs.writeFileSync(filePath, updated, 'utf-8');
          } else {
            // 没有表格,追加到末尾
            const updated = existing + `\n| ${entry.date} | ${entry.change} | ${filesStr} | ${decisionsStr} |\n`;
            fs.writeFileSync(filePath, updated, 'utf-8');
          }
        }
    
        return { success: true };
      } catch (e: any) {
        return { success: false, error: e.message };
      }
    }
  • Type definitions for the module logger: ModuleEntry interface (date, change, files, decisions) and ModuleLog interface (moduleName, entries, currentState, todos).
    export interface ModuleEntry {
      date: string;
      change: string;
      files: string[];
      decisions: string[];
    }
    
    export interface ModuleLog {
      moduleName: string;
      entries: ModuleEntry[];
      currentState: string;
      todos: string[];
    }
Behavior3/5

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

No annotations are provided, so the description carries the burden. It indicates the tool writes a log but does not disclose persistence, idempotency, or error behavior. Some transparency, but minimal beyond the purpose.

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

Conciseness5/5

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

The description is two concise sentences. The first states the purpose, the second gives workflow guidance. No unnecessary words.

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

Completeness3/5

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

Given no output schema and no annotations, the description explains the basic purpose and usage sequence but omits return value, failure behavior, or side effects. Adequate but not comprehensive.

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?

Schema description coverage is 100% (all 4 parameters have descriptions). The tool description adds no additional parameter information beyond what the schema already provides, earning the baseline score.

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

Purpose5/5

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

The description clearly states the tool records a modification by module ('按模块记录一次修改(目录式)') and distinguishes from sibling read_module by specifying the workflow order.

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

Usage Guidelines5/5

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

It provides explicit when-to-use instructions: '修改功能前先 read_module,修改后调用此工具' (read_module before modification, log_module after). This guides the agent on the correct sequence.

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/thana0623/prompts-mcp-server'

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