oscal-mcp 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. oscal_mcp-1.1.0/PKG-INFO +142 -0
  2. oscal_mcp-1.1.0/README.md +108 -0
  3. oscal_mcp-1.1.0/pyproject.toml +78 -0
  4. oscal_mcp-1.1.0/setup.cfg +4 -0
  5. oscal_mcp-1.1.0/src/oscal_mcp/__init__.py +25 -0
  6. oscal_mcp-1.1.0/src/oscal_mcp/__main__.py +6 -0
  7. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/__init__.py +124 -0
  8. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/_manifest.json +129 -0
  9. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/conops.md +80 -0
  10. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/content.md +640 -0
  11. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/converters.md +194 -0
  12. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/getting-started.md +317 -0
  13. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/import-selection-api.md +112 -0
  14. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/importing-controls.md +45 -0
  15. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/imports.md +331 -0
  16. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/logging.md +140 -0
  17. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/method-patterns.md +48 -0
  18. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/overview.md +38 -0
  19. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/profile-processing.md +365 -0
  20. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/query-content.md +246 -0
  21. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/shared-mode.md +164 -0
  22. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/support-module.md +351 -0
  23. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_lib/validation.md +215 -0
  24. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/NIST-ATTRIBUTION.md +26 -0
  25. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/_manifest.json +202 -0
  26. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/additional_notes.md +52 -0
  27. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/assessment-layer.md +17 -0
  28. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/assessment-plan.md +59 -0
  29. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/assessment-results.md +61 -0
  30. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/catalog.md +61 -0
  31. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/component-definition.md +86 -0
  32. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/concepts-overview.md +16 -0
  33. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/control-layer.md +28 -0
  34. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/identifier-use.md +156 -0
  35. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/implementation-layer.md +15 -0
  36. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/layers-and-models.md +192 -0
  37. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/mapping.md +107 -0
  38. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/poam.md +54 -0
  39. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/processing.md +7 -0
  40. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/profile.md +71 -0
  41. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/relations-to-other-standards.md +43 -0
  42. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/ssp.md +96 -0
  43. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/terminology.md +96 -0
  44. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/tutorial-catalog.md +1340 -0
  45. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/tutorial-component-definition.md +690 -0
  46. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/tutorial-extension.md +670 -0
  47. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/tutorial-metadata.md +663 -0
  48. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/tutorial-profile.md +1304 -0
  49. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/tutorial-validation-modeling.md +119 -0
  50. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/uri-use.md +165 -0
  51. oscal_mcp-1.1.0/src/oscal_mcp/knowledge/oscal_std/validation.md +58 -0
  52. oscal_mcp-1.1.0/src/oscal_mcp/py.typed +0 -0
  53. oscal_mcp-1.1.0/src/oscal_mcp/recipes/create-catalog.md +52 -0
  54. oscal_mcp-1.1.0/src/oscal_mcp/recipes/handle-failed-imports.md +44 -0
  55. oscal_mcp-1.1.0/src/oscal_mcp/recipes/inspect-ssp-implementation.md +45 -0
  56. oscal_mcp-1.1.0/src/oscal_mcp/recipes/load-validate-convert.md +51 -0
  57. oscal_mcp-1.1.0/src/oscal_mcp/recipes/tailor-profile.md +45 -0
  58. oscal_mcp-1.1.0/src/oscal_mcp/resources/__init__.py +30 -0
  59. oscal_mcp-1.1.0/src/oscal_mcp/resources/about.py +49 -0
  60. oscal_mcp-1.1.0/src/oscal_mcp/resources/api_reference.py +181 -0
  61. oscal_mcp-1.1.0/src/oscal_mcp/resources/concepts.py +46 -0
  62. oscal_mcp-1.1.0/src/oscal_mcp/resources/knowledge_search.py +83 -0
  63. oscal_mcp-1.1.0/src/oscal_mcp/resources/metaschema.py +27 -0
  64. oscal_mcp-1.1.0/src/oscal_mcp/resources/recipes.py +53 -0
  65. oscal_mcp-1.1.0/src/oscal_mcp/resources/standard.py +69 -0
  66. oscal_mcp-1.1.0/src/oscal_mcp/serialize.py +96 -0
  67. oscal_mcp-1.1.0/src/oscal_mcp/server.py +104 -0
  68. oscal_mcp-1.1.0/src/oscal_mcp/state.py +199 -0
  69. oscal_mcp-1.1.0/src/oscal_mcp/tools/__init__.py +15 -0
  70. oscal_mcp-1.1.0/src/oscal_mcp/tools/content.py +120 -0
  71. oscal_mcp-1.1.0/src/oscal_mcp/tools/conversion.py +68 -0
  72. oscal_mcp-1.1.0/src/oscal_mcp/tools/imports.py +96 -0
  73. oscal_mcp-1.1.0/src/oscal_mcp/tools/query.py +56 -0
  74. oscal_mcp-1.1.0/src/oscal_mcp/tools/support.py +118 -0
  75. oscal_mcp-1.1.0/src/oscal_mcp/tools/validation.py +38 -0
  76. oscal_mcp-1.1.0/src/oscal_mcp.egg-info/PKG-INFO +142 -0
  77. oscal_mcp-1.1.0/src/oscal_mcp.egg-info/SOURCES.txt +79 -0
  78. oscal_mcp-1.1.0/src/oscal_mcp.egg-info/dependency_links.txt +1 -0
  79. oscal_mcp-1.1.0/src/oscal_mcp.egg-info/entry_points.txt +2 -0
  80. oscal_mcp-1.1.0/src/oscal_mcp.egg-info/requires.txt +10 -0
  81. oscal_mcp-1.1.0/src/oscal_mcp.egg-info/top_level.txt +1 -0
