Skip to main content
Glama
essbase-mcp

essbase-mcp

by ontograph
README.md
# essbase-mcp

A read-only MCP web service for Oracle Essbase and Planning. It lets approved AI clients read
Essbase metadata and data through Oracle APS (XMLA and the Smart View provider protocol), and it
keeps a local ontology snapshot of each cube so clients can find members by business words.

Version 0.5.1. Python 3.13 or newer, Windows first (the production host runs it as an NSSM service).

## What it is, and what it is not

- It is a read-only service. It never writes to Essbase: the XMLA layer sends `Discover` requests
  and sends `Execute` only with MDX that the service generates itself (`essbase_get_data` and the
  ontology builder). The Smart View client has a hard allow-list of read requests and never sends
  WriteBack, business rules, SetSubVar or data.
- It is not a general MDX console: there is no tool that runs MDX written by the client.
- It is not an OAuth service: clients send a static bearer token.
- It is Essbase-only. The Oracle database backend was removed (`docs/ADR-003-essbase-only-service.md`).
- Secrets are never shown. Essbase passwords, tokens and password hashes do not appear in logs,
  audit rows, `/ready`, `list_sources` or the admin UI.

## Architecture

- One Python process, asyncio, two listeners:
  - The MCP listener (`mcp_port`): `/` (public install page, no token), `/mcp` (the tools),
    `/health`, `/ready`, and `/skills` (skill zips and install scripts). It is the only listener
    that clients reach. Any other path is a JSON 404.
  - The admin UI (`admin_port`), loopback only: audit log, ontology builds and the Build button,
    a read-only token list, one page per tool, and the Skills page.
- A data folder (`[paths] data_dir`) with three SQLite files: `state.db` (tokens, admins,
  sessions), `audit.db` (one row per call and per admin or CLI action) and `ontology.db` (the
  snapshots).
- Tools are declared once in a registry; the MCP adapter and the admin UI both read it.
- Every call passes one pipeline: token, scope, source and app allow-lists, rate limit,
  concurrency, row and byte caps, timeout, audit row. If the audit writer is down, calls are
  refused.
- Configuration is one TOML file, `connections.toml` (copy `connections.example.toml`).
  It holds the Essbase logins in plain text, so its file ACL is the secret boundary.

## Features

Tools (19, all read-only). Each tool needs a token scope: `meta` for 18 tools, `data` for one.

| Scope | Tool | What it does |
|---|---|---|
| meta | `list_sources` | Configured Essbase sources with environment and enabled flag. No connection details. |
| meta | `essbase_list_applications` | Applications of a source that the token may see. |
| meta | `essbase_list_cubes` | Databases (cubes) of an application. |
| meta | `essbase_list_dimensions` | Dimensions of a cube. |
| meta | `essbase_list_hierarchies` | Hierarchies of a dimension. |
| meta | `essbase_list_levels` | Levels of a dimension. |
| meta | `essbase_list_measures` | Measures of a cube. |
| meta | `essbase_list_members` | Members of a dimension. `root` and `depth` only if the source sets `members_restrictions`. |
| meta | `essbase_list_member_properties` | Member properties of a level. |
| meta | `essbase_list_functions` | MDX functions known to the Essbase server. |
| meta | `essbase_member_info` | Outline record of one member (formula, comment, UDAs, parent, storage, alias values) through Smart View. |
| meta | `essbase_subvars` | Substitution variables of an application and cube. Names that look like secrets are withheld. |
| meta | `ontology_status` | Snapshot status per application and cube: build, counts, warnings, `stale`. |
| meta | `ontology_card` | Cube card: dimensions, top levels, `*_NA` members, UDAs, alias tables, forms summary, hints. |
| meta | `ontology_search` | Find members (and Planning forms) by words in names, comments, aliases and UDAs. |
| meta | `ontology_describe` | One member: comment, aliases, UDAs, shared positions, children, level. |
| meta | `ontology_resolve` | Map a request in business words to members per dimension, with defaults. Metadata only. |
| meta | `ontology_forms` | Planning forms catalogue (folder, name, plan type, description). Needs `planning_smartview_url` at build time. |
| data | `essbase_get_data` | Read cell values without writing MDX: `pov`, `rows`, `columns`, `suppress_empty`, optional `max_cells`. Returns the generated MDX and the rows. |

