Skip to main content
Glama
rawr-ai

Filesystem MCP Server

json_query

Extract and query JSON data using JSONPath expressions to locate values, arrays, and nested structures within specified directories and file size limits.

Instructions

Query JSON data using JSONPath expressions. Provides powerful search capabilities for selecting data within JSON structures. Supports standard JSONPath syntax for finding values, arrays, and nested structures. Requires maxBytes parameter (default 10KB). The path must be within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxBytesYesMaximum bytes to read from the file. Must be a positive integer. Handler default: 10KB.
pathYesPath to the JSON file to query
queryYesJSONPath expression to execute against the JSON data

Implementation Reference

  • The main handler function for the 'json_query' tool. It parses arguments using JsonQueryArgsSchema, validates the file path, reads and parses the JSON file, executes a JSONPath query, and returns the result as formatted text.
    export async function handleJsonQuery(
      args: unknown,
      allowedDirectories: string[],
      symlinksMap: Map<string, string>,
      noFollowSymlinks: boolean
    ) {
      const parsed = parseArgs(JsonQueryArgsSchema, args, 'json_query');
    
      const validPath = await validatePath(parsed.path, allowedDirectories, symlinksMap, noFollowSymlinks);
      const jsonData = await readJsonFile(validPath, parsed.maxBytes);
    
      try {
        const result = JSONPath({
          path: parsed.query,
          json: jsonData,
          wrap: false // Don't wrap single results in an array
        });
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify(result, null, 2)
          }],
        };
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`JSONPath query failed: ${error.message}`);
        }
        throw error;
      }
    }
  • TypeBox schema definition for JsonQueryArgsSchema and corresponding TypeScript type JsonQueryArgs, defining the input parameters: path (string), query (string), maxBytes (integer).
    export const JsonQueryArgsSchema = Type.Object({
      path: Type.String({ description: 'Path to the JSON file to query' }),
      query: Type.String({ description: 'JSONPath expression to execute against the JSON data' }),
      maxBytes: Type.Integer({
        minimum: 1,
        description: 'Maximum bytes to read from the file. Must be a positive integer. Handler default: 10KB.'
      })
    });
    export type JsonQueryArgs = Static<typeof JsonQueryArgsSchema>;
  • index.ts:279-280 (registration)
    Registration of the 'json_query' tool handler in the toolHandlers object, mapping the tool name to the handleJsonQuery function with necessary parameters.
    json_query: (a: unknown) =>
      handleJsonQuery(a, allowedDirectories, symlinksMap, noFollowSymlinks),
  • index.ts:387-396 (registration)
    Generic tool registration loop that adds 'json_query' (included in tools array) to the FastMCP server, using the handler from toolHandlers and schema from toolSchemas.
    for (const tool of tools) {
      const execute = toolHandlers[tool.name as keyof typeof toolHandlers];
      const schema = (toolSchemas as Record<string, any>)[tool.name];
      server.addTool({
        name: tool.name,
        description: tool.description,
        parameters: toZodParameters(schema as any) as any,
        execute: async (a) => execute(a) as any,
      });
    }
  • index.ts:326-326 (registration)
    Inclusion of 'json_query' in the allTools array with name and description, determining if it's enabled based on permissions.
    { name: "json_query", description: "Query JSON" },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'Requires `maxBytes` parameter (default 10KB)' and directory restrictions, but lacks critical details like error handling, performance implications, memory usage, or output format. For a query tool with zero annotation coverage, this leaves significant behavioral gaps.

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

Conciseness4/5

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

The description is appropriately sized with three sentences that each add value: purpose, capabilities, and constraints. It's front-loaded with the core function and avoids redundancy. Minor improvement could come from slightly tighter phrasing, but it's efficient overall.

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 the tool's complexity (JSON querying with multiple parameters), no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., matched values, arrays, or errors), how results are formatted, or provide examples. For a query tool in a JSON-heavy sibling set, more context is needed 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?

Schema description coverage is 100%, so the schema fully documents all three parameters. The description adds minimal value by noting the default for maxBytes and the directory restriction for path, but doesn't provide additional syntax examples or constraints beyond what's in the schema. This meets the baseline for high schema coverage.

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: 'Query JSON data using JSONPath expressions' with 'powerful search capabilities for selecting data within JSON structures.' It specifies the verb (query) and resource (JSON data) but doesn't explicitly differentiate from sibling JSON tools like json_filter or json_get_value, which prevents a perfect score.

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 minimal usage guidance. It mentions 'Supports standard JSONPath syntax' and 'The path must be within allowed directories,' but offers no explicit advice on when to use this tool versus alternatives like json_filter or json_search_kv. No context about when-not-to-use or comparisons with siblings is included.

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