Skip to Content

MCP Server

The Ledger MCP server is an optional, read-only Model Context Protocol server. It lets MCP clients, such as AI assistants like Claude Code, Copilot, or Cursor, query Ledger data through a small set of tools. You can then ask questions such as "which hosts are affected by this CVE?" in plain language.

The server is read-only by design: every tool maps to a GET request to the Ledger REST API, so an assistant can never change anything in Ledger through it.

How it works

The MCP server does not connect to the Ledger database. It is a thin proxy in front of the REST API served by the Ledger web service:

MCP client ──MCP (streamable HTTP)──▶ ledger-mcp ──REST GET──▶ Ledger web service ──▶ database
  • It runs as its own container, from the ledger-mcp image published alongside the other Ledger images.
  • It serves the MCP streamable HTTP transport in stateless mode, so each request is self-contained.
  • Each tool calls the REST API and returns the JSON result. A REST error is returned to the assistant as a tool error with the API's status and reason, for example 403 Forbidden: ACCESS DENIED.

Because it reuses the REST API, everything the API enforces applies unchanged: each user's permissions, the API row limit, masking of secrets in the settings output, and the local password policy.

Authentication

The MCP server holds no credentials of its own. Each MCP client signs in with its own Ledger identity, and the server passes those credentials through to the REST API:

  • The client sends an Authorization: Basic header (a base64-encoded username:password) on its MCP requests: the same credentials it would use with the REST API directly.
  • The server forwards the header unchanged on every REST request, and never stores or substitutes credentials.
  • The REST API checks the user's permissions, so a tool only returns what that user is allowed to see. Two users connected to the same MCP server see different, correctly scoped results.
  • A request without credentials is refused with an error asking the caller to authenticate, and no REST call is made. There is no anonymous access. Invalid credentials are rejected by the REST API.
Use a local account

Only local accounts can authenticate this way, because the REST API verifies the password against the account's stored password. LDAP, SAML, and OpenID Connect accounts have no local password. Give each assistant integration a dedicated local account with only the permissions it needs. The local password policy applies: if the account's password expires or must be changed, the tools return 403 PASSWORD CHANGE REQUIRED until it is changed in the web interface.

Available tools

ToolArgumentsPermission
list_resourcesNoneAny
list_hostspage, limitView Hosts
get_hostidView Hosts
get_elm_host_packagesuuidView Packages
get_elm_host_factsuuidView Facts
list_factspage, limit, host, fact, typeView Facts
list_changespage, limit, host, playbook, task_action, searchView Changes
get_changeidView Changes
list_packagespage, limit, host, name, arch, errataView Packages
list_package_logpage, limit, host, name, arch, actionView Package Logs
list_servicespage, limit, host, name, state, statusView Services
list_service_logpage, limit, host, name, state, statusView Service Logs
get_cvecveView Errata (plus View Hosts and View Packages for the affected hosts list)
get_errataname, vendorView Errata
list_reportspage, limitView Reports
get_reportidView Reports
list_serverspage, limitAdministrator
get_serveridAdministrator
list_userspage, limitAdministrator
get_useridAdministrator
get_settingsNoneAdministrator

Notes:

  • list_resources returns the resource types the calling user can read, so an assistant can find out up front which tools will work for that user.
  • The list_* tools are paginated and honor Row Limit for API Queries under Settings > Visual. The get_* tools return the whole resource in one call.
  • list_packages takes errata: true to list only packages with outstanding advisories. list_package_log accepts an action of added or removed.
  • get_cve returns the CVE's details and fixing advisories and, for a user who also has the View Hosts and View Packages permissions, every affected host with the installed packages involved.
  • get_errata takes an optional vendor, because an advisory name is unique only per vendor.
  • get_elm_host_packages and get_elm_host_facts look a host up by the UUID that the CIQ Enterprise Linux Manager agent assigns, and return its complete package or fact list.
  • list_reports and get_report only return reports shared with the calling user.
  • The host filter of the list tools takes a numeric host ID. Use list_hosts to find it.

