Metadata-Version: 2.4
Name: oscal-mcp
Version: 1.1.0
Summary: MCP Server that wraps the oscal Python library to enable an Agentic AI to validate, convert, query and mutate OSCAL content.
Author-email: Brian Ruf <Brian@RufRisk.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/brian-ruf/oscal-class-mcp
Project-URL: Repository, https://github.com/brian-ruf/oscal-class-mcp.git
Project-URL: Documentation, https://github.com/brian-ruf/oscal-class-mcp#readme
Project-URL: Issues, https://github.com/brian-ruf/oscal-class-mcp/issues
Keywords: oscal,nist,security,compliance,automation,ssp,fedramp,csf
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
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 :: Libraries :: Python Modules
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: oscal<5,>=4.3.0
Requires-Dist: fastmcp>=2.0.0
Requires-Dist: platformdirs>=3.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: hypothesis; extra == "dev"
Requires-Dist: ruff; extra == "dev"

# OSCAL MCP Server

An [MCP](https://modelcontextprotocol.io) server that wraps the
[`oscal`](https://github.com/brian-ruf/oscal-class) Python library so agentic AI can
**create, validate, convert, query and inspect** OSCAL content — and get **help writing
Python** against the library itself.

All OSCAL interaction is delegated to the `oscal` library. This server never parses or
mutates OSCAL content directly.

## What it provides

### Content-operation tools
Generic across all eight OSCAL models (catalog, profile, mapping-collection,
component-definition, system-security-plan, assessment-plan, assessment-results,
plan-of-action-and-milestones). Every document tool takes a `handle` returned when the
document is opened.

| Tool | Purpose |
|---|---|
| `open_document` / `load_content` / `new_document` | Open a file/URI, load in-memory text, or create from template |
| `list_documents` / `get_document_summary` / `close_document` | Manage the open-document cache |
| `validate_document` | Tiered metaschema validation (L2, or L3 with `full=true`) |
| `convert_document` / `save_document` | Serialize to XML/JSON/YAML (string or file) |
| `query_document` | XPath-inspired query (XML-element or JSON-key syntax) |
| `inspect_imports` / `resolve_imports` / `retry_import` | Import resolution and recovery |
| `list_oscal_models` / `list_oscal_versions` | Enumerate support-database coverage |
| `describe_model_structure` | Metaschema structure outline / node detail |
| `update_oscal_support` | Fetch newly published OSCAL versions (**needs Internet**) |

### Library coding-help
| Resource / Tool | Purpose |
|---|---|
| `oscal-lib://about` | Server/library versions and bundled-knowledge parity status |
| `oscal-lib://api` | Compact API index (modules → classes → members + signatures) |
| `oscal-lib://api/{fqname}` | Full signature + docstring for one symbol |
| `oscal-lib://metaschema/{model}` | OSCAL model structure outline |
| `oscal-lib://recipes` + `oscal-lib://recipes/{name}` | Curated usage recipes |
| `oscal-lib://concepts` + `oscal-lib://concepts/{name}` | Library operating-concept guides (validation, imports, profile processing, …), bundled offline |
| `oscal-std://concepts` + `oscal-std://concepts/{name}` | Curated NIST OSCAL **standard** snapshot (concepts, layers, per-model pages, tutorials), bundled offline |
| `oscal-std://notes` | Authored **expert enhancements** to the standard — draft-status caveats & known gaps NIST omits |
| `search_library_api` | Ranked search over the library API (names, signatures, docs) |
| `search_knowledge` | Ranked search over the bundled concept/standard guides (`scope`: lib/std/all) |

The API reference is generated by **runtime introspection** of the installed `oscal`
package, so it always reflects the version in use — new getters/setters added as the
library matures appear automatically.

### Version alignment
This server targets the `oscal` library **4.3.x**. The API reference tracks whatever
`oscal` is installed automatically; bundled operating-concept and OSCAL-standard
documentation (see below) is synced from a specific `oscal-class` release and its source
tag is recorded in a manifest. `oscal-lib://about` reports the installed library version
against the bundled-docs release so any drift is visible (`ok` / `mismatch` /
`not-bundled`).

### OSCAL standard & expert notes
`oscal-std://concepts` is a curated, offline snapshot of the NIST OSCAL "Learn" pages
(from [`usnistgov/OSCAL-Pages`](https://github.com/usnistgov/OSCAL-Pages); public domain /
CC0 — see `knowledge/oscal_std/NIST-ATTRIBUTION.md`). `oscal-std://notes` holds **authored
expert commentary** (not NIST) — draft-status caveats and known gaps the official docs do
not state, maintained by hand and versioned independently. Refreshing any bundled content,
and the policy that **adding to the expert notes bumps the server version**, are documented
in [`docs/MAINTAINING_KNOWLEDGE.md`](docs/MAINTAINING_KNOWLEDGE.md).

## Install

```bash
python -m venv .venv && . .venv/bin/activate
pip install oscal-mcp
```

This pulls in the `oscal` library and all other dependencies from PyPI automatically.

## Run

```bash
python -m oscal_mcp            # stdio (default MCP transport)
oscal-mcp --transport http --port 8000
```

### Support database location
The `oscal` library needs a SQLite support database of the NIST metaschemas. This server
pins its location (so it does not depend on the launch CWD) in this order:

1. `--support-db /path/to/oscal_support.db`
2. `OSCAL_MCP_SUPPORT_DB` environment variable
3. a per-user default under the platform data dir (e.g.
   `~/.local/share/oscal-mcp/support/oscal_support.db`)

The library auto-extracts its bundled database on first run, so the server works offline.
Use `update_oscal_support` (online) to add newly published OSCAL versions.

## Coexistence with other OSCAL MCP servers

This server is **standalone**. Its tool names are plain (`open_document`, …) and its
resources use a dedicated `oscal-lib://` scheme, so it does not collide with other OSCAL
MCP servers (e.g. `awslabs/mcp-server-for-oscal`, `metaschema-framework/claude-plugins`)
if they are installed alongside it. It shares no state or database with them.

## Scope

This is the core MVP. Model-specific **authoring** tools (catalog `create_control`,
profile tailoring/`resolve`, SSP/component implementation authoring, assessment models)
are planned for a second phase; today they are reachable as library methods documented
via the coding-help resources. If a required OSCAL operation is missing from the `oscal`
library, it is recorded as a hand-off document in [`docs/`](docs/) rather than worked
around in this server.
