feat: add Finance MCP workflow
Some checks failed
Some checks failed
This commit is contained in:
57
apps/finance-mcp-service/src/config.ts
Normal file
57
apps/finance-mcp-service/src/config.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import process from 'node:process';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
const DEFAULT_BASE_URL = 'http://172.16.74.149:5666';
|
||||
|
||||
const EnvSchema = z.object({
|
||||
FINANCE_API_BASE_URL: z.string().trim().optional(),
|
||||
FINANCE_API_KEY: z.string().trim().optional(),
|
||||
FINANCE_API_TIMEOUT: z.string().trim().optional(),
|
||||
FINANCE_BASIC_USERNAME: z.string().optional(),
|
||||
FINANCE_BASIC_PASSWORD: z.string().optional(),
|
||||
FINANCE_BASIC_USER: z.string().optional(),
|
||||
FINANCE_USERNAME: z.string().optional(),
|
||||
FINANCE_PASSWORD: z.string().optional(),
|
||||
FINANCE_MCP_MAX_CONCURRENCY: z.string().trim().optional(),
|
||||
});
|
||||
|
||||
const parsed = EnvSchema.parse(process.env);
|
||||
|
||||
const baseUrl =
|
||||
parsed.FINANCE_API_BASE_URL && parsed.FINANCE_API_BASE_URL.length > 0
|
||||
? parsed.FINANCE_API_BASE_URL
|
||||
: DEFAULT_BASE_URL;
|
||||
|
||||
const timeoutMs = parsed.FINANCE_API_TIMEOUT
|
||||
? Number.parseInt(parsed.FINANCE_API_TIMEOUT, 10)
|
||||
: undefined;
|
||||
|
||||
const maxConcurrencyRaw = parsed.FINANCE_MCP_MAX_CONCURRENCY
|
||||
? Number.parseInt(parsed.FINANCE_MCP_MAX_CONCURRENCY, 10)
|
||||
: undefined;
|
||||
|
||||
const maxConcurrency =
|
||||
Number.isFinite(maxConcurrencyRaw ?? Number.NaN) &&
|
||||
(maxConcurrencyRaw ?? 0) > 0
|
||||
? (maxConcurrencyRaw as number)
|
||||
: 4;
|
||||
|
||||
const username =
|
||||
parsed.FINANCE_BASIC_USERNAME ??
|
||||
parsed.FINANCE_BASIC_USER ??
|
||||
parsed.FINANCE_USERNAME ??
|
||||
null;
|
||||
const password =
|
||||
parsed.FINANCE_BASIC_PASSWORD ?? parsed.FINANCE_PASSWORD ?? null;
|
||||
|
||||
export const config = {
|
||||
baseUrl,
|
||||
apiKey: parsed.FINANCE_API_KEY,
|
||||
timeoutMs:
|
||||
Number.isFinite(timeoutMs ?? Number.NaN) && (timeoutMs ?? 0) > 0
|
||||
? (timeoutMs as number)
|
||||
: undefined,
|
||||
maxConcurrency,
|
||||
basicAuth: username && password ? { username, password } : undefined,
|
||||
};
|
||||
Reference in New Issue
Block a user