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";
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool writes to a file, implying a mutation operation, but doesn't disclose whether this overwrites existing settings, requires specific permissions, or has any side effects like creating directories. It lacks details on error handling or what happens if the file doesn't exist.

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 a single, efficient sentence in Chinese that directly states the tool's purpose without any fluff. It's appropriately sized and front-loaded with the core action, making it easy to understand quickly.

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 the tool has one optional parameter with full schema coverage and no output schema, the description is minimally adequate. However, as a mutation tool with no annotations, it should provide more behavioral context about file operations and potential impacts, leaving some gaps in completeness for safe usage.

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 single parameter 'project_path' well-documented in the schema as the project root directory path defaulting to the current workspace. The description doesn't add any additional parameter semantics beyond what the schema provides, so it meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('写入' - writes) and the resource ('.cursor/settings.json' with '推荐的 AI 配置' - recommended AI configuration). It specifies the exact file and type of configuration being written, though it doesn't explicitly differentiate from sibling tools like 'init_project' which might have overlapping initialization purposes.

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 explicit guidance on when to use this tool versus alternatives is provided. The description implies it's for initializing AI configuration in a specific file, but it doesn't mention when to choose this over other initialization or configuration tools, or any prerequisites like needing a .cursor directory.

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

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