{
  "id": "data.query",
  "object": "tool",
  "name": "SQL over files",
  "summary": "DuckDB SQL on CSV, Parquet, XLSX.",
  "description": "Runs a read-only DuckDB SQL query over one or more CSV, TSV, JSON, NDJSON, Parquet or XLSX files. Each file is a table named after the file (orders.csv -> orders) or the alias you give. Returns the result as CSV, JSON, Parquet or XLSX plus a preview, row count and column types. No network or file access from SQL.",
  "category": "data",
  "hosted_by": "Opentools",
  "runtime": "container",
  "side_effects": false,
  "status": "live",
  "credits": 3,
  "price": "$0.0030",
  "providers": [
    {
      "id": "opentools",
      "name": "Opentools",
      "price": "$0.0030"
    }
  ],
  "mcp_name": "data_query",
  "input_schema": {
    "type": "object",
    "properties": {
      "files": {
        "minItems": 1,
        "maxItems": 10,
        "type": "array",
        "items": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "format": "uri",
                  "description": "Public http(s) URL of the file"
                }
              },
              "required": [
                "url"
              ]
            },
            {
              "type": "object",
              "properties": {
                "file_id": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                  "description": "An id returned by POST /v1/files"
                }
              },
              "required": [
                "file_id"
              ]
            },
            {
              "type": "object",
              "properties": {
                "base64": {
                  "type": "string",
                  "description": "Base64-encoded file bytes (up to 10 MB)"
                },
                "name": {
                  "type": "string",
                  "description": "File name, e.g. invoice.pdf"
                },
                "content_type": {
                  "type": "string"
                }
              },
              "required": [
                "base64",
                "name"
              ]
            },
            {
              "type": "object",
              "properties": {
                "connection": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "A storage connection id or name (see storage.connections)"
                },
                "path": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 1024,
                  "description": "Path of the file in that connection, e.g. reports/q3.pdf"
                }
              },
              "required": [
                "connection",
                "path"
              ]
            }
          ],
          "x-file": true,
          "description": "A file: { url }, { file_id }, { base64, name } or { connection, path } from connected storage"
        },
        "description": "Data files; each becomes a table"
      },
      "sql": {
        "type": "string",
        "minLength": 1,
        "maxLength": 20000,
        "description": "One SQL query, e.g. SELECT country, sum(total) FROM orders GROUP BY 1"
      },
      "aliases": {
        "description": "Table names for the files, in order. Defaults to the file names.",
        "maxItems": 10,
        "type": "array",
        "items": {
          "type": "string",
          "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,62}$"
        }
      },
      "output": {
        "default": "csv",
        "description": "Result file format",
        "type": "string",
        "enum": [
          "csv",
          "json",
          "parquet",
          "xlsx"
        ]
      },
      "preview_rows": {
        "default": 20,
        "description": "Rows to include in the response",
        "type": "integer",
        "minimum": 0,
        "maximum": 50
      }
    },
    "required": [
      "files",
      "sql"
    ]
  },
  "kind": "tool"
}