@@ -0,0 +1,97 @@
1+// ---------------------------------------------------------------------------
2+// Environment-based configuration for the ZERA MCP server
3+// ---------------------------------------------------------------------------
4+5+export interface ZeraConfig {
6+/** Solana RPC URL. */
7+rpcUrl: string;
8+9+/** ZERA shielded-pool program ID (base58). */
10+programId: string;
11+12+/** Path to the deposit circuit WASM file. */
13+depositWasmPath: string;
14+15+/** Path to the deposit circuit zkey file. */
16+depositZkeyPath: string;
17+18+/** Path to the withdraw circuit WASM file. */
19+withdrawWasmPath: string;
20+21+/** Path to the withdraw circuit zkey file. */
22+withdrawZkeyPath: string;
23+24+/** Path to the transfer circuit WASM file. */
25+transferWasmPath: string;
26+27+/** Path to the transfer circuit zkey file. */
28+transferZkeyPath: string;
29+30+/** Path to the encrypted note store file. */
31+noteStorePath: string;
32+33+/** Solana wallet keypair path (standard Solana CLI format). */
34+walletPath: string;
35+}
36+37+/**
38+ * Load configuration from environment variables.
39+ *
40+ * Required:
41+ * SOLANA_RPC_URL
42+ *
43+ * Optional (with defaults):
44+ * ZERA_PROGRAM_ID - defaults to the SDK's SHIELDED_POOL_PROGRAM_ID
45+ * ZERA_DEPOSIT_WASM_PATH - path to deposit.wasm
46+ * ZERA_DEPOSIT_ZKEY_PATH - path to deposit.zkey
47+ * ZERA_WITHDRAW_WASM_PATH - path to withdraw.wasm
48+ * ZERA_WITHDRAW_ZKEY_PATH - path to withdraw.zkey
49+ * ZERA_TRANSFER_WASM_PATH - path to transfer.wasm
50+ * ZERA_TRANSFER_ZKEY_PATH - path to transfer.zkey
51+ * ZERA_NOTE_STORE_PATH - defaults to ~/.zera/notes.enc
52+ * ZERA_WALLET_PATH - defaults to ~/.config/solana/id.json
53+ */
54+export function loadConfig(): ZeraConfig {
55+const rpcUrl = requireEnv("SOLANA_RPC_URL");
56+57+const home = process.env.HOME ?? process.env.USERPROFILE ?? "~";
58+const defaultCircuitDir = `${home}/.zera/circuits`;
59+60+return {
61+ rpcUrl,
62+programId: process.env.ZERA_PROGRAM_ID ?? "",
63+depositWasmPath:
64+process.env.ZERA_DEPOSIT_WASM_PATH ??
65+`${defaultCircuitDir}/deposit.wasm`,
66+depositZkeyPath:
67+process.env.ZERA_DEPOSIT_ZKEY_PATH ??
68+`${defaultCircuitDir}/deposit.zkey`,
69+withdrawWasmPath:
70+process.env.ZERA_WITHDRAW_WASM_PATH ??
71+`${defaultCircuitDir}/withdraw.wasm`,
72+withdrawZkeyPath:
73+process.env.ZERA_WITHDRAW_ZKEY_PATH ??
74+`${defaultCircuitDir}/withdraw.zkey`,
75+transferWasmPath:
76+process.env.ZERA_TRANSFER_WASM_PATH ??
77+`${defaultCircuitDir}/transfer.wasm`,
78+transferZkeyPath:
79+process.env.ZERA_TRANSFER_ZKEY_PATH ??
80+`${defaultCircuitDir}/transfer.zkey`,
81+noteStorePath:
82+process.env.ZERA_NOTE_STORE_PATH ?? `${home}/.zera/notes.enc`,
83+walletPath:
84+process.env.ZERA_WALLET_PATH ?? `${home}/.config/solana/id.json`,
85+};
86+}
87+88+function requireEnv(name: string): string {
89+const value = process.env[name];
90+if (!value) {
91+throw new Error(
92+`Missing required environment variable: ${name}. ` +
93+`Set it in your claude_desktop_config.json env block or shell environment.`
94+);
95+}
96+return value;
97+}
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.