Metadata-Version: 2.5
Name: mcp-server-pci-dss-compliance-assistant
Version: 1.1.1
Summary: Independent, community-maintained MCP server for checking code/configs and querying a locally built PCI DSS v4.0.1 knowledge base.
Project-URL: Repository, https://github.com/itssaeedyari/mcp-server-pci-dss-compliance-assistant
Project-URL: Issues, https://github.com/itssaeedyari/mcp-server-pci-dss-compliance-assistant/issues
Project-URL: Documentation, https://github.com/itssaeedyari/mcp-server-pci-dss-compliance-assistant/wiki
Author: Saeed Yari
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: compliance,mcp,model-context-protocol,owasp-asvs,pci-dss,security,static-analysis
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.11
Requires-Dist: fastembed
Requires-Dist: mcp[cli]<3,>=2.3
Requires-Dist: numpy
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: rank-bm25
Provides-Extra: build
Requires-Dist: jsonschema>=4.26.0; extra == 'build'
Requires-Dist: openpyxl>=3.1.5; extra == 'build'
Requires-Dist: pdfplumber; extra == 'build'
Requires-Dist: pymupdf; extra == 'build'
Provides-Extra: dev
Requires-Dist: jsonschema>=4.26.0; extra == 'dev'
Requires-Dist: openpyxl>=3.1.5; extra == 'dev'
Requires-Dist: pdfplumber; extra == 'dev'
Requires-Dist: pillow>=13.0.0; extra == 'dev'
Requires-Dist: pymupdf; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Description-Content-Type: text/markdown

# mcp-server-pci-dss-compliance-assistant

<!-- mcp-name: io.github.itssaeedyari/mcp-server-pci-dss-compliance-assistant -->

