Skip to main content
Glama
thana0623

prompts-mcp-server

by thana0623

init_prompts

Scans a project root directory and generates initial prompts files (context.md, workflow-log.md, recent-5.md, summary-10.md, todos.md, dev-rules.md, modules/) for AI coding assistants, without overwriting existing files.

Instructions

【初始化】扫描目标项目,自动生成原始 prompts 体系(context.md / workflow-log.md / recent-5.md / summary-10.md / todos.md / dev-rules.md / modules/)。已有文件不会覆盖。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectRootNo目标项目根目录路径。不传则使用 PROJECT_ROOT 环境变量或当前目录。

Implementation Reference

  • MCP tool handler for init_prompts. Calls the core initPrompts() function from prompts-generator.ts and formats the result as a markdown response.
    private async handleInitPrompts(args: any) {
      const projectRoot = typeof args?.projectRoot === 'string'
        ? args.projectRoot
        : getProjectRoot();
    
      const result = initPrompts(projectRoot);
    
      const lines: string[] = [];
      lines.push('# 🚀 Prompts 体系初始化完成');
      lines.push('');
      lines.push(`**项目**: ${result.projectInfo.name}`);
      lines.push(`**路径**: ${result.promptsDir}`);
      lines.push('');
    
      lines.push('## ✅ 已创建文件');
      lines.push('');
      for (const f of result.filesCreated) {
        lines.push(`- \`${f}\``);
      }
      lines.push('');
    
      lines.push('## 📋 检测到的项目信息');
      lines.push('');
      lines.push(`- 语言: ${result.projectInfo.languages.join(', ') || '未检测到'}`);
      lines.push(`- 框架: ${result.projectInfo.frameworks.join(', ') || '未检测到'}`);
      lines.push(`- 构建工具: ${result.projectInfo.buildTools.join(', ') || '未检测到'}`);
      lines.push(`- 数据库: ${result.projectInfo.databases.join(', ') || '未检测到'}`);
      lines.push(`- 前端: ${result.projectInfo.hasFrontend ? result.projectInfo.frontendFramework : '无'}`);
      lines.push(`- 后端: ${result.projectInfo.hasBackend ? result.projectInfo.backendFramework : '无'}`);
      lines.push('');
    
      if (result.errors.length > 0) {
        lines.push('## ⚠️ 错误');
        lines.push('');
        for (const e of result.errors) {
          lines.push(`- ❌ ${e}`);
        }
        lines.push('');
      }
    
      lines.push('## 📖 下一步');
      lines.push('');
      lines.push('1. 检查生成的 prompts 文件,根据项目实际情况补充修改');
      lines.push('2. 运行 `bootstrap` 验证加载正常');
      lines.push('3. 开始开发时,先运行 `check_requirements` 澄清需求');
    
      return {
        content: [{ type: 'text', text: lines.join('\n') }],
      };
    }
  • src/index.ts:89-100 (registration)
    Registers the 'init_prompts' tool with name, description, and inputSchema (projectRoot optional string).
      name: 'init_prompts',
      description: '【初始化】扫描目标项目,自动生成原始 prompts 体系(context.md / workflow-log.md / recent-5.md / summary-10.md / todos.md / dev-rules.md / modules/)。已有文件不会覆盖。',
      inputSchema: {
        type: 'object',
        properties: {
          projectRoot: {
            type: 'string',
            description: '目标项目根目录路径。不传则使用 PROJECT_ROOT 环境变量或当前目录。',
          },
        },
      },
    },
  • src/index.ts:237-239 (registration)
    Routes the 'init_prompts' tool call to handleInitPrompts() in the CallToolRequestSchema handler.
    switch (name) {
      case 'init_prompts':
        return this.handleInitPrompts(args);
  • InitResult interface defining the return type of initPrompts(): success, promptsDir, filesCreated, projectInfo, errors.
    export interface InitResult {
      success: boolean;
      promptsDir: string;
      filesCreated: string[];
      projectInfo: ProjectInfo;
      errors: string[];
    }
  • Core initPrompts() function: scans the project, creates .github/prompts/ directories, and generates prompt files (context.md, workflow-log.md, recent-5.md, summary-10.md, log-state.json, todos.md, dev-rules.md) without overwriting existing files.
    export function initPrompts(projectRoot: string): InitResult {
      const errors: string[] = [];
      const filesCreated: string[] = [];
    
      // 扫描项目
      const info = scanProject(projectRoot);
    
      // 创建 .github/prompts 目录
      const promptsDir = path.join(projectRoot, '.github', 'prompts');
      const dirsToCreate = [
        promptsDir,
        path.join(promptsDir, 'daily'),
        path.join(promptsDir, 'modules'),
      ];
    
      for (const dir of dirsToCreate) {
        try {
          if (!fs.existsSync(dir)) {
            fs.mkdirSync(dir, { recursive: true });
          }
        } catch (e: any) {
          errors.push(`创建目录失败: ${dir} - ${e.message}`);
        }
      }
    
      // 生成文件
      const files: { name: string; content: string }[] = [
        { name: 'context.md', content: generateContextMd(info) },
        { name: 'workflow-log.md', content: generateWorkflowLogMd() },
        { name: 'recent-5.md', content: generateRecent5Md() },
        { name: 'summary-10.md', content: generateSummary10Md() },
        { name: 'log-state.json', content: generateLogStateJson() },
        { name: 'todos.md', content: generateTodosMd() },
        { name: 'dev-rules.md', content: generateDevRulesPrompt(info) },
      ];
    
      for (const file of files) {
        const filePath = path.join(promptsDir, file.name);
        try {
          // 不覆盖已存在的文件
          if (!fs.existsSync(filePath)) {
            fs.writeFileSync(filePath, file.content, 'utf-8');
            filesCreated.push(file.name);
          } else {
            filesCreated.push(`${file.name} (已存在,跳过覆盖)`);
          }
        } catch (e: any) {
          errors.push(`写入文件失败: ${file.name} - ${e.message}`);
        }
      }
    
      return {
        success: errors.length === 0,
        promptsDir,
        filesCreated,
        projectInfo: info,
        errors,
      };
    }
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses that existing files are not overwritten, which is a key safety behavior. Additional traits like side effects are not mentioned but the non-destructive nature is clear.

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

Conciseness4/5

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

Single sentence listing all generated files; no redundant information. Could be slightly more structured but it is efficient and front-loaded.

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

Completeness4/5

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

Given no output schema and one parameter, the description covers generation scope, parameter fallback, and non-destructive behavior. Lacks details on return values but that is acceptable.

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

Parameters4/5

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

The schema describes the parameter, and the description adds value by explaining the fallback behavior (using PROJECT_ROOT environment variable or current directory if not provided), which goes beyond schema.

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 initializes a target project by scanning and auto-generating specific prompt files, listing them explicitly. This distinguishes it from sibling tools like 'bootstrap' or 'make_plan'.

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

Usage Guidelines4/5

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

The description implies it's for initial setup and that existing files are not overwritten, but does not explicitly state when to use vs alternatives or provide exclusions. The context is clear enough for an AI agent.

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