@icure/cardinal-mcp-server 1.0.0

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 (79) hide show
  1. package/dist/helpers/docs-loader.d.ts +56 -0
  2. package/dist/helpers/docs-loader.d.ts.map +1 -0
  3. package/dist/helpers/docs-loader.js +14 -0
  4. package/dist/helpers/docs-loader.js.map +1 -0
  5. package/dist/helpers/filter-builder.d.ts +7 -0
  6. package/dist/helpers/filter-builder.d.ts.map +1 -0
  7. package/dist/helpers/filter-builder.js +53 -0
  8. package/dist/helpers/filter-builder.js.map +1 -0
  9. package/dist/helpers/model-builder.d.ts +10 -0
  10. package/dist/helpers/model-builder.d.ts.map +1 -0
  11. package/dist/helpers/model-builder.js +64 -0
  12. package/dist/helpers/model-builder.js.map +1 -0
  13. package/dist/helpers/pagination.d.ts +13 -0
  14. package/dist/helpers/pagination.d.ts.map +1 -0
  15. package/dist/helpers/pagination.js +56 -0
  16. package/dist/helpers/pagination.js.map +1 -0
  17. package/dist/helpers/serialization.d.ts +7 -0
  18. package/dist/helpers/serialization.d.ts.map +1 -0
  19. package/dist/helpers/serialization.js +36 -0
  20. package/dist/helpers/serialization.js.map +1 -0
  21. package/dist/index.d.ts +3 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +13 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/resources/api-docs.d.ts +3 -0
  26. package/dist/resources/api-docs.d.ts.map +1 -0
  27. package/dist/resources/api-docs.js +63 -0
  28. package/dist/resources/api-docs.js.map +1 -0
  29. package/dist/resources/filter-docs.d.ts +3 -0
  30. package/dist/resources/filter-docs.d.ts.map +1 -0
  31. package/dist/resources/filter-docs.js +56 -0
  32. package/dist/resources/filter-docs.js.map +1 -0
  33. package/dist/resources/model-docs.d.ts +3 -0
  34. package/dist/resources/model-docs.d.ts.map +1 -0
  35. package/dist/resources/model-docs.js +59 -0
  36. package/dist/resources/model-docs.js.map +1 -0
  37. package/dist/resources/overview.d.ts +3 -0
  38. package/dist/resources/overview.d.ts.map +1 -0
  39. package/dist/resources/overview.js +76 -0
  40. package/dist/resources/overview.js.map +1 -0
  41. package/dist/resources/search.d.ts +3 -0
  42. package/dist/resources/search.d.ts.map +1 -0
  43. package/dist/resources/search.js +121 -0
  44. package/dist/resources/search.js.map +1 -0
  45. package/dist/resources/tutorial-docs.d.ts +3 -0
  46. package/dist/resources/tutorial-docs.d.ts.map +1 -0
  47. package/dist/resources/tutorial-docs.js +42 -0
  48. package/dist/resources/tutorial-docs.js.map +1 -0
  49. package/dist/server.d.ts +3 -0
  50. package/dist/server.d.ts.map +1 -0
  51. package/dist/server.js +38 -0
  52. package/dist/server.js.map +1 -0
  53. package/dist/tools/admin-tools.d.ts +3 -0
  54. package/dist/tools/admin-tools.d.ts.map +1 -0
  55. package/dist/tools/admin-tools.js +13 -0
  56. package/dist/tools/admin-tools.js.map +1 -0
  57. package/dist/tools/crypto-tools.d.ts +3 -0
  58. package/dist/tools/crypto-tools.d.ts.map +1 -0
  59. package/dist/tools/crypto-tools.js +13 -0
  60. package/dist/tools/crypto-tools.js.map +1 -0
  61. package/dist/tools/data-owner-tools.d.ts +3 -0
  62. package/dist/tools/data-owner-tools.d.ts.map +1 -0
  63. package/dist/tools/data-owner-tools.js +24 -0
  64. package/dist/tools/data-owner-tools.js.map +1 -0
  65. package/dist/tools/dispatch.d.ts +16 -0
  66. package/dist/tools/dispatch.d.ts.map +1 -0
  67. package/dist/tools/dispatch.js +141 -0
  68. package/dist/tools/dispatch.js.map +1 -0
  69. package/dist/tools/init.d.ts +3 -0
  70. package/dist/tools/init.d.ts.map +1 -0
  71. package/dist/tools/init.js +45 -0
  72. package/dist/tools/init.js.map +1 -0
  73. package/dist/tools/sdk-state.d.ts +5 -0
  74. package/dist/tools/sdk-state.d.ts.map +1 -0
  75. package/dist/tools/sdk-state.js +14 -0
  76. package/dist/tools/sdk-state.js.map +1 -0
  77. package/generated/docs-manifest.json +33264 -0
  78. package/generated/method-registry.ts +9453 -0
  79. package/package.json +45 -0