[![CI](https://github.com/itssaeedyari/mcp-server-pci-dss-compliance-assistant/actions/workflows/ci.yml/badge.svg)](https://github.com/itssaeedyari/mcp-server-pci-dss-compliance-assistant/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/itssaeedyari/mcp-server-pci-dss-compliance-assistant)](https://github.com/itssaeedyari/mcp-server-pci-dss-compliance-assistant/releases)
[![License](https://img.shields.io/github/license/itssaeedyari/mcp-server-pci-dss-compliance-assistant)](LICENSE)
![Python](https://img.shields.io/badge/python-3.11%2B-blue)
![Status](https://img.shields.io/badge/status-experimental-yellow)

An **independent, community-maintained open-source [MCP](https://modelcontextprotocol.io) 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: build the local dataset with uvx, connect an MCP client, then ask questions and audit code](docs/demo.gif)

> **⚠️ 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.
- **Cover application security too:** findings carry the matching OWASP ASVS 5.0.0 requirement IDs, and with the companion [OWASP ASVS security assistant](https://github.com/itssaeedyari/mcp-server-asvs-security-assistant) connected the two servers work as one; see [Working with the OWASP ASVS security assistant](#working-with-the-owasp-asvs-security-assistant).

## Architecture

```mermaid
flowchart LR
    subgraph build["Build once, on your machine: pci-dss-mcp-build"]
        pdf["Your PCI DSS v4.0.1 PDF"] --> extract["extract"] --> enrich["enrich"] --> validate["validate"]
        xlsx["Prioritized Approach .xlsx"] -. cross-check .-> enrich
        validate --> dataset[("pci_dss_v4_0_1.json")]
        dataset --> embed["embeddings<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
    client <-. "stdio, optional" .-> asvssrv["OWASP ASVS security<br/>assistant (separate server)"]
```

Nothing from the standard is in this repository or in the published package. The dataset, the embeddings and the model live in your user data folder (or under `data/` in a clone, which `.gitignore` keeps local), and the PDF stays wherever you saved it.

## Quickstart

You need [uv](https://docs.astral.sh/uv/) (it installs Python 3.11+ for you if needed) and your own copy of the standard.

1. **Download the standard.** Get `PCI-DSS-v4_0_1.pdf` from the [PCI SSC Document Library](https://www.pcisecuritystandards.org/document_library/). This project cannot ship it.
2. **Build your local dataset** (about a minute):

   ```bash
   uvx --from "mcp-server-pci-dss-compliance-assistant[build]" pci-dss-mcp-build ~/Downloads/PCI-DSS-v4_0_1.pdf
   ```

   It parses the PDF on your machine, validates the result and writes it to your user data folder, where the server looks for it: `~/.local/share/pci-dss-mcp` on Linux, `~/Library/Application Support/pci-dss-mcp` on macOS, `%LOCALAPPDATA%\pci-dss-mcp` on Windows. Nothing is uploaded. It also downloads a ~90 MB embedding model once for semantic search; add `--no-embeddings` to skip that, or `--workbook path/to/Prioritized-Approach-Tool-For-PCI-DSS-v4_0_1.xlsx` to cross-check against the Prioritized Approach workbook. Rerun it whenever you replace the PDF.
3. **Add the server to your client** (below). The client starts it with `uvx mcp-server-pci-dss-compliance-assistant`.

Always use the full package name with `uvx`: the short name `pci-dss-mcp` on PyPI belongs to an unrelated project.

### Connect a client

Ready-made configs are in [`examples/`](examples/).

| Client | Example | Where it goes |
|---|---|---|
| Claude Desktop | [`claude_desktop_config.json`](examples/claude_desktop_config.json) | Settings > Developer > Edit Config |
| Cursor | [`cursor_mcp.json`](examples/cursor_mcp.json) | `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` |
| VS Code | [`vscode_mcp.json`](examples/vscode_mcp.json) | `.vscode/mcp.json` (project), or **MCP: Open User Configuration** for every project |
| Claude Code | `claude mcp add pci-dss -- uvx mcp-server-pci-dss-compliance-assistant` | Run it in a terminal |
| Any client, via Docker | [`docker_mcp.json`](examples/docker_mcp.json) | Your client's MCP config; see [Run with Docker](#run-with-docker) |

```json
{
  "mcpServers": {
    "pci-dss": {
      "command": "uvx",
      "args": ["mcp-server-pci-dss-compliance-assistant"]
    }
  }
}
```

VS Code uses `"servers"` instead of `"mcpServers"` and adds `"type": "stdio"` to the entry. Desktop apps may not see your shell's `PATH`: if the server does not start, replace `"uvx"` with the full path from `which uvx` (`where uvx` on Windows).

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.

### Install from source

For development, or to run an unreleased version. You need [git](https://git-scm.com/) and uv. Run every command from the repository folder, in this order:

```bash
# 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. Put PCI-DSS-v4_0_1.pdf in 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 in data/processed/ (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 the dataset schema

# 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](#development). In a client config, run it with `"command": "uv", "args": ["run", "--directory", "/ABSOLUTE/PATH/TO/mcp-server-pci-dss-compliance-assistant", "pci-dss-mcp"]` (on Windows, write the path with forward slashes).

### Run with Docker

The image contains only the code: no PCI SSC documents, dataset or embedding model. Build the dataset first (Quickstart step 2), then mount it read-only, along with any project you want `audit_directory` to scan:

```bash
docker run -i --rm --network none --read-only --tmpfs /tmp --cap-drop ALL --security-opt no-new-privileges \
  -v ~/.local/share/pci-dss-mcp:/app/data/processed:ro \
  -v /path/to/your/project:/workspace:ro \
  ghcr.io/itssaeedyari/mcp-server-pci-dss-compliance-assistant:latest
```

Use your platform's data folder from step 2 (or `data/processed` in a clone), and pin a version tag such as `:1.1.0` instead of `:latest` if you prefer. 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`](examples/docker_mcp.json) and replace both placeholder paths. To build the image yourself from a clone: `docker build -t pci-dss-mcp .`

### Configuration

| Variable | Default | Purpose |
|---|---|---|
| `PCI_DSS_DATA_PATH` | `data/processed/pci_dss_v4_0_1.json` in the current folder or a clone, else `pci_dss_v4_0_1.json` in your user data folder (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 `pci-dss-mcp-build` (Quickstart step 2), or point `PCI_DSS_DATA_PATH` at a dataset file. |
| `pci-dss-mcp-build: error: missing build dependency` | Include the `[build]` extra: `uvx --from "mcp-server-pci-dss-compliance-assistant[build]" pci-dss-mcp-build ...` |
| `pci-dss-mcp-build` says the PDF does not exist | Check the path you passed. From source, the file must be named exactly `data/raw/PCI-DSS-v4_0_1.pdf`. |
| Search results show `"search_mode": "lexical"` | Rerun `pci-dss-mcp-build` without `--no-embeddings` (from source: `scripts/build_embeddings.py`), again after rebuilding the dataset. |
| The client says the server failed to start | Use the full path to `uvx` (or `uv`) as `command`. From source, check the folder path in `args`. |
| Preflight fails the `git check-ignore` checks | From source, clone with git: a ZIP download has no git metadata. |
| 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`. |
| Docker logs `Ignoring corrupted tree cache file ... Permission denied` | Harmless, but the dataset folder was built with v1.1.0, which left one model cache file unreadable for the container's user. Run `chmod -R a+rX` on the folder, or rerun `pci-dss-mcp-build` (v1.1.1 or later). |
| `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:

```json
{
  "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 `asvs_requirement_ids` when an OWASP ASVS 5.0.0 requirement covers the same issue, and a line or location and masked evidence where available:

```json
{
  "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;'.",
  "asvs_requirement_ids": ["V12.1.1"],
  "line": 4,
  "evidence": "<scanned_artifact>ssl_protocols TLSv1 TLSv1.2;</scanned_artifact>"
}
```

```json
{
  "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"],
  "asvs_requirement_ids": ["V14.2.4"],
  "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):

```json
{
  "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},
    "by_asvs_requirement": {"V14.2.4": 1, "...": "..."}
  },
  "gap_analysis": [
    {
      "severity": "critical",
      "pci_requirement_id": "3.5.1",
      "related_requirement_ids": ["3.4.1"],
      "asvs_requirement_ids": ["V14.2.4"],
      "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 |

<a id="working-with-the-owasp-asvs-security-assistant"></a>

## Working with the OWASP ASVS security assistant

PCI DSS Requirement 6.2.4 asks you to prevent common software attacks; the [OWASP ASVS security assistant](https://github.com/itssaeedyari/mcp-server-asvs-security-assistant) is a separate, companion MCP server that spells out what that means for application code. It ships with OWASP ASVS 5.0.0 (no dataset to build) and scans code, HTTP headers and nginx for issues such as unsafe deserialization, JWT signature bypasses, disabled TLS verification and missing security headers. This server works without it; connect both for payment applications. MCP servers do not call each other: the assistant in your client uses both, and each server tells it how to use the other.

- **Shared IDs.** Findings here carry `asvs_requirement_ids`; its requirements, checklists and findings carry `pci_dss_ids`. Each server's instructions tell the model to look the other standard's IDs up on the other server.
- **Mapping and conflicts.** Its `get_pci_dss_mapping` lists the ASVS requirements behind a PCI DSS requirement (and back), and notes where the standards disagree, such as password composition (8.3.6), periodic password changes (8.3.9) and lockout (8.3.4). For systems in PCI DSS scope the PCI DSS rule applies.
- **One review.** Its `unified_compliance_review_prompt` runs both servers' `audit_directory` on the same folder and merges findings that share a file and line into one table with PCI DSS, ASVS and CWE columns. `pci_code_review_prompt` here also runs its code scanner when it is connected.

Both servers in one client (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "pci-dss": {
      "command": "uvx",
      "args": ["mcp-server-pci-dss-compliance-assistant"]
    },
    "asvs": {
      "command": "uvx",
      "args": ["mcp-server-asvs-security-assistant"]
    }
  }
}
```

## Search

`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](tests/fixtures/mock_pci_sample.json)) with paraphrased mock controls, so CI never needs the copyrighted PDF.

```bash
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](CONTRIBUTING.md) before adding scanner rules.

To explore the server interactively with the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):

```bash
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](CONTRIBUTING.md) first: it covers the workflow (open an issue, agree on the approach, then send a pull request into `develop`), 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.

## License

The code in this repository is released under the [Apache License 2.0](LICENSE); see also [NOTICE](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.
