Skip to content

EventListener MCP Server User Guide

EventListener MCP Server

MCP (Model Context Protocol) server for the EventListener application, built with FastMCP in Python. Provides AI-accessible read-only tools for querying the change history Maat sends to EventListener.

The server exposes: - 3 MCP tools for documentation, summary, and event querying - 1 MCP prompt describing the event model and query patterns - Streamable HTTP transport for remote connectivity - Configuration via environment variables / .env


Project Structure

mcp_server_for_eventlistener/
  .env
  requirements.txt
  pyproject.toml
  README.md
  CLAUDE.md

  docker/
    Dockerfile
    docker-compose.yml

  src/
    eventlistener_mcp/
      __init__.py
      server.py            # MCP server, tools, HTTP client

      config/
        __init__.py
        config.py          # Environment variable loading
        logging.py         # Logger setup

      docs/                # Data model documentation served by the documentation tool
        README.md
        event_types.md
        query_patterns.md
        record_schema.md

      prompts/
        eventlistener-guide.md

Requirements

  • Python 3.10+
  • pip
  • A running EventListener instance (default http://localhost:8081)

Dependencies (requirements.txt): - fastmcp - MCP server framework - httpx - async HTTP client - python-dotenv - environment variable loading


Installation

Create and activate a virtual environment:

python -m venv .venv
.venv\Scripts\activate      # Windows
source .venv/bin/activate   # Linux/macOS

Install dependencies (editable mode, so the entrypoint eventlistener-mcp is registered):

pip install -e .

Or plain requirements only:

pip install -r requirements.txt

Configuration

Copy .env.example to .env and adjust:

# EventListener API
EVENTLISTENER_BASE_URL=http://localhost:8081
EVENTLISTENER_EVENTS_ENDPOINT=/events
EVENTLISTENER_TIMEOUT=60
EVENTLISTENER_TLS_VERIFY=true

# MCP server
EVENTLISTENER_MCP_HOST=127.0.0.1
EVENTLISTENER_MCP_PORT=8003
EVENTLISTENER_LOG_LEVEL=INFO
Variable Default Description
EVENTLISTENER_BASE_URL http://localhost:8081 EventListener REST API base URL
EVENTLISTENER_EVENTS_ENDPOINT /events Path to the events endpoint
EVENTLISTENER_TIMEOUT 60 HTTP timeout (seconds)
EVENTLISTENER_TLS_VERIFY true TLS certificate verification
EVENTLISTENER_MCP_HOST 127.0.0.1 MCP server bind host
EVENTLISTENER_MCP_PORT 8003 MCP server bind port
EVENTLISTENER_LOG_LEVEL INFO Logging level

All env vars are namespaced with EVENTLISTENER_ so this server can coexist with mcp_server_for_maat in the same docker-compose.yml without name collisions.


Running

Local

python -m eventlistener_mcp.server

Or using FastMCP CLI:

fastmcp run src/eventlistener_mcp/server.py

The server starts on http://{EVENTLISTENER_MCP_HOST}:{EVENTLISTENER_MCP_PORT}/mcp using Streamable HTTP transport.

Docker

Build:

docker build -t mcp-server-for-eventlistener -f docker/Dockerfile .

Run:

docker run -p 8003:8003 --env-file .env -e EVENTLISTENER_MCP_HOST=0.0.0.0 mcp-server-for-eventlistener

Docker Compose (standalone)

A standalone docker/docker-compose.yml is provided. It uses build: so the image is built locally from the source tree. Run from the project root:

docker compose -f docker/docker-compose.yml up --build

The server is then reachable on http://localhost:8003/mcp and reads EVENTLISTENER_* variables from the project's .env file.

Integration with the existing Maat docker-compose-7.yml

The MCP server can be added as a service to the existing Maat deployment's docker/docker-compose-7.yml. A ready-to-paste service block lives at docker/compose-snippet.yml (the EventListener MCP Server repository).

Steps:

  1. Open the Maat deployment's docker/docker-compose-7.yml.
  2. Copy the service block from docker/compose-snippet.yml (the EventListener MCP Server repository) and paste it under services:, e.g. right after the existing mcp-server: block.
  3. From the Maat docker/ directory run:
docker compose -f docker-compose-7.yml up --build mcp-server-for-eventlistener

(Or just docker compose -f docker-compose-7.yml up --build to bring up everything.)

How it integrates: - It reads the existing $EVENT_LISTENER_PROTOCOL, $EVENT_LISTENER_HOST, $EVENT_LISTENER_PORT variables from your Maat .env and builds the EventListener URL automatically. - Inside the docker network it talks to eventListener by hostname, so no extra network config is needed. - It depends on the eventListener service - it starts only once EventListener is up. - All env vars inside the container are prefixed EVENTLISTENER_ to avoid collisions with the Maat MCP service (MCP_HOST, MCP_PORT, ...). - Exposed port 8003 (no conflict with Maat MCP on 8002).

Pointing chat-ui at both MCP servers:

In the existing chatui service the MCP_SERVERS env var lists MCP endpoints. To add EventListener MCP, change:

MCP_SERVERS=[{"name":"maat","url":"https://host.docker.internal:8082/mcp"}]

to (one line):

MCP_SERVERS=[{"name":"maat","url":"https://host.docker.internal:8082/mcp"},{"name":"eventlistener","url":"http://host.docker.internal:8003/mcp"}]

(Note: EventListener MCP is exposed on plain HTTP - no nginx gateway in front of it.)


MCP Tools

Tool Description
eventlistener_get_documentation Get topical documentation about the event model and query patterns
eventlistener_summarize Lightweight summary: counts per eventType, optional time window, time range bounds
eventlistener_get_events Main query: filters (incl. nested JSON paths), time window, field projection, lookup by eventId

Query examples

# Overview of activity today
eventlistener_summarize(
    time_from="2026-05-13T00:00:00",
    time_to="2026-05-13T23:59:59",
)

# All resource deletions in a window
eventlistener_get_events(
    filters={"eventType": "ResourceDeleteEvent"},
    time_from="2026-05-10T00:00:00",
    time_to="2026-05-13T23:59:59",
)

# Single event by id (full payload returned automatically)
eventlistener_get_events(filters={"eventId": "1234abc-1234-abcd-1234-1234567abcde"})

# History for a single Maat object (forward timeline)
eventlistener_get_events(
    filters={"event.record.id": "e0ea9a0a-9cf7-46ca-8afd-8211ab6d9620"},
    sort="eventTime",   # oldest first; default is "-eventTime" (newest first)
    limit=500,
)

Filtering note: the EventListener REST API uses exact-match filters. Wildcards / regex are not supported.

Sorting note: eventlistener_get_events defaults to sort="-eventTime" (newest first). MongoDB's natural insertion order is NOT guaranteed, so the tool always sorts. Past usage hit ordering bugs without explicit sort - don't disable it outside debugging.


MCP Prompt

Prompt Description
eventlistener-guide Event model, query rules, and recommended patterns for combining with Maat

Relationship with Maat MCP

This server is the history companion to Maat MCP Server (which exposes the current state).

Typical combined flow: 1. Summarize events in a time window via this MCP. 2. List specific events to find an event.record.id of interest. 3. Query the current state of that object via Maat MCP (maat_get_resources / maat_get_services).