@dudamel/mcp-context 0.1.0 → 2026.917.2

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.
Files changed (48) hide show
  1. package/dist/annotations.test.d.ts +2 -0
  2. package/dist/annotations.test.d.ts.map +1 -0
  3. package/dist/cache-dir.d.ts +14 -0
  4. package/dist/cache-dir.d.ts.map +1 -0
  5. package/dist/cache-dir.test.d.ts +2 -0
  6. package/dist/cache-dir.test.d.ts.map +1 -0
  7. package/dist/context-backend.d.ts +36 -0
  8. package/dist/context-backend.d.ts.map +1 -0
  9. package/dist/context-client.d.ts +5 -2
  10. package/dist/context-client.d.ts.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1645 -3
  14. package/dist/mirror-backend.d.ts +61 -0
  15. package/dist/mirror-backend.d.ts.map +1 -0
  16. package/dist/mirror-backend.test.d.ts +2 -0
  17. package/dist/mirror-backend.test.d.ts.map +1 -0
  18. package/dist/server.d.ts.map +1 -1
  19. package/dist/stdio-server.d.ts +12 -0
  20. package/dist/stdio-server.d.ts.map +1 -1
  21. package/dist/stdio-server.js +1700 -36
  22. package/dist/tools/instructions.d.ts +2 -2
  23. package/dist/tools/instructions.d.ts.map +1 -1
  24. package/dist/tools/navigate.d.ts +4 -4
  25. package/dist/tools/navigate.d.ts.map +1 -1
  26. package/dist/tools/read.d.ts +7 -7
  27. package/dist/tools/read.d.ts.map +1 -1
  28. package/dist/tools/search.d.ts +3 -3
  29. package/dist/tools/search.d.ts.map +1 -1
  30. package/dist/types.d.ts +37 -0
  31. package/dist/types.d.ts.map +1 -1
  32. package/package.json +5 -3
  33. package/dist/context-client.js +0 -118
  34. package/dist/context-client.js.map +0 -1
  35. package/dist/index.js.map +0 -1
  36. package/dist/server.js +0 -90
  37. package/dist/server.js.map +0 -1
  38. package/dist/stdio-server.js.map +0 -1
  39. package/dist/tools/instructions.js +0 -40
  40. package/dist/tools/instructions.js.map +0 -1
  41. package/dist/tools/navigate.js +0 -121
  42. package/dist/tools/navigate.js.map +0 -1
  43. package/dist/tools/read.js +0 -352
  44. package/dist/tools/read.js.map +0 -1
  45. package/dist/tools/search.js +0 -103
  46. package/dist/tools/search.js.map +0 -1
  47. package/dist/types.js +0 -2
  48. package/dist/types.js.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { ContextServerClient } from '../context-client.js';
2
+ import type { ContextBackend } from '../context-backend.js';
3
3
  /**
4
4
  * `get_instructions` — returns the AGENTS.md file at the VFS root, which
5
5
  * teaches the agent the `.index.yaml` navigation pattern. Every other tool's
6
6
  * description points here, and the server `instructions` field also tells the
7
7
  * LLM to call this first.
8
8
  */
9
- export declare function registerInstructionsTool(server: McpServer, client: ContextServerClient): void;
9
+ export declare function registerInstructionsTool(server: McpServer, client: ContextBackend): void;
10
10
  //# sourceMappingURL=instructions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/tools/instructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAoC7F"}