@@ -0,0 +1,142 @@
1
+ Metadata-Version: 2.4
2
+ Name: oscal-mcp
3
+ Version: 1.1.0
4
+ Summary: MCP Server that wraps the oscal Python library to enable an Agentic AI to validate, convert, query and mutate OSCAL content.
5
+ Author-email: Brian Ruf <Brian@RufRisk.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/brian-ruf/oscal-class-mcp
8
+ Project-URL: Repository, https://github.com/brian-ruf/oscal-class-mcp.git
9
+ Project-URL: Documentation, https://github.com/brian-ruf/oscal-class-mcp#readme
10
+ Project-URL: Issues, https://github.com/brian-ruf/oscal-class-mcp/issues
11
+ Keywords: oscal,nist,security,compliance,automation,ssp,fedramp,csf
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Operating System :: OS Independent
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: oscal<5,>=4.3.0
26
+ Requires-Dist: fastmcp>=2.0.0
27
+ Requires-Dist: platformdirs>=3.0.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=8.0; extra == "dev"
30
+ Requires-Dist: pytest-cov; extra == "dev"
31
+ Requires-Dist: pytest-asyncio; extra == "dev"
32
+ Requires-Dist: hypothesis; extra == "dev"
33
+ Requires-Dist: ruff; extra == "dev"
34
+
35
+ # OSCAL MCP Server
36
+
37
+ An [MCP](https://modelcontextprotocol.io) server that wraps the
38
+ [`oscal`](https://github.com/brian-ruf/oscal-class) Python library so agentic AI can
39
+ **create, validate, convert, query and inspect** OSCAL content — and get **help writing
40
+ Python** against the library itself.
41
+
42
+ All OSCAL interaction is delegated to the `oscal` library. This server never parses or
43
+ mutates OSCAL content directly.
44
+
45
+ ## What it provides
46
+
47
+ ### Content-operation tools
48
+ Generic across all eight OSCAL models (catalog, profile, mapping-collection,
49
+ component-definition, system-security-plan, assessment-plan, assessment-results,
50
+ plan-of-action-and-milestones). Every document tool takes a `handle` returned when the
51
+ document is opened.
52
+
53
+ | Tool | Purpose |
54
+ |---|---|
55
+ | `open_document` / `load_content` / `new_document` | Open a file/URI, load in-memory text, or create from template |
56
+ | `list_documents` / `get_document_summary` / `close_document` | Manage the open-document cache |
57
+ | `validate_document` | Tiered metaschema validation (L2, or L3 with `full=true`) |
58
+ | `convert_document` / `save_document` | Serialize to XML/JSON/YAML (string or file) |
59
+ | `query_document` | XPath-inspired query (XML-element or JSON-key syntax) |
60
+ | `inspect_imports` / `resolve_imports` / `retry_import` | Import resolution and recovery |
61
+ | `list_oscal_models` / `list_oscal_versions` | Enumerate support-database coverage |
62
+ | `describe_model_structure` | Metaschema structure outline / node detail |
63
+ | `update_oscal_support` | Fetch newly published OSCAL versions (**needs Internet**) |
64
+
65
+ ### Library coding-help
66
+ | Resource / Tool | Purpose |
67
+ |---|---|
68
+ | `oscal-lib://about` | Server/library versions and bundled-knowledge parity status |
69
+ | `oscal-lib://api` | Compact API index (modules → classes → members + signatures) |
70
+ | `oscal-lib://api/{fqname}` | Full signature + docstring for one symbol |
71
+ | `oscal-lib://metaschema/{model}` | OSCAL model structure outline |
72
+ | `oscal-lib://recipes` + `oscal-lib://recipes/{name}` | Curated usage recipes |
73
+ | `oscal-lib://concepts` + `oscal-lib://concepts/{name}` | Library operating-concept guides (validation, imports, profile processing, …), bundled offline |
74
+ | `oscal-std://concepts` + `oscal-std://concepts/{name}` | Curated NIST OSCAL **standard** snapshot (concepts, layers, per-model pages, tutorials), bundled offline |
75
+ | `oscal-std://notes` | Authored **expert enhancements** to the standard — draft-status caveats & known gaps NIST omits |
76
+ | `search_library_api` | Ranked search over the library API (names, signatures, docs) |
77
+ | `search_knowledge` | Ranked search over the bundled concept/standard guides (`scope`: lib/std/all) |
78
+
79
+ The API reference is generated by **runtime introspection** of the installed `oscal`
80
+ package, so it always reflects the version in use — new getters/setters added as the
81
+ library matures appear automatically.
82
+
83
+ ### Version alignment
84
+ This server targets the `oscal` library **4.3.x**. The API reference tracks whatever
85
+ `oscal` is installed automatically; bundled operating-concept and OSCAL-standard
86
+ documentation (see below) is synced from a specific `oscal-class` release and its source
87
+ tag is recorded in a manifest. `oscal-lib://about` reports the installed library version
88
+ against the bundled-docs release so any drift is visible (`ok` / `mismatch` /
89
+ `not-bundled`).
90
+
91
+ ### OSCAL standard & expert notes
92
+ `oscal-std://concepts` is a curated, offline snapshot of the NIST OSCAL "Learn" pages
93
+ (from [`usnistgov/OSCAL-Pages`](https://github.com/usnistgov/OSCAL-Pages); public domain /
94
+ CC0 — see `knowledge/oscal_std/NIST-ATTRIBUTION.md`). `oscal-std://notes` holds **authored
95
+ expert commentary** (not NIST) — draft-status caveats and known gaps the official docs do
96
+ not state, maintained by hand and versioned independently. Refreshing any bundled content,
97
+ and the policy that **adding to the expert notes bumps the server version**, are documented
98
+ in [`docs/MAINTAINING_KNOWLEDGE.md`](docs/MAINTAINING_KNOWLEDGE.md).
99
+
100
+ ## Install
101
+
102
+ ```bash
103
+ python -m venv .venv && . .venv/bin/activate
104
+ pip install oscal-mcp
105
+ ```
106
+
107
+ This pulls in the `oscal` library and all other dependencies from PyPI automatically.
108
+
109
+ ## Run
110
+
111
+ ```bash
112
+ python -m oscal_mcp # stdio (default MCP transport)
113
+ oscal-mcp --transport http --port 8000
114
+ ```
115
+
116
+ ### Support database location
117
+ The `oscal` library needs a SQLite support database of the NIST metaschemas. This server
118
+ pins its location (so it does not depend on the launch CWD) in this order:
119
+
120
+ 1. `--support-db /path/to/oscal_support.db`
121
+ 2. `OSCAL_MCP_SUPPORT_DB` environment variable
122
+ 3. a per-user default under the platform data dir (e.g.
123
+ `~/.local/share/oscal-mcp/support/oscal_support.db`)
124
+
125
+ The library auto-extracts its bundled database on first run, so the server works offline.
126
+ Use `update_oscal_support` (online) to add newly published OSCAL versions.
127
+
128
+ ## Coexistence with other OSCAL MCP servers
129
+
130
+ This server is **standalone**. Its tool names are plain (`open_document`, …) and its
131
+ resources use a dedicated `oscal-lib://` scheme, so it does not collide with other OSCAL
132
+ MCP servers (e.g. `awslabs/mcp-server-for-oscal`, `metaschema-framework/claude-plugins`)
133
+ if they are installed alongside it. It shares no state or database with them.
134
+
135
+ ## Scope
136
+
137
+ This is the core MVP. Model-specific **authoring** tools (catalog `create_control`,
138
+ profile tailoring/`resolve`, SSP/component implementation authoring, assessment models)
139
+ are planned for a second phase; today they are reachable as library methods documented
140
+ via the coding-help resources. If a required OSCAL operation is missing from the `oscal`
141
+ library, it is recorded as a hand-off document in [`docs/`](docs/) rather than worked
142
+ around in this server.
@@ -0,0 +1,108 @@
1
+ # OSCAL MCP Server
2
+
3
+ An [MCP](https://modelcontextprotocol.io) server that wraps the
4
+ [`oscal`](https://github.com/brian-ruf/oscal-class) Python library so agentic AI can
5
+ **create, validate, convert, query and inspect** OSCAL content — and get **help writing
6
+ Python** against the library itself.
7
+
8
+ All OSCAL interaction is delegated to the `oscal` library. This server never parses or
9
+ mutates OSCAL content directly.
10
+
11
+ ## What it provides
12
+
13
+ ### Content-operation tools
14
+ Generic across all eight OSCAL models (catalog, profile, mapping-collection,
15
+ component-definition, system-security-plan, assessment-plan, assessment-results,
16
+ plan-of-action-and-milestones). Every document tool takes a `handle` returned when the
17
+ document is opened.
18
+
19
+ | Tool | Purpose |
20
+ |---|---|
21
+ | `open_document` / `load_content` / `new_document` | Open a file/URI, load in-memory text, or create from template |
22
+ | `list_documents` / `get_document_summary` / `close_document` | Manage the open-document cache |
23
+ | `validate_document` | Tiered metaschema validation (L2, or L3 with `full=true`) |
24
+ | `convert_document` / `save_document` | Serialize to XML/JSON/YAML (string or file) |
25
+ | `query_document` | XPath-inspired query (XML-element or JSON-key syntax) |
26
+ | `inspect_imports` / `resolve_imports` / `retry_import` | Import resolution and recovery |
27
+ | `list_oscal_models` / `list_oscal_versions` | Enumerate support-database coverage |
28
+ | `describe_model_structure` | Metaschema structure outline / node detail |
29
+ | `update_oscal_support` | Fetch newly published OSCAL versions (**needs Internet**) |
30
+
31
+ ### Library coding-help
32
+ | Resource / Tool | Purpose |
33
+ |---|---|
34
+ | `oscal-lib://about` | Server/library versions and bundled-knowledge parity status |
35
+ | `oscal-lib://api` | Compact API index (modules → classes → members + signatures) |
36
+ | `oscal-lib://api/{fqname}` | Full signature + docstring for one symbol |
37
+ | `oscal-lib://metaschema/{model}` | OSCAL model structure outline |
38
+ | `oscal-lib://recipes` + `oscal-lib://recipes/{name}` | Curated usage recipes |
39
+ | `oscal-lib://concepts` + `oscal-lib://concepts/{name}` | Library operating-concept guides (validation, imports, profile processing, …), bundled offline |
40
+ | `oscal-std://concepts` + `oscal-std://concepts/{name}` | Curated NIST OSCAL **standard** snapshot (concepts, layers, per-model pages, tutorials), bundled offline |
41
+ | `oscal-std://notes` | Authored **expert enhancements** to the standard — draft-status caveats & known gaps NIST omits |
42
+ | `search_library_api` | Ranked search over the library API (names, signatures, docs) |
43
+ | `search_knowledge` | Ranked search over the bundled concept/standard guides (`scope`: lib/std/all) |
44
+
45
+ The API reference is generated by **runtime introspection** of the installed `oscal`
46
+ package, so it always reflects the version in use — new getters/setters added as the
47
+ library matures appear automatically.
48
+
49
+ ### Version alignment
50
+ This server targets the `oscal` library **4.3.x**. The API reference tracks whatever
51
+ `oscal` is installed automatically; bundled operating-concept and OSCAL-standard
52
+ documentation (see below) is synced from a specific `oscal-class` release and its source
53
+ tag is recorded in a manifest. `oscal-lib://about` reports the installed library version
54
+ against the bundled-docs release so any drift is visible (`ok` / `mismatch` /
55
+ `not-bundled`).
56
+
57
+ ### OSCAL standard & expert notes
58
+ `oscal-std://concepts` is a curated, offline snapshot of the NIST OSCAL "Learn" pages
59
+ (from [`usnistgov/OSCAL-Pages`](https://github.com/usnistgov/OSCAL-Pages); public domain /
60
+ CC0 — see `knowledge/oscal_std/NIST-ATTRIBUTION.md`). `oscal-std://notes` holds **authored
61
+ expert commentary** (not NIST) — draft-status caveats and known gaps the official docs do
62
+ not state, maintained by hand and versioned independently. Refreshing any bundled content,
63
+ and the policy that **adding to the expert notes bumps the server version**, are documented
64
+ in [`docs/MAINTAINING_KNOWLEDGE.md`](docs/MAINTAINING_KNOWLEDGE.md).
65
+
66
+ ## Install
67
+
68
+ ```bash
69
+ python -m venv .venv && . .venv/bin/activate
70
+ pip install oscal-mcp
71
+ ```
72
+
73
+ This pulls in the `oscal` library and all other dependencies from PyPI automatically.
74
+
75
+ ## Run
76
+
77
+ ```bash
78
+ python -m oscal_mcp # stdio (default MCP transport)
79
+ oscal-mcp --transport http --port 8000
80
+ ```
81
+
82
+ ### Support database location
83
+ The `oscal` library needs a SQLite support database of the NIST metaschemas. This server
84
+ pins its location (so it does not depend on the launch CWD) in this order:
85
+
86
+ 1. `--support-db /path/to/oscal_support.db`
87
+ 2. `OSCAL_MCP_SUPPORT_DB` environment variable
88
+ 3. a per-user default under the platform data dir (e.g.
89
+ `~/.local/share/oscal-mcp/support/oscal_support.db`)
90
+
91
+ The library auto-extracts its bundled database on first run, so the server works offline.
92
+ Use `update_oscal_support` (online) to add newly published OSCAL versions.
93
+
94
+ ## Coexistence with other OSCAL MCP servers
95
+
96
+ This server is **standalone**. Its tool names are plain (`open_document`, …) and its
97
+ resources use a dedicated `oscal-lib://` scheme, so it does not collide with other OSCAL
98
+ MCP servers (e.g. `awslabs/mcp-server-for-oscal`, `metaschema-framework/claude-plugins`)
99
+ if they are installed alongside it. It shares no state or database with them.
100
+
101
+ ## Scope
102
+
103
+ This is the core MVP. Model-specific **authoring** tools (catalog `create_control`,
104
+ profile tailoring/`resolve`, SSP/component implementation authoring, assessment models)
105
+ are planned for a second phase; today they are reachable as library methods documented
106
+ via the coding-help resources. If a required OSCAL operation is missing from the `oscal`
107
+ library, it is recorded as a hand-off document in [`docs/`](docs/) rather than worked
108
+ around in this server.
@@ -0,0 +1,78 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+
6
+ [project]
7
+ name = "oscal-mcp"
8
+ version = "1.1.0"
9
+ description = "MCP Server that wraps the oscal Python library to enable an Agentic AI to validate, convert, query and mutate OSCAL content."
10
+ requires-python = ">=3.9"
11
+ authors = [{ name = "Brian Ruf", email = "Brian@RufRisk.com" }]
12
+ readme = "README.md"
13
+ license = "MIT"
14
+ classifiers = [
15
+ "Development Status :: 5 - Production/Stable",
16
+ "Intended Audience :: Developers",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Security",
24
+ "Topic :: Software Development :: Libraries :: Python Modules",
25
+ "Operating System :: OS Independent",
26
+ ]
27
+ keywords = ["oscal", "nist", "security", "compliance", "automation", "ssp", "fedramp", "csf"]
28
+
29
+ # The server imports only these three directly. OSCAL-side needs (jsonpath-python,
30
+ # markdown, xmlschema, …) are declared by `oscal` and come in transitively.
31
+ dependencies = [
32
+ "oscal >= 4.3.0, < 5",
33
+ "fastmcp >= 2.0.0",
34
+ "platformdirs >= 3.0.0",
35
+ ]
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/brian-ruf/oscal-class-mcp"
39
+ Repository = "https://github.com/brian-ruf/oscal-class-mcp.git"
40
+ Documentation = "https://github.com/brian-ruf/oscal-class-mcp#readme"
41
+ Issues = "https://github.com/brian-ruf/oscal-class-mcp/issues"
42
+
43
+ [project.optional-dependencies]
44
+ dev = [
45
+ "pytest >= 8.0",
46
+ "pytest-cov",
47
+ "pytest-asyncio",
48
+ "hypothesis",
49
+ "ruff",
50
+ ]
51
+
52
+ [project.scripts]
53
+ oscal-mcp = "oscal_mcp.server:main"
54
+
55
+ [tool.ruff]
56
+ target-version = "py39"
57
+ line-length = 120
58
+
59
+ [tool.ruff.lint]
60
+ # FA102 guards the py39 target: it flags PEP 604 (`X | Y`) unions used in
61
+ # annotations without `from __future__ import annotations`, which raise at runtime
62
+ # on Python 3.9.
63
+ select = ["E", "F", "W", "FA102"]
64
+ ignore = ["W291", "W293", "E501"]
65
+
66
+ [tool.ruff.lint.per-file-ignores]
67
+ "tests/*" = ["F401"]
68
+
69
+ [tool.pytest.ini_options]
70
+ testpaths = ["tests"]
71
+ asyncio_mode = "auto"
72
+
73
+ [tool.setuptools.packages.find]
74
+ where = ["src"]
75
+ include = ["oscal_mcp*"]
76
+
77
+ [tool.setuptools.package-data]
78
+ oscal_mcp = ["py.typed", "recipes/*.md", "knowledge/*/*.md", "knowledge/*/_manifest.json"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,25 @@
1
+ """OSCAL MCP — an MCP server wrapping the ``oscal`` Python library.
2
+
3
+ The server exposes two complementary capability sets:
4
+
5
+ 1. **OSCAL content operations** — loading, validating, converting, querying and
6
+ inspecting OSCAL documents. *Every* OSCAL interaction is delegated to the
7
+ ``oscal`` library; this package never parses or mutates OSCAL content itself.
8
+ 2. **Library coding help** — MCP resources and a search tool that surface the
9
+ ``oscal`` library's own API reference, OSCAL model structure, and curated usage
10
+ recipes, so an agentic AI can write correct Python against the library.
11
+ """
12
+
13
+ import logging
14
+ from importlib.metadata import version as _pkg_version, PackageNotFoundError
15
+
16
+ try:
17
+ __version__ = _pkg_version("oscal-mcp")
18
+ except PackageNotFoundError: # pragma: no cover - running from an uninstalled tree
19
+ __version__ = "0.0.0+unknown"
20
+
21
+ # Library convention (mirrors ``oscal``): emit records but install no handler, so we
22
+ # stay silent unless the host application configures logging.
23
+ logging.getLogger("oscal_mcp").addHandler(logging.NullHandler())
24
+
25
+ __all__ = ["__version__"]
@@ -0,0 +1,6 @@
1
+ """Enable ``python -m oscal_mcp``."""
2
+
3
+ from .server import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1,124 @@
1
+ """Bundled knowledge collections and version-parity helpers.
2
+
3
+ This package holds offline snapshots of documentation the server teaches an agent from:
4
+
5
+ * ``oscal_lib/`` — the ``oscal`` Python library's operating-concept guides (validation,
6
+ imports, profile processing, …), synced from a specific ``oscal-class`` release.
7
+ * ``oscal_std/`` — a curated snapshot of the NIST OSCAL standard (pages.nist.gov/OSCAL).
8
+
9
+ Each collection is described by a ``_manifest.json`` written by
10
+ ``scripts/sync_knowledge.py``. The runtime **never fetches these over the network** — they
11
+ are bundled so the server works offline while staying in parity with a known source
12
+ release. Collections may be absent (e.g. before the first sync); every accessor degrades
13
+ gracefully to ``None``/empty.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import json
19
+ from importlib.metadata import PackageNotFoundError
20
+ from importlib.metadata import version as _pkg_version
21
+ from pathlib import Path
22
+ from typing import Optional
23
+
24
+ KNOWLEDGE_DIR = Path(__file__).resolve().parent
25
+
26
+ # Collection directory -> human-readable label.
27
+ COLLECTIONS = {
28
+ "oscal_lib": "oscal Python library concepts",
29
+ "oscal_std": "NIST OSCAL standard",
30
+ }
31
+
32
+
33
+ def collection_dir(name: str) -> Path:
34
+ """Filesystem directory backing a knowledge collection (may not exist yet)."""
35
+ return KNOWLEDGE_DIR / name
36
+
37
+
38
+ def load_manifest(name: str) -> Optional[dict]:
39
+ """Return the parsed ``_manifest.json`` for a collection, or ``None`` if not bundled."""
40
+ path = collection_dir(name) / "_manifest.json"
41
+ if not path.is_file():
42
+ return None
43
+ try:
44
+ return json.loads(path.read_text(encoding="utf-8"))
45
+ except (OSError, ValueError):
46
+ return None
47
+
48
+
49
+ def installed_oscal_version() -> Optional[str]:
50
+ """Version of the ``oscal`` library currently importable, or ``None``."""
51
+ try:
52
+ return _pkg_version("oscal")
53
+ except PackageNotFoundError: # pragma: no cover - uninstalled tree
54
+ try:
55
+ import oscal
56
+
57
+ return getattr(oscal, "__version__", None)
58
+ except Exception:
59
+ return None
60
+
61
+
62
+ def bundled_oscal_release() -> Optional[str]:
63
+ """Source release/tag the bundled library concept docs were synced from, or ``None``."""
64
+ man = load_manifest("oscal_lib")
65
+ if not man:
66
+ return None
67
+ return man.get("source_release") or man.get("source_tag")
68
+
69
+
70
+ def parity_status() -> dict:
71
+ """Compare the installed ``oscal`` version against the bundled-docs source release.
72
+
73
+ ``status`` is ``"ok"`` when they match, ``"mismatch"`` when bundled docs trail/lead the
74
+ installed library, or ``"not-bundled"`` when no library-concept docs are bundled yet.
75
+ """
76
+ installed = installed_oscal_version()
77
+ bundled = bundled_oscal_release()
78
+ if bundled is None:
79
+ status = "not-bundled"
80
+ else:
81
+ status = "ok" if installed and bundled.lstrip("v") == installed else "mismatch"
82
+ return {
83
+ "installed_oscal": installed,
84
+ "bundled_docs_release": bundled,
85
+ "status": status,
86
+ }
87
+
88
+
89
+ # -----------------------------------------------------------------------------
90
+ # Document access (manifest-driven; shared by the concepts/standard resources
91
+ # and the search_knowledge tool)
92
+ # -----------------------------------------------------------------------------
93
+ def list_documents(collection: str) -> list:
94
+ """Return the manifest ``documents`` list for a collection (``[]`` if not bundled)."""
95
+ man = load_manifest(collection)
96
+ if not man:
97
+ return []
98
+ return list(man.get("documents", []) or [])
99
+
100
+
101
+ def _doc_record(collection: str, name: str) -> Optional[dict]:
102
+ for rec in list_documents(collection):
103
+ if rec.get("name") == name:
104
+ return rec
105
+ return None
106
+
107
+
108
+ def read_document(collection: str, name: str) -> Optional[str]:
109
+ """Return the markdown body of one bundled document, or ``None`` if absent."""
110
+ rec = _doc_record(collection, name)
111
+ if rec is None:
112
+ return None
113
+ path = collection_dir(collection) / rec.get("file", f"{name}.md")
114
+ if not path.is_file():
115
+ return None
116
+ return path.read_text(encoding="utf-8")
117
+
118
+
119
+ def iter_documents(collection: str):
120
+ """Yield ``(record, body)`` for every readable document in a collection."""
121
+ for rec in list_documents(collection):
122
+ path = collection_dir(collection) / rec.get("file", "")
123
+ if path.is_file():
124
+ yield rec, path.read_text(encoding="utf-8")
@@ -0,0 +1,129 @@
1
+ {
2
+ "collection": "oscal_lib",
3
+ "source_repo": "brian-ruf/oscal-class",
4
+ "source_release": "v4.3.0",
5
+ "synced": "2026-11-24T21:23:30Z",
6
+ "generator": "scripts/sync_knowledge.py",
7
+ "documents": [
8
+ {
9
+ "name": "overview",
10
+ "title": "OSCAL Library Overview",
11
+ "file": "overview.md",
12
+ "source": "docs/OVERVIEW.md",
13
+ "source_ref": "local:/work/rr/class",
14
+ "words": 321
15
+ },
16
+ {
17
+ "name": "conops",
18
+ "title": "Concept of Operations (ConOps)",
19
+ "file": "conops.md",
20
+ "source": "docs/CONOPS.md",
21
+ "source_ref": "local:/work/rr/class",
22
+ "words": 745
23
+ },
24
+ {
25
+ "name": "getting-started",
26
+ "title": "Getting Started",
27
+ "file": "getting-started.md",
28
+ "source": "docs/GETTING_STARTED.md",
29
+ "source_ref": "local:/work/rr/class",
30
+ "words": 988
31
+ },
32
+ {
33
+ "name": "content",
34
+ "title": "OSCAL Class",
35
+ "file": "content.md",
36
+ "source": "docs/CONTENT.md",
37
+ "source_ref": "local:/work/rr/class",
38
+ "words": 3106
39
+ },
40
+ {
41
+ "name": "validation",
42
+ "title": "Tiered Validation",
43
+ "file": "validation.md",
44
+ "source": "docs/VALIDATION.md",
45
+ "source_ref": "local:/work/rr/class",
46
+ "words": 1690
47
+ },
48
+ {
49
+ "name": "imports",
50
+ "title": "Import Resolution",
51
+ "file": "imports.md",
52
+ "source": "docs/IMPORTS.md",
53
+ "source_ref": "local:/work/rr/class",
54
+ "words": 1751
55
+ },
56
+ {
57
+ "name": "import-selection-api",
58
+ "title": "Profile import-selection API \u2014 reference",
59
+ "file": "import-selection-api.md",
60
+ "source": "docs/IMPORT_SELECTION_API.md",
61
+ "source_ref": "local:/work/rr/class",
62
+ "words": 780
63
+ },
64
+ {
65
+ "name": "importing-controls",
66
+ "title": "Importing Controls",
67
+ "file": "importing-controls.md",
68
+ "source": "docs/IMPORTING_CONTROLS.md",
69
+ "source_ref": "local:/work/rr/class",
70
+ "words": 325
71
+ },
72
+ {
73
+ "name": "profile-processing",
74
+ "title": "Profile Processing",
75
+ "file": "profile-processing.md",
76
+ "source": "docs/PROFILE_PROCESSING.md",
77
+ "source_ref": "local:/work/rr/class",
78
+ "words": 2272
79
+ },
80
+ {
81
+ "name": "query-content",
82
+ "title": "Querying OSCAL Content",
83
+ "file": "query-content.md",
84
+ "source": "docs/QUERY_CONTENT.md",
85
+ "source_ref": "local:/work/rr/class",
86
+ "words": 1295
87
+ },
88
+ {
89
+ "name": "converters",
90
+ "title": "OSCAL Format Converters",
91
+ "file": "converters.md",
92
+ "source": "docs/CONVERTERS.md",
93
+ "source_ref": "local:/work/rr/class",
94
+ "words": 749
95
+ },
96
+ {
97
+ "name": "support-module",
98
+ "title": "The OSCAL Support Module",
99
+ "file": "support-module.md",
100
+ "source": "docs/SUPPORT_MODULE.md",
101
+ "source_ref": "local:/work/rr/class",
102
+ "words": 1769
103
+ },
104
+ {
105
+ "name": "shared-mode",
106
+ "title": "Shared Mode (multi-process / multi-user workspaces)",
107
+ "file": "shared-mode.md",
108
+ "source": "docs/SHARED_MODE.md",
109
+ "source_ref": "local:/work/rr/class",
110
+ "words": 1126
111
+ },
112
+ {
113
+ "name": "method-patterns",
114
+ "title": "Patterns getters must follow in this library",
115
+ "file": "method-patterns.md",
116
+ "source": "docs/METHOD_PATTERNS.md",
117
+ "source_ref": "local:/work/rr/class",
118
+ "words": 351
119
+ },
120
+ {
121
+ "name": "logging",
122
+ "title": "Logging in `oscal`",
123
+ "file": "logging.md",
124
+ "source": "docs/LOGGING.md",
125
+ "source_ref": "local:/work/rr/class",
126
+ "words": 691
127
+ }
128
+ ]
129
+ }