Skip to main content
Glama

mcp-server-pci-dss-compliance-assistant

CI Release License Python Status

An independent, community-maintained open-source MCP server that helps developers check code and configuration for PCI DSS v4.0.1 readiness, and query a PCI DSS knowledge base that you build locally from your own copy of the standard.

Quick tour: install, build the local dataset, connect an MCP client, then ask questions and audit code

⚠️ Disclaimer & Legal Notice

  • Experimental Release: This tool is currently released as an experimental, community-maintained open-source project. It is provided "as-is" without warranties of any kind and is under active development.

  • Basis of Implementation: The parsing logic, rule mappings, and helper tools in this repository are structured around the PCI DSS v4.0.1 standard documents. However, this repository does not redistribute any copyrighted PCI SSC documents; users must obtain official files directly from the PCI Security Standards Council.

  • No Official Affiliation: PCI DSS and PCI Security Standards Council are registered trademarks of PCI Security Standards Council, LLC. This project is an independent developer utility and is not affiliated with, endorsed, sponsored, or certified by PCI SSC.

  • Not a Formal Assessment: This tool is intended solely to assist developers and security teams with technical readiness and code/configuration hygiene. It does not constitute legal/compliance advice and does not replace a formal assessment by a Qualified Security Assessor (QSA) or official SAQ/ROC validation.

What it does

  • Look up the standard: fetch any of the 249 Requirement 1-12 controls, search them in plain language, group testing procedures for audit prep, list periodic tasks and the controls that became mandatory on 31 March 2025, and build SAQ checklists.

  • Check your code and config: flag PANs, card-number variables written to logs, CVV/PIN/track data handling, weak crypto, hardcoded secrets and SQL built from strings in source code; root/privileged containers, exposed ports, weak TLS, public or unencrypted storage and disabled audit logging in Dockerfile, docker-compose, Kubernetes, nginx and Terraform (AWS resources); and missing SRI or weak CSP on payment pages (6.4.3 / 11.6.1).

  • Audit a whole project: audit_directory walks a local folder read-only, sends each file to the right scanner and returns one gap analysis grouped by severity and PCI DSS requirement.

Related MCP server: Security Context MCP Server

Architecture

flowchart LR
    subgraph build["Build once, on your machine"]
        pdf["PCI DSS v4.0.1 PDF<br/>data/raw/"] --> extract["extract_pci.py"] --> enrich["enrich_pci.py"] --> validate["validate_dataset.py"]
        xlsx["Prioritized Approach .xlsx"] -. cross-check .-> enrich
        validate --> dataset[("pci_dss_v4_0_1.json")]
        dataset --> embed["build_embeddings.py<br/>(optional)"] --> vectors[("embeddings.npy<br/>+ local model")]
    end
    subgraph server["pci-dss-mcp server: read-only, offline"]
        tools["server.py<br/>11 tools, 2 resources, 2 prompts"]
        loader["data_loader.py"] --> search["search_engine.py<br/>BM25 + embeddings, RRF"]
        tools --> loader
        tools --> scanners["scanners/<br/>code, infra, payment page,<br/>repository"]
        tools --> security["security.py<br/>input caps, masking,<br/>untrusted tags, audit log"]
    end
    dataset --> loader
    vectors --> search
    client["MCP client"] <-- "stdio" --> tools

Nothing from the standard is committed to this repository. The PDF, the dataset, the embeddings and the model live under data/, which .gitignore keeps local.

Quickstart

You need git and uv. uv installs Python 3.11+ for you if needed. Run every command from the repository folder, in this order:

# 1. Get the code and install dependencies
git clone https://github.com/itssaeedyari/mcp-server-pci-dss-compliance-assistant.git
cd mcp-server-pci-dss-compliance-assistant
uv sync --all-extras

# 2. Check the setup. Until step 3 it warns that the PDF is missing; that is expected.
uv run python scripts/preflight_check.py

