Skip to main content
Glama
mcp-opensearch-dashboards

mcp-opensearch-dashboards

README.md
# mcp-opensearch-dashboards

MCP server for OpenSearch Dashboards: an AI agent searches your logs and pulls one trace grouped by Kubernetes namespace and app, so it can tell which service broke a request.
It needs only the Dashboards URL, a user name and a password, so it also works where the OpenSearch API is closed.

![Claude Code is asked why checkout failed for order 123 and finds that fraud-check in the risk namespace cannot reach its Redis](docs/demo.gif)

Recorded with Claude Code on the [local demo](examples/demo), sped up 2x.

## Why

Working out where a request failed usually means opening Dashboards, searching one service, copying the trace id, and searching again in the next namespace.
An agent can do that loop on its own if it can run the searches.

This server talks to Dashboards the way the browser does:
it logs in with the login form, keeps the session cookie and sends its searches through the Dev Tools console proxy.

## When to use it

Use it when:

- The OpenSearch API is not reachable from where the agent runs, but Dashboards is.
- You log in to Dashboards with a user name and a password.
- You want the agent to search logs and follow a trace id across namespaces and apps.

Use something else when:

- Dashboards only lets you in through SSO (SAML, OIDC). The server needs the login form.
- You run Elastic Kibana or Open Distro. Only OpenSearch Dashboards is supported.
- The agent can reach the OpenSearch API directly. A server that uses the API can do more than
  search logs.
- The agent should change something. This server only reads logs.

