@mcpdesc/validator 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Cisco Systems, Inc. and its affiliates
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,66 @@
1
+ # Modifications to imported material
2
+
3
+ This file records material imported from `cisco-open/mcptoolkit-contract` and subsequently modified in this repository.
4
+
5
+ The exact source repository and commit are recorded in [`ORIGIN.md`](ORIGIN.md).
6
+
7
+ ## Repository bootstrap — 2026-07-28
8
+
9
+ | File or path | Change | Reason |
10
+ |---|---|---|
11
+ | `README.md` | Created for the independent specification repository | Explain repository status and scope |
12
+ | `GOVERNANCE.md` | Created | Establish current community governance |
13
+ | `CONTRIBUTING.md` | Created | Establish repository contribution rules |
14
+ | `NOTICE` | Extended while retaining upstream notice verbatim | Preserve attribution and explain project relationship |
15
+ | `spec/GOVERNANCE.md` | Replaced with pointer; upstream file preserved as `spec/GOVERNANCE-0.7.0.md` | Separate historical v0.7.0 governance from current governance |
16
+ | `spec/README.md` | Repository-status wording updated | Reflect v0.7.0 canonical source and v0.8.0 development home |
17
+
18
+ Add an entry whenever imported material from `cisco-open/mcptoolkit-contract` — specification text, schemas, or examples — is modified, relocated, or re-imported. This file is **not** a release changelog: ongoing v0.8.0 development and released-version history are tracked in [`spec/draft/CHANGELOG.md`](spec/draft/CHANGELOG.md) and Git tags. Where the file format permits, modified derivative files should also contain a prominent origin/modification notice.
19
+
20
+ ## Preserved verbatim
21
+
22
+ - `schemas/mcp-description/0.1.0.json` … `0.7.0.json` — imported unchanged (JSON Schema draft-07). The stable v0.7.0 schema must remain byte-for-byte identical to upstream.
23
+ - `schemas/latest.json` — imported unchanged; still identifies `mcp-description` `0.7.0`.
24
+ - `LICENSE` — imported Apache-2.0 license, unchanged.
25
+ - Normative `spec/draft/sections/**`, `spec/draft/guides/**`, `spec/draft/examples/**`, and `spec/draft/mcp-description.md` — the imported v0.7.0 body is preserved apart from the draft front matter/status noted below; relocated into `spec/draft/` by the 2026-07-29 restructure.
26
+
27
+ ## Bootstrap tooling notes
28
+
29
+ - `scripts/validate-repository.mjs` — supplied validation scaffold; corrected to meta-validate and compile each versioned schema against the JSON Schema dialect it declares (draft-07 for the current stable schemas, 2020-12 for future draft schemas) rather than assuming a single dialect.
30
+ - The original bootstrap pack (master prompt, project decisions, plan, acceptance criteria, reference sources, and import helper) lived under `bootstrap/` and was removed from the working tree on 2026-07-29; it remains recoverable in Git history.
31
+
32
+ ## Draft branch (`draft/0.8.0`) — 2026-07-28
33
+
34
+ | File or path | Change | Reason |
35
+ |---|---|---|
36
+ | `spec/draft/mcp-description.md`, `spec/draft/sections/00-front-matter.md` | Front matter and status marked as the v0.8.0 community working draft (unreleased); the normative body still tracks the v0.7.0 baseline | Label the working draft without representing it as a release |
37
+ | `spec/draft/CHANGELOG.md` | Added an unreleased `[0.8.0]` section | Track v0.8.0 changes |
38
+ | `schemas/draft.json` | Added, identifying `0.8.0` as the unreleased draft | Distinguish the draft from the released `schemas/latest.json` (`0.7.0`) |
39
+ | `scripts/validate-repository.mjs` | Added a guarded check that `schemas/draft.json` remains an unreleased `0.8.0` | Enforce the draft invariant |
40
+
41
+ ## Repository restructure — 2026-07-29
42
+
43
+ Adopted a folder-versioned layout (each specification version is a folder under `spec/`) with `main` as the integration branch.
44
+
45
+ | File or path | Change | Reason |
46
+ |---|---|---|
47
+ | `spec/draft/**` | Imported v0.7.0 normative material (`mcp-description.md`, `sections/`, `guides/`, `examples/`, `extensions/`, `CHANGELOG.md`) relocated from `spec/` into `spec/draft/`; root-relative links adjusted for the new depth | In-progress work lives in `spec/draft/`; released versions freeze into `spec/<version>/` |
48
+ | `spec/0.7.0/README.md` | Added a pointer to the canonical Cisco Open source for v0.7.0; no specification text copied | Keep the stable release discoverable without forking its canonical source |
49
+ | `bootstrap/` | Removed from the working tree (recoverable in Git history) | Completed one-time bootstrap material |
50
+ | `planning/` | Removed; transient tracking moved to GitHub issues and the impact matrix folded into Proposal 0001 in [PR #5](https://github.com/mcpdesc/mcpdesc-specification/pull/5) | Avoid duplicating issue-tracker content |
51
+ | `scripts/freeze-version.mjs` | Added | Automate freezing `spec/draft/` into a versioned folder at release |
52
+ | `scripts/validate-repository.mjs` | Requires `spec/draft/mcp-description.md`; validates examples under any `spec/**/examples/` | Match the folder-versioned layout |
53
+ | `GOVERNANCE.md`, `CONTRIBUTING.md`, `AGENTS.md`, `README.md`, `spec/README.md`, `.github/PULL_REQUEST_TEMPLATE.md`, `specification-status.json`, `schemas/draft.json` | Updated to the `main`-integration, folder-versioned layout and the merge-on-accept proposal workflow | Reflect the current repository model |
54
+ | `spec/GOVERNANCE.md`, `spec/GOVERNANCE-0.7.0.md` | Removed | The repository has a single governance document (`GOVERNANCE.md`); the v0.7.0 specification and its historical governance remain at the canonical Cisco Open source |
55
+
56
+ ## MCP Description v0.8.0 Community Working Draft 1 implementation — frozen 2026-08-24
57
+
58
+ This work began as an unreleased experiment on `experiment/0.8.0-draft-implementation` and was frozen on 2026-08-24 for publication on `main` as MCP Description v0.8.0 Community Working Draft 1 (`v0.8.0-draft.1`). It does not modify or supersede the stable v0.7.0 artifacts. It contains candidate implementations based on exact snapshots of proposals that remain under review; publication of this draft does not accept a proposal or alter its authoritative design and decision record. Proposal changes belong on the corresponding `feature/<slug>-proposal` branch and are captured under `spec/draft/proposal-snapshots/` with commit and digest provenance when used by a public draft.
59
+
60
+ | File or path | Change | Reason |
61
+ |---|---|---|
62
+ | `spec/draft/sections/**`, `spec/draft/mcp-description.md` | Revised the imported v0.7.0 baseline into the experimental v0.8.0 normative draft | Implement protocol-revision scoping, named security requirements, revision-aware Tool schemas, Effective Protocol Views, and related conformance rules for interoperability testing |
63
+ | `spec/draft/guides/**`, `spec/draft/examples/**`, `spec/draft/extensions/**`, `spec/draft/CHANGELOG.md` | Updated supporting material and examples for the experimental draft | Keep non-normative guidance and examples synchronized with the normative changes while preserving origin attribution |
64
+ | `schemas/mcp-description/0.8.0.json`, `schemas/draft.json` | Added the unreleased v0.8.0 schema and pointed the draft metadata at it | Provide a testable draft without changing the stable `schemas/latest.json` pointer |
65
+ | `scripts/validate-0.8.mjs`, `scripts/mcpdesc-views.mjs`, `scripts/test-views.mjs`, `scripts/validate-repository.mjs`, `spec/draft/fixtures/**`, `package.json` | Added semantic validation, projection/merge behavior, fixtures, and dependencies | Exercise cross-object requirements that the structural JSON Schema cannot express |
66
+ | `spec/README.md` | Linked the experimental v0.8.0 schema and retained its unreleased status | Keep the specification index synchronized with the available draft artifacts |
package/NOTICE ADDED
@@ -0,0 +1,32 @@
1
+ MCP Description Specification community development repository
2
+
3
+ This repository contains material derived from the MCP Description Specification
4
+ published in the cisco-open/mcptoolkit-contract repository. The upstream work was
5
+ made available under the Apache License, Version 2.0.
6
+
7
+ Cisco retains copyright in Cisco-originated contributions where applicable.
8
+ Subsequent contributions remain copyright their respective contributors or
9
+ employers. Hosting and maintaining this repository does not imply a copyright
10
+ donation or assignment, Cisco endorsement, partnership, certification,
11
+ sponsorship, or support commitment.
12
+
13
+ The applicable upstream NOTICE is reproduced verbatim below:
14
+
15
+ -------------------------------------------------------------------------------
16
+ mcpcontract (mcptoolkit-contract)
17
+ Copyright 2026 Cisco Systems, Inc. and its affiliates
18
+
19
+ This product includes software developed at Cisco Systems, Inc.
20
+
21
+ Licensed under the Apache License, Version 2.0 (the "License");
22
+ you may not use this file except in compliance with the License.
23
+ You may obtain a copy of the License at
24
+
25
+ https://www.apache.org/licenses/LICENSE-2.0
26
+
27
+ Unless required by applicable law or agreed to in writing, software
28
+ distributed under the License is distributed on an "AS IS" BASIS,
29
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
+ See the License for the specific language governing permissions and
31
+ limitations under the License.
32
+ -------------------------------------------------------------------------------
package/ORIGIN.md ADDED
@@ -0,0 +1,20 @@
1
+ # Origin and provenance
2
+
3
+ MCP Description v0.7.0 originated in the Cisco Open `mcptoolkit-contract` repository and remains the current stable release as of 2026-07-28; its canonical source stays there.
4
+
5
+ This repository is the development home for v0.8.0 and later community work.
6
+ The transition changes future development and governance only — it is **not** a
7
+ copyright assignment or donation, and it does not transfer Cisco's copyright in
8
+ existing contributions.
9
+
10
+ ## Source import
11
+
12
+ | Field | Value |
13
+ |---|---|
14
+ | Upstream repository | `https://github.com/cisco-open/mcptoolkit-contract` |
15
+ | Upstream commit | `874ffba8dd2772a6df4df2d76f402ba731a74617` |
16
+ | Import date | `2026-07-28` |
17
+ | Method | History-preserving filtered import (`git-filter-repo`); commit hashes rewritten by path filtering |
18
+ | Imported paths | `spec/**`, `schemas/mcp-description/**`, `schemas/latest.json`, `LICENSE`, `NOTICE` |
19
+
20
+ The imported v0.7.0 JSON Schemas are preserved byte-for-byte. The v0.7.0 specification text is not stored in this repository; its canonical source is the upstream repository above, and [`spec/0.7.0/`](spec/0.7.0/) points to it. Changes to imported material are recorded in [`MODIFICATIONS.md`](MODIFICATIONS.md) and Git history.
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @mcpdesc/validator
2
+
3
+ Isomorphic structural and semantic validation for immutable MCP Description specification snapshots.
4
+
5
+ The initial implementation supports exactly MCP Description `0.8.0-draft.1`, bound to tag `v0.8.0-draft.1` and the embedded `schemas/mcp-description/0.8.0.json` SHA-256 digest `4ceb6042c3fd31703199cd3db869ec5c35c17d2fe9ab7b2f5b96a2a3af0cebe4`.
6
+
7
+ ## Usage
8
+
9
+ ```js
10
+ import { validateMcpDescription } from '@mcpdesc/validator';
11
+
12
+ const result = validateMcpDescription(parsedDocument, {
13
+ specification: '0.8.0-draft.1'
14
+ });
15
+
16
+ if (!result.valid) {
17
+ console.error(result.diagnostics);
18
+ }
19
+ ```
20
+
21
+ Callers provide an already parsed JavaScript value. JSON and YAML parsing are outside this package.
22
+
23
+ The `options` argument and exact `specification` selector are required. The unqualified selector `0.8.0` is intentionally unsupported because draft iterations are immutable compatibility contracts.
24
+
25
+ ## Result
26
+
27
+ `validateMcpDescription` returns:
28
+
29
+ ```ts
30
+ interface McpDescriptionValidationResult {
31
+ valid: boolean;
32
+ diagnostics: Array<{
33
+ code: string;
34
+ severity: 'error' | 'warning';
35
+ message: string;
36
+ path: Array<string | number>;
37
+ }>;
38
+ }
39
+ ```
40
+
41
+ `valid` is false only when at least one error diagnostic exists. Structural JSON Schema failures are emitted as individual diagnostics. Semantic diagnostics are deterministic and receive root-relative paths at their rule sites.
42
+
43
+ Structural paths start with AJV's instance path. A `required` error appends its `missingProperty`; an `additionalProperties` error appends its `additionalProperty`. This lets callers identify the absent or unexpected property directly.
44
+
45
+ ## Support metadata
46
+
47
+ The package exports frozen `supportedSpecifications`, `supportedProtocolVersions`, and `specificationProvenance` values. npm package SemVer tracks implementation releases independently from specification snapshot identity. A future draft snapshot must use a sibling implementation and selector rather than changing Draft 1 behavior.
48
+
49
+ The runtime bundles its schema, performs no network fetches for external schema references, and imports no Node.js built-ins. Unresolved external Tool-schema references produce incomplete-validation warnings and are preserved. The same ESM entry point supports Node.js 20 or later and browser bundlers.
50
+
51
+ ## Development checks
52
+
53
+ From the repository root:
54
+
55
+ ```bash
56
+ npm test --workspace @mcpdesc/validator
57
+ npm run test:types --workspace @mcpdesc/validator
58
+ npm run test:browser --workspace @mcpdesc/validator
59
+ npm run test:package --workspace @mcpdesc/validator
60
+ ```
61
+
62
+ The package test covers every official Draft 1 valid, invalid, and warning fixture. The other checks compile the declarations, build for a browser target, and inspect `npm pack --dry-run --json` against the intended tarball contents.
package/index.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ export type McpDescriptionSpecification = '0.8.0-draft.1';
2
+
3
+ export type SupportedProtocolVersion =
4
+ | '2024-11-05'
5
+ | '2025-03-26'
6
+ | '2025-06-18'
7
+ | '2025-11-25'
8
+ | '2026-07-28';
9
+
10
+ export type McpDescriptionDiagnosticSeverity = 'error' | 'warning';
11
+
12
+ export interface McpDescriptionDiagnostic {
13
+ readonly code: string;
14
+ readonly severity: McpDescriptionDiagnosticSeverity;
15
+ readonly message: string;
16
+ readonly path: Array<string | number>;
17
+ }
18
+
19
+ export interface McpDescriptionValidationResult {
20
+ readonly valid: boolean;
21
+ readonly diagnostics: McpDescriptionDiagnostic[];
22
+ }
23
+
24
+ export interface ValidateMcpDescriptionOptions {
25
+ specification: McpDescriptionSpecification;
26
+ }
27
+
28
+ export interface SpecificationProvenance {
29
+ readonly snapshotTag: 'v0.8.0-draft.1';
30
+ readonly schemaSha256: '4ceb6042c3fd31703199cd3db869ec5c35c17d2fe9ab7b2f5b96a2a3af0cebe4';
31
+ }
32
+
33
+ export declare const supportedSpecifications: readonly ['0.8.0-draft.1'];
34
+
35
+ export declare const supportedProtocolVersions: readonly [
36
+ '2024-11-05',
37
+ '2025-03-26',
38
+ '2025-06-18',
39
+ '2025-11-25',
40
+ '2026-07-28'
41
+ ];
42
+
43
+ export declare const specificationProvenance: Readonly<{
44
+ readonly '0.8.0-draft.1': Readonly<SpecificationProvenance>;
45
+ }>;
46
+
47
+ export declare function validateMcpDescription(
48
+ document: unknown,
49
+ options: ValidateMcpDescriptionOptions
50
+ ): McpDescriptionValidationResult;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@mcpdesc/validator",
3
+ "version": "0.1.0",
4
+ "description": "Structural and semantic validation for MCP Description snapshots",
5
+ "type": "module",
6
+ "types": "./index.d.ts",
7
+ "license": "Apache-2.0",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/mcpdesc/mcpdesc-specification.git",
11
+ "directory": "packages/validator"
12
+ },
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
16
+ "exports": {
17
+ ".": {
18
+ "types": "./index.d.ts",
19
+ "import": "./src/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "src/index.js",
24
+ "src/snapshots",
25
+ "index.d.ts",
26
+ "README.md",
27
+ "LICENSE",
28
+ "NOTICE",
29
+ "ORIGIN.md",
30
+ "MODIFICATIONS.md"
31
+ ],
32
+ "scripts": {
33
+ "test": "node --test test/*.test.js && npm run test:types && npm run test:browser && npm run test:package",
34
+ "test:browser": "node scripts/check-browser-bundle.mjs",
35
+ "test:package": "node scripts/check-package.mjs",
36
+ "test:types": "tsc --project test/types/tsconfig.json && node scripts/check-declarations.mjs"
37
+ },
38
+ "dependencies": {
39
+ "ajv": "^8.20.0",
40
+ "ajv-formats": "^3.0.1",
41
+ "uri-template-matcher": "^1.1.2"
42
+ },
43
+ "devDependencies": {
44
+ "esbuild": "^0.25.0",
45
+ "typescript": "^5.9.0",
46
+ "yaml": "^2.9.0"
47
+ }
48
+ }
package/src/index.js ADDED
@@ -0,0 +1,28 @@
1
+ import {
2
+ schemaSha256,
3
+ snapshotTag,
4
+ specification,
5
+ supportedProtocolVersions,
6
+ validate
7
+ } from './snapshots/0.8.0-draft.1/index.js';
8
+
9
+ export const supportedSpecifications = Object.freeze([specification]);
10
+ export { supportedProtocolVersions };
11
+
12
+ export const specificationProvenance = Object.freeze({
13
+ [specification]: Object.freeze({
14
+ snapshotTag,
15
+ schemaSha256
16
+ })
17
+ });
18
+
19
+ export function validateMcpDescription(document, options) {
20
+ if (!options || typeof options !== 'object' || Array.isArray(options) || !Object.hasOwn(options, 'specification')) {
21
+ throw new TypeError('options.specification is required');
22
+ }
23
+ if (options.specification !== specification) {
24
+ throw new RangeError(`Unsupported MCP Description specification: ${String(options.specification)}`);
25
+ }
26
+
27
+ return validate(document);
28
+ }
@@ -0,0 +1,69 @@
1
+ import schema from './schema.json' with { type: 'json' };
2
+
3
+ import {
4
+ createMcpdesc08Validator,
5
+ semanticValidateDocument,
6
+ supportedProtocolVersions
7
+ } from './semantic.js';
8
+
9
+ export const specification = '0.8.0-draft.1';
10
+ export const snapshotTag = 'v0.8.0-draft.1';
11
+ export const schemaSha256 = '4ceb6042c3fd31703199cd3db869ec5c35c17d2fe9ab7b2f5b96a2a3af0cebe4';
12
+ export { supportedProtocolVersions };
13
+
14
+ const validateStructure = createMcpdesc08Validator(schema);
15
+
16
+ function decodePointerSegment(segment) {
17
+ return segment.replaceAll('~1', '/').replaceAll('~0', '~');
18
+ }
19
+
20
+ function instancePath(document, pointer) {
21
+ if (!pointer) return [];
22
+ const path = [];
23
+ let current = document;
24
+ for (const encodedSegment of pointer.slice(1).split('/')) {
25
+ const segment = decodePointerSegment(encodedSegment);
26
+ const key = Array.isArray(current) && /^(?:0|[1-9][0-9]*)$/.test(segment)
27
+ ? Number(segment)
28
+ : segment;
29
+ path.push(key);
30
+ current = current?.[key];
31
+ }
32
+ return path;
33
+ }
34
+
35
+ function structuralPath(document, error) {
36
+ const path = instancePath(document, error.instancePath);
37
+ if (error.keyword === 'required' && typeof error.params.missingProperty === 'string') {
38
+ path.push(error.params.missingProperty);
39
+ } else if (error.keyword === 'additionalProperties' && typeof error.params.additionalProperty === 'string') {
40
+ path.push(error.params.additionalProperty);
41
+ }
42
+ return path;
43
+ }
44
+
45
+ function compareDiagnostics(left, right) {
46
+ return left.code.localeCompare(right.code)
47
+ || left.message.localeCompare(right.message)
48
+ || JSON.stringify(left.path).localeCompare(JSON.stringify(right.path));
49
+ }
50
+
51
+ export function validate(document) {
52
+ let diagnostics;
53
+ if (validateStructure(document)) {
54
+ diagnostics = semanticValidateDocument(document);
55
+ } else {
56
+ diagnostics = (validateStructure.errors ?? []).map((error) => ({
57
+ code: 'schema-validation',
58
+ severity: 'error',
59
+ message: `does not validate against 0.8.0: ${error.instancePath || '/'} ${error.message ?? 'unknown error'}`,
60
+ path: structuralPath(document, error)
61
+ }));
62
+ diagnostics.sort(compareDiagnostics);
63
+ }
64
+
65
+ return {
66
+ valid: !diagnostics.some((diagnostic) => diagnostic.severity === 'error'),
67
+ diagnostics
68
+ };
69
+ }