# 3. Download PCI-DSS-v4_0_1.pdf from the PCI SSC Document Library into data/raw/
#    (see data/raw/README.md; the Prioritized Approach workbook is optional), then check again:
uv run python scripts/preflight_check.py

# 4. Build your local dataset (about 20 seconds)
uv run python scripts/extract_pci.py       # parse the Requirement 1-12 tables from the PDF
uv run python scripts/enrich_pci.py        # add metadata, cross-check the workbook, write data/processed/extraction_report.md
uv run python scripts/validate_dataset.py  # check the result against data/processed/schema.json

# 5. Optional, for semantic search: downloads a ~90 MB model once (about 30 seconds)
uv run python scripts/build_embeddings.py

# 6. Start the server
uv run pci-dss-mcp

The server speaks MCP over stdin/stdout, so in a terminal it just waits for a client (press Ctrl+C to stop). To try it by hand, use the MCP Inspector. Rerun steps 4 and 5 whenever you replace the PDF.

Connect a client

Copy one of the ready-made configs from examples/ and replace /ABSOLUTE/PATH/TO/mcp-server-pci-dss-compliance-assistant with the folder you cloned into.

Client

Example

Where it goes

Claude Desktop

claude_desktop_config.json

Settings > Developer > Edit Config

Cursor

cursor_mcp.json

.cursor/mcp.json (project) or ~/.cursor/mcp.json

VS Code

vscode_mcp.json

.vscode/mcp.json in this repository (uses ${workspaceFolder}, no path to edit). To use it in your other projects, run MCP: Open User Configuration and add the same entry with the absolute path instead of ${workspaceFolder}

Any client, via Docker

docker_mcp.json

Your client's MCP config; see Run with Docker

  • Desktop apps may not see your shell's PATH. If the server does not start, replace "uv" with the full path from which uv (where uv on Windows).

  • On Windows, write paths with forward slashes or escaped backslashes, e.g. "C:/Users/you/mcp-server-pci-dss-compliance-assistant".

You don't need to name the tools. Ask normally, for example "Is this Dockerfile OK for our payment service?" or "How must we store card numbers?", and the assistant picks the right tools from their descriptions. If it answers from memory instead, add this once as a standing instruction (Cursor: Settings → Rules → User Rules; Claude Desktop: your profile's personal preferences or a Project's instructions):

For questions about PCI DSS, payment card data, SAQs, or reviews of payment-related code and configuration, use the pci-dss MCP tools and cite the requirement IDs they return.

Run with Docker

The image contains only the code: no PCI SSC documents, dataset or embedding model. Complete Quickstart steps 1-5 first, then build the image and mount your data read-only, along with any project you want audit_directory to scan. From the repository folder:

docker build -t pci-dss-mcp .
docker run -i --rm --network none --read-only --tmpfs /tmp --cap-drop ALL --security-opt no-new-privileges \
  -v "$PWD/data/processed:/app/data/processed:ro" \
  -v /path/to/your/project:/workspace:ro \
  pci-dss-mcp

Then ask for audit_directory on /workspace. The container runs as the non-root appuser and works with --network none: search loads the embedding model from the mounted folder. For an MCP client, use examples/docker_mcp.json and replace both placeholder paths.

Configuration

Variable

Default

Purpose

PCI_DSS_DATA_PATH

data/processed/pci_dss_v4_0_1.json (Docker: /app/data/processed/pci_dss_v4_0_1.json)

Dataset file to load (CI uses tests/fixtures/mock_pci_sample.json)

PCI_MCP_AUDIT_LOG

off

Set to 1 for one JSON line per tool call on stderr (tool, status, latency, finding count; never inputs)

Troubleshooting

Symptom

Fix

PCI DSS dataset not found when the server starts

Run Quickstart step 4, or point PCI_DSS_DATA_PATH at a dataset file.

Preflight fails the git check-ignore checks

Clone with git: a ZIP download has no git metadata.

extract_pci.py says the PDF is missing

The file must be named exactly data/raw/PCI-DSS-v4_0_1.pdf.

Search results show "search_mode": "lexical"