@@ -0,0 +1,56 @@
1
+ export interface ParamDoc {
2
+ name: string;
3
+ type: string;
4
+ description: string;
5
+ optional: boolean;
6
+ }
7
+ export interface MethodDoc {
8
+ name: string;
9
+ description: string;
10
+ params: ParamDoc[];
11
+ returnType: string;
12
+ throws?: string[];
13
+ flavours: string[];
14
+ }
15
+ export interface ApiDoc {
16
+ name: string;
17
+ description: string;
18
+ isEncryptable: boolean;
19
+ methods: MethodDoc[];
20
+ }
21
+ export interface ModelField {
22
+ name: string;
23
+ type: string;
24
+ description: string;
25
+ }
26
+ export interface ModelDoc {
27
+ name: string;
28
+ variants?: string[];
29
+ implements?: string[];
30
+ fields: ModelField[];
31
+ }
32
+ export interface FilterMethodDoc {
33
+ name: string;
34
+ description: string;
35
+ params: Array<{
36
+ name: string;
37
+ type: string;
38
+ }>;
39
+ }
40
+ export interface FilterDoc {
41
+ entityName: string;
42
+ methods: FilterMethodDoc[];
43
+ }
44
+ export interface TutorialDoc {
45
+ slug: string;
46
+ title: string;
47
+ content: string;
48
+ }
49
+ export interface DocsManifest {
50
+ apis: Record<string, ApiDoc>;
51
+ models: Record<string, ModelDoc>;
52
+ filters: Record<string, FilterDoc>;
53
+ tutorials: TutorialDoc[];
54
+ }
55
+ export declare function getManifest(): DocsManifest;
56
+ //# sourceMappingURL=docs-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-loader.d.ts","sourceRoot":"","sources":["../../src/helpers/docs-loader.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,QAAQ,EAAE,CAAC;IACn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BAAgB,WAAW,IAAI,YAAY,CAO1C"}
@@ -0,0 +1,14 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
+ let cachedManifest = null;
6
+ export function getManifest() {
7
+ if (!cachedManifest) {
8
+ const manifestPath = path.resolve(__dirname, "..", "..", "generated", "docs-manifest.json");
9
+ const raw = fs.readFileSync(manifestPath, "utf-8");
10
+ cachedManifest = JSON.parse(raw);
11
+ }
12
+ return cachedManifest;
13
+ }
14
+ //# sourceMappingURL=docs-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-loader.js","sourceRoot":"","sources":["../../src/helpers/docs-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AA8D/D,IAAI,cAAc,GAAwB,IAAI,CAAC;AAE/C,MAAM,UAAU,WAAW;IAC1B,IAAI,CAAC,cAAc,EAAE,CAAC;QACrB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,CAAC,CAAC;QAC5F,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACnD,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAiB,CAAC;IAClD,CAAC;IACD,OAAO,cAAc,CAAC;AACvB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Build a filter from a JSON description.
3
+ * If the input has a _factory property, it's resolved to a filter factory function.
4
+ * Otherwise, the object is returned as-is (may already be a filter instance).
5
+ */
6
+ export declare function buildFilter(filterDesc: Record<string, unknown>): unknown;
7
+ //# sourceMappingURL=filter-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-builder.d.ts","sourceRoot":"","sources":["../../src/helpers/filter-builder.ts"],"names":[],"mappings":"AASA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CA+BxE"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Constructs filter objects from JSON descriptions.
3
+ * Input format: { "_factory": "PatientFilters.bySsinsForSelf", "ssins": ["123456"] }
4
+ * Maps to actual SDK filter factory calls.
5
+ */
6
+ import * as cardinalSdk from "@icure/cardinal-sdk";
7
+ const filters = cardinalSdk.filters;
8
+ /**
9
+ * Build a filter from a JSON description.
10
+ * If the input has a _factory property, it's resolved to a filter factory function.
11
+ * Otherwise, the object is returned as-is (may already be a filter instance).
12
+ */
13
+ export function buildFilter(filterDesc) {
14
+ const factory = filterDesc._factory;
15
+ if (typeof factory !== "string") {
16
+ return filterDesc;
17
+ }
18
+ // Parse "EntityFilters.methodName" format
19
+ const [factoryObject, methodName] = factory.split(".");
20
+ if (!factoryObject || !methodName) {
21
+ throw new Error(`Invalid filter factory format: "${factory}". Expected "EntityFilters.methodName".`);
22
+ }
23
+ // Resolve the filter factory object
24
+ const factoryObj = resolveFilterFactory(factoryObject);
25
+ if (!factoryObj) {
26
+ throw new Error(`Filter factory "${factoryObject}" not found in SDK.`);
27
+ }
28
+ const factoryFn = factoryObj[methodName];
29
+ if (typeof factoryFn !== "function") {
30
+ throw new Error(`Method "${methodName}" not found on "${factoryObject}".`);
31
+ }
32
+ // Extract params (everything except _factory)
33
+ const params = { ...filterDesc };
34
+ delete params._factory;
35
+ // Call the factory function with the params spread as arguments
36
+ // Most filter factories use positional args matching param names
37
+ const paramValues = Object.values(params);
38
+ return factoryFn(...paramValues);
39
+ }
40
+ function resolveFilterFactory(name) {
41
+ // Try in filters namespace
42
+ if (filters) {
43
+ const factory = filters[name];
44
+ if (factory)
45
+ return factory;
46
+ }
47
+ // Try in top-level exports
48
+ const topLevel = cardinalSdk[name];
49
+ if (topLevel)
50
+ return topLevel;
51
+ return null;
52
+ }
53
+ //# sourceMappingURL=filter-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-builder.js","sourceRoot":"","sources":["../../src/helpers/filter-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AAEnD,MAAM,OAAO,GAAI,WAAuC,CAAC,OAA8C,CAAC;AAExG;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,UAAmC;IAC9D,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC;IACpC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,0CAA0C;IAC1C,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvD,IAAI,CAAC,aAAa,IAAI,CAAC,UAAU,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,mCAAmC,OAAO,yCAAyC,CAAC,CAAC;IACtG,CAAC;IAED,oCAAoC;IACpC,MAAM,UAAU,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAAC;IACvD,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,mBAAmB,aAAa,qBAAqB,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,SAAS,GAAI,UAAsC,CAAC,UAAU,CAAC,CAAC;IACtE,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,mBAAmB,aAAa,IAAI,CAAC,CAAC;IAC5E,CAAC;IAED,8CAA8C;IAC9C,MAAM,MAAM,GAAG,EAAE,GAAG,UAAU,EAAE,CAAC;IACjC,OAAO,MAAM,CAAC,QAAQ,CAAC;IAEvB,gEAAgE;IAChE,iEAAiE;IACjE,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAQ,SAA6C,CAAC,GAAG,WAAW,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACzC,2BAA2B;IAC3B,IAAI,OAAO,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC;IAC7B,CAAC;IAED,2BAA2B;IAC3B,MAAM,QAAQ,GAAI,WAAuC,CAAC,IAAI,CAAC,CAAC;IAChE,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAE9B,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Tries to construct a model instance from a plain JSON object.
3
+ * Falls back to returning the plain object if no constructor is found.
4
+ */
5
+ export declare function buildModel(typeName: string, data: Record<string, unknown>): unknown;
6
+ /**
7
+ * Resolves a type name with "Decrypted" or "Encrypted" prefix.
8
+ */
9
+ export declare function buildEntityModel(typeName: string, data: Record<string, unknown>, flavour?: string): unknown;
10
+ //# sourceMappingURL=model-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-builder.d.ts","sourceRoot":"","sources":["../../src/helpers/model-builder.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAcnF;AA8BD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAS3G"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Constructs SDK model instances from plain JSON objects.
3
+ * Most TypeScript model classes accept Partial<T> in constructors.
4
+ */
5
+ import * as cardinalSdk from "@icure/cardinal-sdk";
6
+ // Access model namespace
7
+ const model = cardinalSdk.model;
8
+ /**
9
+ * Tries to construct a model instance from a plain JSON object.
10
+ * Falls back to returning the plain object if no constructor is found.
11
+ */
12
+ export function buildModel(typeName, data) {
13
+ // Try to find the class in the SDK exports
14
+ const Constructor = resolveConstructor(typeName);
15
+ if (Constructor) {
16
+ try {
17
+ return new Constructor(data);
18
+ }
19
+ catch {
20
+ // Some constructors may have different signatures, fall back to plain object
21
+ return data;
22
+ }
23
+ }
24
+ return data;
25
+ }
26
+ function resolveConstructor(typeName) {
27
+ // Try direct lookup in top-level exports
28
+ const directExport = cardinalSdk[typeName];
29
+ if (typeof directExport === "function") {
30
+ return directExport;
31
+ }
32
+ // Try in model namespace
33
+ if (model) {
34
+ const modelExport = model[typeName];
35
+ if (typeof modelExport === "function") {
36
+ return modelExport;
37
+ }
38
+ // Try nested namespaces (e.g., model.embed, model.base)
39
+ for (const ns of Object.values(model)) {
40
+ if (ns && typeof ns === "object") {
41
+ const nested = ns[typeName];
42
+ if (typeof nested === "function") {
43
+ return nested;
44
+ }
45
+ }
46
+ }
47
+ }
48
+ return null;
49
+ }
50
+ /**
51
+ * Resolves a type name with "Decrypted" or "Encrypted" prefix.
52
+ */
53
+ export function buildEntityModel(typeName, data, flavour) {
54
+ if (flavour === "encrypted") {
55
+ return buildModel("Encrypted" + typeName, data);
56
+ }
57
+ // Default to Decrypted for encryptable entities
58
+ const decrypted = buildModel("Decrypted" + typeName, data);
59
+ if (decrypted !== data)
60
+ return decrypted;
61
+ // Fallback to plain type name
62
+ return buildModel(typeName, data);
63
+ }
64
+ //# sourceMappingURL=model-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-builder.js","sourceRoot":"","sources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,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,IAA6B,EAAE,OAAgB;IACjG,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC,WAAW,GAAG,QAAQ,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,gDAAgD;IAChD,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,GAAG,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC3D,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACzC,8BAA8B;IAC9B,OAAO,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export interface PaginatedListIterator<T> {
3
+ hasNext(): Promise<boolean>;
4
+ next(limit: number): Promise<Array<T>>;
5
+ }
6
+ export declare function storeIterator(iterator: PaginatedListIterator<unknown>): string;
7
+ export declare function collectFirstPage<T>(iterator: PaginatedListIterator<T>, pageSize?: number): Promise<{
8
+ items: T[];
9
+ hasMore: boolean;
10
+ iteratorId?: string;
11
+ }>;
12
+ export declare function registerContinueIterationTool(server: McpServer): void;
13
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/helpers/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACvC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;CACvC;AAMD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,MAAM,CAK9E;AAWD,wBAAsB,gBAAgB,CAAC,CAAC,EACvC,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAClC,QAAQ,SAAM,GACZ,OAAO,CAAC;IAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAUhE;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,SAAS,QAmC9D"}
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ import { randomUUID } from "node:crypto";
3
+ const iteratorStore = new Map();
4
+ const ITERATOR_TTL_MS = 10 * 60 * 1000; // 10 minutes
5
+ export function storeIterator(iterator) {
6
+ const id = randomUUID();
7
+ iteratorStore.set(id, { iterator, createdAt: Date.now() });
8
+ cleanupExpired();
9
+ return id;
10
+ }
11
+ function cleanupExpired() {
12
+ const now = Date.now();
13
+ for (const [id, entry] of iteratorStore) {
14
+ if (now - entry.createdAt > ITERATOR_TTL_MS) {
15
+ iteratorStore.delete(id);
16
+ }
17
+ }
18
+ }
19
+ export async function collectFirstPage(iterator, pageSize = 100) {
20
+ const items = await iterator.next(pageSize);
21
+ const hasMore = await iterator.hasNext();
22
+ if (hasMore) {
23
+ const iteratorId = storeIterator(iterator);
24
+ return { items, hasMore: true, iteratorId };
25
+ }
26
+ return { items, hasMore: false };
27
+ }
28
+ export function registerContinueIterationTool(server) {
29
+ server.tool("cardinal_continue_iteration", "Fetch the next page of results from a paginated query. Use the iteratorId returned by a previous call.", {
30
+ iteratorId: z.string().describe("The iterator ID from a previous paginated response"),
31
+ pageSize: z.number().optional().default(100).describe("Number of items to fetch (default 100)"),
32
+ }, async ({ iteratorId, pageSize }) => {
33
+ const entry = iteratorStore.get(iteratorId);
34
+ if (!entry) {
35
+ return {
36
+ content: [{
37
+ type: "text",
38
+ text: JSON.stringify({ error: "Iterator not found or expired. Start a new query." }),
39
+ }],
40
+ isError: true,
41
+ };
42
+ }
43
+ const items = await entry.iterator.next(pageSize);
44
+ const hasMore = await entry.iterator.hasNext();
45
+ if (!hasMore) {
46
+ iteratorStore.delete(iteratorId);
47
+ }
48
+ return {
49
+ content: [{
50
+ type: "text",
51
+ text: JSON.stringify({ items, hasMore, iteratorId: hasMore ? iteratorId : undefined }, null, 2),
52
+ }],
53
+ };
54
+ });
55
+ }
56
+ //# sourceMappingURL=pagination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/helpers/pagination.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,MAAM,aAAa,GAAG,IAAI,GAAG,EAA2E,CAAC;AAEzG,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAErD,MAAM,UAAU,aAAa,CAAC,QAAwC;IACrE,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC;IACxB,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC3D,cAAc,EAAE,CAAC;IACjB,OAAO,EAAE,CAAC;AACX,CAAC;AAED,SAAS,cAAc;IACtB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,aAAa,EAAE,CAAC;QACzC,IAAI,GAAG,GAAG,KAAK,CAAC,SAAS,GAAG,eAAe,EAAE,CAAC;YAC7C,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACrC,QAAkC,EAClC,QAAQ,GAAG,GAAG;IAEd,MAAM,KAAK,GAAG,MAAM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AC,MAAM,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QAED,OAAO;YACN,OAAO,EAAE,CAAC;oBACT,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC/F,CAAC;SACF,CAAC;IACH,CAAC,CACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Serializes SDK results to JSON-safe objects.
3
+ * Handles special types and strips internal properties.
4
+ */
5
+ export declare function serializeResult(value: unknown): unknown;
6
+ export declare function formatResponse(data: unknown): string;
7
+ //# sourceMappingURL=serialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/helpers/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA6BvD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Serializes SDK results to JSON-safe objects.
3
+ * Handles special types and strips internal properties.
4
+ */
5
+ export function serializeResult(value) {
6
+ if (value === null || value === undefined)
7
+ return value;
8
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean")
9
+ return value;
10
+ if (Array.isArray(value)) {
11
+ return value.map(serializeResult);
12
+ }
13
+ if (value instanceof Date) {
14
+ return value.toISOString();
15
+ }
16
+ if (typeof value === "object") {
17
+ // If the object has a toJSON method, use it
18
+ if ("toJSON" in value && typeof value.toJSON === "function") {
19
+ return value.toJSON();
20
+ }
21
+ // Otherwise serialize each property
22
+ const result = {};
23
+ for (const [key, val] of Object.entries(value)) {
24
+ // Skip internal properties
25
+ if (key.startsWith("__") || key.startsWith("$"))
26
+ continue;
27
+ result[key] = serializeResult(val);
28
+ }
29
+ return result;
30
+ }
31
+ return String(value);
32
+ }
33
+ export function formatResponse(data) {
34
+ return JSON.stringify(serializeResult(data), null, 2);
35
+ }
36
+ //# sourceMappingURL=serialization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/helpers/serialization.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC7C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAEvG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,4CAA4C;QAC5C,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAQ,KAA6B,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACtF,OAAQ,KAAmC,CAAC,MAAM,EAAE,CAAC;QACtD,CAAC;QAED,oCAAoC;QACpC,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChD,2BAA2B;YAC3B,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;gBAAE,SAAS;YAC1D,MAAM,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAa;IAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { createServer } from "./server.js";
4
+ async function main() {
5
+ const server = createServer();
6
+ const transport = new StdioServerTransport();
7
+ await server.connect(transport);
8
+ }
9
+ main().catch((error) => {
10
+ console.error("Fatal error:", error);
11
+ process.exit(1);
12
+ });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,KAAK,UAAU,IAAI;IAClB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACtB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerApiDocs(server: McpServer): void;
3
+ //# sourceMappingURL=api-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-docs.d.ts","sourceRoot":"","sources":["../../src/resources/api-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AAGtF,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,QA0EhD"}
@@ -0,0 +1,63 @@
1
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { getManifest } from "../helpers/docs-loader.js";
3
+ export function registerApiDocs(server) {
4
+ server.resource("api-docs", new ResourceTemplate("cardinal://docs/api/{apiName}", {
5
+ list: async () => {
6
+ const manifest = getManifest();
7
+ return {
8
+ resources: Object.keys(manifest.apis).sort().map(name => ({
9
+ uri: `cardinal://docs/api/${name}`,
10
+ name: `${name}Api`,
11
+ description: manifest.apis[name].description,
12
+ })),
13
+ };
14
+ },
15
+ }), {
16
+ title: "API Documentation",
17
+ description: "Full reference for a Cardinal SDK API",
18
+ mimeType: "text/markdown",
19
+ }, async (uri, variables) => {
20
+ const apiName = variables.apiName;
21
+ const manifest = getManifest();
22
+ const api = manifest.apis[apiName];
23
+ if (!api) {
24
+ const available = Object.keys(manifest.apis).sort().join(", ");
25
+ return {
26
+ contents: [{
27
+ uri: uri.href,
28
+ mimeType: "text/markdown",
29
+ text: `# API Not Found: ${apiName}\n\nAvailable APIs: ${available}`,
30
+ }],
31
+ };
32
+ }
33
+ let md = `# ${api.name}\n\n${api.description}\n\n`;
34
+ if (api.isEncryptable) {
35
+ md += `> **Encryptable Entity** — Supports flavours: decrypted (default), encrypted, tryAndRecover\n\n`;
36
+ }
37
+ md += `## Methods (${api.methods.length})\n\n`;
38
+ for (const method of api.methods) {
39
+ md += `### ${method.name}\n\n`;
40
+ if (method.description) {
41
+ md += `${method.description}\n\n`;
42
+ }
43
+ if (method.params.length > 0) {
44
+ md += `**Parameters:**\n`;
45
+ for (const param of method.params) {
46
+ const opt = param.optional ? " *(optional)*" : "";
47
+ const desc = param.description ? ` — ${param.description}` : "";
48
+ md += `- \`${param.name}\`: \`${param.type}\`${opt}${desc}\n`;
49
+ }
50
+ md += "\n";
51
+ }
52
+ md += `**Returns:** \`${method.returnType}\`\n\n`;
53
+ if (method.throws && method.throws.length > 0) {
54
+ md += `**Throws:** ${method.throws.join(", ")}\n\n`;
55
+ }
56
+ md += "---\n\n";
57
+ }
58
+ return {
59
+ contents: [{ uri: uri.href, mimeType: "text/markdown", text: md }],
60
+ };
61
+ });
62
+ }
63
+ //# sourceMappingURL=api-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-docs.js","sourceRoot":"","sources":["../../src/resources/api-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,UAAU,eAAe,CAAC,MAAiB;IAChD,MAAM,CAAC,QAAQ,CACd,UAAU,EACV,IAAI,gBAAgB,CAAC,+BAA+B,EAAE;QACrD,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;YAC/B,OAAO;gBACN,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBACzD,GAAG,EAAE,uBAAuB,IAAI,EAAE;oBAClC,IAAI,EAAE,GAAG,IAAI,KAAK;oBAClB,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW;iBAC5C,CAAC,CAAC;aACH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mB,CAAC;gBAC1B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;oBACnC,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;oBAClD,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBAChE,EAAE,IAAI,OAAO,KAAK,CAAC,IAAI,SAAS,KAAK,CAAC,IAAI,KAAK,GAAG,GAAG,IAAI,IAAI,CAAC;gBAC/D,CAAC;gBACD,EAAE,IAAI,IAAI,CAAC;YACZ,CAAC;YAED,EAAE,IAAI,kBAAkB,MAAM,CAAC,UAAU,QAAQ,CAAC;YAElD,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/C,EAAE,IAAI,eAAe,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YACrD,CAAC;YAED,EAAE,IAAI,SAAS,CAAC;QACjB,CAAC;QAED,OAAO;YACN,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;SAClE,CAAC;IACH,CAAC,CACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerFilterDocs(server: McpServer): void;
3
+ //# sourceMappingURL=filter-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-docs.d.ts","sourceRoot":"","sources":["../../src/resources/filter-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AAGtF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,QA6DnD"}
@@ -0,0 +1,56 @@
1
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { getManifest } from "../helpers/docs-loader.js";
3
+ export function registerFilterDocs(server) {
4
+ server.resource("filter-docs", new ResourceTemplate("cardinal://docs/filter/{entityName}", {
5
+ list: async () => {
6
+ const manifest = getManifest();
7
+ return {
8
+ resources: Object.keys(manifest.filters).sort().map(name => ({
9
+ uri: `cardinal://docs/filter/${name}`,
10
+ name: `${name}Filters`,
11
+ description: `${manifest.filters[name].methods.length} filter methods for ${name}`,
12
+ })),
13
+ };
14
+ },
15
+ }), {
16
+ title: "Filter Documentation",
17
+ description: "Available filter factory methods for an entity type",
18
+ mimeType: "text/markdown",
19
+ }, async (uri, variables) => {
20
+ const entityName = variables.entityName;
21
+ const manifest = getManifest();
22
+ const filter = manifest.filters[entityName];
23
+ if (!filter) {
24
+ const available = Object.keys(manifest.filters).sort().join(", ");
25
+ return {
26
+ contents: [{
27
+ uri: uri.href,
28
+ mimeType: "text/markdown",
29
+ text: `# Filters Not Found: ${entityName}\n\nAvailable: ${available}`,
30
+ }],
31
+ };
32
+ }
33
+ let md = `# ${entityName}Filters\n\n`;
34
+ md += `Filter factory methods for querying ${entityName} entities.\n\n`;
35
+ md += `## Usage with MCP tools\n\n`;
36
+ md += `Pass filters as the \`filter\` parameter using the \`_factory\` format:\n`;
37
+ md += `\`\`\`json\n`;
38
+ md += `{\n`;
39
+ md += ` "filter": {\n`;
40
+ md += ` "_factory": "${entityName}Filters.methodName",\n`;
41
+ md += ` "param1": "value1"\n`;
42
+ md += ` }\n`;
43
+ md += `}\n`;
44
+ md += `\`\`\`\n\n`;
45
+ md += `## Methods (${filter.methods.length})\n\n`;
46
+ for (const method of filter.methods) {
47
+ const paramStr = method.params.map(p => `${p.name}: ${p.type}`).join(", ");
48
+ md += `### ${method.name}\n`;
49
+ md += `\`\`\`typescript\n${entityName}Filters.${method.name}(${paramStr})\n\`\`\`\n\n`;
50
+ }
51
+ return {
52
+ contents: [{ uri: uri.href, mimeType: "text/markdown", text: md }],
53
+ };
54
+ });
55
+ }
56
+ //# sourceMappingURL=filter-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-docs.js","sourceRoot":"","sources":["../../src/resources/filter-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IACnD,MAAM,CAAC,QAAQ,CACd,aAAa,EACb,IAAI,gBAAgB,CAAC,qCAAqC,EAAE;QAC3D,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;YAC/B,OAAO;gBACN,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAC5D,GAAG,EAAE,0BAA0B,IAAI,EAAE;oBACrC,IAAI,EAAE,GAAG,IAAI,SAAS;oBACtB,WAAW,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,uBAAuB,IAAI,EAAE;iBAClF,CAAC,CAAC;aACH,CAAC;QACH,CAAC;KACD,CAAC,EACF;QACC,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,qDAAqD;QAClE,QAAQ,EAAE,eAAe;KACzB,EACD,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE;QACxB,MAAM,UAAU,GAAG,SAAS,CAAC,UAAoB,CAAC;QAClD,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,M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G,EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;SAClE,CAAC;IACH,CAAC,CACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerModelDocs(server: McpServer): void;
3
+ //# sourceMappingURL=model-docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-docs.d.ts","sourceRoot":"","sources":["../../src/resources/model-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AAGtF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,QAiElD"}
@@ -0,0 +1,59 @@
1
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { getManifest } from "../helpers/docs-loader.js";
3
+ export function registerModelDocs(server) {
4
+ server.resource("model-docs", new ResourceTemplate("cardinal://docs/model/{modelName}", {
5
+ list: async () => {
6
+ const manifest = getManifest();
7
+ return {
8
+ resources: Object.keys(manifest.models).sort().map(name => ({
9
+ uri: `cardinal://docs/model/${name}`,
10
+ name,
11
+ description: manifest.models[name].variants
12
+ ? `Encryptable: ${manifest.models[name].variants.join(", ")}`
13
+ : `Model with ${manifest.models[name].fields.length} fields`,
14
+ })),
15
+ };
16
+ },
17
+ }), {
18
+ title: "Model Documentation",
19
+ description: "Model fields, types, variants, and parent interfaces",
20
+ mimeType: "text/markdown",
21
+ }, async (uri, variables) => {
22
+ const modelName = variables.modelName;
23
+ const manifest = getManifest();
24
+ const model = manifest.models[modelName];
25
+ if (!model) {
26
+ const available = Object.keys(manifest.models).sort().join(", ");
27
+ return {
28
+ contents: [{
29
+ uri: uri.href,
30
+ mimeType: "text/markdown",
31
+ text: `# Model Not Found: ${modelName}\n\nAvailable models: ${available}`,
32
+ }],
33
+ };
34
+ }
35
+ let md = `# ${model.name}\n\n`;
36
+ if (model.variants) {
37
+ md += `**Encryptable entity** with variants: ${model.variants.map(v => `\`${v}\``).join(", ")}\n\n`;
38
+ }
39
+ if (model.implements && model.implements.length > 0) {
40
+ md += `**Implements:** ${model.implements.map(i => `\`${i}\``).join(", ")}\n\n`;
41
+ }
42
+ if (model.fields.length > 0) {
43
+ md += `## Fields (${model.fields.length})\n\n`;
44
+ md += "| Field | Type | Description |\n";
45
+ md += "|-------|------|-------------|\n";
46
+ for (const field of model.fields) {
47
+ const desc = field.description || "";
48
+ md += `| \`${field.name}\` | \`${field.type}\` | ${desc} |\n`;
49
+ }
50
+ }
51
+ else {
52
+ md += "*No fields documented.*\n";
53
+ }
54
+ return {
55
+ contents: [{ uri: uri.href, mimeType: "text/markdown", text: md }],
56
+ };
57
+ });
58
+ }
59
+ //# sourceMappingURL=model-docs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-docs.js","sourceRoot":"","sources":["../../src/resources/model-docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IAClD,MAAM,CAAC,QAAQ,CACd,YAAY,EACZ,IAAI,gBAAgB,CAAC,mCAAmC,EAAE;QACzD,IAAI,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;YAC/B,OAAO;gBACN,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAC3D,GAAG,EAAE,yBAAyB,IAAI,EAAE;oBACpC,IAAI;oBACJ,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ;wBAC1C,CAAC,CAAC,gBAAgB,QAAQ,CAAC,MAAM,CAAC,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,mBAAmB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QACjF,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,EAAE,IAAI,cAAc,KAAK,CAAC,MAAM,CAAC,MAAM,OAAO,CAAC;YAC/C,EAAE,IAAI,kCAAkC,CAAC;YACzC,EAAE,IAAI,kCAAkC,CAAC;YACzC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBAClC,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC;gBACrC,EAAE,IAAI,OAAO,KAAK,CAAC,IAAI,UAAU,KAAK,CAAC,IAAI,QAAQ,IAAI,MAAM,CAAC;YAC/D,CAAC;QACF,CAAC;aAAM,CAAC;YACP,EAAE,IAAI,2BAA2B,CAAC;QACnC,CAAC;QAED,OAAO;YACN,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;SAClE,CAAC;IACH,CAAC,CACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerOverview(server: McpServer): void;
3
+ //# sourceMappingURL=overview.d.ts.map