1
+ {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/tools/instructions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAqCxF"}
@@ -1,22 +1,22 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { ContextServerClient } from '../context-client.js';
2
+ import type { ContextBackend } from '../context-backend.js';
3
3
  /**
4
4
  * `list_sources` — top-level entry point. Returns the source catalog
5
5
  * generated from /data/context/.index.yaml, where each source is a
6
6
  * directory with its own subtree and `.index.yaml`.
7
7
  */
8
- export declare function registerListSourcesTool(server: McpServer, client: ContextServerClient): void;
8
+ export declare function registerListSourcesTool(server: McpServer, client: ContextBackend): void;
9
9
  /**
10
10
  * `browse` — the ls-with-descriptions primitive. Returns the description of
11
11
  * the directory itself plus the entries inside (files and subdirectories),
12
12
  * each with their own description. One tool call per directory is enough to
13
13
  * decide what to drill into next.
14
14
  */
15
- export declare function registerBrowseTool(server: McpServer, client: ContextServerClient): void;
15
+ export declare function registerBrowseTool(server: McpServer, client: ContextBackend): void;
16
16
  /**
17
17
  * `tree` — a compact recursive listing of a VFS subtree. One call gives a
18
18
  * full picture of everything available under `path`, up to `maxDepth` levels.
19
19
  * Rendered as an indented outline so the LLM can scan it line-by-line.
20
20
  */
21
- export declare function registerTreeTool(server: McpServer, client: ContextServerClient): void;
21
+ export declare function registerTreeTool(server: McpServer, client: ContextBackend): void;
22
22
  //# sourceMappingURL=navigate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/tools/navigate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAIhE;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAsB5F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAkDvF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAmCrF"}
1
+ {"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/tools/navigate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAoBvF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAmDlF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAwChF"}
@@ -1,23 +1,23 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { ContextServerClient } from '../context-client.js';
2
+ import type { ContextBackend } from '../context-backend.js';
3
3
  /**
4
4
  * `read_file` — fetch the text of a file in the VFS. Supports optional byte
5
5
  * offset + length slicing so the caller can stream large files without
6
6
  * blowing the MCP response size budget.
7
7
  */
8
- export declare function registerReadFileTool(server: McpServer, client: ContextServerClient): void;
8
+ export declare function registerReadFileTool(server: McpServer, client: ContextBackend): void;
9
9
  /**
10
10
  * `stat` — path metadata without reading the content.
11
11
  * Useful to decide whether a file is worth reading (size, line count) or to
12
12
  * check that a directory is populated before diving in with `browse`/`tree`.
13
13
  */
14
- export declare function registerStatTool(server: McpServer, client: ContextServerClient): void;
14
+ export declare function registerStatTool(server: McpServer, client: ContextBackend): void;
15
15
  /**
16
16
  * `tail` — last N lines of a file. Mirrors the shell `tail -n`, handy for
17
17
  * logs or files where only the end is relevant. For arbitrary slices use
18
18
  * `read_file` with `offset` / `length` instead.
19
19
  */
20
- export declare function registerTailTool(server: McpServer, client: ContextServerClient): void;
20
+ export declare function registerTailTool(server: McpServer, client: ContextBackend): void;
21
21
  /**
22
22
  * `read_section` — grab a single markdown section by heading. Useful for
23
23
  * "show me the Screens table from luna-android.arch.md" kind of queries
@@ -25,19 +25,19 @@ export declare function registerTailTool(server: McpServer, client: ContextServe
25
25
  * When `heading` is omitted, the tool returns the available headings so
26
26
  * the caller can pick one without guessing.
27
27
  */
28
- export declare function registerReadSectionTool(server: McpServer, client: ContextServerClient): void;
28
+ export declare function registerReadSectionTool(server: McpServer, client: ContextBackend): void;
29
29
  /**
30
30
  * `read_yaml` — navigate a YAML file by dot-path key. Without `keyPath`,
31
31
  * lists top-level keys with types and previews so the caller can drill down.
32
32
  * With `keyPath`, returns the value at that path (scalars as text, objects/arrays
33
33
  * as YAML). Supports array index access (e.g. "servers.0.host").
34
34
  */
35
- export declare function registerReadYamlTool(server: McpServer, client: ContextServerClient): void;
35
+ export declare function registerReadYamlTool(server: McpServer, client: ContextBackend): void;
36
36
  /**
37
37
  * `read_csv` — structured CSV reader with filtering and column selection.
38
38
  * Without filters, returns headers and a preview of the first rows. With
39
39
  * `filterColumn` + `filterValue`, returns matching rows (case-insensitive
40
40
  * substring). Use `columns` to select only specific columns.
41
41
  */
42
- export declare function registerReadCsvTool(server: McpServer, client: ContextServerClient): void;
42
+ export declare function registerReadCsvTool(server: McpServer, client: ContextBackend): void;
43
43
  //# sourceMappingURL=read.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAOhE;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAqF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Ac,GAAG,IAAI,CAyEpF;AAID;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAkFnF"}
@@ -1,16 +1,16 @@
1
1
  import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { ContextServerClient } from '../context-client.js';
2
+ import type { ContextBackend } from '../context-backend.js';
3
3
  /**
4
4
  * `grep` — regex search across VFS file contents. Thin MCP wrapper around
5
5
  * the context-server's `POST /search/grep` (which shells out to real `grep
6
6
  * -rn` with safety caps). Skips dotfiles and .index.yaml catalogs so results
7
7
  * stay focused on actual documentation.
8
8
  */
9
- export declare function registerGrepTool(server: McpServer, client: ContextServerClient): void;
9
+ export declare function registerGrepTool(server: McpServer, client: ContextBackend): void;
10
10
  /**
11
11
  * `find` — locate files by name glob across the VFS. Scoped by `path`.
12
12
  * Returns a plain list of VFS paths. Use this to discover where specific
13
13
  * filenames live when `browse` would take too many hops.
14
14
  */
15
- export declare function registerFindTool(server: McpServer, client: ContextServerClient): void;
15
+ export declare function registerFindTool(server: McpServer, client: ContextBackend): void;
16
16
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAsDrF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAgDrF"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAiDhF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAwChF"}
package/dist/types.d.ts CHANGED
@@ -15,8 +15,45 @@ export interface McpContextConfigProxy {
15
15
  baseUrl: string;
16
16
  /** API key sent on every request. */
17
17
  apiKey: string;
18
+ /**
19
+ * When set, keep a read-only local mirror of the VFS and answer tool calls from
20
+ * it (falling back to HTTP for not-yet-mirrored sources). Only honored in proxy
21
+ * mode — in-cluster the context-server is one hop away, so a mirror isn't worth it.
22
+ */
23
+ cache?: LocalCacheConfig;
18
24
  }