Run scripts/build_embeddings.py (again after rebuilding the dataset).

The client says the server failed to start

Use the full path to uv as command, and check the folder path in args.

Docker: PCI_DSS_DATA_PATH is set to '/app/data/processed/...', but that file does not exist

Mount your data/processed folder: -v /path/to/data/processed:/app/data/processed:ro.

audit_directory: directory_path does not exist or cannot be resolved

Check the path. In Docker, pass the container path (/workspace), not the folder's path on your machine.

audit_directory: Refusing to scan ...: it is a system or home root

Point it at a project folder. Exact system paths (/etc, /var, ...), the filesystem root and your home folder itself are refused; subfolders such as /var/www are fine.

audit_directory reports "truncated": true

Raise max_files (up to 1,000) or audit subfolders separately.

Tools

Lookup tools read the local dataset. Text such as requirement wording comes from your copy of the standard and is shown below as <...>. Parameters marked optional can be left out.

Tool

Parameters

Returns

get_requirement_details

requirement_id: a control ("6.4.3"), section ("6.4") or requirement ("6")

Full record, or a summary list of the controls under a section or requirement

search_pci_controls

query; optional requirement_number (1-12), component (e.g. "Payment Page"), frequency, effective_status (immediate or post_march_2025), limit (default 10, max 50)

Ranked summaries, plus search_mode (hybrid or lexical)

get_testing_and_evidence_guide

requirement_id (e.g. "8.3.6")

Testing procedures grouped by Examine / Interview / Observe / Test, evidence types, frequency

generate_saq_checklist

saq_type (SAQ-A, SAQ-A-EP or SAQ-D); optional requirement_number

Markdown checklist (SAQ mapping is approximate; SAQ-D lists every control, including the 16 that apply only to service providers)

get_related_controls

requirement_id (e.g. "11.6.1")

The control, the controls it references, and the controls that reference it

list_periodic_tasks

frequency: Continuous, Upon change, Quarterly, Semi-annually or Annually

Controls with that schedule

get_post_march_2025_requirements

optional requirement_number

Controls that were best practice until 31 March 2025 (46 in Requirements 1-12)

scan_code_snippet_for_pci

code_snippet; language (default generic; e.g. python, java, javascript, go, php)

Findings for PANs, card numbers written to logs, SAD, weak crypto, hardcoded secrets, SQL built from strings

audit_infrastructure_config

config_content; config_type: dockerfile, docker-compose, kubernetes, nginx or terraform (AWS resources only)

Misconfiguration findings for that file type

audit_payment_page_html

html_or_headers: page HTML, raw HTTP response headers, or both

SRI and CSP findings, a script inventory, and the effective script-src

audit_directory

directory_path (e.g. "/workspace"); max_files (default 100, max 1,000)

Gap analysis for a whole project folder, grouped by severity and requirement, with file paths and lines

Example search result:

{
  "query": "How do I protect cardholder data in browser scripts?",
  "search_mode": "hybrid",
  "count": 3,
  "results": [
    {"id": "6.4.3", "section_title": "<...>", "requirement": "<...>", "frequency": "Continuous",
     "effective_date_status": "post_march_2025", "score": 0.0328},
    {"id": "11.6.1", "...": "..."},
    {"id": "2.2.4", "...": "..."}
  ]
}

Every scanner finding has a severity, a pci_requirement_id, an issue_description and a remediation_step, plus a line or location and masked evidence where available:

{
  "severity": "high",
  "pci_requirement_id": "4.2.1",
  "issue_description": "Weak TLS/SSL protocols enabled: TLSv1.",
  "remediation_step": "Use 'ssl_protocols TLSv1.2 TLSv1.3;'.",
  "line": 4,
  "evidence": "<scanned_artifact>ssl_protocols TLSv1 TLSv1.2;</scanned_artifact>"
}
{
  "severity": "critical",
  "pci_requirement_id": "3.5.1",
  "issue_description": "Unmasked PAN found in code, data or a comment.",
  "remediation_step": "Remove the PAN. Never hardcode or log full PANs; ...",
  "related_requirement_ids": ["3.4.1"],
  "line": 3,
  "evidence": "<scanned_artifact>card = \"453914******6467\"</scanned_artifact>"
}

