Skip to main content
Glama

Config Manager

manage_config

Configure browser baselines, polyfills, and feature overrides to customize compatibility checking for CSS/JS features.

Instructions

Configure browser baselines, polyfills, and feature overrides for more accurate compatibility checking

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNoConfiguration action to performview
baselineNoSet default baseline browser target (e.g., 'chrome-37', 'chrome-57')
polyfillNoFeature name to add/remove from polyfills list
featureNoFeature name for override setting
overrideNoForce feature support status
targetNameNoCustom target name (e.g., 'chrome-57')
browserNoBrowser name for custom target
versionNoBrowser version for custom target

Implementation Reference

  • The handleManageConfig function that executes the manage_config tool logic, dispatching to different configuration actions using the ConfigManager class.
    export async function handleManageConfig(args) {
      const { action = 'view', baseline, polyfill, feature, override, targetName, browser, version } = args;
    
      try {
        switch (action) {
          case 'view':
            const config = await configManager.loadConfig();
            const targets = await configManager.getBrowserTargets();
            return {
              action: 'view',
              currentConfig: {
                defaultBaseline: config.defaultBaseline,
                polyfills: config.polyfills,
                overrides: config.overrides,
                customTargets: config.customTargets
              },
              availableTargets: Object.keys(targets),
              instructions: {
                setBaseline: 'Use action="set_baseline" with baseline="chrome-57"',
                addPolyfill: 'Use action="add_polyfill" with polyfill="css-grid"',
                removePolyfill: 'Use action="remove_polyfill" with polyfill="css-grid"',
                setOverride: 'Use action="set_override" with feature="css-variables" and override="supported"',
                addTarget: 'Use action="add_target" with targetName="chrome-57", browser="chrome", version="57"',
                createTemplate: 'Use action="create_template" to create .caniuse-config.json file'
              }
            };
    
          case 'set_baseline':
            if (!baseline) {
              throw new Error('baseline parameter required for set_baseline action');
            }
            await configManager.updateConfig({ defaultBaseline: baseline });
            return {
              action: 'set_baseline',
              success: true,
              message: `Default baseline set to ${baseline}`,
              newBaseline: baseline
            };
    
          case 'add_polyfill':
            if (!polyfill) {
              throw new Error('polyfill parameter required for add_polyfill action');
            }
            await configManager.addPolyfill(polyfill);
            const updatedConfig = await configManager.loadConfig();
            return {
              action: 'add_polyfill',
              success: true,
              message: `Added ${polyfill} to polyfills list`,
              feature: polyfill,
              currentPolyfills: updatedConfig.polyfills
            };
    
          case 'remove_polyfill':
            if (!polyfill) {
              throw new Error('polyfill parameter required for remove_polyfill action');
            }
            await configManager.removePolyfill(polyfill);
            const configAfterRemoval = await configManager.loadConfig();
            return {
              action: 'remove_polyfill',
              success: true,
              message: `Removed ${polyfill} from polyfills list`,
              feature: polyfill,
              currentPolyfills: configAfterRemoval.polyfills
            };
    
          case 'set_override':
            if (!feature || !override) {
              throw new Error('feature and override parameters required for set_override action');
            }
            await configManager.setFeatureOverride(feature, override);
            return {
              action: 'set_override',
              success: true,
              message: `Set ${feature} override to ${override}`,
              feature,
              override
            };
    
          case 'add_target':
            if (!targetName || !browser || !version) {
              throw new Error('targetName, browser, and version parameters required for add_target action');
            }
            const currentConfig = await configManager.loadConfig();
            const newCustomTargets = {
              ...currentConfig.customTargets,
              [targetName]: { browser, version }
            };
            await configManager.updateConfig({ customTargets: newCustomTargets });
            return {
              action: 'add_target',
              success: true,
              message: `Added custom target ${targetName} (${browser} ${version})`,
              targetName,
              browserConfig: { browser, version }
            };
    
          case 'create_template':
            const templatePath = await ConfigManager.createConfigTemplate('.');
            return {
              action: 'create_template',
              success: true,
              message: 'Created .caniuse-config.json template file',
              configFile: templatePath,
              instructions: [
                'Edit the created .caniuse-config.json file to customize your settings',
                'Run manage_config with action="view" to see current configuration',
                'The configuration will be automatically loaded for all compatibility checks'
              ]
            };
    
          case 'reset':
            // Reset to default configuration
            await configManager.updateConfig({
              defaultBaseline: 'chrome-37',
              customTargets: {},
              polyfills: [],
              overrides: {}
            });
            return {
              action: 'reset',
              success: true,
              message: 'Configuration reset to defaults',
              newConfig: {
                defaultBaseline: 'chrome-37',
                customTargets: {},
                polyfills: [],
                overrides: {}
              }
            };
    
          default:
            throw new Error(`Unknown config action: ${action}`);
        }
      } catch (error) {
        return {
          action,
          error: true,
          message: error.message,
          suggestion: 'Check the action parameter and required fields. Use action="view" to see available options.'
        };
      }
    }
  • Zod input schema defining parameters for the manage_config tool, including action types and optional fields.
    inputSchema: {
      action: z.enum(["view", "set_baseline", "add_polyfill", "remove_polyfill", "set_override", "add_target", "create_template", "reset"]).optional().default("view").describe("Configuration action to perform"),
      baseline: z.string().optional().describe("Set default baseline browser target (e.g., 'chrome-37', 'chrome-57')"),
      polyfill: z.string().optional().describe("Feature name to add/remove from polyfills list"),
      feature: z.string().optional().describe("Feature name for override setting"),
      override: z.enum(["supported", "unsupported"]).optional().describe("Force feature support status"),
      targetName: z.string().optional().describe("Custom target name (e.g., 'chrome-57')"),
      browser: z.string().optional().describe("Browser name for custom target"),
      version: z.string().optional().describe("Browser version for custom target")
    }
  • index.js:166-205 (registration)
    Registration of the manage_config tool on the MCP server, including schema and wrapper handler that calls the main handleManageConfig.
    server.registerTool(
      "manage_config",
      {
        title: "Config Manager",
        description: "Configure browser baselines, polyfills, and feature overrides for more accurate compatibility checking",
        inputSchema: {
          action: z.enum(["view", "set_baseline", "add_polyfill", "remove_polyfill", "set_override", "add_target", "create_template", "reset"]).optional().default("view").describe("Configuration action to perform"),
          baseline: z.string().optional().describe("Set default baseline browser target (e.g., 'chrome-37', 'chrome-57')"),
          polyfill: z.string().optional().describe("Feature name to add/remove from polyfills list"),
          feature: z.string().optional().describe("Feature name for override setting"),
          override: z.enum(["supported", "unsupported"]).optional().describe("Force feature support status"),
          targetName: z.string().optional().describe("Custom target name (e.g., 'chrome-57')"),
          browser: z.string().optional().describe("Browser name for custom target"),
          version: z.string().optional().describe("Browser version for custom target")
        }
      },
      async (args) => {
        try {
          const result = await handleManageConfig(args);
          return {
            content: [{
              type: "text",
              text: JSON.stringify(result, null, 2)
            }]
          };
        } catch (error) {
          return {
            content: [{
              type: "text",
              text: JSON.stringify({
                error: true,
                message: error.message,
                suggestion: "Check the action parameter and required fields. Use action='view' to see available options."
              }, null, 2)
            }],
            isError: true
          };
        }
      }
    );
  • ConfigManager class providing persistent configuration storage, loading, updating, and management utilities used by the manage_config handler.
    export class ConfigManager {
      constructor(projectPath = '.') {
        this.projectPath = projectPath;
        this.config = null;
        this.defaultConfig = {
          defaultBaseline: 'chrome-37',
          customTargets: {},
          polyfills: [],
          overrides: {},
          browserFallbacks: {
            chrome: ['37'], // fallback versions if specific version not found
            firefox: ['78'],
            safari: ['12'],
            ie: ['11'],
            edge: ['18']
          }
        };
      }
    
      async loadConfig() {
        if (this.config) return this.config;
    
        // Try to load from file first
        const configPath = path.join(this.projectPath, '.caniuse-config.json');
        let fileConfig = {};
        
        try {
          if (fs.existsSync(configPath)) {
            const configContent = await fs.promises.readFile(configPath, 'utf8');
            fileConfig = JSON.parse(configContent);
          }
        } catch (error) {
          console.warn(`Warning: Could not load config from ${configPath}: ${error.message}`);
        }
    
        // Merge with environment variables
        const envConfig = this._loadFromEnvironment();
    
        // Merge all configurations: default < file < environment
        this.config = {
          ...this.defaultConfig,
          ...fileConfig,
          ...envConfig,
          // Merge nested objects properly
          customTargets: {
            ...this.defaultConfig.customTargets,
            ...fileConfig.customTargets,
            ...envConfig.customTargets
          },
          polyfills: [
            ...this.defaultConfig.polyfills,
            ...(fileConfig.polyfills || []),
            ...(envConfig.polyfills || [])
          ],
          overrides: {
            ...this.defaultConfig.overrides,
            ...fileConfig.overrides,
            ...envConfig.overrides
          },
          browserFallbacks: {
            ...this.defaultConfig.browserFallbacks,
            ...fileConfig.browserFallbacks,
            ...envConfig.browserFallbacks
          }
        };
    
        return this.config;
      }
    
      _loadFromEnvironment() {
        const envConfig = {};
        
        if (process.env.CANIUSE_DEFAULT_BASELINE) {
          envConfig.defaultBaseline = process.env.CANIUSE_DEFAULT_BASELINE;
        }
        
        if (process.env.CANIUSE_POLYFILLS) {
          try {
            envConfig.polyfills = JSON.parse(process.env.CANIUSE_POLYFILLS);
          } catch (error) {
            envConfig.polyfills = process.env.CANIUSE_POLYFILLS.split(',').map(p => p.trim());
          }
        }
        
        if (process.env.CANIUSE_OVERRIDES) {
          try {
            envConfig.overrides = JSON.parse(process.env.CANIUSE_OVERRIDES);
          } catch (error) {
            console.warn('Invalid CANIUSE_OVERRIDES environment variable format');
          }
        }
    
        return envConfig;
      }
    
      async getBrowserTargets() {
        const config = await this.loadConfig();
        
        // Built-in targets
        const builtInTargets = {
          'chrome-37': { browser: 'chrome', version: '37' },
          'chrome-latest': { browser: 'chrome', version: 'latest' },
          'firefox-esr': { browser: 'firefox', version: '78' },
          'safari-12': { browser: 'safari', version: '12' },
          'ie-11': { browser: 'ie', version: '11' },
          'edge-legacy': { browser: 'edge', version: '18' }
        };
    
        // Merge with custom targets
        return {
          ...builtInTargets,
          ...config.customTargets
        };
      }
    
      async resolveTargetVersion(targetString) {
        const config = await this.loadConfig();
        const targets = await this.getBrowserTargets();
        
        // Check if it's a known target
        if (targets[targetString]) {
          return targets[targetString];
        }
        
        // Try to parse browser-version format (e.g., "chrome-57")
        const match = targetString.match(/^([a-z]+)-(.+)$/);
        if (match) {
          const [, browser, version] = match;
          return { browser, version };
        }
        
        // Fallback to default baseline
        const defaultTarget = targets[config.defaultBaseline];
        if (defaultTarget) {
          return defaultTarget;
        }
        
        // Final fallback
        return { browser: 'chrome', version: '37' };
      }
    
      async isFeaturePolyfilled(featureName) {
        const config = await this.loadConfig();
        return config.polyfills.includes(featureName);
      }
    
      async getFeatureOverride(featureName) {
        const config = await this.loadConfig();
        return config.overrides[featureName];
      }
    
      async getFallbackVersions(browser) {
        const config = await this.loadConfig();
        return config.browserFallbacks[browser] || [];
      }
    
      async updateConfig(updates) {
        const config = await this.loadConfig();
        const newConfig = { ...config, ...updates };
        
        const configPath = path.join(this.projectPath, '.caniuse-config.json');
        await fs.promises.writeFile(configPath, JSON.stringify(newConfig, null, 2));
        
        // Reload config
        this.config = null;
        return await this.loadConfig();
      }
    
      async addPolyfill(featureName) {
        const config = await this.loadConfig();
        if (!config.polyfills.includes(featureName)) {
          config.polyfills.push(featureName);
          await this.updateConfig({ polyfills: config.polyfills });
        }
      }
    
      async removePolyfill(featureName) {
        const config = await this.loadConfig();
        const index = config.polyfills.indexOf(featureName);
        if (index > -1) {
          config.polyfills.splice(index, 1);
          await this.updateConfig({ polyfills: config.polyfills });
        }
      }
    
      async setFeatureOverride(featureName, supportStatus) {
        const config = await this.loadConfig();
        config.overrides[featureName] = supportStatus;
        await this.updateConfig({ overrides: config.overrides });
      }
    
      // Helper to create a config file template
      static async createConfigTemplate(projectPath) {
        const configPath = path.join(projectPath, '.caniuse-config.json');
        const template = {
          "$schema": "https://json-schema.org/draft-07/schema#",
          "$comment": "CanIUse MCP Configuration",
          "defaultBaseline": "chrome-37",
          "customTargets": {
            "chrome-57": { "browser": "chrome", "version": "57" },
            "chrome-60": { "browser": "chrome", "version": "60" }
          },
          "polyfills": [
            "css-grid",
            "flexbox",
            "promises"
          ],
          "overrides": {
            "css-variables": "supported"
          },
          "browserFallbacks": {
            "chrome": ["37", "40", "45"],
            "firefox": ["78", "68"],
            "safari": ["12", "11"],
            "ie": ["11"],
            "edge": ["18", "16"]
          }
        };
        
        await fs.promises.writeFile(configPath, JSON.stringify(template, null, 2));
        return configPath;
      }
    }
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 mentions the tool's purpose but doesn't describe what happens during operations (e.g., whether 'reset' is destructive, if changes persist, authentication needs, rate limits, or error conditions). This is inadequate for a tool with 8 parameters and multiple action types.

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 that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded with the core functionality.

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?

For a tool with 8 parameters, multiple action types, and no annotations or output schema, the description is insufficient. It doesn't explain what the tool returns, how different actions behave, or provide enough context for an agent to understand the tool's full scope and limitations.

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?

Schema description coverage is 100%, so the schema already documents all parameters. The description doesn't add any parameter-specific information beyond what's in the schema. It mentions the general categories (baselines, polyfills, overrides) but provides no additional syntax, format details, or usage examples.

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: configuring browser baselines, polyfills, and feature overrides for compatibility checking. It uses specific verbs ('configure') and resources ('browser baselines, polyfills, and feature overrides'), but doesn't explicitly distinguish it from sibling tools like 'generate_configs' or 'check_compatibility'.

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. It doesn't mention sibling tools like 'check_compatibility' or 'generate_configs', nor does it specify prerequisites, exclusions, or appropriate contexts for its use.

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/Amirmahdi-Kaheh/caniuse-mcp'

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