[Alternatives](#alternatives) lists other servers and when they fit better.

## Setup

You need:

- Node.js 22.19 or newer.
- OpenSearch Dashboards with the security plugin and its login form (user name and password).
- The Dev Tools console enabled in Dashboards, and an account that can use it and read the log
  indices. All searches go through the console.

Tested with the latest patch of every minor release of OpenSearch and OpenSearch Dashboards from 1.0
to 3.10, in the Global and the Private tenant. `node test/compat.ts <version>` runs the same test on
another version.

Your MCP client starts and stops the server itself, so there is nothing to keep running. The whole
setup can live in the client's MCP config: the Dashboards URLs, one user and one password.

### Claude Code

Put this in `.mcp.json` at the root of your project. The password comes from the environment Claude
Code runs in, so export `OSD_MCP_PASSWORD` before you start `claude`. When it is not set, Claude
Code passes the text `${OSD_MCP_PASSWORD}` on instead, and the server refuses to log in with it.

```json
{
  "mcpServers": {
    "mcp-opensearch-dashboards": {
      "command": "npx",
      "args": ["-y", "mcp-opensearch-dashboards"],
      "env": {
        "OSD_MCP_SOURCES": "dev=https://dashboards-dev.example.com/, prod=https://dashboards.example.com/",
        "OSD_MCP_USER": "mcp-reader",
        "OSD_MCP_PASSWORD": "${OSD_MCP_PASSWORD}"
      }
    }
  }
}
```

Each `name=url` pair in `OSD_MCP_SOURCES` is one source, and the agent picks an environment by its
name. With a single Dashboards, the bare URL is enough and the source is called `default`.

### Other clients

VS Code, Cursor, Codex, Gemini CLI and Claude Desktop are covered in
[docs/clients.md](docs/clients.md).

### Check the settings

To try the settings from a terminal, run the check. It logs in to every source, lists its index
patterns and runs one search on the first of them.

```sh
OSD_MCP_SOURCES='https://dashboards.example.com/' OSD_MCP_USER='mcp-reader' \
  OSD_MCP_PASSWORD='your password' npx mcp-opensearch-dashboards --check
```

Without a cluster at hand, the [local demo](examples/demo) starts OpenSearch and Dashboards with
sample logs and a user for the agent.

## Tools

| Tool                  | What it does                                                            |
| --------------------- | ----------------------------------------------------------------------- |
| `list_sources`        | The configured Dashboards instances                                     |
| `list_index_patterns` | Index patterns of a source, for example `logs-*`                        |
| `list_fields`         | Field names and types of an index pattern, for writing queries          |
| `search_logs`         | Lines matching a query, a time range, or both, newest first             |
| `get_trace`           | The lines of one trace, oldest first, grouped by namespace and then app |

`search_logs` takes a Lucene query (`query_string`) and time bounds as ISO 8601 or date math
(`now-1h`). It is the syntax of the Dashboards search bar with DQL switched off, so write `AND`,
`OR` and `NOT` in upper case. It refuses to run with neither a query nor a time range.

Results are kept small for the model. A search returns 100 lines by default and a trace 200, with
1000 as the maximum. Messages are cut at 2000 characters, the raw document comes only with
`include_source`, and a result stops growing at about 200 000 characters. When there is more,
`next_cursor` continues where the result ended.

## Configuration

These variables apply to every source in `OSD_MCP_SOURCES`.

| Variable                    | Default      | Meaning                                          |
| --------------------------- | ------------ | ------------------------------------------------ |
| `OSD_MCP_SOURCES`           | required     | `name=url` pairs separated by commas, or one URL |
| `OSD_MCP_USER`              | required     | User name                                        |
| `OSD_MCP_PASSWORD`          | required     | Password                                         |
| `OSD_MCP_TENANT`            | `global`     | `global` or `private`                            |
| `OSD_MCP_TIMEOUT_MS`        | `30000`      | Per request                                      |
| `OSD_MCP_ALLOW_SELF_SIGNED` | `false`      | `true` skips TLS certificate checks              |
| `OSD_MCP_TIME_FIELD`        | `@timestamp` | Date field for time ranges and ordering          |

For a company CA, set `NODE_EXTRA_CA_CERTS=/path/to/ca.pem` and leave `OSD_MCP_ALLOW_SELF_SIGNED`
off.

If Dashboards is only reachable through an HTTP proxy, set `HTTPS_PROXY` (or `HTTP_PROXY` for an
`http://` URL) next to the other variables, for example `"HTTPS_PROXY": "http://localhost:8079"`.
`NO_PROXY` lists hosts to reach directly.

### Config file

Use a file when the sources need different users or settings, or when your logs use other field
names for the trace id, namespace or app. [`config.example.toml`](config.example.toml) lists every
option.

```toml
[[source]]
name = "prod"
url = "https://dashboards.example.com/"
user = "mcp-reader"
password_env = "OSD_MCP_PROD_PASSWORD"
```

`--config <file>` always wins. Without it, `OSD_MCP_SOURCES` is used when it is set. Otherwise the
file is `$OSD_MCP_CONFIG`, else `mcp-opensearch-dashboards/config.toml` in `$XDG_CONFIG_HOME` or in
`~/.config`.

## Security

### Account

Give the server an account that can only read the log indices. That account is the real limit on
what an agent can see: `index_pattern` is not limited to the saved index patterns, so the agent can
search any index the account can read.

The role below is enough, together with the built-in `kibana_user` role that Dashboards needs for
listing index patterns. The role only reads `logs-*`, and `kibana_user` adds the saved objects of
Dashboards. The [demo seed](examples/demo/seed.ts) creates such a user.

```json
{
  "cluster_permissions": ["cluster_composite_ops_ro"],
  "index_permissions": [{ "index_patterns": ["logs-*"], "allowed_actions": ["read"] }],
  "tenant_permissions": [
    { "tenant_patterns": ["global_tenant"], "allowed_actions": ["kibana_all_read"] }
  ]
}
```

Do not name the account after your log indices. The stock security configuration gives every user
full rights to an index with the user's own name (the `own_index` role), so a user called
`logs-reader` could create that index and write lines that show up under `logs-*`.

### What leaves your cluster

The server talks only to the Dashboards URLs you configure and writes nothing to disk. It sends the
login, the tenant choice for its own session, and reads: the saved index patterns, the fields of a
pattern, and searches through the console.

The model receives what the tools return: log lines (the raw document only with `include_source`),
field names, index pattern names, and for each source its name, URL, tenant and user name. Your MCP
client may store these results too: Claude Code saves a result of more than 50 000 characters to a
file.

### Passwords and TLS

Passwords are read from environment variables. A `password` key in the config file is rejected, and
so is a URL with credentials in it. Passwords are never logged or returned to the agent.

`allow_self_signed = true` in the config file turns off certificate verification for one source,
and `OSD_MCP_ALLOW_SELF_SIGNED=true` for all of them. An `http://` URL sends the password and the
logs unencrypted, and the server warns about it on stderr unless the host is local.

### Log content

Log lines are untrusted input. An application can log text that reads like an instruction to the
agent. The server says so in its instructions, but you should still review what your agent does
with log content. Logs can also contain personal data, and that data reaches the model.

## Limitations

- Only the Global and the Private tenant can be used.
- The call flow is the order in which apps first appear in the trace. Span and parent ids are
  returned but not used to build a tree.
- The per-app counts, the flow and the duration of a `get_trace` result cover the lines in that
  result. For a trace longer than one page, read the next pages too.
- A cursor lives in the server process. After a restart, run the search again.
- Paging remembers which lines it already returned for the last timestamp. If more than 10 000
  lines share one timestamp, paging stops there with a note and you have to narrow the query.
- Paging tells lines apart by document id. Two documents with the same id and the same timestamp in
  different indices count as one.
- A `date_nanos` time field is not supported.
- When the cluster answers only in part (failed shards, a search timeout), the result says so in a
  `note`. Read the note before trusting a count.
- A single line larger than the size budget is still returned whole.
- Error counts look at the level names `error`, `fatal` and `critical`.

## Alternatives

Other servers read OpenSearch through Dashboards too. This one adds `get_trace`: one trace grouped
by namespace and app, with field names you can configure. Pick another server when it fits better
(as of November 2026):

| Server                                                                                                                       | Reaches the data through                        | Pick it when                                                                                       |
| ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| [opensearch-mcp-server-py](https://github.com/opensearch-project/opensearch-mcp-server-py), by the OpenSearch project        | The OpenSearch REST API                         | The agent can reach the API. It covers much more than logs, supports AWS IAM, and can also write.  |
| [In-cluster MCP server](https://docs.opensearch.org/latest/ml-commons-plugin/mcp/in-cluster-mcp-server/), part of OpenSearch | The REST API of the cluster it runs in          | You run OpenSearch 3.3 or newer, can reach its API and want no extra process.                      |
| [opensearch-dashboard-mcp](https://pypi.org/project/opensearch-dashboard-mcp/)                                               | Dashboards, the search endpoint behind Discover | Your account cannot use the Dev Tools console, or you need a tenant other than Global and Private. |
| [mcp-opensearch](https://github.com/bunnyiesart/mcp-opensearch)                                                              | The Dashboards console, or the REST API         | You want aggregations, PPL or alerting data, read-only.                                            |