Skip to main content
Glama
wonderwhy-er

Claude Desktop Commander MCP

set_config_value

Update specific configuration values in Claude Desktop Commander MCP to customize settings like allowed directories, command restrictions, file limits, and telemetry preferences.

Instructions

                    Set a specific configuration value by key.
                    
                    WARNING: Should be used in a separate chat from file operations and 
                    command execution to prevent security issues.
                    
                    Config keys include:
                    - blockedCommands (array)
                    - defaultShell (string)
                    - allowedDirectories (array of paths)
                    - fileReadLineLimit (number, max lines for read_file)
                    - fileWriteLineLimit (number, max lines per write_file call)
                    - telemetryEnabled (boolean)
                    
                    IMPORTANT: Setting allowedDirectories to an empty array ([]) allows full access 
                    to the entire file system, regardless of the operating system.
                    
                    This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes
valueNo

Implementation Reference

  • The core handler function implementing the set_config_value tool. Parses arguments using the schema, handles JSON parsing for complex values, special array handling for certain keys, updates config via configManager, and returns success/error responses with updated config.
    export async function setConfigValue(args: unknown) {
      console.error(`setConfigValue called with args: ${JSON.stringify(args)}`);
      try {
        const parsed = SetConfigValueArgsSchema.safeParse(args);
        if (!parsed.success) {
          console.error(`Invalid arguments for set_config_value: ${parsed.error}`);
          return {
            content: [{
              type: "text",
              text: `Invalid arguments: ${parsed.error}`
            }],
            isError: true
          };
        }
    
        try {
          // Parse string values that should be arrays or objects
          let valueToStore = parsed.data.value;
          
          // If the value is a string that looks like an array or object, try to parse it
          if (typeof valueToStore === 'string' && 
              (valueToStore.startsWith('[') || valueToStore.startsWith('{'))) {
            try {
              valueToStore = JSON.parse(valueToStore);
              console.error(`Parsed string value to object/array: ${JSON.stringify(valueToStore)}`);
            } catch (parseError) {
              console.error(`Failed to parse string as JSON, using as-is: ${parseError}`);
            }
          }
    
          // Special handling for known array configuration keys
          if ((parsed.data.key === 'allowedDirectories' || parsed.data.key === 'blockedCommands') && 
              !Array.isArray(valueToStore)) {
            if (typeof valueToStore === 'string') {
              const originalString = valueToStore;
              try {
                const parsedValue = JSON.parse(originalString);
                valueToStore = parsedValue;
              } catch (parseError) {
                console.error(`Failed to parse string as array for ${parsed.data.key}: ${parseError}`);
                // If parsing failed and it's a single value, convert to an array with one item
                if (!originalString.includes('[')) {
                  valueToStore = [originalString];
                }
              }
            } else if (valueToStore !== null) {
              // If not a string or array (and not null), convert to an array with one item
              valueToStore = [String(valueToStore)];
            }
            
            // Ensure the value is an array after all our conversions
            if (!Array.isArray(valueToStore)) {
              console.error(`Value for ${parsed.data.key} is still not an array, converting to array`);
              valueToStore = [String(valueToStore)];
            }
          }
    
          await configManager.setValue(parsed.data.key, valueToStore);
          // Get the updated configuration to show the user
          const updatedConfig = await configManager.getConfig();
          console.error(`setConfigValue: Successfully set ${parsed.data.key} to ${JSON.stringify(valueToStore)}`);
          return {
            content: [{
              type: "text",
              text: `Successfully set ${parsed.data.key} to ${JSON.stringify(valueToStore, null, 2)}\n\nUpdated configuration:\n${JSON.stringify(updatedConfig, null, 2)}`
            }],
          };
        } catch (saveError: any) {
          console.error(`Error saving config: ${saveError.message}`);
          // Continue with in-memory change but report error
          return {
            content: [{
              type: "text", 
              text: `Value changed in memory but couldn't be saved to disk: ${saveError.message}`
            }],
            isError: true
          };
        }
      } catch (error) {
        console.error(`Error in setConfigValue: ${error instanceof Error ? error.message : String(error)}`);
        console.error(error instanceof Error && error.stack ? error.stack : 'No stack trace available');
        return {
          content: [{
            type: "text",
            text: `Error setting value: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
  • Zod schema defining the input parameters for the set_config_value tool: key (string) and value (string|number|boolean|string[]|null).
    export const SetConfigValueArgsSchema = z.object({
      key: z.string(),
      value: z.union([
        z.string(),
        z.number(),
        z.boolean(),
        z.array(z.string()),
        z.null(),
      ]),
    });
  • src/server.ts:206-232 (registration)
    Tool registration in the list_tools handler. Defines the tool name, detailed description with warnings and config keys, input schema converted to JSON schema, and annotations indicating it's destructive.
        name: "set_config_value",
        description: `
                Set a specific configuration value by key.
                
                WARNING: Should be used in a separate chat from file operations and 
                command execution to prevent security issues.
                
                Config keys include:
                - blockedCommands (array)
                - defaultShell (string)
                - allowedDirectories (array of paths)
                - fileReadLineLimit (number, max lines for read_file)
                - fileWriteLineLimit (number, max lines per write_file call)
                - telemetryEnabled (boolean)
                
                IMPORTANT: Setting allowedDirectories to an empty array ([]) allows full access 
                to the entire file system, regardless of the operating system.
                
                ${CMD_PREFIX_DESCRIPTION}`,
        inputSchema: zodToJsonSchema(SetConfigValueArgsSchema),
        annotations: {
            title: "Set Configuration Value",
            readOnlyHint: false,
            destructiveHint: true,
            openWorldHint: false,
        },
    },
  • Dispatch handler in call_tool request that routes set_config_value calls to the setConfigValue function, with error capturing.
    case "set_config_value":
        try {
            result = await setConfigValue(args);
        } catch (error) {
            capture('server_request_error', { message: `Error in set_config_value handler: ${error}` });
            result = {
                content: [{ type: "text", text: `Error: Failed to set configuration value` }],
                isError: true,
            };
        }
Behavior4/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 does well by including a WARNING about security implications and important notes about the 'allowedDirectories' parameter behavior. It also mentions the tool can be referenced as 'DC: ...' which provides implementation context. However, it doesn't cover error conditions, validation rules, or what happens when invalid keys/values are provided.

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

Conciseness3/5

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

The description is appropriately sized but not optimally structured. The core purpose is clear in the first sentence, but the WARNING and IMPORTANT sections are buried in the middle rather than front-loaded. The final sentence about referencing as 'DC: ...' feels somewhat out of place and doesn't add critical value for tool selection.

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 this is a mutation tool with no annotations and no output schema, the description does quite well. It covers the purpose, security implications, parameter details, and specific behavioral notes. The main gap is the lack of information about return values or error responses, which would be important for a configuration-setting operation.

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

Parameters5/5

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

With 0% schema description coverage and 2 parameters, the description compensates excellently. It provides a comprehensive list of config keys with their expected data types and specific behavioral notes (like the empty array behavior for allowedDirectories). This adds substantial meaning beyond what the bare schema provides, fully documenting the parameter semantics.

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 tool's purpose: 'Set a specific configuration value by key.' This is a specific verb+resource combination (set + configuration value). However, it doesn't explicitly distinguish from its sibling 'get_config' beyond the obvious set vs. get difference, missing an opportunity for clearer sibling differentiation.

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 provides clear context about when to use this tool: 'Should be used in a separate chat from file operations and command execution to prevent security issues.' This gives important operational guidance. However, it doesn't explicitly mention when NOT to use it or provide alternatives to setting configuration values.

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

Related 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/wonderwhy-er/DesktopCommanderMCP'

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