init_setting
Initialize AI configuration by writing recommended settings to .cursor/settings.json file for enhanced development workflow.
Instructions
【初始化配置】在 .cursor/settings.json 中写入推荐的 AI 配置
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | No | 项目根目录的完整路径(默认使用当前工作区路径) |
Implementation Reference
- src/tools/init_setting.ts:5-56 (handler)The main handler function for the 'init_setting' tool. It defines recommended Cursor AI settings and generates 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, }; } }
- src/index.ts:55-67 (schema)The schema definition for the init_setting tool, including name, description, and optional input parameters, registered in the ListTools handler.name: "init_setting", description: "【初始化配置】在 .cursor/settings.json 中写入推荐的 AI 配置", inputSchema: { type: "object", properties: { project_path: { type: "string", description: "项目根目录的完整路径(默认使用当前工作区路径)", }, }, required: [], }, },
- src/index.ts:462-463 (registration)Registration in the CallToolRequestSchema switch statement that dispatches calls to the initSetting handler.case "init_setting": return await initSetting(args);
- src/tools/index.ts:2-2 (registration)Re-export of the initSetting function from its implementation module, allowing it to be imported in src/index.ts.export { initSetting } from "./init_setting.js";
- src/index.ts:11-12 (registration)Import of the initSetting handler from the tools index, making it available for dispatch in the main server.import { detectShell, initSetting, initProject, gencommit, debug, genapi,