Skip to main content
Glama

Compile an Arkime expression to OpenSearch DSL

arkime_build_query
Read-only

Translate an Arkime expression into OpenSearch DSL without executing it, enabling inspection and editing of the compiled query before running a search.

Instructions

Translate an Arkime expression into the OpenSearch DSL it compiles to, without running it.

    Do NOT use this to run a search: nothing is executed and no session
    comes back. Come here only when the DSL itself is the goal — a
    substring, wildcard, fuzzy or script clause Arkime's syntax cannot say,
    or a look at the compiled query before spending a scan on it. Compile
    the part the expression can express, edit the returned DSL, then run it
    with search_dsl (or count, which takes the inner query clause only).
    When the expression already says what you mean, send it straight to
    arkime_sessions for the rows or arkime_sessions_summary for the totals.

    Returns JSON shaped for that handoff: `index` and `query_dsl`, the two
    arguments search_dsl takes, plus the compiled body's own size and sort,
    which search_dsl overrides with its `size`. `query_dsl` is returned as
    an object so it can be edited, but search_dsl and count declare it a
    JSON STRING: serialise it before the handoff (the object verbatim is
    refused with "Input should be a valid string"). `index` is the concrete
    daily index the window resolves to, so a window covering no captured day
    shows up here rather than as a mysteriously empty search. An expression
    Arkime cannot parse is reported as an error naming the offending token:
    upstream answers 200 with an error field and no query, which would
    otherwise read as success.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
time_toNoEnd time as EPOCH SECONDS (NOT a dateparser string). Empty = now.
time_fromNoStart time as EPOCH SECONDS (NOT a dateparser string). It becomes a range clause on lastPacket in the compiled query and decides which daily indices the search covers.
expressionNoArkime expression syntax to compile, e.g. "protocols == http && ip.dst == 203.0.113.5". Empty compiles the time window alone, which is a useful starting skeleton.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

The description discloses several critical behaviors beyond annotations: that no session data is returned, that the upstream service returns 200 with an error field on parse failures, that query_dsl must be serialized to a string for search_dsl, and that the resolved index reveals empty-window cases. These are non-obvious and highly valuable, going well beyond the basic readOnlyHint and openWorldHint annotations.

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

Conciseness5/5

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

Although longer than typical, every sentence earns its place. The structure front-loads the core distinction (not a search), then covers usage contexts, handoff details, and edge-case gotchas. The warnings about serialization and error handling are essential for correct invocation. The formatting with a 'Do NOT' warning and explicit 'Returns JSON' section makes it scannable despite the length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is complete for a tool of this complexity. It explains when to use it, what it returns, how to hand off to search_dsl, how the index resolves, and how errors manifest. It also covers the empty-window case and the size override, leaving no major questions for an agent. The output schema exists, but the description adds necessary behavioral context that would not be inferable from schema alone.

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?

The input schema already provides 100% parameter coverage with detailed descriptions, including epoch-second expectations, examples, and empty-expression behavior. The tool description adds no additional parameter-specific semantics, so the baseline score of 3 is appropriate. It does clarify how the compiled query interacts with the time window, but that's more about output behavior than parameter syntax.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence 'Translate an Arkime expression into the OpenSearch DSL it compiles to, without running it' uses a specific verb ('translate') and resource ('Arkime expression to OpenSearch DSL'), and immediately distinguishes it from running a search. It also contrast with sibling tools like search_dsl and arkime_sessions, making the tool's role clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance: 'Do NOT use this to run a search' and 'Come here only when the DSL itself is the goal.' It names alternatives ('send it straight to arkime_sessions...'), recommends follow-up tools (search_dsl, count), and even notes when an expression is better sent directly elsewhere. This is exemplary when-versus-alternative guidance.

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

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/nagameTW/mcp-server-malcolm'

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