mirror of
https://github.com/Sea-Haven-Industries/sh-mcp.git
synced 2026-10-07 11:38:58 +00:00
Add an in-memory Client implementation per integration package (seeded fake data, no network) selected when SH_MCP_ENV=local (build-plan §4). Gmail/calendar/ tasks dev clients partition by ctx.sub; payments/qbo seed sensitive-looking fields so the redaction egress path has real targets to mask. Make the eager default-tool exports in tasks/reminders/qbo LAZY (getDefaultTools) so importing a package barrel no longer constructs an AWS client at module load (build-plan §7 'no I/O at import time') — the previous eager construction broke server startup. Fix payments tsconfig rootDir (src, was '.') so its declarations resolve under dist/index.d.ts like the other 8 packages.
44 lines
1.8 KiB
TypeScript
44 lines
1.8 KiB
TypeScript
/**
|
|
* @sh-mcp/reminders
|
|
*
|
|
* Exports the reminders tool array pre-wired with the production AwsSchedulerClient.
|
|
* Server bundles import this directly. Tests import buildReminderTools and inject
|
|
* a mock client instead.
|
|
*
|
|
* NOTE: The production AwsSchedulerClient constructor reads REMINDER_TARGET_ARN and
|
|
* SCHEDULER_ROLE_ARN from environment variables, which are injected by CDK at deploy
|
|
* time. Importing this module without those env vars set (e.g. in unit tests) is safe
|
|
* because the real client is never called — tests inject their own mock via
|
|
* buildReminderTools().
|
|
*/
|
|
|
|
export { buildReminderTools } from './tools.js';
|
|
export type { CreateReminderInput, CreateReminderOutput } from './tools.js';
|
|
export type { SchedulerClient, CreateScheduleInput, CreateScheduleOutput } from './client.js';
|
|
export { AwsSchedulerClient } from './client.js';
|
|
export { InMemorySchedulerClient } from './dev-client.js';
|
|
|
|
import { buildReminderTools } from './tools.js';
|
|
import { AwsSchedulerClient } from './client.js';
|
|
|
|
let _defaultTools: ReturnType<typeof buildReminderTools> | undefined;
|
|
|
|
/**
|
|
* Build (once) the default tools wired to the production AwsSchedulerClient.
|
|
*
|
|
* LAZY by design (build-plan §7): construction is deferred to first call so
|
|
* importing `@sh-mcp/reminders` performs no work and reads no env at import
|
|
* time. Reads the scheduler env only when first invoked, by which point CDK
|
|
* env vars are present. Servers normally wire via `buildReminderTools` directly.
|
|
*/
|
|
export function getDefaultTools(): ReturnType<typeof buildReminderTools> {
|
|
if (!_defaultTools) {
|
|
_defaultTools = buildReminderTools({
|
|
client: new AwsSchedulerClient({
|
|
targetArn: process.env['REMINDER_TARGET_ARN'] ?? '',
|
|
roleArn: process.env['SCHEDULER_ROLE_ARN'] ?? '',
|
|
}),
|
|
});
|
|
}
|
|
return _defaultTools;
|
|
}
|