---
title: "corestack_logs_query"
url: https://docs.corefinity.com/mcp/tools/corestack_logs_query
type: tool
last_updated: 2026-11-13
feature: logs
related:
  - https://docs.corefinity.com/api/reference/logs/query-site-logs.md
  - https://docs.corefinity.com/guides/sites/logs-and-monitoring/logs.md
---
# corestack_logs_query

**Query logs.** Search a site's logs with LogsQL over a time window: the matching lines newest first with a cursor for the next page, or one table per log account for a query ending in stats, uniq or top. Scope: read.

- Scope: `read`
- Runs as a task: no

## When to use it

Search a site's logs with LogsQL over a time window: the matching lines newest first with a cursor for the next page, or one table per log account for a query ending in stats, uniq or top.

## Inputs

- `site_id` (integer, ≥ 1, required): The site (any of its environments answers for its group).
- `environment_id` (integer, ≥ 1): A row of the same site: production or one of its environments. Omitted: the row site_id names.
- `scope` (one of `env`, `site`, default `"env"`): env (the default): that one row; site: every environment of the site you may see.
- `source` (one of `all`, `web-access`, `web-error`, `php`, `app`, `cron`, `database`, `cache`, `search`, `queue`, default `"all"`): One log source (corestack_logs_streams_list says which this row has).
- `query` (string, up to 4096 characters): LogsQL, sent as written (* when empty).
- `filters` (object): The filter builder's entries (level, text, fields), ANDed with the query.
- `from` (string): ISO 8601; with to, instead of range.
- `to` (string): ISO 8601; defaults to now.
- `range` (one of `15m`, `1h`, `6h`, `24h`, `7d`, `30d`): Back from now, inside the site's retention.
- `limit` (integer, 1–1000, default `200`)
- `cursor` (string, up to 65536 characters): next_cursor from the previous page.
- `facets` (array of string, pattern `^[A-Za-z0-9_.:@-]{1,128}$`, up to 20 items): Fields whose top ten values to add (a records page only).

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "cursor": {
      "description": "next_cursor from the previous page.",
      "maxLength": 65536,
      "type": "string"
    },
    "environment_id": {
      "description": "Production or an environment of the same site; omitted: site_id's row.",
      "minimum": 1,
      "type": "integer"
    },
    "facets": {
      "description": "Fields whose top ten values to add (a records page only).",
      "items": {
        "pattern": "^[A-Za-z0-9_.:@-]{1,128}$",
        "type": "string"
      },
      "maxItems": 20,
      "type": "array"
    },
    "filters": {
      "description": "Filter builder entries (level, text, fields), ANDed.",
      "type": "object"
    },
    "from": {
      "format": "date-time",
      "type": "string"
    },
    "limit": {
      "default": 200,
      "maximum": 1000,
      "minimum": 1,
      "type": "integer"
    },
    "query": {
      "description": "LogsQL (* when empty).",
      "maxLength": 4096,
      "type": "string"
    },
    "range": {
      "description": "Back from now, inside the site's retention.",
      "enum": [
        "15m",
        "1h",
        "6h",
        "24h",
        "7d",
        "30d"
      ],
      "type": "string"
    },
    "scope": {
      "default": "env",
      "description": "site: every environment of the site you may see.",
      "enum": [
        "env",
        "site"
      ],
      "type": "string"
    },
    "site_id": {
      "description": "The site (any of its environments answers for its group).",
      "minimum": 1,
      "type": "integer"
    },
    "source": {
      "default": "all",
      "description": "One log source (see corestack_logs_streams_list).",
      "enum": [
        "all",
        "web-access",
        "web-error",
        "php",
        "app",
        "cron",
        "database",
        "cache",
        "search",
        "queue"
      ],
      "type": "string"
    },
    "to": {
      "format": "date-time",
      "type": "string"
    }
  },
  "required": [
    "site_id"
  ],
  "type": "object"
}
```

## Refusals

- The refusals every tool can answer: `invalid_arguments`, `tenant_mismatch`, `scope_required`, `pin_refused`, `rate_limited`, `temporarily_unavailable`, `internal_error` (corestack://guides/how-this-server-works).

## Example

```json
{
  "name": "corestack_logs_query",
  "arguments": {
    "site_id": 4211
  }
}
```

## The answer

- The answer's `kind` is `records` (the lines newest first, `next_cursor` for the next page — send it back with the same
  `limit` and `window`) or `table` (one table per log account for a query ending in an aggregating pipe; no cursor).
- Its `window` `{from, to}` holds the absolute instants the page was read over, a `range` resolved back from now. Send these
  as `from` / `to` to read the same window again (later pages, the histogram) instead of a `range` that moves with the clock.
- **A large page comes as a link.** A page larger than an answer carries inline (256 KB by default) answers its
  metadata — `kind`, `window`, `next_cursor`, `effective_query`, `tenant` — with `linked {uri, bytes, rows, expires_at,
  message}` and a `resource_link` to `corestack://logs/pages/{ref}`. Read that URI with `resources/read` before it expires
  (an hour by default): it answers the whole page as this tool's JSON, under the same token. Or call again with a smaller
  `limit`. The link works only for the token and person it was issued to.

## Prompt

```text
Using the Corefinity MCP server, call corestack_logs_query with site_id 4211. (Query logs.) Tell me what it returned.
```

## The same task elsewhere

- Endpoint: [POST /api/corestack/sites/{site}/logs/query](https://docs.corefinity.com/api/reference/logs/query-site-logs.md)
- Guide: [Logs](https://docs.corefinity.com/guides/sites/logs-and-monitoring/logs.md)