Running the MCP server

The Ascender Pro installer does not deploy the MCP server. To use it, run the ledger-mcp image (from the same registry as your other Ledger images) where it can reach the Ledger web service, and configure it with these environment variables:

VariableDefaultPurpose
MCP_PORT8085Port the MCP endpoint listens on. The endpoint is served at /.
LEDGER_API_URLhttp://ledger-webBase URL of the Ledger web service. In the same Kubernetes cluster as an Ascender Pro installation, this is the web-svc service in the Ledger namespace, for example http://web-svc.ledger.

On startup the server logs a line such as ledger MCP server (read-only) ... listening on :8085, proxying http://ledger-web.

Starting the MCP server and testing it with curl

To check it end to end without an MCP client, send a tool call with curl. This exercises the MCP endpoint, the credential pass-through, and the REST API in one request:

curl -s http://127.0.0.1:8085/ \ -u "$USER_NAME:$PASSWORD" \ -H 'Content-Type: application/json' \ -H 'Accept: application/json, text/event-stream' \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_hosts","arguments":{"limit":2}}}'

The response is a server-sent event whose data: line carries the JSON-RPC result. The tool's output is under result.structuredContent.

Securing the MCP server

  1. Put TLS in front of the endpoint. The server speaks plain HTTP, and credentials travel in the Authorization header, so it must sit behind TLS (for example, a reverse proxy or an ingress with a certificate) whenever it can be reached from anywhere other than the local machine. Never expose it over plain HTTP.
  2. Do not publish the port publicly. Keep the server on an internal network, or bind its published port to loopback, until a TLS proxy and firewall are in place.
  3. Use least-privilege accounts. There is no shared or elevated account to leak: each caller has exactly its own read permissions, and the tools are read-only. Give each assistant integration its own local account with only the permissions it needs.

Connecting a client

Point the client at the MCP server's URL (for example http://127.0.0.1:8085/, or the TLS URL you publish) using the streamable HTTP transport, and attach a Basic Authorization header. The client must be able to send a custom header.

For example, with Claude Code:

claude mcp add --transport http ledger http://127.0.0.1:8085/ \ --header "Authorization: Basic $(printf '%s:%s' "$USER_NAME" "$PASSWORD" | base64 -w0)"

The equivalent entry for clients that read an mcpServers map in JSON:

{ "mcpServers": { "ledger": { "type": "http", "url": "http://127.0.0.1:8085/", "headers": { "Authorization": "Basic <base64(username:password)>" } } } }

In Claude Code, claude mcp list shows the server as Connected (it performs a real handshake, so a wrong URL or a closed port shows up here), and claude mcp get ledger prints the stored configuration. Add --scope user to claude mcp add to make the server available in every project, and use claude mcp remove ledger to remove it.

Registering the Ledger MCP server with Claude Code and checking its status

Using Ledger from an assistant

Once connected, the assistant sees the tools listed above and chooses them itself. Claude Code prefixes the tool names with the server name, for example mcp__ledger__list_hosts. Some questions that work well:

  • "Which hosts have critical security advisories outstanding?" uses list_hosts, where each host carries its advisory counts by severity.
  • "Which of our hosts are affected by CVE-2026-1234, and which packages need updating?" uses get_cve.
  • "What changed on web01 in the last playbook run?" uses list_hosts to find the host ID, then list_changes and get_change.
  • "Show me the kernel packages across the fleet and whether an advisory covers them." uses list_packages with name and errata: true.
  • "Is the httpd service running everywhere it should be?" uses list_services.
  • "What does the web-inventory report contain?" uses list_reports, then get_report.

Claude Code answering a fleet question with the Ledger MCP tools

What to expect:

  • Answers are limited to what the account in the header may see. A user without View Hosts gets 403 Forbidden: ACCESS DENIED from list_hosts, and the assistant usually says so.
  • Nothing is changed. The assistant cannot edit users, servers, or settings through the MCP server, whatever it is asked.
  • A missing Authorization header is an error, not an anonymous request.