Skip to main content
Glama

Upsert Runtime Field

upsert_runtime_field
Idempotent

Create or replace a runtime field on a data view by view id, computing values at search time with a Painless script. Returns created status and the previous definition for undo.

Instructions

Create or replace a runtime field on a data view, by view id (from list_data_views): a field computed at search time by a Painless script that calls emit(...) with a value of type (e.g. "emit(doc['timestamp'].value.getHour())" for a long). Without a script the field reads the _source value of the same name. Kibana does NOT compile the script: one that does not compile, or emits another type, makes every search that Kibana runs on the data view fail (Discover, and visualizations that use the view) until you fix it with another call or remove it with delete_runtime_field. A name the view already has as a mapped field is refused (describe_data_view lists its fields); composite runtime fields are not managed here. A replacement keeps the field's custom label and description. Returns the stored field (name, type, script), created, and previous — the definition replaced (null on a create): pass its type and script back to undo.

space targets a Kibana space by id (default: the default space).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "view_id": "<view_id>",
      "name": "<name>",
      "type": "<type>"
    },
    "name": "upsert_runtime_field"
  }
}

Input Schema

NameRequiredDescriptionDefault
nameYes
typeYes
spaceNo
scriptNo
view_idYes

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.5.0

TDQS

A4.9/5.0
Behavior5/5

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

Beyond the annotations (which only say not read-only, idempotent, not destructive), the description discloses a serious failure mode: Kibana does not compile the script, so a non-compiling or wrong-type script breaks every search on the view until fixed. It also discloses that mapped-field name collisions are refused, that replacements preserve label and description, and that the space parameter defaults to the default space.

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

Conciseness4/5

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

The core action and its failure mode are front-loaded, and the return-value/undo note is placed last where it belongs. The prose is dense but nearly every clause carries operative information; the only mild redundancy is restating the return shape when an output schema already exists.

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?

For a mutating, script-executing tool the description covers consequences, collisions, undo path, and scoping. Return contents are summarized even though an output schema exists, which is valuable here because it explains how to reverse a replacement.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must carry the load and does: script is explained with a concrete Painless emit example, the no-script fallback to _source is stated, type is illustrated with a long/hour example, space's default is given, and view_id's provenance is noted. Only name lacks a dedicated sentence, and its collision rule is still covered.

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 clause gives a specific verb and resource — 'Create or replace a runtime field on a data view, by view id' — and immediately explains the resource's nature (a search-time computed field). It also draws a boundary against related operations (delete_runtime_field, describe_data_view, composite runtime fields), so an agent can distinguish it from siblings without opening a schema.

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?

It names where view_id comes from (list_data_views), where existing field names can be checked (describe_data_view), and which tool removes the field (delete_runtime_field). It also states an explicit exclusion: composite runtime fields are not managed here. That is when-to-use, when-not-to-use, and alternatives in one place.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.