Skip to main content
Glama

getConfig

Read configuration files in JSON, YAML, TOML, or JSONC format and extract specific settings using dot notation paths for workspace configuration management.

Instructions

Read a configuration file (JSON/JSONC/YAML/TOML) and optionally extract a specific key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYesPath to the configuration file
keyNoOptional dot-separated key path (e.g., 'database.host')

Implementation Reference

  • Handler function for the 'getConfig' tool. Reads the configuration file using readConfigFile helper and optionally extracts a value at a dot-separated key path, returning the result as JSON string or error.
    async ({ file, key }: { file: string; key?: string }) => {
      try {
        const data = await readConfigFile(file);
        const value = key
          ? key.split(".").reduce((o: any, k: string) => (o ? o[k] : undefined), data)
          : data;
        return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
      } catch (error) {
        return { content: [{ type: "text", text: `Error reading config: ${error}` }], isError: true };
      }
    }
  • Zod input schema defining parameters for getConfig: 'file' (required path string) and 'key' (optional dot-separated path string).
    {
      file: z.string().describe("Path to the configuration file"),
      key: z.string().optional().describe("Optional dot-separated key path (e.g., 'database.host')"),
    },
  • src/index.ts:59-77 (registration)
    MCP tool registration for 'getConfig', including name, description, input schema, and inline handler implementation.
    mcp.tool(
      "getConfig",
      "Read a configuration file (JSON/JSONC/YAML/TOML) and optionally extract a specific key",
      {
        file: z.string().describe("Path to the configuration file"),
        key: z.string().optional().describe("Optional dot-separated key path (e.g., 'database.host')"),
      },
      async ({ file, key }: { file: string; key?: string }) => {
        try {
          const data = await readConfigFile(file);
          const value = key
            ? key.split(".").reduce((o: any, k: string) => (o ? o[k] : undefined), data)
            : data;
          return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text", text: `Error reading config: ${error}` }], isError: true };
        }
      }
    );
  • Helper function that reads and parses configuration files in supported formats (JSON, JSONC, YAML/YML, TOML) by detecting the file extension and using appropriate parsers.
    export async function readConfigFile(file: string): Promise<any> {
      const fmt = detectFormat(file);
      const content = await fs.readFile(file, "utf8");
      switch (fmt) {
        case "yaml":
        case "yml":
          return parseYaml(content);
        case "toml":
          return TOML.parse(content);
        case "jsonc":
          return parseCommentJson(content);
        case "json":
        default:
          return JSON.parse(content);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions reading and optional extraction, but fails to disclose critical behavioral traits such as error handling (e.g., if the file doesn't exist or key is invalid), permissions required, or output format details. This is inadequate for a tool with no annotation coverage.

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 front-loads the core action ('Read a configuration file') and includes essential details (formats, optional extraction). Every word earns its place with zero waste, making it highly concise and well-structured.

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 no annotations, no output schema, and a tool that reads files (potentially with errors or permissions issues), the description is incomplete. It lacks information on return values, error conditions, or behavioral constraints, leaving significant gaps for an AI agent to use it correctly in context.

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 both parameters fully. The description adds minimal value beyond the schema by hinting at the key path format ('dot-separated'), but does not elaborate on semantics like file path resolution or key extraction behavior. Baseline 3 is appropriate as the schema does the heavy lifting.

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 verb ('Read') and resource ('configuration file'), specifying the supported file formats (JSON/JSONC/YAML/TOML) and the optional extraction capability. It distinguishes from sibling 'listConfigs' (which likely lists files) and 'setConfig' (which writes), though not explicitly. The purpose is specific but lacks explicit 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 Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for reading configuration files with optional key extraction, but does not explicitly state when to use this tool versus alternatives like 'searchSettings' or 'searchDocs'. No guidance on prerequisites or exclusions is provided, leaving usage context partially inferred.

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/cloud-aspect/Config-MCP-Server'

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