Other features:

- **Ontology snapshot.** `ontology.db` holds dimensions, members, comments, UDAs, alias tables and
  the forms catalogue of each cube. It is built on request (CLI `build-ontology`, or the Build
  button in the admin UI), never at start. The card is also an MCP resource
  (`essbase://<source>/<app>/<cube>/card`) and the prompt `essbase_context`.
- **Auto-rebuild (off by default).** With `[ontology.auto] enabled = true` the service checks the
  cube's schema stamp in APS and rebuilds when the outline changed, when the build is too old, or
  nightly. Quiet hours pause rebuilds. A failed build keeps the previous one active.
- **Glossary.** `glossary.toml` next to `connections.toml` maps business words ("план", "ФОТ") to
  members. `ontology_resolve` and `ontology_search` check it first. See `glossary.example.toml`.
- **`essbase_get_data` limits.** Every name is checked against the snapshot, so a build is
  required. A dimension the request does not name gets the configured `default_pov` member, then
  its `*_NA` member, then the root; the reply lists `pov_used`. A request larger than
  `[limits] max_cells` is refused before any query is sent. The data scope has its own rate limit
  (`data_rate_limit_per_minute`) and concurrency limit.
- **Skills download.** The service serves six Claude skills (`essbase-ask`, `essbase-cube-tour`,
  `essbase-mcp`, `essbase-mdx-check`, `essbase-member-lookup`, `planning-form-explain`) at `/skills`
  as zips with install scripts. Any valid token works, no scope needed. A skill folder with a
  `.not-served` file is not served (the operator skill `essbase-ontology-ops` has it).
- **Install page `/`.** Open the server address in a browser: a public page (no token) with
  install instructions and copy buttons for people and for AI agents. Two options: **Skills only**
  (preferred; no MCP client configuration; the skills call the service through the helper
  `emcp.py` or `emcp.ps1` of the skill `essbase-mcp`) and **MCP + Skills** (adds a `.mcp.json`).
  The page shows the server address, the version and the skill names; nothing secret.
- **Audit.** One row per tool call and per admin or CLI action. Tool arguments are masked by
  default. CLI actions record the operator (the OS account) and are marked as alerts.
- **Token governance.** One token per person (`emcp_...`), only the SHA-256 is stored, 30 days by
  default and 90 at most. Tokens are issued and revoked only with `essbase-mcp-cli`, on the server.
  There is no approval step; the admin UI lists tokens but cannot create or revoke them.

## Getting started

Full steps for the server and for a client: **[INSTALL.md](INSTALL.md)**. In short:

```powershell
py -3.13 -m venv .venv ; .venv\Scripts\python.exe -m pip install -e .
copy connections.example.toml connections.toml        # edit: listeners, [xmla.<name>], [paths]
.venv\Scripts\essbase-mcp-cli.exe --config connections.toml init
.venv\Scripts\essbase-mcp-cli.exe --config connections.toml create-admin --username <admin>
.venv\Scripts\python.exe -m essbase_mcp --config connections.toml
```

## Security model

- Read-only everywhere (see the first section). The service holds no database account.
- Bearer tokens over TLS (a reverse proxy, or `mcp_ssl_certfile` and `mcp_ssl_keyfile`). Plain
  `http` is for development only: a non-loopback `mcp_host` without TLS is refused at start unless
  `allow_plain_http = true`, and `allow_plain_http` on an XMLA source is accepted only for env
  `dev`, `test`, `qa` or `sandbox`.