audit_directory returns one group per issue, with up to 10 occurrences each (sample from a small test project):

{
  "scanner": "repository",
  "root": "/workspace",
  "files": {"scanned": 9, "skipped": {"unsupported_type": 1}, "truncated": false, "with_findings": 8},
  "summary": {
    "total": 15,
    "by_severity": {"critical": 1, "high": 9, "medium": 2, "low": 3},
    "by_requirement": {"1.3.1": 1, "2.2.1": 3, "2.2.4": 1, "2.2.6": 1, "3.5.1": 1, "4.2.1": 2, "6.2.4": 4,
                       "6.4.3": 1, "8.6.2": 1}
  },
  "gap_analysis": [
    {
      "severity": "critical",
      "pci_requirement_id": "3.5.1",
      "issue_description": "Unmasked PAN found in code, data or a comment.",
      "remediation_step": "Remove the PAN. Never hardcode or log full PANs; ...",
      "occurrence_count": 1,
      "occurrences": [
        {"file": "<scanned_artifact>app/payments.py</scanned_artifact>", "line": 1,
         "evidence": "<scanned_artifact>card = \"453201******0366\"</scanned_artifact>"}
      ]
    }
  ],
  "errors": [],
  "note": "..."
}

Resources

URI

Content

pci://requirements/overview

The 12 principal requirements with titles, section lists, control counts and post-March-2025 counts

pci://requirement/{id}

Full JSON record for one control, e.g. pci://requirement/6.4.3

Prompts

Prompt

Arguments

Workflow

pci_code_review_prompt

code_or_diff, language

Run the code scanner, confirm each finding with get_requirement_details, review what the scanner cannot see, report a severity-ordered table

pci_architecture_audit_prompt

architecture_description

Map the cardholder data flow and CDE, check segmentation (Req 1), stored data (Req 3) and transmission (Req 4), output a gap table

search_pci_controls combines two rankings with Reciprocal Rank Fusion, then applies the metadata filters:

  • BM25 (rank_bm25) over IDs, titles, requirement text, guidance, keywords and SAQ tags. Acronyms such as PAN, SAD, SRI, CSP, HSM, TLS, AES, MFA and WAF are expanded with the words the standard uses.

  • Semantic similarity with sentence-transformers/all-MiniLM-L6-v2 (via fastembed, ONNX, CPU). Control embeddings are precomputed by scripts/build_embeddings.py. The server only reads them and loads the model in offline mode.

If the embeddings are missing or stale (the dataset changed), search falls back to BM25 and the startup line says so. The server is ready about 0.5 s after launch; the first semantic query loads the model (about 0.3 s), and later queries take a few milliseconds.

Security model

  • Read-only and offline. The server makes no file writes, network calls or subprocess calls. A test fails if server code imports networking or subprocess modules, and another blocks sockets while running semantic search.

  • Input caps. Code, config and HTML inputs are limited to 500,000 characters, directory paths to 4,096, queries to 500, and other text parameters to 100.

  • No cardholder data or secrets in output. Every tool result passes through a sanitizer that masks Luhn-valid PANs (first 6 / last 4), redacts track data and well-known secret formats (AWS, GitHub, Stripe, Slack, Google keys, private key headers). The scanners also hide secret values they detect.

  • Untrusted content is marked. Anything quoted from scanned input (code lines, config values, script URLs) is wrapped in <scanned_artifact>...</scanned_artifact>, and tag look-alikes inside it are neutralized so the content cannot close the block. Finding descriptions and remediation text are fixed templates. Tool descriptions and server instructions tell the model to treat tagged content as data, never as instructions.

  • Directory audits stay inside the folder. audit_directory resolves the path first and refuses the filesystem root, your home folder itself, exact system paths (/etc, /usr, /var, /opt, ...) and anything under /proc, /sys, /dev or /run; subfolders such as /var/www can be scanned. It skips every symlinked file (counted as symlink, or symlink_outside_root when the link points outside the folder), never enters symlinked folders, opens files with O_NOFOLLOW, skips .git, node_modules, .venv, build output, data/raw, binaries and files over 500 KB, and stops at max_files (default 100, at most 1,000).

  • Audit log (opt-in). PCI_MCP_AUDIT_LOG=1 writes metadata-only JSON lines to stderr.

