Skip to main content
Glama
kshayk

AviBase MCP Server

by kshayk

execute_jsonata_query

Execute JSONata queries to analyze and transform bird data from the AviBase dataset for advanced data processing.

Instructions

Execute a raw JSONata query for advanced data analysis and transformation. JSONata is a powerful query language for JSON data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesJSONata query expression (e.g., "$count($[Taxon_rank = \"species\"])" to count species)
limitNoMaximum number of results to return for array results (default: 50)

Implementation Reference

  • The handler function that destructures query and optional limit from args, sends POST to /query endpoint with JSON body, processes response into formatted markdown text distinguishing array or single result, and returns structured content.
      async handleExecuteJsonataQuery(args) {
        const { query, limit = 50 } = args;
        const endpoint = `/query`;
        const response = await this.makeAPIRequest(endpoint, {
          method: 'POST',
          body: JSON.stringify({ query, limit }),
        });
    
        let resultText;
        if (Array.isArray(response.data)) {
          resultText = `**Query:** \`${query}\`
    **Result Type:** Array with ${response.pagination?.totalItems || response.data.length} items
    
    **Results:**
    ${response.data.map((item, i) => `${i + 1}. ${typeof item === 'object' ? JSON.stringify(item, null, 2) : item}`).join('\n\n')}`;
        } else {
          resultText = `**Query:** \`${query}\`
    **Result Type:** ${typeof response.data}
    **Result:** ${typeof response.data === 'object' ? JSON.stringify(response.data, null, 2) : response.data}`;
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `# JSONata Query Execution
    
    ${resultText}
    
    ${response.pagination?.hasNext ? `\n*Note: Showing first ${response.data.length} of ${response.pagination.totalItems} total results.*` : ''}`,
            },
          ],
        };
      }
  • Input schema defining required 'query' string and optional 'limit' number for the tool.
    inputSchema: {
      type: 'object',
      properties: {
        query: {
          type: 'string',
          description: 'JSONata query expression (e.g., "$count($[Taxon_rank = \\"species\\"])" to count species)',
        },
        limit: {
          type: 'number',
          description: 'Maximum number of results to return for array results (default: 50)',
          default: 50,
        },
      },
      required: ['query'],
    },
  • mcp-server.js:318-319 (registration)
    Switch case dispatching tool calls to the specific handler method.
    case 'execute_jsonata_query':
      return await this.handleExecuteJsonataQuery(args);
  • mcp-server.js:259-277 (registration)
    Tool definition object added to the tools list for ListToolsRequestHandler, including name, description, and inputSchema.
    {
      name: 'execute_jsonata_query',
      description: 'Execute a raw JSONata query for advanced data analysis and transformation. JSONata is a powerful query language for JSON data.',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'JSONata query expression (e.g., "$count($[Taxon_rank = \\"species\\"])" to count species)',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of results to return for array results (default: 50)',
            default: 50,
          },
        },
        required: ['query'],
      },
    },

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/kshayk/avibase-mcp'

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