A Go application that fetches DMARC reports from IMAP mailboxes, parses them, and displays them in a Vue.js dashboard. Also supports MCP (Model Context Protocol) for AI assistant integration.
- Backend: Go 1.25.4 (see go.mod for exact version)
- Frontend: Vue.js 3 with Vite
- Database: SQLite (supports both CGO and pure-Go variants)
- Package Manager: Bun (for frontend)
- Task Runner: Just (Justfile)
- CLI Framework: urfave/cli/v3
- JSON Library: goccy/go-json (high-performance)
- Logging: rs/zerolog (structured logging)
- Metrics: Prometheus client_golang
- MCP SDK: modelcontextprotocol/go-sdk
parse-dmarc/
βββ main.go # Main application entry point
βββ internal/
β βββ api/ # REST API server and embedded frontend
β β βββ server.go # HTTP server, routes, metrics middleware
β βββ config/ # Configuration management (JSON + env vars)
β β βββ config.go # Config loading and validation
β βββ imap/ # IMAP client for fetching emails
β β βββ client.go # Email fetching logic
β βββ logger/ # Structured logging setup
β β βββ logger.go # Zerolog configuration
β βββ mcp/ # MCP (Model Context Protocol) server
β β βββ server.go # MCP server (stdio and HTTP/SSE)
β β βββ tools.go # MCP tool implementations
β β βββ oauth/ # OAuth2 authentication for MCP
β β βββ config.go # OAuth configuration
β β βββ middleware.go # Bearer auth middleware
β β βββ metadata.go # RFC 9728 metadata endpoint
β β βββ verifier.go # Token verification
β βββ metrics/ # Prometheus metrics
β β βββ metrics.go # Metrics definitions and HTTP middleware
β βββ parser/ # DMARC XML parser
β β βββ dmarc.go # Parsing logic
β β βββ dmarc_test.go # Parser tests
β βββ storage/ # SQLite database layer
β βββ common.go # Shared SQL queries and types
β βββ sqlite_cgo.go # CGO SQLite (mattn/go-sqlite3)
β βββ sqlite_no_cgo.go # Pure Go SQLite (modernc.org/sqlite)
βββ src/ # Vue.js 3 frontend source
β βββ App.vue # Main application component
β βββ main.js # Vue entry point
β βββ assets/
β β βββ base.css # Base styles
β βββ stores/ # Pinia-like state management
β β βββ index.js # Store exports
β β βββ theme.js # Theme (dark/light/system) store
β β βββ settings.js # API endpoint settings store
β βββ components/
β βββ dashboard/
β β βββ DashboardHero.vue # Dashboard header/hero section
β β βββ RecentReports.vue # Recent reports list
β β βββ ReportDrawer.vue # Report detail drawer
β βββ settings/
β β βββ SettingsModal.vue # Settings modal (theme, API endpoint)
β βββ tools/
β βββ DnsGenerator.vue # DMARC DNS record generator
βββ public/ # Static frontend assets (favicons, logos)
βββ assets/ # Project assets (screenshots, images)
βββ deploy/ # Deployment configurations
β βββ coolify.yaml # Coolify deployment
β βββ captain-definition # CapRover deployment
β βββ digitalocean/ # DigitalOcean Droplet/Marketplace
β β βββ packer.pkr.hcl # Packer image build
β β βββ marketplace.yaml # DO Marketplace metadata
β β βββ scripts/ # Setup scripts
β βββ dokploy/ # Dokploy deployment
β βββ template.toml
β βββ docker-compose.yml
βββ grafana/ # Grafana monitoring
β βββ dashboard.json # Pre-built dashboard
β βββ provisioning.yaml # Auto-provisioning config
βββ scripts/ # Utility scripts
βββ Justfile # Build commands
βββ Dockerfile # Multi-stage Docker build
βββ compose.yml # Docker Compose for local dev
βββ parse-dmarc.service # systemd service file
βββ zeabur.yml # Zeabur deployment template
βββ render.yaml # Render deployment config
βββ Northflank.json # Northflank deployment config
βββ ROADMAP.md # Product roadmap
βββ CONTRIBUTING.md # Contribution guidelines
βββ .goreleaser.yml # Release automation
βββ .github/workflows/ci.yml # CI/CD pipeline
# Install all dependencies (Go + Node)
just install-deps
# Build full application (frontend + backend)
just build
# Build with CGO (for native SQLite)
just build-cgo
# Run development server with hot reload (uses air)
just dev
# Run frontend dev server only
just frontend-dev
# Run tests
just test
# Generate config file
just config
# Clean build artifacts
just clean
# Install binary to /usr/local/bin
just install
# Update Zeabur template
just update-zeabur-templateThe build process:
- Frontend is built with
bun run build - Frontend dist is copied to
internal/api/dist/ - Go binary embeds the frontend and serves it
- Output binary:
bin/parse-dmarc
Two build modes:
just build- Pure Go (CGO_ENABLED=0), uses modernc.org/sqlitejust build-cgo- CGO enabled, uses mattn/go-sqlite3
# Run all Go tests
go test -v ./...
# Run tests for specific package
go test -v ./internal/parser/...# Continuous fetching and dashboard
./parse-dmarc --config config.json
# Fetch once and exit
./parse-dmarc --config config.json --fetch-once
# Dashboard only (no IMAP fetching)
./parse-dmarc --config config.json --serve-only# MCP over stdio (for Claude Desktop, etc.)
./parse-dmarc --mcp
# MCP over HTTP/SSE
./parse-dmarc --mcp-http :8081
# MCP with OAuth2 authentication
./parse-dmarc --mcp-http :8081 --mcp-oauth \
--mcp-oauth-issuer https://auth.example.com \
--mcp-oauth-audience https://mcp.example.com| Flag | Env Var | Description |
|---|---|---|
--config, -c |
PARSE_DMARC_CONFIG |
Config file path (default: config.json) |
--gen-config |
PARSE_DMARC_GEN_CONFIG |
Generate sample config |
--fetch-once |
PARSE_DMARC_FETCH_ONCE |
Fetch reports once and exit |
--serve-only |
PARSE_DMARC_SERVE_ONLY |
Dashboard only, no fetching |
--fetch-interval |
PARSE_DMARC_FETCH_INTERVAL |
Fetch interval in seconds (default: 300) |
--metrics |
PARSE_DMARC_METRICS |
Enable Prometheus metrics (default: true) |
--mcp |
PARSE_DMARC_MCP |
Run as MCP server over stdio |
--mcp-http |
PARSE_DMARC_MCP_HTTP |
Run MCP over HTTP at address |
--mcp-oauth |
PARSE_DMARC_MCP_OAUTH |
Enable OAuth2 for MCP HTTP |
--mcp-oauth-issuer |
PARSE_DMARC_MCP_OAUTH_ISSUER |
OAuth2/OIDC issuer URL |
--mcp-oauth-audience |
PARSE_DMARC_MCP_OAUTH_AUDIENCE |
Expected token audience |
--mcp-oauth-client-id |
PARSE_DMARC_MCP_OAUTH_CLIENT_ID |
OAuth2 client ID for token introspection |
--mcp-oauth-client-secret |
PARSE_DMARC_MCP_OAUTH_CLIENT_SECRET |
OAuth2 client secret for token introspection |
--mcp-oauth-scopes |
PARSE_DMARC_MCP_OAUTH_SCOPES |
Required scopes (comma-separated, default: mcp:tools) |
--mcp-oauth-introspection-endpoint |
PARSE_DMARC_MCP_OAUTH_INTROSPECTION_ENDPOINT |
Token introspection endpoint URL |
--mcp-oauth-resource-name |
PARSE_DMARC_MCP_OAUTH_RESOURCE_NAME |
Human-readable name for MCP server metadata |
--mcp-oauth-insecure |
PARSE_DMARC_MCP_OAUTH_INSECURE |
Skip TLS certificate verification (dev only) |
- Go: Standard gofmt formatting, golangci-lint for linting
- Frontend: Vue 3 Composition API, Prettier for formatting
- Pre-commit hooks configured in
.pre-commit-config.yaml
main.go- CLI entry point with flag parsing, signal handlinginternal/api/server.go- HTTP server, API routes, metrics middlewareinternal/config/config.go- Configuration loading (JSON + env vars)internal/parser/dmarc.go- DMARC XML parsing (gzip, zip, raw XML)internal/imap/client.go- IMAP email fetchinginternal/storage/common.go- SQL queries, data typesinternal/mcp/server.go- MCP server implementationinternal/mcp/tools.go- MCP tool handlersinternal/metrics/metrics.go- Prometheus metrics definitions
src/App.vue- Main Vue.js dashboard componentsrc/stores/theme.js- Theme state management (light/dark/system)src/stores/settings.js- API endpoint settings managementsrc/components/dashboard/DashboardHero.vue- Statistics overviewsrc/components/dashboard/RecentReports.vue- Reports listsrc/components/dashboard/ReportDrawer.vue- Report detail viewsrc/components/settings/SettingsModal.vue- Settings dialog (theme, API endpoint)src/components/tools/DnsGenerator.vue- DMARC DNS record generator
GET /api/statistics- Dashboard statisticsGET /api/reports- List reports (paginated:?limit=50&offset=0)GET /api/reports/:id- Single report detailsGET /api/top-sources- Top sending source IPs
GET /metrics- Prometheus metrics endpoint
When running in MCP mode, the following tools are available:
| Tool | Description |
|---|---|
get_statistics |
Overall DMARC compliance statistics |
get_reports |
List reports with pagination |
get_report_by_id |
Get detailed report by ID |
get_top_source_ips |
Top sending IP addresses |
get_domain_stats |
Per-domain compliance stats |
get_org_stats |
Stats by reporting organization |
get_spf_stats |
SPF authentication result stats |
get_dkim_stats |
DKIM authentication result stats |
parse_dmarc_report |
Parse raw DMARC XML (base64 encoded) |
Key metrics exposed at /metrics:
parse_dmarc_reports_fetched_total- Reports fetched from IMAPparse_dmarc_reports_parsed_total- Successfully parsed reportsparse_dmarc_reports_stored_total- Reports saved to databaseparse_dmarc_reports_fetch_duration_seconds- Fetch operation duration
parse_dmarc_dmarc_reports_total- Total reports in databaseparse_dmarc_dmarc_messages_total- Total messages processedparse_dmarc_dmarc_compliance_rate- Overall compliance rateparse_dmarc_dmarc_messages_by_domain{domain}- Per-domain message countparse_dmarc_dmarc_compliance_rate_by_domain{domain}- Per-domain compliance
parse_dmarc_http_requests_total{method,path,status}- Request countparse_dmarc_http_request_duration_seconds{method,path}- Request latency
The Vue.js dashboard includes:
- Dashboard Hero - Overview statistics with compliance rate
- Recent Reports - Paginated list of DMARC reports
- Report Drawer - Detailed view of individual reports
- Top Sources - Visualization of top sending source IPs
- DMARC DNS Generator - Interactive tool to generate DMARC DNS TXT records
- Settings Modal - Theme switching (light/dark/system) and custom API endpoint configuration
Config via JSON file or environment variables (using caarlos0/env):
{
"imap": {
"host": "imap.example.com",
"port": 993,
"username": "dmarc@example.com",
"password": "your-password",
"mailbox": "INBOX",
"use_tls": true
},
"database": {
"path": "~/.parse-dmarc/db.sqlite"
},
"server": {
"host": "0.0.0.0",
"port": 8080
}
}Environment variables: IMAP_HOST, IMAP_PORT, IMAP_USERNAME, IMAP_PASSWORD, IMAP_MAILBOX, IMAP_USE_TLS, DATABASE_PATH, SERVER_HOST, SERVER_PORT
docker run -d -p 8080:8080 \
-e IMAP_HOST=imap.example.com \
-e IMAP_USERNAME=dmarc@example.com \
-e IMAP_PASSWORD=secret \
ghcr.io/meysam81/parse-dmarc:latestSee compose.yml for a complete example with persistence.
See parse-dmarc.service for systemd service configuration.
- DigitalOcean:
deploy/digitalocean/- Packer template for Marketplace - Dokploy:
deploy/dokploy/- Docker Compose template - Coolify:
deploy/coolify.yaml - CapRover:
deploy/captain-definition - Zeabur:
zeabur.yml- Zeabur platform template - Render:
render.yaml- Render.com configuration - Northflank:
Northflank.json- Northflank configuration
- GitHub Actions workflow in
.github/workflows/ci.yml - Prettier for code formatting (auto-commit in PRs)
- golangci-lint for Go linting
- Docker build with cosign signing
- Kubescape security scanning
- Release automation via release-please and goreleaser
- Multi-platform Docker images (amd64, arm64)
See ROADMAP.md for the comprehensive product roadmap including:
- Phase 1: Delightful Defaults (dark mode, DNS generator, health score, exports)
- Phase 2: Proactive Intelligence (alerting, trends, GeoIP maps, DNS validator)
- Phase 3: Enterprise Ready (auth, multi-org, RBAC, Prometheus metrics)
- Phase 4: AI-Powered Security (AI assistant, anomaly detection, forensic reports)
See CONTRIBUTING.md for development setup and contribution guidelines. Key areas:
- Forensic Reports (RUF support)
- OAuth2 for IMAP authentication
- CSV/JSON export functionality
- Email alerts for compliance issues
- Historical trend analysis
- Test coverage improvements
reportstable: Stores report metadata and raw JSONrecordstable: Stores individual record data per report- Build tags (
cgo/!cgo) select SQLite driver at compile time
The Vue.js frontend is built to dist/, copied to internal/api/dist/, and embedded via Go's embed directive. The binary is self-contained.
The frontend uses a custom reactive store pattern (similar to Pinia):
theme.js- Manages light/dark/system theme with localStorage persistencesettings.js- Manages custom API endpoint with validation and connection testing
The MCP server uses the official modelcontextprotocol/go-sdk. It supports:
- stdio transport: For desktop apps like Claude Desktop
- HTTP/SSE transport: For web-based MCP clients
- OAuth2: Optional authentication via OIDC/token introspection