Skip to main content
Glama
seansoreilly

ABS MCP Server

by seansoreilly

query_dataset

Query Australian Bureau of Statistics datasets using SDMX-ML API to retrieve and analyze statistical data with optional filtering capabilities.

Instructions

Query a specific ABS dataset with optional filters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
datasetIdYesID of the dataset to query (e.g., C21_G01_LGA)

Implementation Reference

  • The handler function for CallToolRequestSchema that implements the logic for the 'query_dataset' tool, including validation, API call to ABS, and response formatting.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      try {
        const { name, arguments: args } = request.params;
    
        if (name !== "query_dataset") {
          throw new Error(`Unknown tool: ${name}`);
        }
    
        if (!args?.datasetId || typeof args.datasetId !== "string") {
          throw new Error("datasetId is required and must be a string");
        }
    
        const url = `${ABS_API_BASE}/data/${args.datasetId}/all?format=json&dimensionAtObservation=AllDimensions`;
        
        try {
          const response = await axios.get(url);
          return {
            content: [{
              type: "text",
              text: JSON.stringify(response.data, null, 2)
            }]
          };
        } catch (error) {
          if (error instanceof AxiosError && error.response) {
            throw new Error(`ABS API Error: ${error.response.status} - ${JSON.stringify(error.response.data)}`);
          }
          throw error;
        }
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new Error(`Error querying dataset: ${errorMessage}`);
      }
    });
  • src/index.ts:29-48 (registration)
    Registers the 'query_dataset' tool in the ListToolsRequestSchema handler by including it in the tools list.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "query_dataset",
            description: "Query a specific ABS dataset with optional filters",
            inputSchema: {
              type: "object",
              required: ["datasetId"],
              properties: {
                datasetId: {
                  type: "string",
                  description: "ID of the dataset to query (e.g., C21_G01_LGA)"
                }
              }
            }
          }
        ]
      };
    });
  • Input schema definition for the 'query_dataset' tool, specifying the required 'datasetId' parameter.
    inputSchema: {
      type: "object",
      required: ["datasetId"],
      properties: {
        datasetId: {
          type: "string",
          description: "ID of the dataset to query (e.g., C21_G01_LGA)"
        }
      }
    }
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/seansoreilly/mcp-server-abs'

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