19
25
  export type McpContextConfig = McpContextConfigDirect | McpContextConfigProxy;
26
+ /** Local-mirror cache settings (proxy mode only). */
27
+ export interface LocalCacheConfig {
28
+ /** Root directory for the mirror + its state. */
29
+ dir: string;
30
+ /** Poll interval before re-checking the server manifest (ms). */
31
+ ttlMs: number;
32
+ /** Hard cap for the total mirror size (bytes). Exceeding it disables the cache. */
33
+ maxBytes: number;
34
+ }
35
+ /** One file inside a manifest directory entry (mirrors @dudamel/vfs-search). */
36
+ export interface ManifestFile {
37
+ path: string;
38
+ hash: string;
39
+ size: number;
40
+ }
41
+ /** One top-level entry in the context-server manifest. */
42
+ export type ManifestEntry = {
43
+ path: string;
44
+ type: 'directory';
45
+ digest: string;
46
+ files: ManifestFile[];
47
+ } | {
48
+ path: string;
49
+ type: 'file';
50
+ digest: string;
51
+ size: number;
52
+ };
53
+ export interface ContextManifest {
54
+ generatedAt: string;
55
+ entries: ManifestEntry[];
56
+ }
20
57
  /** One entry in a directory's .index.yaml catalog. */
21
58
  export interface CatalogEntry {
22
59
  path: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,gGAAgG;IAChG,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,GAAG,qBAAqB,CAAC;AAE9E,sDAAsD;AACtD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB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ChB,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;QACpE,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;CACxE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudamel/mcp-context",
3
- "version": "0.1.0",
3
+ "version": "2026.917.2",
4
4
  "description": "Dudamel Context MCP — stdio client for an org's Dudamel knowledge base (VFS) over its REST API.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",
@@ -33,7 +33,9 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/express": "^5.0.0",
36
- "@types/js-yaml": "^4.0.9"
36
+ "@types/js-yaml": "^4.0.9",
37
+ "esbuild": "^0.25.0",
38
+ "@dudamel/vfs-search": "0.1.0"
37
39
  },
38
40
  "peerDependencies": {
39
41
  "express": "^4.18.0 || ^5.0.0"
@@ -44,7 +46,7 @@
44
46
  }
45
47
  },