- Requests that carry an `Origin` header are refused (`403`); browser-based clients are not
  supported.
- Tokens expire, can be revoked at once, and are shown once. A privileged scope (`data`, `logic`,
  `security`) or a non-default profile is issued directly by the operator and audited; the CLI
  prints a warning (`docs/ADR-003-essbase-only-service.md`, section 7a).
- The admin UI is loopback only, with sign-in, roles, CSRF tokens and an HttpOnly `__Host-`
  session cookie. The MCP listener has no admin routes.
- `connections.toml` holds plain-text passwords. `scripts\harden-acl.ps1` removes access for
  Users, Authenticated Users and Everyone. Logs and audit rows are masked and the settings `repr`
  hides passwords.
- Limits on every call: row and byte caps, query timeouts, per-source concurrency, per-token rate.
- Grant the `data` scope only after the Essbase administrator has set the query governors
  `QRYGOVEXECTIME` and `QRYGOVEXECBLK` for the XMLA account. The service cannot stop a query that
  Essbase still runs.

## Documentation

| Document | Purpose |
|---|---|
| `INSTALL.md` | Step-by-step install: quick server setup, production summary, client setup, troubleshooting. |
| `DEPLOY.md` | Production deployment on Windows: wheels, NSSM service, ACL hardening, TLS, backup and restore, upgrade and rollback. |
| `docs/OPERATIONS.md` | Daily operation: tokens, credential rotation, ontology, skills, logs, troubleshooting. |
| `docs/CLIENTS.md` | MCP client configuration, skills-only option and helper, connection test, skills install. |
| `docs/ERROR-CODES.md` | Error codes, HTTP status mapping, `trace_id`. |
| `docs/LIVE-CHECKLIST.md` | Live golden tests, admin UI check, client test, Essbase governor checks. |
| `docs/LIVE-FINDINGS.md` | Findings from live runs against APS. |
| `docs/ADR-003-essbase-only-service.md` | Current design (one page). |
| `docs/ADR-002-essbase-ontology-for-mcp-context.md` | Ontology design, live findings, data tool options. |
| `docs/PLAN-002-retrospective.md` | Retrospective and cleanup plan. |
| `docs/VERSIONING.md`, `CHANGELOG.md` | Version rules and the list of changes. |
| `docs/reference/` | Third-party source samples (XMLA notebook, Smart View plugin definition). Kept locally, not in the repository (gitignored). |
| `docs/archive/` | Historical, superseded documents (ADR-001, IMPLEMENTATION-PLAN-001, SPIKE-001, QUERY-CONTRACTS). Do not use them as current. |

## Development

```powershell
py -3.13 -m venv .venv
.venv\Scripts\python.exe -m pip install -e . pytest pytest-asyncio ruff   # test and lint tools are not in requirements.lock
.venv\Scripts\python.exe -m pytest -q                      # or: scripts\test.ps1 -q
.venv\Scripts\python.exe -m ruff check src tests           # or: scripts\lint.ps1
```

- Source: `src\essbase_mcp`. Tests: `tests\`. A full run takes about 4 minutes.
- Live tests (`-m live`) run when `connections.toml` exists and are skipped when it is missing.
  They are read-only. Do not run two full suites at the same time in the same folder.
- A hang watchdog in `tests\conftest.py` stops a run that lasts longer than
  `ESSBASE_MCP_TEST_TIMEOUT` seconds (default 900, 15 minutes; `0` turns it off for a debugger).
  It prints every thread's stack and exits with code 1.

## Status

Version 0.5.1: 0.5.0 added the public install page `/`, the `essbase-mcp` connector skill with
its helper, and reviewed skills; 0.5.1 adds reverse-proxy prefixes (`mcp_public_url`) and
install-script fixes (see `CHANGELOG.md`). Unit-tested with fake data, plus a
few read-only live tests against a real Essbase and APS. The owner's go-live checks are in
`docs/LIVE-CHECKLIST.md`.