update_project_config
Configure project-specific settings for AI assistants, including allowed commands, auto-formatting, git auto-commit, and format command, to control workspace behavior.
Instructions
Update specific project configuration settings
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| allowedCommands | No | Commands that are allowed to run | |
| formatOnSave | No | Auto-format files after editing | |
| gitAutoCommit | No | Auto-commit AI changes | |
| formatCommand | No | Format command (use {{file}} as placeholder) | |
| projectInstructions | No | Project-specific instructions for AI |
Implementation Reference
- src/index.ts:260-263 (handler)Tool execution handler for 'update_project_config'. Loads current config, merges with incoming args, and saves the updated config back.
case 'update_project_config': const currentConfig = await this.projectConfigService.loadProjectConfig(); const updatedConfig = { ...currentConfig, ...args }; return await this.projectConfigService.saveProjectConfig(updatedConfig); - src/toolDefinitions.ts:654-682 (schema)Tool definition/schema for 'update_project_config' with input validation properties (allowedCommands, formatOnSave, gitAutoCommit, formatCommand, projectInstructions).
{ name: 'update_project_config', description: 'Update specific project configuration settings', inputSchema: { type: 'object', properties: { allowedCommands: { type: 'array', items: { type: 'string' }, description: 'Commands that are allowed to run' }, formatOnSave: { type: 'boolean', description: 'Auto-format files after editing' }, gitAutoCommit: { type: 'boolean', description: 'Auto-commit AI changes' }, formatCommand: { type: 'string', description: 'Format command (use {{file}} as placeholder)' }, projectInstructions: { type: 'string', description: 'Project-specific instructions for AI' } } } - src/index.ts:112-114 (registration)Registration of all tool definitions (including 'update_project_config') via ListToolsRequestSchema handler.
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS, })); - Helper method that serializes the ProjectConfig to TOML and writes it to .vscode-mcp.toml. Called by the handler after merging.
async saveProjectConfig(config: ProjectConfig, workspacePath?: string): Promise<ToolResult> { try { const resolvedPath = workspacePath || this.workspaceService.workspacePath; const configPath = path.join(resolvedPath, ProjectConfigService.CONFIG_FILENAME); const tomlContent = toml.stringify(config as any); await fs.writeFile(configPath, tomlContent, 'utf-8'); // Update cache this.configCache.set(configPath, config); return { content: [{ type: 'text', text: `Project configuration saved to ${configPath}` }] }; } catch (error) { return { isError: true, content: [{ type: 'text', text: `Failed to save project configuration: ${error}` }] }; } } - Helper method that loads the current project config from .vscode-mcp.toml (used by the handler to get the current state before merging).
async loadProjectConfig(workspacePath?: string): Promise<ProjectConfig> { const resolvedPath = workspacePath || this.workspaceService.workspacePath; const configPath = path.join(resolvedPath, ProjectConfigService.CONFIG_FILENAME); // Check cache first if (this.configCache.has(configPath)) { return this.configCache.get(configPath)!; } try { const configContent = await fs.readFile(configPath, 'utf-8'); const parsedConfig = toml.parse(configContent) as any; // Handle nested TOML structure const flatConfig: Partial<ProjectConfig> = { // General settings formatOnSave: parsedConfig.general?.formatOnSave ?? parsedConfig.formatOnSave, gitAutoCommit: parsedConfig.general?.gitAutoCommit ?? parsedConfig.gitAutoCommit, gitAutoCommitMessage: parsedConfig.general?.gitAutoCommitMessage ?? parsedConfig.gitAutoCommitMessage, sessionTracking: parsedConfig.general?.sessionTracking ?? parsedConfig.sessionTracking, maxSessionCommits: parsedConfig.general?.maxSessionCommits ?? parsedConfig.maxSessionCommits, formatCommand: parsedConfig.general?.formatCommand ?? parsedConfig.formatCommand, format: parsedConfig.general?.format ?? parsedConfig.format, // Security settings allowedCommands: parsedConfig.security?.allowedCommands ?? parsedConfig.allowedCommands ?? [], // Project settings projectInstructions: parsedConfig.project?.projectInstructions ?? parsedConfig.projectInstructions, projectDescription: parsedConfig.project?.projectDescription ?? parsedConfig.projectDescription, // Custom tools customTools: parsedConfig.customTools ?? parsedConfig.project?.customTools, // Remote server remoteServer: parsedConfig.remoteServer }; // Merge with defaults const config = this.mergeWithDefaults(flatConfig); this.configCache.set(configPath, config); return config; } catch (error) { // Return default config if file doesn't exist or can't be parsed const defaultConfig = this.getDefaultConfig(); this.configCache.set(configPath, defaultConfig); return defaultConfig; } }