46
48
  "scripts": {
47
- "build": "tsc",
49
+ "build": "esbuild src/stdio-server.ts src/index.ts --bundle --platform=node --target=node20 --format=esm --outdir=dist --external:@modelcontextprotocol/sdk --external:js-yaml --external:zod && tsc --emitDeclarationOnly",
48
50
  "lint": "eslint src/",
49
51
  "lint:fix": "eslint src/ --fix",
50
52
  "test": "vitest run --passWithNoTests",
@@ -1,118 +0,0 @@
1
- import yaml from 'js-yaml';
2
- /**
3
- * HTTP client for the dudamel context-server. The context-server is the single
4
- * source of truth for the VFS — directory layout, per-directory .index.yaml
5
- * catalogs, and on-disk files. The MCP adapts those HTTP endpoints into tool
6
- * calls for the LLM.
7
- */
8
- export class ContextServerError extends Error {
9
- status;
10
- url;
11
- constructor(message, status, url) {
12
- super(message);
13
- this.status = status;
14
- this.url = url;
15
- this.name = 'ContextServerError';
16
- }
17
- }
18
- export class ContextServerClient {
19
- baseUrl;
20
- apiKey;
21
- pathPrefix;
22
- constructor(options) {
23
- this.baseUrl = options.baseUrl.replace(/\/+$/, '');
24
- this.apiKey = options.apiKey;
25
- this.pathPrefix = this.apiKey ? '/api/context' : '';
26
- }
27
- url(path) {
28
- if (!path.startsWith('/'))
29
- throw new Error(`ContextServerClient path must start with "/", got "${path}"`);
30
- return `${this.baseUrl}${this.pathPrefix}${path}`;
31
- }
32
- headers(extra) {
33
- const out = { ...(extra ?? {}) };
34
- if (this.apiKey)
35
- out['Authorization'] = `ApiKey ${this.apiKey}`;
36
- return out;
37
- }
38
- async get(path) {
39
- const target = this.url(path);
40
- const res = await fetch(target, { method: 'GET', headers: this.headers() });
41
- if (!res.ok) {
42
- const body = await res.text().catch(() => '');
43
- throw new ContextServerError(`GET ${path} -> ${res.status}${body ? `: ${body}` : ''}`, res.status, target);
44
- }
45
- return (await res.json());
46
- }
47
- async post(path, body) {
48
- const target = this.url(path);
49
- const res = await fetch(target, {
50
- method: 'POST',
51
- headers: this.headers({ 'Content-Type': 'application/json' }),
52
- body: JSON.stringify(body ?? {}),
53
- });
54
- if (!res.ok) {
55
- const text = await res.text().catch(() => '');
56
- throw new ContextServerError(`POST ${path} -> ${res.status}${text ? `: ${text}` : ''}`, res.status, target);
57
- }
58
- return (await res.json());
59
- }
60
- grep(req) {
61
- return this.post('/search/grep', req);
62
- }
63
- find(req) {
64
- return this.post('/search/find', req);
65
- }
66
- stat(path) {
67
- return this.post('/search/stat', { path });
68
- }
69
- tree(path, maxDepth) {
70
- return this.post('/search/tree', { path, maxDepth });
71
- }
72
- tail(path, lines) {
73
- return this.post('/search/tail', { path, lines });
74
- }
75
- readSection(path, heading) {
76
- return this.post('/search/section', { path, heading });
77
- }
78
- readYaml(path, keyPath) {
79
- return this.post('/search/yaml', { path, keyPath });
80
- }
81
- readCsv(path, opts) {
82
- return this.post('/search/csv', { path, ...opts });
83
- }
84
- /**
85
- * Fetch a file's raw text from the VFS. Path is VFS-relative:
86
- * "AGENTS.md" -> /data/context/AGENTS.md
87
- * "src/foo" -> /data/context/src/foo
88
- */
89
- async readFile(vfsPath) {
90
- const segments = vfsPath.split('/').filter((s) => s.length > 0);
91
- if (segments.length === 0)
92
- throw new Error('Path cannot be empty');
93
- const [sourceName, ...rest] = segments;
94
- const encoded = encodeURIComponent(sourceName);
95
- const url = rest.length === 0
96
- ? `/read/${encoded}`
97
- : `/read/${encoded}/${rest.map(encodeURIComponent).join('/')}`;
98
- return this.get(url);
99
- }
100
- /**
101
- * Parsed .index.yaml for a directory.
102
- * `dirPath` is VFS-relative: "source" or "source/sub/dir".
103
- */
104
- async readDirectoryCatalog(dirPath) {
105
- const trimmed = dirPath.replace(/\/$/, '');
106
- const catalogPath = trimmed.length === 0 ? '.index.yaml' : `${trimmed}/.index.yaml`;
107
- const raw = await this.readFile(catalogPath);
108
- return parseCatalog(raw.content);
109
- }
110
- }
111
- function parseCatalog(text) {
112
- const parsed = yaml.load(text);
113
- if (parsed == null || typeof parsed !== 'object') {
114
- throw new Error(`Catalog YAML did not parse into an object: ${typeof parsed}`);
115
- }
116
- return parsed;
117
- }
118
- //# sourceMappingURL=context-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-client.js","sourceRoot":"","sources":["../src/context-client.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AA6B3B;;;;;GAKG;A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C;IACjF,CAAC;IACD,OAAO,MAAW,CAAC;AACrB,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/server.js DELETED
@@ -1,90 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { ContextServerClient } from './context-client.js';
3
- import { registerInstructionsTool } from './tools/instructions.js';
4
- import { registerListSourcesTool, registerBrowseTool, registerTreeTool } from './tools/navigate.js';
5
- import { registerReadFileTool, registerStatTool, registerTailTool, registerReadSectionTool, registerReadYamlTool, registerReadCsvTool } from './tools/read.js';
6
- import { registerGrepTool, registerFindTool } from './tools/search.js';
7
- const BASE_INSTRUCTIONS = `
8
- Dudamel Context MCP — read-only access to the organization's knowledge base (the VFS).
9
-
10
- Call \`get_instructions\` on your first interaction for background on the .index.yaml
11
- catalog convention. Not required — the tools work without it, but it helps you
12
- understand the data model the first time.
13
-
14
- Typical workflow:
15
- 1. get_instructions — understand the conventions
16
- 2. list_sources — see what knowledge bases exist
17
- 3. browse <path> — explore a source; read catalog descriptions
18
- 4. tree <path> — compact recursive map of a subtree in one call
19
- 5. stat <path> — check size / line count before reading large files
20
- 6. read_file <path> — fetch actual content when it's relevant
21
- 7. read_section <path, h> — pull one markdown section instead of the whole file
22
- 8. read_yaml <path, key> — navigate a YAML file by dot-path key
23
- 9. read_csv <path, filter> — query a CSV file with column filtering
24
- 10. tail <path> — peek at the end of a file (logs, recent entries)
25
- 11. grep / find — search content or filenames across the VFS
26
-
27
- Prefer reading catalog descriptions (via \`browse\`) over reading full files —
28
- catalogs are dense summaries. Use \`grep\`/\`find\` to locate things you don't
29
- already have a path for; scope them with \`path\` when you can.
30
- `.trim();
31
- /**
32
- * Fetch the root catalog and render a "available sources" section the LLM can
33
- * match against. Descriptions are generated by the indexer from actual source
34
- * content, so this is how the server tells the model what topics it covers
35
- * without anyone hardcoding "use this for Luna Lines" — the data is per-org.
36
- * Falls back silently to the static base instructions if the catalog can't
37
- * be reached (fresh deploy, network hiccup, etc.).
38
- */
39
- async function buildInstructions(client) {
40
- try {
41
- const catalog = await client.readDirectoryCatalog('');
42
- const entries = catalog.entries ?? [];
43
- if (entries.length === 0)
44
- return BASE_INSTRUCTIONS;
45
- const sourceLines = entries
46
- .map((e) => `- **${e.path}** — ${e.description || '(no description yet — call browse for details)'}`)
47
- .join('\n');
48
- const discovery = `
49
- ## Available knowledge sources
50
-
51
- This server is the authoritative source for the topics below. **When the user
52
- asks about anything that overlaps with these descriptions, use this server's
53
- tools before answering from memory** — call \`browse\`/\`grep\`/\`read_file\`
54
- to confirm the current state rather than guessing.
55
-
56
- ${sourceLines}
57
- `.trim();
58
- return `${BASE_INSTRUCTIONS}\n\n${discovery}`;
59
- }
60
- catch {
61
- // Best-effort — if we can't reach the context-server at init time, ship
62
- // the static instructions. Subsequent tool calls will fail the same way
63
- // and surface the real error to the LLM.
64
- return BASE_INSTRUCTIONS;
65
- }
66
- }
67
- export async function createContextServer(config) {
68
- const client = config.mode === 'proxy'
69
- ? new ContextServerClient({ baseUrl: config.baseUrl, apiKey: config.apiKey })
70
- : new ContextServerClient({ baseUrl: config.baseUrl });
71
- const instructions = await buildInstructions(client);
72
- const server = new McpServer({ name: 'dudamel-context', version: '0.1.0' }, {
73
- capabilities: { tools: {} },
74
- instructions,
75
- });
76
- registerInstructionsTool(server, client);
77
- registerListSourcesTool(server, client);
78
- registerBrowseTool(server, client);
79
- registerTreeTool(server, client);
80
- registerReadFileTool(server, client);
81
- registerReadSectionTool(server, client);
82
- registerReadYamlTool(server, client);
83
- registerReadCsvTool(server, client);
84
- registerStatTool(server, client);
85
- registerTailTool(server, client);
86
- registerGrepTool(server, client);
87
- registerFindTool(server, client);
88
- return server;
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E,mEAAmE;IACnE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC1B,8EAA8E;IAC9E,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC1G,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,40 +0,0 @@
1
- import { ContextServerError } from '../context-client.js';
2
- /**
3
- * `get_instructions` — returns the AGENTS.md file at the VFS root, which
4
- * teaches the agent the `.index.yaml` navigation pattern. Every other tool's
5
- * description points here, and the server `instructions` field also tells the
6
- * LLM to call this first.
7
- */
8
- export function registerInstructionsTool(server, client) {
9
- server.tool('get_instructions', 'Read the usage guide for this knowledge base (AGENTS.md). Recommended on your first interaction — it explains the .index.yaml catalog structure and navigation conventions. Not required: `list_sources` and `browse` work without it.', {}, async () => {
10
- try {
11
- const result = await client.readFile('AGENTS.md');
12
- return {
13
- content: [{ type: 'text', text: result.content }],
14
- };
15
- }
16
- catch (error) {
17
- if (error instanceof ContextServerError && error.status === 404) {
18
- return {
19
- content: [
20
- {
21
- type: 'text',
22
- text: 'No AGENTS.md was found at the VFS root. The admin may not have seeded one yet. ' +
23
- 'For reference, each directory should contain a .index.yaml like:\n\n' +
24
- '```yaml\n' +
25
- 'description: "Summary of this directory"\n' +
26
- 'entries:\n' +
27
- ' - path: file.md\n' +
28
- ' type: file\n' +
29
- ' description: "Summary of this file"\n' +
30
- '```\n\n' +
31
- 'Start by calling `list_sources`, then `browse` to drill down, and `read_file` for actual content.',
32
- },
33
- ],
34
- };
35
- }
36
- throw error;
37
- }
38
- });
39
- }
40
- //# sourceMappingURL=instructions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../../src/tools/instructions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAiB,EAAE,MAA2B;IACrF,MAAM,CAAC,IAAI,CACT,kBAAkB,EAClB,wOAAwO,EACxO,EAAE,EACF,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAClD,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;aAClD,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,kBAAkB,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAChE,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EACF,iFAAiF;gCACjF,sEAAsE;gCACtE,WAAW;gCACX,4CAA4C;gCAC5C,YAAY;gCACZ,qBAAqB;gCACrB,kBAAkB;gCAClB,2CAA2C;gCAC3C,SAAS;gCACT,mGAAmG;yBACtG;qBACF;iBACF,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1,121 +0,0 @@
1
- import { z } from 'zod';
2
- import { ContextServerError } from '../context-client.js';
3
- /**
4
- * `list_sources` — top-level entry point. Returns the source catalog
5
- * generated from /data/context/.index.yaml, where each source is a
6
- * directory with its own subtree and `.index.yaml`.
7
- */
8
- export function registerListSourcesTool(server, client) {
9
- server.tool('list_sources', 'List the top-level knowledge sources in this VFS. Each source is a directory at the VFS root with its own documentation tree. Use this to discover what is available, then call `browse` on a source to explore it. If you have not read the usage guide yet, call `get_instructions` first.', {}, async () => {
10
- const catalog = await client.readDirectoryCatalog('');
11
- const entries = catalog.entries ?? [];
12
- if (entries.length === 0) {
13
- return {
14
- content: [{ type: 'text', text: 'No sources are configured in the VFS yet.' }],
15
- };
16
- }
17
- const text = entries
18
- .map((e) => `- **${e.path}** — ${e.description || '(no description)'}`)
19
- .join('\n');
20
- return { content: [{ type: 'text', text }] };
21
- });
22
- }
23
- /**
24
- * `browse` — the ls-with-descriptions primitive. Returns the description of
25
- * the directory itself plus the entries inside (files and subdirectories),
26
- * each with their own description. One tool call per directory is enough to
27
- * decide what to drill into next.
28
- */
29
- export function registerBrowseTool(server, client) {
30
- server.tool('browse', 'List the contents of a directory in the VFS with a description for each entry. Path is VFS-relative, e.g. "my-source" or "my-source/subdir". Omit `path` to browse the root. Prefer this over `read_file` for navigation — reading catalog descriptions is much cheaper than reading every file.', {
31
- path: z
32
- .string()
33
- .optional()
34
- .describe('VFS path to the directory. Examples: "my-source", "my-source/tech", "". Leave empty for the root.'),
35
- }, async ({ path }) => {
36
- const normalised = (path ?? '').replace(/\/$/, '');
37
- try {
38
- const catalog = await client.readDirectoryCatalog(normalised);
39
- const lines = [
40
- normalised === '' ? '# / (root)' : `# /${normalised}`,
41
- '',
42
- catalog.description ? catalog.description : '(no directory description)',
43
- '',
44
- '## Entries',
45
- ];
46
- if (!catalog.entries || catalog.entries.length === 0) {
47
- lines.push('_(empty)_');
48
- }
49
- else {
50
- for (const entry of catalog.entries) {
51
- lines.push(`- **${entry.path}** (${entry.type}) — ${entry.description || '(no description)'}`);
52
- }
53
- }
54
- return { content: [{ type: 'text', text: lines.join('\n') }] };
55
- }
56
- catch (error) {
57
- if (error instanceof ContextServerError && error.status === 404) {
58
- return {
59
- content: [
60
- {
61
- type: 'text',
62
- text: `No directory catalog found at "${normalised}". The path may not exist or may not have been indexed yet. Try \`list_sources\` to see what's available.`,
63
- },
64
- ],
65
- isError: true,
66
- };
67
- }
68
- throw error;
69
- }
70
- });
71
- }
72
- /**
73
- * `tree` — a compact recursive listing of a VFS subtree. One call gives a
74
- * full picture of everything available under `path`, up to `maxDepth` levels.
75
- * Rendered as an indented outline so the LLM can scan it line-by-line.
76
- */
77
- export function registerTreeTool(server, client) {
78
- server.tool('tree', 'Recursively list directories + files under a VFS path, with depth information. Returns a compact outline — much cheaper than chained `browse` calls when you want a broad map. Defaults to depth 3; max 10.', {
79
- path: z
80
- .string()
81
- .optional()
82
- .describe('VFS path to the subtree root. Examples: "my-source", "my-source/tech". Omit for the whole VFS.'),
83
- maxDepth: z
84
- .number()
85
- .int()
86
- .min(1)
87
- .max(10)
88
- .optional()
89
- .describe('How many levels deep to descend (default 3, hard cap 10).'),
90
- }, async ({ path, maxDepth }) => {
91
- const result = await client.tree(path, maxDepth);
92
- if (result.entries.length === 0) {
93
- return {
94
- content: [
95
- {
96
- type: 'text',
97
- text: `No entries under ${result.root ? `"${result.root}"` : 'the VFS root'} (or it doesn't exist).`,
98
- },
99
- ],
100
- };
101
- }
102
- const lines = formatTree(result.entries);
103
- const footer = result.truncated ? '\n\n(truncated — pass a more specific `path` or a smaller `maxDepth`)' : '';
104
- const header = result.root ? `# /${result.root}\n` : '# / (root)\n';
105
- return { content: [{ type: 'text', text: header + lines + footer }] };
106
- });
107
- }
108
- function formatTree(entries) {
109
- return entries
110
- .map((e) => {
111
- const indent = ' '.repeat(Math.max(0, e.depth - 1));
112
- const suffix = e.type === 'directory' ? '/' : '';
113
- // Show only the leaf name so the indent carries hierarchy; keep full path
114
- // available for follow-up tool calls via the leading ` ` (agents can
115
- // reconstruct it or we can be explicit). Being explicit is cheaper to
116
- // read — emit the full path.
117
- return `${indent}- ${e.path}${suffix}`;
118
- })
119
- .join('\n');
120
- }
121
- //# sourceMappingURL=navigate.js.map