Skip to main content
Glama
rawr-ai

Filesystem MCP Server

json_get_value

Retrieve specific values from JSON files using field paths and dot notation, including nested properties and array indices. Requires file path and byte size limit, ensuring secure access within permitted directories.

Instructions

Get a specific value from a JSON file using a field path. Supports dot notation for accessing nested properties and array indices. Requires maxBytes parameter (default 10KB). Returns the value directly, properly formatted. The path must be within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldYesPath to the field to retrieve (e.g., "user.address.city" or "items[0].name")
maxBytesYesMaximum bytes to read from the file. Must be a positive integer. Handler default: 10KB.
pathYesPath to the JSON file

Implementation Reference

  • Main handler function for 'json_get_value' tool. Parses input arguments using the schema, validates and reads the JSON file, extracts the specified field using lodash.get (aliased as getProp), and returns the value as a formatted JSON string in the expected MCP response format. Handles cases where the field is not found.
    export async function handleJsonGetValue(
      args: unknown,
      allowedDirectories: string[],
      symlinksMap: Map<string, string>,
      noFollowSymlinks: boolean
    ) {
      const parsed = parseArgs(JsonGetValueArgsSchema, args, 'json_get_value');
    
      const validPath = await validatePath(parsed.path, allowedDirectories, symlinksMap, noFollowSymlinks);
      const jsonData = await readJsonFile(validPath, parsed.maxBytes);
    
      try {
        const value = getProp(jsonData, parsed.field);
        if (value === undefined) {
          throw new Error(`Field "${parsed.field}" not found in JSON data`);
        }
    
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify(value, null, 2)
          }],
        };
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`Failed to get JSON value: ${error.message}`);
        }
        throw error;
      }
    }
  • TypeBox schema definition for input arguments of json_get_value tool, including path to JSON file, field path (dot notation or JSONPath-like), and optional maxBytes limit.
    export const JsonGetValueArgsSchema = Type.Object({
      path: Type.String({ description: 'Path to the JSON file' }),
      field: Type.String({ description: 'Path to the field to retrieve (e.g., "user.address.city" or "items[0].name")' }),
      maxBytes: Type.Integer({
        minimum: 1,
        description: 'Maximum bytes to read from the file. Must be a positive integer. Handler default: 10KB.'
      })
    });
    export type JsonGetValueArgs = Static<typeof JsonGetValueArgsSchema>;
  • index.ts:285-286 (registration)
    Registers the 'json_get_value' tool handler in the toolHandlers object, binding it to handleJsonGetValue with server context (allowedDirectories, symlinksMap, noFollowSymlinks).
    json_get_value: (a: unknown) =>
      handleJsonGetValue(a, allowedDirectories, symlinksMap, noFollowSymlinks),
  • index.ts:329-329 (registration)
    Declares the tool metadata (name and description) in the allTools array used for MCP server registration.
    { name: "json_get_value", description: "Get value from JSON" },
  • Re-exports the JsonGetValueArgsSchema in the central toolSchemas index for use in server registration.
    json_get_value: JsonGetValueArgsSchema,
Behavior3/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 usefully describes the return format ('Returns the value directly, properly formatted'), the maxBytes parameter behavior, and the directory restriction. However, it doesn't mention error handling, performance characteristics, or what happens with invalid paths or files.

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 efficiently structured in three sentences that each earn their place: purpose statement, technical details (notation and parameter), and return behavior with constraints. No wasted words, front-loaded with the core functionality.

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?

For a read-only tool with no output schema and 100% schema coverage, the description provides adequate context about what the tool does, how to use it, and constraints. The main gap is the lack of output format details beyond 'properly formatted,' but given the tool's relative simplicity and good parameter documentation, this is acceptable.

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 fully documents all three parameters. The description adds minimal value beyond the schema - it mentions the maxBytes default (10KB) which is also in the schema, and reinforces the field parameter's purpose. Baseline 3 is appropriate when the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('Get a specific value'), resource ('from a JSON file'), and method ('using a field path'), distinguishing it from sibling tools like json_query or json_filter which have different purposes. It explicitly mentions dot notation and array indices for accessing nested properties.

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 (to retrieve a specific value from JSON files using path notation) and mentions the 'path must be within allowed directories' constraint. However, it doesn't explicitly contrast when to use this versus alternatives like json_query or json_filter among the many sibling tools.

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/rawr-ai/mcp-filesystem'

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