@mcp-layer/schema 1.0.4 → 2.0.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/README.md +23 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mcp-layer/schema
|
|
2
2
|
|
|
3
|
-
`@mcp-layer/schema` extracts MCP server definitions (tools, resources, prompts, templates, and MCP Apps metadata) and normalizes them into a unified
|
|
3
|
+
`@mcp-layer/schema` extracts MCP server definitions (tools, resources, prompts, templates, and MCP Apps metadata) and normalizes them into a unified schema backed by Zod 4. The output is designed for downstream generators that need a single contract to build CLIs, REST endpoints, UI renderers, or additional MCP layers without re-parsing the MCP protocol surface.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
- [MCP Apps support](#mcp-apps-support)
|
|
12
12
|
- [Generator guidance](#generator-guidance)
|
|
13
13
|
- [Responsibilities and lifecycle](#responsibilities-and-lifecycle)
|
|
14
|
+
- [API Reference](#api-reference)
|
|
14
15
|
- [Error handling](#error-handling)
|
|
15
16
|
- [JSON Schema vs Zod](#json-schema-vs-zod)
|
|
16
17
|
- [Runtime Error Reference](#runtime-error-reference)
|
|
@@ -104,7 +105,7 @@ Type discriminator:
|
|
|
104
105
|
```js
|
|
105
106
|
detail: {
|
|
106
107
|
input: {
|
|
107
|
-
schema, // Zod schema (Ajv-backed)
|
|
108
|
+
schema, // Zod 4 schema (Ajv-backed)
|
|
108
109
|
json, // original JSON Schema
|
|
109
110
|
error // optional Ajv compile error message
|
|
110
111
|
},
|
|
@@ -170,6 +171,25 @@ Suggested uses for the unified schema:
|
|
|
170
171
|
- `composeCatalog(...)` is pure and does not require a connection.
|
|
171
172
|
- If the server doesn't advertise a capability (tools/resources/prompts), extraction skips that surface.
|
|
172
173
|
|
|
174
|
+
## API Reference
|
|
175
|
+
|
|
176
|
+
### `composeCatalog(input = {})`
|
|
177
|
+
|
|
178
|
+
Build a catalog from MCP data that is already available. This function does not connect to a server.
|
|
179
|
+
|
|
180
|
+
- **Input:** an optional `server` object with `info`, `capabilities`, and `instructions`, plus optional `tools`, `resources`, `templates`, and `prompts` arrays.
|
|
181
|
+
- **Result:** `{ server, items }`. Missing values become `undefined` or add no items. Tool input and output schemas use Zod 4 and Ajv.
|
|
182
|
+
- **Errors:** Ajv compile errors appear in the item's `error` field. This function does not make MCP calls.
|
|
183
|
+
|
|
184
|
+
### `extract(session)`
|
|
185
|
+
|
|
186
|
+
Read a catalog from an active `Session`.
|
|
187
|
+
|
|
188
|
+
- **Input:** a connected `Session` from `@mcp-layer/connect` or `@mcp-layer/attach`.
|
|
189
|
+
- **Result:** `Promise<{ server, items }>` with the same shape as `composeCatalog`.
|
|
190
|
+
- **Errors:** if `session.client` is missing, this function throws `LayerError` with reference `error-49ae61`. It passes MCP call errors to the caller.
|
|
191
|
+
- **Lifecycle:** this function does not close the session.
|
|
192
|
+
|
|
173
193
|
## Error handling
|
|
174
194
|
|
|
175
195
|
- Schema compilation uses Ajv under the hood. If a tool exposes an invalid JSON Schema, extraction still succeeds but `detail.input.error` or `detail.output.error` will be populated for that item.
|
|
@@ -178,7 +198,7 @@ Suggested uses for the unified schema:
|
|
|
178
198
|
|
|
179
199
|
## JSON Schema vs Zod
|
|
180
200
|
|
|
181
|
-
Zod
|
|
201
|
+
The `schema` field contains a Zod 4 validator backed by Ajv. Call `.parse()` or `.safeParse()` to validate data. The original JSON Schema stays in `detail.input.json` and `detail.output.json` for generators that need OpenAPI, JSON Schema, or another schema format.
|
|
182
202
|
|
|
183
203
|
## Runtime Error Reference
|
|
184
204
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-layer/schema",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Extract and normalize MCP schemas into a unified Zod-based format.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"ajv": "^8.
|
|
38
|
-
"zod": "^
|
|
37
|
+
"ajv": "^8.20.0",
|
|
38
|
+
"zod": "^4.6.7",
|
|
39
39
|
"@mcp-layer/error": "0.2.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@mcp-layer/attach": "1.
|
|
42
|
+
"@mcp-layer/attach": "1.2.0",
|
|
43
43
|
"@mcp-layer/config": "1.0.2",
|
|
44
44
|
"@mcp-layer/connect": "1.2.1",
|
|
45
45
|
"@mcp-layer/test-server": "1.0.4"
|