Skip to content

About

MCP server for Kibana — search logs, query indices, and explore dashboards from AI agents over stdio

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

kibana-mcp
==========

A Model Context Protocol (MCP) server that exposes Kibana capabilities to
AI agents over stdio transport. Search logs, inspect indices, run raw
Elasticsearch DSL queries, and explore dashboards — all from your AI client.
Works with Kibana 7.10+ / 8.x and AWS OpenSearch Dashboards.


What is this?
-------------

This server bridges the MCP protocol and the Kibana REST API. An AI agent
(Claude, Cursor, OpenCode, etc.) connects over stdio and calls tools that
execute against your Kibana instance. Speaks the stateless 2026-07-28 MCP
protocol and still serves 2025-era clients. Auth is via API key,
username/password, or session cookie. Config is via environment variables.
All tools are read-only.


Quick Start
-----------

  export KIBANA_URL="https://your-kibana.example.com"
  export KIBANA_API_KEY="your-api-key"
  npx kibana-mcp start


Environment Variables
---------------------

  KIBANA_URL          (required) Base URL of your Kibana instance, including
                      any base path (AWS OpenSearch: https://host/_plugin/kibana)
  KIBANA_API_KEY      API key value (Authorization: ApiKey <value>)
  KIBANA_USERNAME     Basic auth username, set with KIBANA_PASSWORD
  KIBANA_PASSWORD     Basic auth password, set with KIBANA_USERNAME
  KIBANA_COOKIE       Browser session cookie for SSO/proxy as name=value
                      (e.g. sid=... or _pomerium=...)
                      Set exactly one auth method.
  KIBANA_TIMEOUT_MS   (optional) Request timeout in ms, default 30000
  KIBANA_MAX_RETRIES  (optional) Max retries on transient failures, default 3


MCP Client Setup
----------------

Claude Desktop / Cursor:

  {
    "mcpServers": {
      "kibana": {
        "command": "npx",
        "args": ["kibana-mcp", "start"],
        "env": {
          "KIBANA_URL": "https://your-kibana.example.com",
          "KIBANA_API_KEY": "your-api-key"
        }
      }
    }
  }

OpenCode CLI (~/.config/opencode/config.json):

  {
    "mcp": {
      "kibana": {
        "type": "local",
        "command": ["npx", "kibana-mcp", "start"],
        "environment": {
          "KIBANA_URL": "https://your-kibana.example.com",
          "KIBANA_API_KEY": "your-api-key"
        },
        "enabled": true
      }
    }
  }


Tools
-----

search_logs
  Search logs using Lucene query syntax, newest first, with optional time
  range filtering and pagination.

  index     (required) Index name or pattern, e.g. logs-*
  query     (required) Lucene query string, e.g. level:error AND service:api
  from      (optional) Start time, ISO 8601 with offset
  to        (optional) End time, ISO 8601 with offset
  timeField (optional) Date field to filter and sort on, default @timestamp;
            use timeFieldName from get_index_pattern
  size      (optional) Results to return, default 50, max 500
  offset    (optional) Pagination offset, default 0

get_indices
  List all Elasticsearch indices available through Kibana. No parameters.

get_index_pattern
  Fetch a Kibana index pattern: title, timeFieldName, and every field with
  its Elasticsearch type, searchable and aggregatable flags.

  id        (required) Index pattern ID

run_query
  Execute a raw Elasticsearch DSL query against a Kibana index. Returns
  hits, total, took and aggregations.

  index     (required) Target index name or pattern
  query     (required) Elasticsearch _search request body
  size      (optional) Results to return, default 10, max 10000;
            0 for aggregation-only queries

get_dashboards
  List Kibana dashboards with pagination.

  page      (optional) Page number, default 1
  perPage   (optional) Results per page, default 20, max 100

get_dashboard
  Fetch a specific Kibana dashboard including its panel configuration.

  id        (required) Dashboard saved object ID


Project Layout
--------------

  bin/cli.ts                    kibana-mcp start CLI entry point
  src/server/index.ts           Server factory served over stdio (serveStdio)
  src/server/registry.ts        Registers all tools on McpServer
  src/tools/*.ts                One file per tool: zod schema + Tool object
  src/clients/http.ts           Fetch wrapper: auth, timeout, retry
  src/clients/kibana.ts         Kibana and Elasticsearch (console proxy) calls
  src/config/                   Env parsing and config validation
  src/core/constants.ts         All constants
  src/core/errors.ts            KibanaError and error mapping
  src/types/                    All types

  See CONTRIBUTING.md for code rules and release steps.


Requirements
------------

  Node.js >= 22


License
-------

MIT

About

MCP server for Kibana — search logs, query indices, and explore dashboards from AI agents over stdio

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages