Skip to content

Commit 9523b5a

Browse files
fix: strictly validate manifests (#66)
* fix: strictly validate manifests * spec: align tests with strict schema
1 parent 641213a commit 9523b5a

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

src/schemas.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import * as z from "zod";
22

3-
export const McpServerConfigSchema = z.object({
3+
export const McpServerConfigSchema = z.strictObject({
44
command: z.string(),
55
args: z.array(z.string()).optional(),
66
env: z.record(z.string(), z.string()).optional(),
77
});
88

9-
export const DxtManifestAuthorSchema = z.object({
9+
export const DxtManifestAuthorSchema = z.strictObject({
1010
name: z.string(),
1111
email: z.string().email().optional(),
1212
url: z.string().url().optional(),
1313
});
1414

15-
export const DxtManifestRepositorySchema = z.object({
15+
export const DxtManifestRepositorySchema = z.strictObject({
1616
type: z.string(),
1717
url: z.string().url(),
1818
});
@@ -26,38 +26,38 @@ export const DxtManifestMcpConfigSchema = McpServerConfigSchema.extend({
2626
.optional(),
2727
});
2828

29-
export const DxtManifestServerSchema = z.object({
29+
export const DxtManifestServerSchema = z.strictObject({
3030
type: z.enum(["python", "node", "binary"]),
3131
entry_point: z.string(),
3232
mcp_config: DxtManifestMcpConfigSchema,
3333
});
3434

3535
export const DxtManifestCompatibilitySchema = z
36-
.object({
36+
.strictObject({
3737
claude_desktop: z.string().optional(),
3838
platforms: z.array(z.enum(["darwin", "win32", "linux"])).optional(),
3939
runtimes: z
40-
.object({
40+
.strictObject({
4141
python: z.string().optional(),
4242
node: z.string().optional(),
4343
})
4444
.optional(),
4545
})
4646
.passthrough();
4747

48-
export const DxtManifestToolSchema = z.object({
48+
export const DxtManifestToolSchema = z.strictObject({
4949
name: z.string(),
5050
description: z.string().optional(),
5151
});
5252

53-
export const DxtManifestPromptSchema = z.object({
53+
export const DxtManifestPromptSchema = z.strictObject({
5454
name: z.string(),
5555
description: z.string().optional(),
5656
arguments: z.array(z.string()).optional(),
5757
text: z.string(),
5858
});
5959

60-
export const DxtUserConfigurationOptionSchema = z.object({
60+
export const DxtUserConfigurationOptionSchema = z.strictObject({
6161
type: z.enum(["string", "number", "boolean", "directory", "file"]),
6262
title: z.string(),
6363
description: z.string(),
@@ -76,7 +76,7 @@ export const DxtUserConfigValuesSchema = z.record(
7676
z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]),
7777
);
7878

79-
export const DxtManifestSchema = z.object({
79+
export const DxtManifestSchema = z.strictObject({
8080
$schema: z.string().optional(),
8181
dxt_version: z.string(),
8282
name: z.string(),
@@ -104,7 +104,7 @@ export const DxtManifestSchema = z.object({
104104
.optional(),
105105
});
106106

107-
export const DxtSignatureInfoSchema = z.object({
107+
export const DxtSignatureInfoSchema = z.strictObject({
108108
status: z.enum(["signed", "unsigned", "self-signed"]),
109109
publisher: z.string().optional(),
110110
issuer: z.string().optional(),

test/schemas.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,11 @@ describe("DxtManifestSchema", () => {
6565
args: ["main.py"],
6666
env: { PYTHONPATH: "." },
6767
},
68-
runtime_requirements: {
69-
python: ">=3.8",
70-
},
7168
},
7269
tools: [
7370
{
7471
name: "my_tool",
7572
description: "A useful tool",
76-
input_schema: { type: "object" },
7773
},
7874
],
7975
keywords: ["test", "example"],
@@ -86,13 +82,6 @@ describe("DxtManifestSchema", () => {
8682
node: ">=16.0.0",
8783
},
8884
},
89-
settings: {
90-
configurable: true,
91-
schema: {
92-
type: "object",
93-
properties: {},
94-
},
95-
},
9685
user_config: {
9786
api_key: {
9887
type: "string",

0 commit comments

Comments
 (0)