Skip to main content
Glama
FosterG4

Code Reference Optimizer MCP Server

by FosterG4

update_config

Modify and apply configuration settings to optimize code context extraction, import analysis, and token usage for AI-assisted programming in TypeScript, JavaScript, Python, Go, and Rust.

Instructions

Update configuration settings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
configYesConfiguration updates to apply

Implementation Reference

  • src/index.ts:198-211 (registration)
    Registration of the 'update_config' tool in the MCP server's listTools handler, including name, description, and input schema.
    {
      name: 'update_config',
      description: 'Update configuration settings with new values. Allows fine-tuning of the optimizer behavior including cache policies, token limits, analysis depth, performance thresholds, and feature toggles. Changes are applied immediately and persist for the current session.',
      inputSchema: {
        type: 'object',
        properties: {
          config: {
            type: 'object',
            description: 'Partial configuration object with updates to apply. Can include any combination of configuration sections. Changes are merged with existing settings, not replaced entirely.',
          },
        },
        required: ['config'],
      },
    },
  • Main handler function for the 'update_config' tool. Extracts config from arguments, calls ConfigManager.updateConfig, optionally updates logger, and returns success response.
    private async handleUpdateConfig(args: any) {
      const { config } = args;
      
      if (!config) {
        throw new McpError(ErrorCode.InvalidParams, 'config is required');
      }
      
      try {
        this.configManager.updateConfig(config);
        // Refresh logger configuration when logging section changes
        if (config.logging) {
          const logCfg = this.configManager.getConfig().logging;
          this.logger.updateConfig({ level: logCfg.level, toFile: logCfg.enableFileLogging, filePath: logCfg.logPath });
        }
        
        return {
          content: [{
            type: 'text',
            text: 'Configuration updated successfully',
          }],
        };
      } catch (error) {
        this.logger.error(`update_config failed: ${error instanceof Error ? error.message : String(error)}`);
        throw new McpError(ErrorCode.InternalError, `Failed to update configuration: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • TypeScript interface defining the full structure of CodeReferenceOptimizerConfig, used for config validation and updates in the tool.
    export interface CodeReferenceOptimizerConfig {
      // Cache settings
      cache: {
        maxSize: number;
        ttlMs: number;
        evictionPolicy: CacheEvictionPolicy;
        enablePersistence: boolean;
        persistencePath?: string;
      };
      
      // Context extraction settings
      extraction: {
        strategy: ContextExtractionStrategy;
        maxTokens: number;
        includeComments: boolean;
        includeImports: boolean;
        includeExports: boolean;
        contextLines: number;
        minRelevanceScore: number;
      };
      
      // Import optimization settings
      imports: {
        enableOptimization: boolean;
        preserveSideEffects: boolean;
        analyzeTransitiveDeps: boolean;
        maxDepthLevel: number;
        excludePatterns: string[];
        includePatterns: string[];
      };
      
      // Diff settings
      diff: {
        enableContextualDiff: boolean;
        contextLines: number;
        ignoreWhitespace: boolean;
        ignoreComments: boolean;
        enableSymbolTracking: boolean;
      };
      
      // Performance settings
      performance: {
        maxFileSize: number;
        maxConcurrentOperations: number;
        enableMetrics: boolean;
        timeoutMs: number;
      };
      
      // Language-specific settings
      languages: {
        [language: string]: {
          enabled: boolean;
          extensions: string[];
          parserOptions?: any;
          customRules?: OptimizationConfig;
        };
      };
      
      // Logging settings
      logging: {
        level: LogLevel;
        enableFileLogging: boolean;
        logPath?: string;
        enableMetricsLogging: boolean;
      };
      
      // Security settings
      security: {
        allowedPaths: string[];
        blockedPaths: string[];
        maxFileAccess: number;
        enableSandbox: boolean;
      };
    }
  • ConfigManager.updateConfig method: merges partial updates with current config, validates the new config, and notifies change listeners.
    updateConfig(updates: Partial<CodeReferenceOptimizerConfig>): void {
      this.config = this.mergeConfigs(this.config, updates);
      this.validateConfig();
      this.notifyConfigChange();
    }
  • Logger.updateConfig method: updates logger settings like level, file output, and path, called when logging config changes.
    updateConfig(config: LoggerConfig) {
      if (config.level) this.level = config.level;
      if (typeof config.toFile === 'boolean') this.toFile = config.toFile;
      if (config.filePath !== undefined) this.filePath = config.filePath;
    }
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. 'Update' implies a mutation operation, but it doesn't specify whether this requires special permissions, if changes are reversible, what happens to existing settings not mentioned, or any rate limits. This leaves significant behavioral gaps for a mutation tool.

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 'Update configuration settings' is a single, efficient sentence with zero wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that this is a mutation tool with no annotations, no output schema, and a nested object parameter, the description is incomplete. It lacks details on what configuration settings can be updated, the format of the 'config' object, or what the tool returns, leaving the agent with insufficient context for effective use.

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 parameter 'config' documented as 'Configuration updates to apply' of type 'object'. The description adds no additional meaning beyond this, such as examples of valid configuration fields or structure. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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

Purpose3/5

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

The description 'Update configuration settings' states a clear verb ('Update') and resource ('configuration settings'), which provides basic purpose understanding. However, it doesn't differentiate this tool from its sibling 'reset_config' or specify what types of configuration settings are involved, making it somewhat vague.

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?

The description provides no guidance on when to use this tool versus alternatives like 'get_config' (for reading) or 'reset_config' (for resetting). There's no mention of prerequisites, appropriate contexts, or exclusions, leaving the agent without usage direction.

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/FosterG4/mcpsaver'

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