feat(client): implement OpenProject REST API v3 client layer and context scoping
This commit is contained in:
1 parent
5886419b06
commit
f5bff8a81f
9 files changed
+1781
-7
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { z } from "zod";
|
||||
|
||||
/**
|
||||
* Zod schema for OpenProject MCP server configuration.
|
||||
*/
|
||||
export const configSchema = z.object({
|
||||
baseUrl: z
|
||||
.string({ required_error: "OPENPROJECT_BASE_URL is required" })
|
||||
.url("OPENPROJECT_BASE_URL must be a valid URL")
|
||||
.transform((val) => val.replace(/\/+$/, "")),
|
||||
apiKey: z
|
||||
.string({ required_error: "OPENPROJECT_API_KEY is required" })
|
||||
.min(1, "OPENPROJECT_API_KEY must not be empty"),
|
||||
readOnly: z.boolean().default(false),
|
||||
});
|
||||
|
||||
export type AppConfig = z.infer<typeof configSchema>;
|
||||
|
||||
/**
|
||||
* Parses and validates configuration from environment variables and CLI arguments.
|
||||
*
|
||||
* @param env - Environment variable map (defaults to process.env)
|
||||
* @param argv - CLI arguments array (defaults to process.argv)
|
||||
* @returns Validated AppConfig object
|
||||
*/
|
||||
export function parseConfig(
|
||||
env: Record<string, string | undefined> = process.env,
|
||||
argv: string[] = process.argv
|
||||
): AppConfig {
|
||||
const isReadOnlyArg = argv.includes("--read-only");
|
||||
const readOnlyEnv = env.OPENPROJECT_READ_ONLY?.trim().toLowerCase();
|
||||
const isReadOnly =
|
||||
isReadOnlyArg ||
|
||||
readOnlyEnv === "true" ||
|
||||
readOnlyEnv === "1" ||
|
||||
readOnlyEnv === "yes";
|
||||
|
||||
return configSchema.parse({
|
||||
baseUrl: env.OPENPROJECT_BASE_URL,
|
||||
apiKey: env.OPENPROJECT_API_KEY,
|
||||
readOnly: isReadOnly,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user