@tigerdata/mcp-boilerplate 1.5.3 → 1.6.1

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/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export { Cache } from './cache.js';
2
1
  export { cliEntrypoint } from './cliEntrypoint.js';
3
2
  export { httpServerFactory } from './httpServer.js';
4
3
  export { log } from './logger.js';
@@ -6,5 +5,6 @@ export type { AdditionalSetupArgs } from './mcpServer.js';
6
5
  export { registerExitHandlers } from './registerExitHandlers.js';
7
6
  export { StatusError } from './StatusError.js';
8
7
  export { stdioServerFactory } from './stdio.js';
8
+ export { ArrayStore, Store } from './store.js';
9
9
  export { addAiResultToSpan, withSpan } from './tracing.js';
10
10
  export type { ApiFactory, InferSchema, McpFeatureFlags, MigrationsConfig, ParsedQs, PromptFactory, ResourceFactory, } from './types.js';
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export { Cache } from './cache.js';
2
1
  export { cliEntrypoint } from './cliEntrypoint.js';
3
2
  export { httpServerFactory } from './httpServer.js';
4
3
  export { log } from './logger.js';
5
4
  export { registerExitHandlers } from './registerExitHandlers.js';
6
5
  export { StatusError } from './StatusError.js';
7
6
  export { stdioServerFactory } from './stdio.js';
7
+ export { ArrayStore, Store } from './store.js';
8
8
  export { addAiResultToSpan, withSpan } from './tracing.js';
@@ -1,6 +1,7 @@
1
1
  import type { Octokit } from '@octokit/rest';
2
2
  import { type McpFeatureFlags } from '@tigerdata/mcp-boilerplate';
3
3
  import { type CollectionFlags, type CollectionFlagsCfg, type Skill, type SkillCfgMap, type SkillMatter, type SkillsFlags } from './types.js';
4
+ export declare const setSkillConfigReadOverride: (fn: (() => Promise<SkillCfgMap>) | null) => void;
4
5
  export declare const getSkillConfig: (configFilePath?: string) => Promise<SkillCfgMap>;
5
6
  export declare const parseSkillFile: (fileContent: string) => Promise<{
6
7
  matter: SkillMatter;
@@ -10,11 +10,24 @@ const TTL = process.env.SKILLS_TTL
10
10
  : 5 * 60 * 1000;
11
11
  let lastFetchCfg = 0;
12
12
  let skillCfgMap = null;
13
+ let getSkillOverride = null;
14
+ // added so that the consumer can control where the skill config comes from
15
+ // e.g. programmatically, rather than from a file
16
+ // chose to use a setter pattern to minimize changing signatures everywhere,
17
+ // this approach has a minimal footprint
18
+ export const setSkillConfigReadOverride = (fn) => {
19
+ getSkillOverride = fn;
20
+ };
13
21
  export const getSkillConfig = async (configFilePath = process.env.SKILLS_FILE || './skills.yaml') => {
14
22
  if (skillCfgMap && Date.now() - lastFetchCfg < TTL)
15
23
  return skillCfgMap;
16
- const data = await readFile(configFilePath, 'utf-8');
17
- skillCfgMap = zSkillCfgMap.parse(YAML.parse(data));
24
+ if (getSkillOverride !== null) {
25
+ skillCfgMap = await getSkillOverride();
26
+ }
27
+ else {
28
+ const data = await readFile(configFilePath, 'utf-8');
29
+ skillCfgMap = zSkillCfgMap.parse(YAML.parse(data));
30
+ }
18
31
  lastFetchCfg = Date.now();
19
32
  return skillCfgMap;
20
33
  };
@@ -0,0 +1,22 @@
1
+ interface StoreProps<T> {
2
+ fetch: () => Promise<T>;
3
+ ttl?: number;
4
+ }
5
+ export declare class Store<T> {
6
+ private contents;
7
+ private fetch;
8
+ private ttl?;
9
+ private expirationDateTime?;
10
+ constructor({ fetch, ttl }: StoreProps<T>);
11
+ get(): Promise<T>;
12
+ }
13
+ interface ArrayStoreProps<T> {
14
+ fetch: () => Promise<T[]>;
15
+ ttl?: number;
16
+ }
17
+ export declare class ArrayStore<T> extends Store<T[]> {
18
+ constructor({ fetch, ttl }: ArrayStoreProps<T>);
19
+ find(predicate: (item: T) => boolean): Promise<T | null>;
20
+ filter(predicate: (item: T) => boolean): Promise<T[]>;
21
+ }
22
+ export {};
@@ -1,20 +1,30 @@
1
- export class Cache {
1
+ export class Store {
2
2
  contents = null;
3
3
  fetch;
4
+ ttl;
4
5
  expirationDateTime;
5
6
  constructor({ fetch, ttl }) {
6
7
  this.fetch = fetch;
7
8
  if (ttl) {
9
+ this.ttl = ttl;
8
10
  this.expirationDateTime = Date.now() + ttl;
9
11
  }
10
12
  }
11
13
  async get() {
12
14
  if (this.expirationDateTime && Date.now() > this.expirationDateTime) {
13
15
  this.contents = null;
16
+ if (this.ttl) {
17
+ this.expirationDateTime = Date.now() + this.ttl;
18
+ }
14
19
  }
15
20
  this.contents ??= this.fetch();
16
21
  return this.contents;
17
22
  }
23
+ }
24
+ export class ArrayStore extends Store {
25
+ constructor({ fetch, ttl }) {
26
+ super({ fetch, ttl });
27
+ }
18
28
  async find(predicate) {
19
29
  const items = await this.get();
20
30
  return items.find(predicate) ?? null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tigerdata/mcp-boilerplate",
3
- "version": "1.5.3",
3
+ "version": "1.6.1",
4
4
  "description": "MCP boilerplate code for Node.js",
5
5
  "license": "Apache-2.0",
6
6
  "author": "TigerData",
package/dist/cache.d.ts DELETED
@@ -1,15 +0,0 @@
1
- interface CacheProps<T> {
2
- contents?: T;
3
- fetch: () => Promise<T[]>;
4
- ttl?: number;
5
- }
6
- export declare class Cache<T> {
7
- private contents;
8
- private fetch;
9
- private expirationDateTime?;
10
- constructor({ fetch, ttl }: CacheProps<T>);
11
- get(): Promise<T[]>;
12
- find(predicate: (item: T) => boolean): Promise<T | null>;
13
- filter(predicate: (item: T) => boolean): Promise<T[]>;
14
- }
15
- export {};