Development

Tests use a synthetic fixture (tests/fixtures/mock_pci_sample.json) with paraphrased mock controls, so CI never needs the copyrighted PDF.

uv run pytest                                                        # local dataset (or the fixture if none is built)
PCI_DSS_DATA_PATH=tests/fixtures/mock_pci_sample.json uv run pytest  # what CI runs
uv run ruff check .

tests/test_mcp_protocol.py starts the real pci-dss-mcp process and drives it over stdio with the MCP client SDK. GitHub Actions runs ruff, pytest and the preflight check on Python 3.11 and 3.13 for every push and pull request. See CONTRIBUTING.md before adding scanner rules.

To explore the server interactively with the MCP Inspector:

npx @modelcontextprotocol/inspector uv run pci-dss-mcp                                # web UI
npx @modelcontextprotocol/inspector --cli uv run pci-dss-mcp --method tools/list      # CLI

Contributing

Contributions are welcome. Read CONTRIBUTING.md first: it covers setup, the checks to run, how to add a scanner rule, and the one rule every change must follow, which is that no PCI SSC documents, text from them, real card data or secrets may enter the repository. Issues and pull requests use templates that ask you to confirm this.

🗺️ Future Roadmap

  • v1.1 — CI/CD & AST Precision

    • Upgrade code_scanner with AST / tree-sitter analysis for Python, JS/TS, and Go to reduce false positives.

    • Add SARIF v2.1.0 output export to audit_directory for native GitHub Code Scanning integration.

    • Optional: read requirement IDs from official SAQ PDFs you download into data/raw/ (SAQ A, A-EP, D for Merchants, D for Service Providers) for exact SAQ checklists; fall back to the approximate mapping when they are missing.

  • v1.2 — Cross-Framework Mappings & CDE Scoping

    • Cross-map PCI DSS v4.0.1 controls to OWASP ASVS, NIST 800-53, and ISO 27001.

    • Add a CDE segmentation & scope analyzer for docker-compose and Terraform topologies.

    • Add a Customized Approach Controls Matrix template generator.

  • v1.3 — Remote Team Server & Registry

    • Support Streamable HTTP transport with optional API key / OAuth authentication for self-hosted, internal-only team deployments (requiring organizations to supply their own locally extracted PCI SSC dataset).

    • Automated multi-arch Docker image publishing to ghcr.io on release tags.

License

The code in this repository is released under the Apache License 2.0; see also NOTICE. The license does not cover PCI SSC documents or any text extracted from them, which remain the property of PCI Security Standards Council, LLC.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      C
      maintenance
      Allows developers to query security findings (SAST issues, secrets, patches) using natural language within AI-assisted tools like Claude Desktop, Cursor, and other MCP-compatible environments.
      17
      11
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Provides instant access to authoritative security documentation from organizations like OWASP, NIST, and major cloud providers through natural language semantic search. It enables users to retrieve security best practices, frameworks, and vulnerability information directly from a locally cached knowledge base.
      4
      1
      MIT
    • F
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables local security scanning and compliance gap analysis for code and text, detecting secrets, PII, and OWASP vulnerabilities, and assessing readiness across major frameworks like NCA, ISO 27001, NIST CSF, and SOC 2.
      -
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI agents to run deterministic, fully local static security and compliance audits of code, configurations, and dependencies through 32 MCP tools covering 24 vulnerability categories. It also detects the project stack, generates risk reports and checklists, suggests stack-aware remediations, and re-validates fixes to confirm vulnerabilities were eliminated.
      32
      1
      MIT