forked from toolsdk-ai/toolsdk-mcp-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon-schema.ts
More file actions
136 lines (121 loc) · 3.68 KB
/
common-schema.ts
File metadata and controls
136 lines (121 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { z } from "@hono/zod-openapi";
export const BaseResponseSchema = z.object({
success: z.boolean(),
code: z.number(),
message: z.string(),
});
export const ErrorResponseSchema = BaseResponseSchema.extend({
success: z.literal(false),
data: z.null().optional().openapi({
description: "No data for error responses",
}),
}).openapi("ErrorResponse");
export const createSuccessResponseSchema = <T extends z.ZodTypeAny>(dataSchema: T) => {
return BaseResponseSchema.extend({
success: z.literal(true),
data: dataSchema.optional(),
});
};
export const PackageKeySchema = z.string();
export const CategoryConfigSchema = z
.object({
key: z.string(),
name: z.string(),
description: z.string().optional(),
})
.openapi("CategoryConfig");
export const HostingBlackListSchema = z.array(PackageKeySchema);
export const FeaturedListSchema = z.array(PackageKeySchema);
export const MCPServerPackageConfigSchema = z
.object({
type: z.literal("mcp-server"),
runtime: z.enum(["node", "python", "java", "go", "docker"]),
packageName: z.string().describe("Name of the node, python, java package or docker image"),
packageVersion: z
.string()
.optional()
.describe("Version of the package, if not provided then it will use latest version"),
bin: z
.string()
.optional()
.describe(
"Binary Command to run the MCP server, if not provided then it will use the package name",
),
binArgs: z
.array(z.string())
.optional()
.describe(
"Binary Arguments to pass to the command, if not provided then it will use an empty array",
),
remotes: z
.array(
z.object({
type: z.literal("streamable-http"),
url: z.string().url(),
auth: z
.object({
type: z.enum(["oauth2"]),
scopes: z.array(z.string()).optional(),
})
.optional()
.describe("OAuth 2.1 authentication configuration for MCP Server"),
}),
)
.optional(),
// if no custom key then would use name
key: z.string().optional().describe("Unique key for url and slug"),
name: z
.string()
.optional()
.describe("Custom name for display, if empty then it will use the package name"),
description: z.string().optional(),
readme: z
.string()
.optional()
.describe("URL to the README file, if not provided then it will use the package URL"),
url: z.string().optional(),
license: z.string().optional().describe("Open source license like MIT, AGPL, GPL, etc"),
logo: z
.string()
.optional()
.describe(
"URL to custom logo image, if undefined and the URL is Github, then it will use the Github logo",
),
author: z.string().optional().describe("Author name of the ToolSDK.ai's developer ID"),
env: z
.record(
z.object({
description: z.string(),
required: z.boolean(),
}),
)
.optional(),
})
.openapi("MCPServerPackageConfig");
export const PackageConfigSchema = z
.discriminatedUnion("type", [
MCPServerPackageConfigSchema,
z.object({
type: z.literal("toolapp"),
packageName: z.string(),
url: z.string().optional(),
}),
])
.openapi("PackageConfig");
export const PackagesListSchema = z
.record(
z.object({
category: z.string().optional(),
path: z.string(),
validated: z.boolean().optional(),
tools: z
.record(
z.object({
name: z.string().optional(),
description: z.string().optional(),
}),
)
.optional(),
}),
)
.openapi("PackagesList");