openobserve-readonly-mcp
You can safely explore and query OpenObserve data through a read-only MCP server.
List streams, optionally filtered by type or stream-name substring.
Inspect a stream’s schema to learn valid field names and types before querying.
Run one bounded SQL
SELECT/WITHquery over logs, metrics, or traces with time-window controls and paging.Rely on safeguards: allowlisted read-only endpoints, SQL validation, capped rows/response size/time windows, and credential redaction.
You cannot write, delete, alter streams, change retention, or edit alerts through this server.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@openobserve-readonly-mcp Show me error logs from the app_logs stream in the last hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
openobserve-readonly-mcp
A read-only MCP server for OpenObserve. It lets an AI assistant list streams, inspect schemas, and run bounded SQL searches over your logs, metrics and traces — without the ability to write anything.
Zero runtime dependencies; it uses only the Node standard library.
Why read-only matters here
Giving a model log search is useful. Giving it an observability API token is a different proposition: the same credential that reads logs can often delete streams, change retention, or edit alerts.
This server narrows that surface in-process:
Three endpoints, allowlisted. Every outbound request is matched against an allowlist before it is sent. The only
POSTis/_search. Anything else — including a request the model constructs itself — is refused locally. Redirects are reported rather than followed, so a proxy cannot move a request off the allowlist.SELECT/WITH only. SQL is parsed for structure before it leaves the process: no stacked statements, no comments, no DDL/DML keywords outside string literals.
Bounded output. Row counts, string sizes, the time window, and the total response size are all capped, so one careless query cannot flood the context window or the upstream server.
Secrets redacted. Credentials that appear in log rows are replaced with
[REDACTED]before the model sees them. See Security notes.
This does not reduce the privileges of the credential you supply. The
allowlist constrains this process, not your token. For an actual guarantee,
create a read-only OpenObserve user and put that in O2_AUTH. The two
layers are complementary: the token bounds what is possible, this server
bounds what is attempted.
Related MCP server: o2-readonly
Tools
Tool | Purpose |
| List streams with type, document count, last event time. Supports substring and type filters, and |
| Field names and types for one stream. Use it before writing a query. |
| Run one |
All three are annotated readOnlyHint: true.
Arguments are checked against each tool's schema on the server side too, since
clients don't have to validate them. An unknown or misspelled argument (limt,
minute) gets an error that lists the expected names. It is not dropped
silently, where it would quietly run the query with defaults.
Install
Requires Node.js 18.17 or newer.
npx openobserve-readonly-mcpOr install globally:
npm install -g openobserve-readonly-mcpOr from source:
git clone https://github.com/KietDev-JS/openobserve-readonly-mcp.git
cd openobserve-readonly-mcp
npm testConfiguration
Configuration is environment-only. There is no default host: the server exits with status 2 and an explanatory message rather than guessing where to send your credentials.
Variable | Required | Default | Notes |
| yes | — | e.g. |
| yes | — |
|
| no |
| OpenObserve organization identifier. |
| no |
| Largest allowed search window, in minutes. |
| no |
| Upstream time limit for one tool call, retries included. |
| no |
| Retries after a 429, 502, 503, 504 or dropped connection, from |
| no |
| Set to |
| no | — | Log the resolved config (credential redacted) to stderr. |
openobserve-readonly-mcp --help prints this list; --version prints the
package version.
Generate the Basic value with:
printf 'you@example.com:YOUR_PASSWORD' | base64 | tr -d '\n'Client setup
Claude Desktop (claude_desktop_config.json), Claude Code (~/.claude.json):
{
"mcpServers": {
"openobserve": {
"command": "npx",
"args": ["-y", "openobserve-readonly-mcp"],
"env": {
"O2_BASE_URL": "https://openobserve.example.com",
"O2_AUTH": "Basic BASE64_HERE"
}
}
}
}opencode (opencode.json):
{
"mcp": {
"openobserve": {
"type": "local",
"command": ["npx", "-y", "openobserve-readonly-mcp"],
"enabled": true,
"environment": {
"O2_BASE_URL": "https://openobserve.example.com",
"O2_AUTH": "Basic BASE64_HERE"
}
}
}
}See docs/SETUP.md for a step-by-step walkthrough, including a connectivity check to run before touching any MCP config.
Querying
Stream names must be double-quoted, and results are ordered by _timestamp
descending in practice:
SELECT _timestamp, level, message
FROM "app_logs"
WHERE level = 'ERROR'
ORDER BY _timestamp DESCUseful details:
_timestampis microseconds since the epoch. Each returned row also carries an ISO-8601_timefield for readability.The window defaults to the last 15 minutes. Pass
minutes, or an explicitstart/endISO-8601 pair.sizedefaults to 50 and is capped at 200 rows.When a result reports
has_more: true, call again withoffsetset to itsnext_offset. A full page reportshas_moreeven if it was the last one, so the final page can be empty.Keywords inside string literals are fine: searching for the text
'delete'is not mistaken for aDELETEstatement.A column named after a reserved word needs double quotes:
SELECT "set".Escape a quote inside a literal by doubling it (
'it''s'). A backslash before the literal's own quote character is refused.
Limits
Limit | Value | Why |
Rows per search | 200 | Keeps a single call from flooding the context window. |
Streams per listing | 500 | Same. |
String cell length | 500 chars | Clipped at any nesting depth; long stack traces are the usual culprit. |
Response size | 60 KB | Rows are shed progressively; output is always valid JSON. |
Time window | 1440 min | Bounds upstream query cost. Raise with |
Paging offset | 10,000 | Deep paging is expensive upstream. Narrow the window instead. |
SQL length | 64 KB | Rejects runaway generated queries. |
Upstream body | 32 MB | Protects this process from an oversized response. |
When a result is reduced, the response includes a truncated object recording
how many rows were returned out of how many matched — the reduction is
reported rather than silent. next_offset then points at the first row that was
left out, so paging continues without gaps.
Security notes
The credential is never echoed in error messages or logs;
O2_DEBUGoutput redacts it.Log rows are redacted by default. This covers fields named like credentials (
password,api_key,accessToken,authorization,cookie),key=valuepairs in text, bearer and basic tokens, JWTs, private keys, passwords in connection strings, and common cloud and SaaS key formats.Redaction is best effort. It cannot recognize a password stored in an ordinary field such as
note, and it can occasionally hide a harmless value. Treat it as a safety net, and keep secrets out of logs at the source.Redirects are never followed. If your deployment redirects, set
O2_BASE_URLto the final address.Credentials embedded in
O2_BASE_URLare refused, and plainhttpto a non-loopback host prints a warning to stderr.Stream names are validated against
^[A-Za-z0-9_][A-Za-z0-9_.-]*$, and any request whose path changes under URL normalization is refused, so traversal attempts cannot escape the allowlisted routes.Prefer passing
O2_AUTHthrough your MCP client'senvblock over exporting it into your shell profile.
Development
npm test # 253 tests, no network access required
npm run test:coverage # ~99% line coverageThe suite injects a fake fetch, so it runs fully offline and deterministically.
License
MIT
Available Tools
3 toolso2_list_streamsARead-onlyIdempotent
List OpenObserve streams (read-only) with type, document count and last event time.
Inputs: type, limit, filter.
o2_searchARead-onlyIdempotent
Run one read-only SQL SELECT/WITH query against OpenObserve. Quote the stream name: SELECT * FROM "stream" ORDER BY _timestamp DESC. Defaults to the last 15 minutes and returns at most 200 rows. No semicolons or SQL comments outside string literals.
Inputs: sql (required), end, size, type, +2 more.
o2_stream_schemaARead-onlyIdempotent
Field names and types of one stream (read-only). Use before writing a query to learn valid column names.
Inputs: stream (required), type.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
The three tools serve clearly distinct purposes: listing streams, retrieving schema, and running queries. No overlap exists, so an agent can confidently select the right tool.
All tools share the 'o2_' prefix, and most follow a verb_noun pattern (list_streams, search). 'stream_schema' is a slight deviation as it's noun_phrase, but it remains predictable and readable.
With only 3 tools, the server is tightly scoped for read-only access to OpenObserve. Each tool is essential and earns its place, making the set easy to navigate.
For a read-only server, the surface is complete: discover streams, inspect schemas, and execute queries. These cover the core workflows without missing critical operations.
Maintenance
Related MCP Connectors
Ask your AI assistant about your logs, traces, security events, robot runs and video. Read-only.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceGives AI agents read-only access to any QuestDB instance, enabling schema discovery, time-series querying, and monitoring of partitions, WAL state, symbols, and ingestion health through MCP.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to list OpenObserve log streams, inspect their schemas, and run read-only SELECT queries with enforced safety caps.MIT
- AlicenseAqualityCmaintenanceEnables querying OpenObserve logs—listing streams, inspecting schemas, and running SearchSQL time-windowed searches—so you can answer what actually happened in production. Optionally correlates those logs against a database through a verified read-only connection via DbSchema and DbQuery tools.3MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to explore and query PostgreSQL or SQLite databases read-only, with SQL allow-listing, automatic row limits, statement timeouts, column masking, per-tool rate limits and JSONL audit logging.MIT