Skip to main content
Glama

init_setting

Configure AI development settings by writing recommended configurations to .cursor/settings.json for project initialization.

Instructions

【初始化配置】在 .cursor/settings.json 中写入推荐的 AI 配置

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathNo项目根目录的完整路径(默认使用当前工作区路径)

Implementation Reference

  • The main handler function for the 'init_setting' tool. It defines recommended Cursor AI settings and returns a message instructing to append them to .cursor/settings.json in the project root.
    export async function initSetting(args: any) {
      try {
    
        // 要写入的配置
        const settings = {
          // 统一使用 Claude-4.5-Sonnet(Chat / Composer / Edit 三处都钉死,便于复现)
          "ai.chatModel": "claude-sonnet-4-5",
          "ai.composerModel": "claude-sonnet-4-5",
          "ai.editModel": "claude-sonnet-4-5",
    
          // 采样温度:0 更"严格/确定",适合生成结构化/按规范的代码与 JSON
          "ai.temperature": 0,
    
          // 单次生成的最大 token(上限按平台限制,4096 对大多数修改/重构足够)
          // "ai.maxTokens": 4096, // 保守:4096 平衡:8192 激进:16384
    
          // ======================= 代码库上下文(让模型更懂你的项目) =======================
          // 语义检索:用向量搜索理解项目,而不是仅靠邻近几行
          "ai.contextEngine": "semantic",
          // 检索深度:high 提高命中率(更"聪明"地找引用/类型/API 使用示例)
          "ai.contextDepth": "high",
          // 是否将代码库上下文喂给模型:日常开发建议开启
          "ai.includeCodebaseContext": true, // 做模型指纹/一致性实验时 设置成:false
          // 语义与邻近的折中策略:balanced(常用且稳)
          "ai.contextStrategy": "balanced", // 做模型指纹/一致性实验时 设置成:neighboring
        };
        
        const message = `你要在项目的根目录下 .cursor/settings.json 文件内容追加以下内容,不要替换原有内容:
    ${JSON.stringify(settings, null, 2)}`
    
        return {
          content: [
            {
              type: "text",
              text: message,
            },
          ],
        };
      } catch (error) {
        const errorMessage =
          error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `❌ 初始化配置失败: ${errorMessage}\n\n可能原因:\n- 没有文件写入权限\n- 不在 Cursor 工作区中\n- 路径错误`,
            },
          ],
          isError: true,
        };
      }
    }
  • The input schema for the 'init_setting' tool, defined in the ListToolsRequestSchema handler. Includes an optional 'project_path' parameter.
    {
      name: "init_setting",
      description: "【初始化配置】在 .cursor/settings.json 中写入推荐的 AI 配置",
      inputSchema: {
        type: "object",
        properties: {
          project_path: {
            type: "string",
            description: "项目根目录的完整路径(默认使用当前工作区路径)",
          },
        },
        required: [],
      },
    },
  • src/index.ts:11-15 (registration)
    Import statement in src/index.ts that brings in the initSetting handler from src/tools/index.js.
    import { 
      detectShell, initSetting, initProject, gencommit, debug, genapi,
      codeReview, gentest, genpr, checkDeps, gendoc, genchangelog, refactor, perf,
      fix, gensql, resolveConflict, genui, explain, convert, genreadme, split, analyzeProject
    } from "./tools/index.js";
  • src/index.ts:462-463 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes 'init_setting' calls to the initSetting function.
    case "init_setting":
      return await initSetting(args);
  • src/tools/index.ts:2-2 (registration)
    Re-export of the initSetting function from src/tools/init_setting.js (likely .ts source) in the tools index file.
    export { initSetting } from "./init_setting.js";

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/mybolide/mcp-probe-kit'

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