@bryan-thompson/inspector-assessment-server 1.30.1 → 1.31.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/build/envSchemas.js +111 -0
- package/package.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod Schemas for Server Environment Variables
|
|
3
|
+
*
|
|
4
|
+
* Runtime validation and type coercion for environment variables.
|
|
5
|
+
* Provides type-safe access to server configuration.
|
|
6
|
+
*
|
|
7
|
+
* @module server/envSchemas
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
/**
|
|
11
|
+
* Schema for server environment variables.
|
|
12
|
+
* Handles string-to-type coercion for process.env values.
|
|
13
|
+
*/
|
|
14
|
+
export const ServerEnvSchema = z.object({
|
|
15
|
+
/**
|
|
16
|
+
* JSON string of additional environment variables to pass to MCP servers.
|
|
17
|
+
* Parsed into an object at runtime.
|
|
18
|
+
*/
|
|
19
|
+
MCP_ENV_VARS: z
|
|
20
|
+
.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.transform((val) => {
|
|
23
|
+
if (!val)
|
|
24
|
+
return {};
|
|
25
|
+
try {
|
|
26
|
+
return JSON.parse(val);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
/**
|
|
33
|
+
* Authentication token for MCP proxy.
|
|
34
|
+
* If not provided, a random token is generated at startup.
|
|
35
|
+
*/
|
|
36
|
+
MCP_PROXY_AUTH_TOKEN: z.string().optional(),
|
|
37
|
+
/**
|
|
38
|
+
* Disable authentication (dangerous, for development only).
|
|
39
|
+
* Truthy string values enable this flag.
|
|
40
|
+
*/
|
|
41
|
+
DANGEROUSLY_OMIT_AUTH: z
|
|
42
|
+
.string()
|
|
43
|
+
.optional()
|
|
44
|
+
.transform((val) => val === "true" || val === "1"),
|
|
45
|
+
/**
|
|
46
|
+
* Port for the client web application.
|
|
47
|
+
* Used to construct default allowed origins.
|
|
48
|
+
* @default "6274"
|
|
49
|
+
*/
|
|
50
|
+
CLIENT_PORT: z
|
|
51
|
+
.string()
|
|
52
|
+
.optional()
|
|
53
|
+
.default("6274")
|
|
54
|
+
.transform((val) => parseInt(val, 10))
|
|
55
|
+
.pipe(z.number().int().positive()),
|
|
56
|
+
/**
|
|
57
|
+
* Comma-separated list of allowed origins for CORS.
|
|
58
|
+
* If not set, defaults to localhost with CLIENT_PORT.
|
|
59
|
+
*/
|
|
60
|
+
ALLOWED_ORIGINS: z
|
|
61
|
+
.string()
|
|
62
|
+
.optional()
|
|
63
|
+
.transform((val) => val ? val.split(",").map((s) => s.trim()) : undefined),
|
|
64
|
+
/**
|
|
65
|
+
* Port for the MCP proxy server.
|
|
66
|
+
* @default "6277"
|
|
67
|
+
*/
|
|
68
|
+
SERVER_PORT: z
|
|
69
|
+
.string()
|
|
70
|
+
.optional()
|
|
71
|
+
.default("6277")
|
|
72
|
+
.transform((val) => parseInt(val, 10))
|
|
73
|
+
.pipe(z.number().int().positive()),
|
|
74
|
+
/**
|
|
75
|
+
* Hostname for the server to listen on.
|
|
76
|
+
* @default "localhost"
|
|
77
|
+
*/
|
|
78
|
+
HOST: z.string().optional().default("localhost"),
|
|
79
|
+
/**
|
|
80
|
+
* Node environment mode.
|
|
81
|
+
* Affects behavior like logging and error handling.
|
|
82
|
+
*/
|
|
83
|
+
NODE_ENV: z.enum(["development", "test", "production"]).optional(),
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Parse and validate server environment variables.
|
|
87
|
+
* Returns validated and coerced environment configuration.
|
|
88
|
+
*
|
|
89
|
+
* @returns Validated server environment
|
|
90
|
+
* @throws ZodError if validation fails
|
|
91
|
+
*/
|
|
92
|
+
export function parseServerEnv() {
|
|
93
|
+
return ServerEnvSchema.parse(process.env);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Safely parse server environment without throwing.
|
|
97
|
+
*
|
|
98
|
+
* @returns SafeParseResult with success status and data/error
|
|
99
|
+
*/
|
|
100
|
+
export function safeParseServerEnv() {
|
|
101
|
+
return ServerEnvSchema.safeParse(process.env);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get a specific environment value with defaults.
|
|
105
|
+
* Useful for accessing individual values without full parsing.
|
|
106
|
+
*/
|
|
107
|
+
export const envDefaults = {
|
|
108
|
+
clientPort: 6274,
|
|
109
|
+
serverPort: 6277,
|
|
110
|
+
host: "localhost",
|
|
111
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bryan-thompson/inspector-assessment-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.0",
|
|
4
4
|
"description": "Server-side application for the Enhanced MCP Inspector with assessment capabilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bryan Thompson <bryan@triepod.ai>",
|