How basher83/zammad-mcp works
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: server.py MCP server adapter · client.py ZammadClient · __main__.py Module entrypoint · docker-publish.yml Image publishing workflow
Components 16
Runtime
- AI MCP client · Invokes tools, resources, and prompts.
- Module entrypoint
mcp_zammad/__main__.py - stdio / Streamable HTTP · HTTP serves the MCP endpoint at /mcp.
mcp_zammad/__main__.py - Environment configuration · Loads upstream credentials, TLS, and HTTP bind settings.
mcp_zammad/config.py - Logging setup
mcp_zammad/logging_config.py
MCP application
- MCP server adapter · Registers tools, resources, prompts, and response formatting.
mcp_zammad/server.py - Validation contracts · Strictly validates and sanitizes MCP inputs and API payloads.
mcp_zammad/models.py - Tool documentation templates
mcp_zammad/docstring_templates.py - ZammadClient · Builds authenticated requests, paginates, handles attachments, errors, and metadata caching.
mcp_zammad/client.py - System metadata cache · Caches group, state, and priority lists.
mcp_zammad/client.py
External services & delivery
- Zammad REST API · Configured /api/v1 instance; its permissions govern accessible data.
- Container image · Supports interactive stdio or HTTP deployment.
Dockerfile - GitHub Container Registry
- Image publishing workflow
.github/workflows/docker-publish.yml - TLS/auth reverse proxy · Required to protect public HTTP deployments.
- Python package & lock
pyproject.toml
Connections 19
- 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