# basher83/zammad-mcp architecture

> Architecture diagram of the GitHub repository basher83/zammad-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/basher83/zammad-mcp
- Repository: https://github.com/basher83/zammad-mcp

## Overview

#### Purpose and Entrypoints
This is a Python MCP (Model Context Protocol) server exposing Zammad helpdesk operations to AI clients: ticket, article, attachment, user, organization, group, tag, and system-data access. Main execution is `python -m mcp_zammad` via `mcp_zammad/__main__.py`; the package/server boundary is `mcp_zammad/server.py`. It runs over stdio by default or Streamable HTTP at `/mcp`.

#### Startup, Configuration, and Transport
Startup loads environment-backed configuration, initializes logging and the Zammad client, then selects stdio or HTTP transport. Configuration includes upstream URL/credentials, TLS-verification opt-out, and HTTP bind settings. Core paths: `mcp_zammad/__main__.py`, `mcp_zammad/config.py`, `mcp_zammad/logging_config.py`. HTTP mode has no built-in inbound client authentication; public deployment requires an authenticated TLS reverse proxy.

#### MCP Server Surface
The MCP adapter registers tools, URI resources, and reusable prompts, converting MCP requests into validated application calls and returning Markdown (default) or JSON. Its surface includes ticket lifecycle operations, attachment operations, user/organization lookup, cached system metadata, ticket stats, and ticket/user/organization/queue resources. Core path: `mcp_zammad/server.py`.

#### Validation and Domain Contracts
Pydantic models form the trust boundary for tool inputs and structured API payloads: strict request validation, constrained fields, attachment representations, output-format selection, and sanitization of selected HTML-bearing data. This layer prevents unknown or malformed MCP arguments from reaching the upstream API. Core paths: `mcp_zammad/models.py`, `mcp_zammad/docstring_templates.py`.

#### Zammad API Integration
`ZammadClient` is the outbound integration boundary. Server handlers invoke it for authenticated HTTP calls to a configured Zammad `/api/v1` instance, using API token, OAuth2 token, or username/password authentication. It owns URL validation, request construction, pagination, error handling, attachment base64 download/upload handling, and caching for relatively stable group/state/priority lists. Core paths: `mcp_zammad/client.py`, `mcp_zammad/config.py`.

#### Primary Flow and Boundaries
An AI MCP client sends a tool/resource/prompt request through stdio or HTTP → `server.py` resolves and validates arguments through `models.py` → client methods in `client.py` call Zammad REST endpoints → data is normalized/formatted as Markdown or JSON → MCP response returns to the caller. Credentials and network access terminate at the client-to-Zammad boundary; Zammad permissions determine what each authenticated server instance can read or mutate.

#### Runtime and Delivery
The runtime is Python, packaged through `pyproject.toml` and lockfile `uv.lock`, with direct `uvx`/module execution or a container image built from `Dockerfile`. Docker is suitable for both interactive stdio and HTTP deployment; image publishing targets GitHub Container Registry through `.github/workflows/docker-publish.yml`. The only required external business service is a reachable Zammad instance; optional deployment infrastructure includes Docker and a TLS/authenticating reverse proxy.

Main entry points: [`mcp_zammad/server.py`](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/server.py) (MCP server adapter), [`mcp_zammad/client.py`](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/client.py) (ZammadClient), [`mcp_zammad/__main__.py`](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/__main__.py) (Module entrypoint), [`.github/workflows/docker-publish.yml`](https://github.com/basher83/zammad-mcp/blob/main/.github/workflows/docker-publish.yml) (Image publishing workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_mcp_client(("AI MCP client<br/>caller"))
  node_entrypoint["Module entrypoint<br/>Python entrypoint<br/>[__main__.py]"]
  node_transport["stdio / Streamable HTTP<br/>transport<br/>[__main__.py]"]
  node_configuration["Environment configuration<br/>settings<br/>[config.py]"]
  node_logging["Logging setup<br/>observability<br/>[logging_config.py]"]
end

subgraph group_application["MCP application"]
  node_server{{"MCP server adapter<br/>MCP adapter<br/>[server.py]"}}
  node_models["Validation contracts<br/>Pydantic models<br/>[models.py]"]
  node_templates["Tool documentation templates<br/>docstrings"]
  node_zammad_client{{"ZammadClient<br/>API client<br/>[client.py]"}}
  node_metadata_cache["System metadata cache<br/>in-process cache<br/>[client.py]"]
end

subgraph group_external["External services &amp; delivery"]
  node_zammad[("Zammad REST API<br/>helpdesk service")]
  node_container["Container image<br/>Docker delivery"]
  node_registry["GitHub Container Registry<br/>image registry"]
  node_publish_workflow["Image publishing workflow<br/>GitHub Actions<br/>[docker-publish.yml]"]
  node_reverse_proxy["TLS/auth reverse proxy<br/>deployment boundary"]
  node_packaging["Python package &amp; lock<br/>packaging<br/>[pyproject.toml]"]
end

node_mcp_client -->|"MCP request"| node_transport
node_transport -->|"selected at startup"| node_entrypoint
node_entrypoint -->|"loads"| node_configuration
node_entrypoint -->|"initializes"| node_logging
node_entrypoint -->|"starts"| node_server
node_server -->|"validates arguments"| node_models
node_server -.->|"documents surface"| node_templates
node_server -->|"application calls"| node_zammad_client
node_zammad_client -->|"uses URL and credentials"| node_configuration
node_zammad_client -->|"reads and refreshes"| node_metadata_cache
node_zammad_client -->|"authenticated HTTP /api/v1"| node_zammad
node_zammad -->|"tickets, users, attachments, metadata"| node_zammad_client
node_zammad_client -->|"normalized data"| node_server
node_server -->|"Markdown or JSON response"| node_mcp_client
node_reverse_proxy -.->|"protects public HTTP"| node_transport
node_packaging -->|"installs module"| node_entrypoint
node_container -->|"runs"| node_entrypoint
node_publish_workflow -->|"builds"| node_container
node_publish_workflow -->|"publishes"| node_registry

click node_entrypoint "https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/__main__.py"
click node_transport "https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/__main__.py"
click node_configuration "https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/config.py"
click node_logging "https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/logging_config.py"
click node_server "https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/server.py"
click node_models "https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/models.py"
click node_templates "https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/docstring_templates.py"
click node_zammad_client "https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/client.py"
click node_metadata_cache "https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/client.py"
click node_container "https://github.com/basher83/zammad-mcp/blob/main/Dockerfile"
click node_publish_workflow "https://github.com/basher83/zammad-mcp/blob/main/.github/workflows/docker-publish.yml"
click node_packaging "https://github.com/basher83/zammad-mcp/blob/main/pyproject.toml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mcp_client,node_entrypoint,node_transport,node_configuration,node_logging toneBlue
class node_server,node_models,node_templates,node_zammad_client,node_metadata_cache toneAmber
class node_zammad,node_container,node_registry,node_publish_workflow,node_reverse_proxy,node_packaging toneMint
```

## Components

### Runtime

- **AI MCP client**: caller · Invokes tools, resources, and prompts.
- [Module entrypoint](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/__main__.py): Python entrypoint · `mcp_zammad/__main__.py`
- [stdio / Streamable HTTP](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/__main__.py): transport · HTTP serves the MCP endpoint at /mcp. · `mcp_zammad/__main__.py`
- [Environment configuration](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/config.py): settings · Loads upstream credentials, TLS, and HTTP bind settings. · `mcp_zammad/config.py`
- [Logging setup](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/logging_config.py): observability · `mcp_zammad/logging_config.py`

### MCP application

- [MCP server adapter](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/server.py): MCP adapter · Registers tools, resources, prompts, and response formatting. · `mcp_zammad/server.py`
- [Validation contracts](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/models.py): Pydantic models · Strictly validates and sanitizes MCP inputs and API payloads. · `mcp_zammad/models.py`
- [Tool documentation templates](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/docstring_templates.py): docstrings · `mcp_zammad/docstring_templates.py`
- [ZammadClient](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/client.py): API client · Builds authenticated requests, paginates, handles attachments, errors, and metadata caching. · `mcp_zammad/client.py`
- [System metadata cache](https://github.com/basher83/zammad-mcp/blob/main/mcp_zammad/client.py): in-process cache · Caches group, state, and priority lists. · `mcp_zammad/client.py`

### External services & delivery

- **Zammad REST API**: helpdesk service · Configured /api/v1 instance; its permissions govern accessible data.
- [Container image](https://github.com/basher83/zammad-mcp/blob/main/Dockerfile): Docker delivery · Supports interactive stdio or HTTP deployment. · `Dockerfile`
- **GitHub Container Registry**: image registry
- [Image publishing workflow](https://github.com/basher83/zammad-mcp/blob/main/.github/workflows/docker-publish.yml): GitHub Actions · `.github/workflows/docker-publish.yml`
- **TLS/auth reverse proxy**: deployment boundary · Required to protect public HTTP deployments.
- [Python package & lock](https://github.com/basher83/zammad-mcp/blob/main/pyproject.toml): packaging · `pyproject.toml`

## Connections

- AI MCP client → stdio / Streamable HTTP: MCP request
- stdio / Streamable HTTP → Module entrypoint: selected at startup
- Module entrypoint → Environment configuration: loads
- Module entrypoint → Logging setup: initializes
- Module entrypoint → MCP server adapter: starts
- MCP server adapter → Validation contracts: validates arguments
- MCP server adapter → Tool documentation templates: documents surface
- MCP server adapter → ZammadClient: application calls
- ZammadClient → Environment configuration: uses URL and credentials
- ZammadClient → System metadata cache: reads and refreshes
- ZammadClient → Zammad REST API: authenticated HTTP /api/v1
- Zammad REST API → ZammadClient: tickets, users, attachments, metadata
- ZammadClient → MCP server adapter: normalized data
- MCP server adapter → AI MCP client: Markdown or JSON response
- TLS/auth reverse proxy → stdio / Streamable HTTP: protects public HTTP
- Python package & lock → Module entrypoint: installs module
- Container image → Module entrypoint: runs
- Image publishing workflow → Container image: builds
- Image publishing workflow → GitHub Container Registry: publishes
