@digital-science-dsl/dimensions-analytics-mcp 0.5.3 → 1.0.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/CHANGELOG.md +4 -56
- package/README.md +1 -5
- package/dist/client/deployment-config.d.ts +20 -2
- package/dist/client/deployment-config.d.ts.map +1 -1
- package/dist/client/deployment-config.js +26 -2
- package/dist/client/deployment-config.js.map +1 -1
- package/dist/client/internal-dsl-client.d.ts +1 -1
- package/dist/client/internal-dsl-client.d.ts.map +1 -1
- package/dist/client/internal-dsl-client.js +2 -5
- package/dist/client/internal-dsl-client.js.map +1 -1
- package/dist/dsl/create-client.d.ts +1 -1
- package/dist/dsl/create-client.js +1 -1
- package/dist/dsl/fluent-query-builder.d.ts +1 -1
- package/dist/dsl/fluent-query-builder.js +1 -1
- package/dist/dsl/schema/cache.d.ts +2 -2
- package/dist/dsl/schema/cache.d.ts.map +1 -1
- package/dist/dsl/schema/cache.js +8 -14
- package/dist/dsl/schema/cache.js.map +1 -1
- package/dist/dsl/schema/load.d.ts +0 -1
- package/dist/dsl/schema/load.d.ts.map +1 -1
- package/dist/dsl/schema/load.js +1 -3
- package/dist/dsl/schema/load.js.map +1 -1
- package/dist/mcp/tools/schema.d.ts +0 -2
- package/dist/mcp/tools/schema.d.ts.map +1 -1
- package/dist/mcp/tools/schema.js.map +1 -1
- package/dist/mcp/utils.d.ts +0 -4
- package/dist/mcp/utils.d.ts.map +1 -1
- package/dist/mcp/utils.js +0 -7
- package/dist/mcp/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/client/deployment-config.ts +39 -2
- package/src/client/internal-dsl-client.ts +2 -6
- package/src/dsl/create-client.ts +1 -1
- package/src/dsl/fluent-query-builder.ts +1 -1
- package/src/dsl/schema/cache.ts +8 -13
- package/src/dsl/schema/load.ts +1 -4
- package/src/mcp/tools/schema.ts +0 -3
- package/src/mcp/utils.ts +0 -12
- package/test/client/deployment-config.test.ts +25 -1
- package/test/client/http-client.test.ts +2 -2
- package/test/client/internal-dsl-client.test.ts +3 -0
- package/test/dsl/schema/cache.test.ts +2 -4
- package/test/helpers/tool-test-harness.ts +2 -19
- package/test/middleware/field-aliases.test.ts +1 -1
- package/test/tools/analytics.test.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/examples/dsl-examples.d.ts +0 -11
- package/dist/examples/dsl-examples.d.ts.map +0 -1
- package/dist/examples/dsl-examples.js +0 -49
- package/dist/examples/dsl-examples.js.map +0 -1
- package/dist/examples/usage-scenarios.d.ts +0 -22
- package/dist/examples/usage-scenarios.d.ts.map +0 -1
- package/dist/examples/usage-scenarios.js +0 -173
- package/dist/examples/usage-scenarios.js.map +0 -1
- package/dist/funder-org-names.d.ts +0 -12
- package/dist/funder-org-names.d.ts.map +0 -1
- package/dist/funder-org-names.js +0 -30
- package/dist/funder-org-names.js.map +0 -1
- package/dist/http.d.ts +0 -29
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -173
- package/dist/http.js.map +0 -1
- package/dist/kwq/build-query.d.ts +0 -26
- package/dist/kwq/build-query.d.ts.map +0 -1
- package/dist/kwq/build-query.js +0 -37
- package/dist/kwq/build-query.js.map +0 -1
- package/dist/kwq/concept-groups.d.ts +0 -49
- package/dist/kwq/concept-groups.d.ts.map +0 -1
- package/dist/kwq/concept-groups.js +0 -55
- package/dist/kwq/concept-groups.js.map +0 -1
- package/dist/kwq/dsl-assembler.d.ts +0 -28
- package/dist/kwq/dsl-assembler.d.ts.map +0 -1
- package/dist/kwq/dsl-assembler.js +0 -124
- package/dist/kwq/dsl-assembler.js.map +0 -1
- package/dist/kwq/ensemble.d.ts +0 -38
- package/dist/kwq/ensemble.d.ts.map +0 -1
- package/dist/kwq/ensemble.js +0 -107
- package/dist/kwq/ensemble.js.map +0 -1
- package/dist/kwq/index.d.ts +0 -16
- package/dist/kwq/index.d.ts.map +0 -1
- package/dist/kwq/index.js +0 -14
- package/dist/kwq/index.js.map +0 -1
- package/dist/kwq/types.d.ts +0 -120
- package/dist/kwq/types.d.ts.map +0 -1
- package/dist/kwq/types.js +0 -11
- package/dist/kwq/types.js.map +0 -1
- package/dist/lambda.d.ts +0 -10
- package/dist/lambda.d.ts.map +0 -1
- package/dist/lambda.js +0 -4
- package/dist/lambda.js.map +0 -1
- package/dist/mcp/tools/concept-profile.d.ts +0 -14
- package/dist/mcp/tools/concept-profile.d.ts.map +0 -1
- package/dist/mcp/tools/concept-profile.js +0 -130
- package/dist/mcp/tools/concept-profile.js.map +0 -1
- package/dist/mcp/tools/dataset-profile.d.ts +0 -15
- package/dist/mcp/tools/dataset-profile.d.ts.map +0 -1
- package/dist/mcp/tools/dataset-profile.js +0 -194
- package/dist/mcp/tools/dataset-profile.js.map +0 -1
- package/dist/mcp/tools/impact-chain.d.ts +0 -15
- package/dist/mcp/tools/impact-chain.d.ts.map +0 -1
- package/dist/mcp/tools/impact-chain.js +0 -96
- package/dist/mcp/tools/impact-chain.js.map +0 -1
- package/dist/mcp/tools/kwq.d.ts +0 -19
- package/dist/mcp/tools/kwq.d.ts.map +0 -1
- package/dist/mcp/tools/kwq.js +0 -156
- package/dist/mcp/tools/kwq.js.map +0 -1
- package/dist/mcp/tools/policy-profile.d.ts +0 -15
- package/dist/mcp/tools/policy-profile.d.ts.map +0 -1
- package/dist/mcp/tools/policy-profile.js +0 -174
- package/dist/mcp/tools/policy-profile.js.map +0 -1
- package/dist/mcp/tools/profile.d.ts +0 -14
- package/dist/mcp/tools/profile.d.ts.map +0 -1
- package/dist/mcp/tools/profile.js +0 -349
- package/dist/mcp/tools/profile.js.map +0 -1
- package/dist/middleware/field-aliases.d.ts +0 -97
- package/dist/middleware/field-aliases.d.ts.map +0 -1
- package/dist/middleware/field-aliases.js +0 -208
- package/dist/middleware/field-aliases.js.map +0 -1
- package/dist/resources/schema.d.ts +0 -13
- package/dist/resources/schema.d.ts.map +0 -1
- package/dist/resources/schema.js +0 -204
- package/dist/resources/schema.js.map +0 -1
- package/dist/schema/context.d.ts +0 -10
- package/dist/schema/context.d.ts.map +0 -1
- package/dist/schema/context.js +0 -6
- package/dist/schema/context.js.map +0 -1
- package/dist/schema/index.d.ts +0 -9
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js +0 -6
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/load.d.ts +0 -43
- package/dist/schema/load.d.ts.map +0 -1
- package/dist/schema/load.js +0 -139
- package/dist/schema/load.js.map +0 -1
- package/dist/schema/store.d.ts +0 -112
- package/dist/schema/store.d.ts.map +0 -1
- package/dist/schema/store.js +0 -173
- package/dist/schema/store.js.map +0 -1
- package/dist/schema/structured-entities.d.ts +0 -21
- package/dist/schema/structured-entities.d.ts.map +0 -1
- package/dist/schema/structured-entities.js +0 -39
- package/dist/schema/structured-entities.js.map +0 -1
- package/dist/schema/types.d.ts +0 -36
- package/dist/schema/types.d.ts.map +0 -1
- package/dist/schema/types.js +0 -6
- package/dist/schema/types.js.map +0 -1
- package/dist/server.d.ts +0 -57
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -144
- package/dist/server.js.map +0 -1
- package/dist/telemetry.d.ts +0 -172
- package/dist/telemetry.d.ts.map +0 -1
- package/dist/telemetry.js +0 -233
- package/dist/telemetry.js.map +0 -1
- package/dist/tools/analytics-filters.d.ts +0 -18
- package/dist/tools/analytics-filters.d.ts.map +0 -1
- package/dist/tools/analytics-filters.js +0 -35
- package/dist/tools/analytics-filters.js.map +0 -1
- package/dist/tools/analytics.d.ts +0 -16
- package/dist/tools/analytics.d.ts.map +0 -1
- package/dist/tools/analytics.js +0 -381
- package/dist/tools/analytics.js.map +0 -1
- package/dist/tools/concept-profile.d.ts +0 -14
- package/dist/tools/concept-profile.d.ts.map +0 -1
- package/dist/tools/concept-profile.js +0 -130
- package/dist/tools/concept-profile.js.map +0 -1
- package/dist/tools/dataset-profile.d.ts +0 -15
- package/dist/tools/dataset-profile.d.ts.map +0 -1
- package/dist/tools/dataset-profile.js +0 -194
- package/dist/tools/dataset-profile.js.map +0 -1
- package/dist/tools/functions.d.ts +0 -14
- package/dist/tools/functions.d.ts.map +0 -1
- package/dist/tools/functions.js +0 -294
- package/dist/tools/functions.js.map +0 -1
- package/dist/tools/impact-chain.d.ts +0 -15
- package/dist/tools/impact-chain.d.ts.map +0 -1
- package/dist/tools/impact-chain.js +0 -96
- package/dist/tools/impact-chain.js.map +0 -1
- package/dist/tools/kwq.d.ts +0 -19
- package/dist/tools/kwq.d.ts.map +0 -1
- package/dist/tools/kwq.js +0 -156
- package/dist/tools/kwq.js.map +0 -1
- package/dist/tools/lookup.d.ts +0 -14
- package/dist/tools/lookup.d.ts.map +0 -1
- package/dist/tools/lookup.js +0 -213
- package/dist/tools/lookup.js.map +0 -1
- package/dist/tools/policy-profile.d.ts +0 -15
- package/dist/tools/policy-profile.d.ts.map +0 -1
- package/dist/tools/policy-profile.js +0 -174
- package/dist/tools/policy-profile.js.map +0 -1
- package/dist/tools/profile.d.ts +0 -14
- package/dist/tools/profile.d.ts.map +0 -1
- package/dist/tools/profile.js +0 -349
- package/dist/tools/profile.js.map +0 -1
- package/dist/tools/query.d.ts +0 -16
- package/dist/tools/query.d.ts.map +0 -1
- package/dist/tools/query.js +0 -53
- package/dist/tools/query.js.map +0 -1
- package/dist/tools/schema.d.ts +0 -23
- package/dist/tools/schema.d.ts.map +0 -1
- package/dist/tools/schema.js +0 -124
- package/dist/tools/schema.js.map +0 -1
- package/dist/tools/search-entity-metadata.d.ts +0 -18
- package/dist/tools/search-entity-metadata.d.ts.map +0 -1
- package/dist/tools/search-entity-metadata.js +0 -221
- package/dist/tools/search-entity-metadata.js.map +0 -1
- package/dist/tools/search.d.ts +0 -23
- package/dist/tools/search.d.ts.map +0 -1
- package/dist/tools/search.js +0 -110
- package/dist/tools/search.js.map +0 -1
- package/dist/tools/solr-fields.d.ts +0 -39
- package/dist/tools/solr-fields.d.ts.map +0 -1
- package/dist/tools/solr-fields.js +0 -40
- package/dist/tools/solr-fields.js.map +0 -1
- package/dist/utils.d.ts +0 -70
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -104
- package/dist/utils.js.map +0 -1
package/dist/schema/load.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Load schema from the Dimensions API or optional disk cache.
|
|
3
|
-
* @module schema/load
|
|
4
|
-
*/
|
|
5
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
6
|
-
import { createSchemaStoreFromResponse } from "./store.js";
|
|
7
|
-
let moduleCache;
|
|
8
|
-
let moduleLoadPromise;
|
|
9
|
-
/**
|
|
10
|
-
* Returns the module-level cached schema store, if loaded.
|
|
11
|
-
* @returns Cached store or undefined before first load
|
|
12
|
-
*/
|
|
13
|
-
export function getCachedSchemaStore() {
|
|
14
|
-
return moduleCache;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Clears the module-level schema cache (for tests and refresh).
|
|
18
|
-
*/
|
|
19
|
-
export function clearSchemaCache() {
|
|
20
|
-
moduleCache = undefined;
|
|
21
|
-
moduleLoadPromise = undefined;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Reads optional cache file from `SCHEMA_CACHE_PATH` or explicit path.
|
|
25
|
-
* @param cachePath - Path to JSON cache file
|
|
26
|
-
* @returns Cached response or undefined
|
|
27
|
-
*/
|
|
28
|
-
async function readCacheFile(cachePath) {
|
|
29
|
-
try {
|
|
30
|
-
const text = await readFile(cachePath, "utf8");
|
|
31
|
-
return JSON.parse(text);
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Writes describe response to cache file.
|
|
39
|
-
* @param cachePath - Path to JSON cache file
|
|
40
|
-
* @param response - Schema response to persist
|
|
41
|
-
*/
|
|
42
|
-
async function writeCacheFile(cachePath, response) {
|
|
43
|
-
await writeFile(cachePath, JSON.stringify(response), "utf8");
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Extracts describe schema payload from a raw API response.
|
|
47
|
-
* @param raw - Raw DSL API response
|
|
48
|
-
* @returns Normalized describe schema object
|
|
49
|
-
*/
|
|
50
|
-
export function extractDescribeSchema(raw) {
|
|
51
|
-
if (typeof raw !== "object" || raw === null) {
|
|
52
|
-
throw new Error("Invalid describe schema response: expected object");
|
|
53
|
-
}
|
|
54
|
-
const record = raw;
|
|
55
|
-
if ("sources" in record || "entities" in record) {
|
|
56
|
-
return {
|
|
57
|
-
sources: record.sources ?? {},
|
|
58
|
-
entities: record.entities ?? {},
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
throw new Error("Invalid describe schema response: missing sources/entities");
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Extracts version string from `describe version` response.
|
|
65
|
-
* @param raw - Raw DSL API response
|
|
66
|
-
* @returns Version string or undefined
|
|
67
|
-
*/
|
|
68
|
-
export function extractDescribeVersion(raw) {
|
|
69
|
-
if (typeof raw !== "object" || raw === null) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
const record = raw;
|
|
73
|
-
if (typeof record.version === "string") {
|
|
74
|
-
return record.version;
|
|
75
|
-
}
|
|
76
|
-
if (typeof record.release === "string") {
|
|
77
|
-
return record.release;
|
|
78
|
-
}
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Fetches schema from the Dimensions API.
|
|
83
|
-
* @param client - Authenticated Dimensions client
|
|
84
|
-
* @param cachePath - Optional cache file path
|
|
85
|
-
* @returns Loaded schema store
|
|
86
|
-
*/
|
|
87
|
-
export async function loadSchema(client, cachePath) {
|
|
88
|
-
const resolvedCachePath = cachePath ?? process.env.SCHEMA_CACHE_PATH;
|
|
89
|
-
if (resolvedCachePath) {
|
|
90
|
-
const cached = await readCacheFile(resolvedCachePath);
|
|
91
|
-
if (cached) {
|
|
92
|
-
let version;
|
|
93
|
-
try {
|
|
94
|
-
version = extractDescribeVersion(await client.rawQuery("describe version"));
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
// Version is optional when using cache
|
|
98
|
-
}
|
|
99
|
-
const store = createSchemaStoreFromResponse(cached, version);
|
|
100
|
-
moduleCache = store;
|
|
101
|
-
return store;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const started = performance.now();
|
|
105
|
-
const [schemaRaw, versionRaw] = await Promise.all([
|
|
106
|
-
client.rawQuery("describe schema"),
|
|
107
|
-
client.rawQuery("describe version").catch(() => undefined),
|
|
108
|
-
]);
|
|
109
|
-
const response = extractDescribeSchema(schemaRaw);
|
|
110
|
-
const version = versionRaw ? extractDescribeVersion(versionRaw) : undefined;
|
|
111
|
-
if (resolvedCachePath) {
|
|
112
|
-
await writeCacheFile(resolvedCachePath, response);
|
|
113
|
-
}
|
|
114
|
-
const store = createSchemaStoreFromResponse(response, version);
|
|
115
|
-
moduleCache = store;
|
|
116
|
-
const stats = store.stats();
|
|
117
|
-
console.error(`[schema] loaded ${stats.sourceCount} sources, ${stats.entityCount} entities` +
|
|
118
|
-
(stats.dslVersion ? ` (DSL ${stats.dslVersion})` : "") +
|
|
119
|
-
` in ${Math.round(performance.now() - started)}ms`);
|
|
120
|
-
return store;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Returns cached schema or loads once per process.
|
|
124
|
-
* @param client - Authenticated Dimensions client
|
|
125
|
-
* @param cachePath - Optional cache override
|
|
126
|
-
* @returns Schema store
|
|
127
|
-
*/
|
|
128
|
-
export async function getOrLoadSchema(client, cachePath) {
|
|
129
|
-
if (moduleCache) {
|
|
130
|
-
return moduleCache;
|
|
131
|
-
}
|
|
132
|
-
if (!moduleLoadPromise) {
|
|
133
|
-
moduleLoadPromise = loadSchema(client, cachePath).finally(() => {
|
|
134
|
-
moduleLoadPromise = undefined;
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
return moduleLoadPromise;
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=load.js.map
|
package/dist/schema/load.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/schema/load.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,6BAA6B,EAAoB,MAAM,YAAY,CAAC;AAG7E,IAAI,WAAoC,CAAC;AACzC,IAAI,iBAAmD,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,WAAW,GAAG,SAAS,CAAC;IACxB,iBAAiB,GAAG,SAAS,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,aAAa,CAAC,SAAiB;IAC5C,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAA2B,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,cAAc,CAAC,SAAiB,EAAE,QAAgC;IAC/E,MAAM,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAChD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,MAAM,MAAM,GAAG,GAA8B,CAAC;IAC9C,IAAI,SAAS,IAAI,MAAM,IAAI,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,CAAC;IACD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YAC7D,iBAAiB,GAAG,SAAS,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
package/dist/schema/store.d.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory schema store built from `describe schema` responses.
|
|
3
|
-
* @module schema/store
|
|
4
|
-
*/
|
|
5
|
-
import { type StructuredEntityType } from "./structured-entities.js";
|
|
6
|
-
import type { DescribeSchemaResponse, EntityDescribe, SourceDescribe } from "./types.js";
|
|
7
|
-
/** Operational limits mirrored from upstream DSL constants. */
|
|
8
|
-
export declare const SCHEMA_LIMITS: {
|
|
9
|
-
readonly maxLimit: 1000;
|
|
10
|
-
readonly maxOffset: 50000;
|
|
11
|
-
readonly maxFacetBuckets: 1000;
|
|
12
|
-
readonly requestsPerMinute: 30;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Read-only schema catalog with derived helper views for MCP tools and resources.
|
|
16
|
-
*/
|
|
17
|
-
export declare class SchemaStore {
|
|
18
|
-
#private;
|
|
19
|
-
/**
|
|
20
|
-
* @param response - Parsed `describe schema` payload
|
|
21
|
-
* @param version - Optional DSL version from `describe version`
|
|
22
|
-
* @param loadedAt - Timestamp when schema was loaded
|
|
23
|
-
*/
|
|
24
|
-
constructor(response: DescribeSchemaResponse, version?: string, loadedAt?: Date);
|
|
25
|
-
/** DSL version string, if known. */
|
|
26
|
-
get version(): string | undefined;
|
|
27
|
-
/** When this store was populated. */
|
|
28
|
-
get loadedAt(): Date;
|
|
29
|
-
/** Full describe payload. */
|
|
30
|
-
get raw(): DescribeSchemaResponse;
|
|
31
|
-
/** All source names. */
|
|
32
|
-
sourceNames(): readonly string[];
|
|
33
|
-
/** All auxiliary entity names. */
|
|
34
|
-
entityNames(): readonly string[];
|
|
35
|
-
/**
|
|
36
|
-
* Returns a source schema by name.
|
|
37
|
-
* @param name - Source name (e.g. `publications`)
|
|
38
|
-
* @returns Source schema or undefined
|
|
39
|
-
*/
|
|
40
|
-
getSource(name: string): SourceDescribe | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Returns an auxiliary entity schema by name.
|
|
43
|
-
* @param name - Entity name (e.g. `journals`)
|
|
44
|
-
* @returns Entity schema or undefined
|
|
45
|
-
*/
|
|
46
|
-
getEntity(name: string): EntityDescribe | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* Filterable field names for a source.
|
|
49
|
-
* @param source - Source name
|
|
50
|
-
* @returns Field names where `is_filter` is true
|
|
51
|
-
*/
|
|
52
|
-
filterableFields(source: string): readonly string[];
|
|
53
|
-
/**
|
|
54
|
-
* Facet field names for a source.
|
|
55
|
-
* @param source - Source name
|
|
56
|
-
* @returns Field names marked as facets or entity fields
|
|
57
|
-
*/
|
|
58
|
-
facetFields(source: string): readonly string[];
|
|
59
|
-
/**
|
|
60
|
-
* Search index names for a source.
|
|
61
|
-
* @param source - Source name
|
|
62
|
-
* @returns Search field/index names
|
|
63
|
-
*/
|
|
64
|
-
searchIndexes(source: string): readonly string[];
|
|
65
|
-
/**
|
|
66
|
-
* Aggregation indicator names for a source.
|
|
67
|
-
* @param source - Source name
|
|
68
|
-
* @returns Metric names
|
|
69
|
-
*/
|
|
70
|
-
metrics(source: string): readonly string[];
|
|
71
|
-
/**
|
|
72
|
-
* Named fieldsets for a source.
|
|
73
|
-
* @param source - Source name
|
|
74
|
-
* @returns Fieldset name to field list map
|
|
75
|
-
*/
|
|
76
|
-
fieldsets(source: string): Readonly<Record<string, readonly string[]>>;
|
|
77
|
-
/**
|
|
78
|
-
* Core entity types supported by structured search tools.
|
|
79
|
-
* @returns Structured sources that exist in the loaded describe schema
|
|
80
|
-
*/
|
|
81
|
-
structuredEntityTypes(): readonly StructuredEntityType[];
|
|
82
|
-
/**
|
|
83
|
-
* Health/stats payload for `/health`.
|
|
84
|
-
* @returns Summary object
|
|
85
|
-
*/
|
|
86
|
-
stats(): {
|
|
87
|
-
dslVersion: string | undefined;
|
|
88
|
-
sourceCount: number;
|
|
89
|
-
entityCount: number;
|
|
90
|
-
schemaLoadedAt: string;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Comma-separated facet fields for tool descriptions.
|
|
94
|
-
* @param source - Source name
|
|
95
|
-
* @returns Hint string
|
|
96
|
-
*/
|
|
97
|
-
facetFieldsHint(source: string): string;
|
|
98
|
-
/**
|
|
99
|
-
* Comma-separated metrics for tool descriptions.
|
|
100
|
-
* @param source - Source name
|
|
101
|
-
* @returns Hint string
|
|
102
|
-
*/
|
|
103
|
-
metricsHint(source: string): string;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Builds a {@link SchemaStore} from a describe response.
|
|
107
|
-
* @param response - `describe schema` JSON
|
|
108
|
-
* @param version - Optional DSL version
|
|
109
|
-
* @returns Schema store instance
|
|
110
|
-
*/
|
|
111
|
-
export declare function createSchemaStoreFromResponse(response: DescribeSchemaResponse, version?: string): SchemaStore;
|
|
112
|
-
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/schema/store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA2B,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEzF,+DAA+D;AAC/D,eAAO,MAAM,aAAa;;;;;CAKhB,CAAC;AAEX;;GAEG;AACH,qBAAa,WAAW;;IAOtB;;;;OAIG;gBACS,QAAQ,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,IAAiB;IAQ3F,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6BAA6B,CAC3C,QAAQ,EAAE,sBAAsB,EAChC,OAAO,CAAC,EAAE,MAAM,GACf,WAAW,CAEb"}
|
package/dist/schema/store.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory schema store built from `describe schema` responses.
|
|
3
|
-
* @module schema/store
|
|
4
|
-
*/
|
|
5
|
-
import { STRUCTURED_ENTITY_TYPES } from "./structured-entities.js";
|
|
6
|
-
/** Operational limits mirrored from upstream DSL constants. */
|
|
7
|
-
export const SCHEMA_LIMITS = {
|
|
8
|
-
maxLimit: 1000,
|
|
9
|
-
maxOffset: 50000,
|
|
10
|
-
maxFacetBuckets: 1000,
|
|
11
|
-
requestsPerMinute: 30,
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Read-only schema catalog with derived helper views for MCP tools and resources.
|
|
15
|
-
*/
|
|
16
|
-
export class SchemaStore {
|
|
17
|
-
#version;
|
|
18
|
-
#loadedAt;
|
|
19
|
-
#sources;
|
|
20
|
-
#entities;
|
|
21
|
-
#raw;
|
|
22
|
-
/**
|
|
23
|
-
* @param response - Parsed `describe schema` payload
|
|
24
|
-
* @param version - Optional DSL version from `describe version`
|
|
25
|
-
* @param loadedAt - Timestamp when schema was loaded
|
|
26
|
-
*/
|
|
27
|
-
constructor(response, version, loadedAt = new Date()) {
|
|
28
|
-
this.#raw = response;
|
|
29
|
-
this.#version = version;
|
|
30
|
-
this.#loadedAt = loadedAt;
|
|
31
|
-
this.#sources = new Map(Object.entries(response.sources ?? {}));
|
|
32
|
-
this.#entities = new Map(Object.entries(response.entities ?? {}));
|
|
33
|
-
}
|
|
34
|
-
/** DSL version string, if known. */
|
|
35
|
-
get version() {
|
|
36
|
-
return this.#version;
|
|
37
|
-
}
|
|
38
|
-
/** When this store was populated. */
|
|
39
|
-
get loadedAt() {
|
|
40
|
-
return this.#loadedAt;
|
|
41
|
-
}
|
|
42
|
-
/** Full describe payload. */
|
|
43
|
-
get raw() {
|
|
44
|
-
return this.#raw;
|
|
45
|
-
}
|
|
46
|
-
/** All source names. */
|
|
47
|
-
sourceNames() {
|
|
48
|
-
return [...this.#sources.keys()].sort();
|
|
49
|
-
}
|
|
50
|
-
/** All auxiliary entity names. */
|
|
51
|
-
entityNames() {
|
|
52
|
-
return [...this.#entities.keys()].sort();
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Returns a source schema by name.
|
|
56
|
-
* @param name - Source name (e.g. `publications`)
|
|
57
|
-
* @returns Source schema or undefined
|
|
58
|
-
*/
|
|
59
|
-
getSource(name) {
|
|
60
|
-
return this.#sources.get(name);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns an auxiliary entity schema by name.
|
|
64
|
-
* @param name - Entity name (e.g. `journals`)
|
|
65
|
-
* @returns Entity schema or undefined
|
|
66
|
-
*/
|
|
67
|
-
getEntity(name) {
|
|
68
|
-
return this.#entities.get(name);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Filterable field names for a source.
|
|
72
|
-
* @param source - Source name
|
|
73
|
-
* @returns Field names where `is_filter` is true
|
|
74
|
-
*/
|
|
75
|
-
filterableFields(source) {
|
|
76
|
-
const fields = this.#sources.get(source)?.fields ?? {};
|
|
77
|
-
return Object.entries(fields)
|
|
78
|
-
.filter(([, f]) => f.is_filter === true)
|
|
79
|
-
.map(([name]) => name)
|
|
80
|
-
.sort();
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Facet field names for a source.
|
|
84
|
-
* @param source - Source name
|
|
85
|
-
* @returns Field names marked as facets or entity fields
|
|
86
|
-
*/
|
|
87
|
-
facetFields(source) {
|
|
88
|
-
const fields = this.#sources.get(source)?.fields ?? {};
|
|
89
|
-
return Object.entries(fields)
|
|
90
|
-
.filter(([, f]) => f.is_facet === true || f.is_entity === true)
|
|
91
|
-
.map(([name]) => name)
|
|
92
|
-
.sort();
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Search index names for a source.
|
|
96
|
-
* @param source - Source name
|
|
97
|
-
* @returns Search field/index names
|
|
98
|
-
*/
|
|
99
|
-
searchIndexes(source) {
|
|
100
|
-
const raw = this.#sources.get(source)?.search_fields;
|
|
101
|
-
if (!raw)
|
|
102
|
-
return [];
|
|
103
|
-
if (Array.isArray(raw))
|
|
104
|
-
return [...raw].sort();
|
|
105
|
-
return Object.keys(raw).sort();
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Aggregation indicator names for a source.
|
|
109
|
-
* @param source - Source name
|
|
110
|
-
* @returns Metric names
|
|
111
|
-
*/
|
|
112
|
-
metrics(source) {
|
|
113
|
-
const raw = this.#sources.get(source)?.metrics;
|
|
114
|
-
if (!raw)
|
|
115
|
-
return [];
|
|
116
|
-
if (Array.isArray(raw))
|
|
117
|
-
return [...raw].sort();
|
|
118
|
-
return Object.keys(raw).sort();
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Named fieldsets for a source.
|
|
122
|
-
* @param source - Source name
|
|
123
|
-
* @returns Fieldset name to field list map
|
|
124
|
-
*/
|
|
125
|
-
fieldsets(source) {
|
|
126
|
-
return this.#sources.get(source)?.fieldsets ?? {};
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Core entity types supported by structured search tools.
|
|
130
|
-
* @returns Structured sources that exist in the loaded describe schema
|
|
131
|
-
*/
|
|
132
|
-
structuredEntityTypes() {
|
|
133
|
-
return STRUCTURED_ENTITY_TYPES.filter((entity) => this.#sources.has(entity));
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Health/stats payload for `/health`.
|
|
137
|
-
* @returns Summary object
|
|
138
|
-
*/
|
|
139
|
-
stats() {
|
|
140
|
-
return {
|
|
141
|
-
dslVersion: this.#version,
|
|
142
|
-
sourceCount: this.#sources.size,
|
|
143
|
-
entityCount: this.#entities.size,
|
|
144
|
-
schemaLoadedAt: this.#loadedAt.toISOString(),
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Comma-separated facet fields for tool descriptions.
|
|
149
|
-
* @param source - Source name
|
|
150
|
-
* @returns Hint string
|
|
151
|
-
*/
|
|
152
|
-
facetFieldsHint(source) {
|
|
153
|
-
return this.facetFields(source).join(", ") || "(none)";
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Comma-separated metrics for tool descriptions.
|
|
157
|
-
* @param source - Source name
|
|
158
|
-
* @returns Hint string
|
|
159
|
-
*/
|
|
160
|
-
metricsHint(source) {
|
|
161
|
-
return this.metrics(source).join(", ") || "(none)";
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Builds a {@link SchemaStore} from a describe response.
|
|
166
|
-
* @param response - `describe schema` JSON
|
|
167
|
-
* @param version - Optional DSL version
|
|
168
|
-
* @returns Schema store instance
|
|
169
|
-
*/
|
|
170
|
-
export function createSchemaStoreFromResponse(response, version) {
|
|
171
|
-
return new SchemaStore(response, version);
|
|
172
|
-
}
|
|
173
|
-
//# sourceMappingURL=store.js.map
|
package/dist/schema/store.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/schema/store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAA6B,MAAM,0BAA0B,CAAC;AAG9F,+DAA+D;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,KAAK;IAChB,eAAe,EAAE,IAAI;IACrB,iBAAiB,EAAE,EAAE;CACb,CAAC;AAEX;;GAEG;AACH,MAAM,OAAO,WAAW;IACb,QAAQ,CAAqB;IAC7B,SAAS,CAAO;IAChB,QAAQ,CAAsC;IAC9C,SAAS,CAAsC;IAC/C,IAAI,CAAyB;IAEtC;;;;OAIG;IACH,YAAY,QAAgC,EAAE,OAAgB,EAAE,WAAiB,IAAI,IAAI,EAAE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AC5C,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structured search entity types supported by MCP search tools.
|
|
3
|
-
* @module schema/structured-entities
|
|
4
|
-
*/
|
|
5
|
-
/** Source names that have dedicated `search_*` MCP tools. */
|
|
6
|
-
export declare const STRUCTURED_ENTITY_TYPES: readonly ["publications", "grants", "researchers", "patents", "clinical_trials", "datasets", "policy_documents", "organizations"];
|
|
7
|
-
/** A source with a structured search tool. */
|
|
8
|
-
export type StructuredEntityType = (typeof STRUCTURED_ENTITY_TYPES)[number];
|
|
9
|
-
/**
|
|
10
|
-
* MCP tool name for a structured entity.
|
|
11
|
-
* @param source - Dimensions source name
|
|
12
|
-
* @returns Tool name (e.g. `search_publications`)
|
|
13
|
-
*/
|
|
14
|
-
export declare function searchToolName(source: StructuredEntityType): string;
|
|
15
|
-
/**
|
|
16
|
-
* JSON result key for entity rows (camelCase where historical tools used it).
|
|
17
|
-
* @param source - Dimensions source name
|
|
18
|
-
* @returns Property name in tool output
|
|
19
|
-
*/
|
|
20
|
-
export declare function searchResultKey(source: StructuredEntityType): string;
|
|
21
|
-
//# sourceMappingURL=structured-entities.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"structured-entities.d.ts","sourceRoot":"","sources":["../../src/schema/structured-entities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6DAA6D;AAC7D,eAAO,MAAM,uBAAuB,mIAS1B,CAAC;AAEX,8CAA8C;AAC9C,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,MAAM,CASpE"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Structured search entity types supported by MCP search tools.
|
|
3
|
-
* @module schema/structured-entities
|
|
4
|
-
*/
|
|
5
|
-
/** Source names that have dedicated `search_*` MCP tools. */
|
|
6
|
-
export const STRUCTURED_ENTITY_TYPES = [
|
|
7
|
-
"publications",
|
|
8
|
-
"grants",
|
|
9
|
-
"researchers",
|
|
10
|
-
"patents",
|
|
11
|
-
"clinical_trials",
|
|
12
|
-
"datasets",
|
|
13
|
-
"policy_documents",
|
|
14
|
-
"organizations",
|
|
15
|
-
];
|
|
16
|
-
/**
|
|
17
|
-
* MCP tool name for a structured entity.
|
|
18
|
-
* @param source - Dimensions source name
|
|
19
|
-
* @returns Tool name (e.g. `search_publications`)
|
|
20
|
-
*/
|
|
21
|
-
export function searchToolName(source) {
|
|
22
|
-
return `search_${source}`;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* JSON result key for entity rows (camelCase where historical tools used it).
|
|
26
|
-
* @param source - Dimensions source name
|
|
27
|
-
* @returns Property name in tool output
|
|
28
|
-
*/
|
|
29
|
-
export function searchResultKey(source) {
|
|
30
|
-
switch (source) {
|
|
31
|
-
case "clinical_trials":
|
|
32
|
-
return "clinicalTrials";
|
|
33
|
-
case "policy_documents":
|
|
34
|
-
return "policyDocuments";
|
|
35
|
-
default:
|
|
36
|
-
return source;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=structured-entities.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"structured-entities.js","sourceRoot":"","sources":["../../src/schema/structured-entities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,cAAc;IACd,QAAQ;IACR,aAAa;IACb,SAAS;IACT,iBAAiB;IACjB,UAAU;IACV,kBAAkB;IAClB,eAAe;CACP,CAAC;AAKX;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAA4B;IACzD,OAAO,UAAU,MAAM,EAAE,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,MAA4B;IAC1D,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,iBAAiB;YACpB,OAAO,gBAAgB,CAAC;QAC1B,KAAK,kBAAkB;YACrB,OAAO,iBAAiB,CAAC;QAC3B;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/schema/types.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types for Dimensions `describe` API responses.
|
|
3
|
-
* @module schema/types
|
|
4
|
-
*/
|
|
5
|
-
/** Field metadata from `describe schema` / `describe source`. */
|
|
6
|
-
export type DescribeField = {
|
|
7
|
-
readonly type: string;
|
|
8
|
-
readonly description?: string;
|
|
9
|
-
readonly long_description?: string;
|
|
10
|
-
readonly is_entity?: boolean;
|
|
11
|
-
readonly is_filter?: boolean;
|
|
12
|
-
readonly is_facet?: boolean;
|
|
13
|
-
readonly is_multivalue?: boolean;
|
|
14
|
-
};
|
|
15
|
-
/** Per-source schema slice from `describe schema`. */
|
|
16
|
-
export type SourceDescribe = {
|
|
17
|
-
readonly fields: Readonly<Record<string, DescribeField>>;
|
|
18
|
-
readonly fieldsets?: Readonly<Record<string, readonly string[]>>;
|
|
19
|
-
readonly metrics?: readonly string[];
|
|
20
|
-
readonly search_fields?: readonly string[];
|
|
21
|
-
};
|
|
22
|
-
/** Auxiliary entity schema from `describe schema`. */
|
|
23
|
-
export type EntityDescribe = {
|
|
24
|
-
readonly fields: Readonly<Record<string, DescribeField>>;
|
|
25
|
-
};
|
|
26
|
-
/** Full response from `describe schema`. */
|
|
27
|
-
export type DescribeSchemaResponse = {
|
|
28
|
-
readonly sources: Readonly<Record<string, SourceDescribe>>;
|
|
29
|
-
readonly entities: Readonly<Record<string, EntityDescribe>>;
|
|
30
|
-
};
|
|
31
|
-
/** Response from `describe version`. */
|
|
32
|
-
export type DescribeVersionResponse = {
|
|
33
|
-
readonly version?: string;
|
|
34
|
-
readonly release?: string;
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/schema/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,iEAAiE;AACjE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,sDAAsD;AACtD,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;IACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C,CAAC;AAEF,sDAAsD;AACtD,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CAC7D,CAAC;AAEF,wCAAwC;AACxC,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC"}
|
package/dist/schema/types.js
DELETED
package/dist/schema/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/schema/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/dist/server.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP server for Dimensions Analytics API.
|
|
3
|
-
* Provides tools for searching and querying the Dimensions database.
|
|
4
|
-
* @module mcp/server
|
|
5
|
-
*/
|
|
6
|
-
import { DimensionsClient } from "@digital-science/dimensions-dsl";
|
|
7
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
-
import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
9
|
-
import type { SchemaContext } from "./schema/context.js";
|
|
10
|
-
import { clearSchemaCache, loadSchema, type SchemaStore } from "./schema/index.js";
|
|
11
|
-
/**
|
|
12
|
-
* Configuration options for the MCP server.
|
|
13
|
-
*/
|
|
14
|
-
export interface McpServerConfig {
|
|
15
|
-
/** Dimensions API key (required) */
|
|
16
|
-
apiKey?: string;
|
|
17
|
-
/** Base URL for the Dimensions API */
|
|
18
|
-
baseUrl?: string;
|
|
19
|
-
/** Pre-loaded schema store (for tests; skips live describe fetch) */
|
|
20
|
-
schemaStore?: SchemaStore;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Builds server instructions from loaded schema.
|
|
24
|
-
* @param schemaStore - Loaded describe schema
|
|
25
|
-
* @returns Instruction string for MCP clients
|
|
26
|
-
*/
|
|
27
|
-
export declare function buildServerInstructions(schemaStore: SchemaStore): string;
|
|
28
|
-
/**
|
|
29
|
-
* Creates and configures the MCP server.
|
|
30
|
-
* Loads describe schema at startup unless `schemaStore` is provided.
|
|
31
|
-
* @param config - Optional configuration
|
|
32
|
-
* @returns Configured MCP server, client, schema context, and store
|
|
33
|
-
*/
|
|
34
|
-
export declare function createMcpServerAsync(config?: McpServerConfig): Promise<{
|
|
35
|
-
server: McpServer;
|
|
36
|
-
client: DimensionsClient;
|
|
37
|
-
schemaContext: SchemaContext;
|
|
38
|
-
schemaStore: SchemaStore;
|
|
39
|
-
}>;
|
|
40
|
-
/**
|
|
41
|
-
* A handle returned by {@link startMcpServer} that allows callers to shut down
|
|
42
|
-
* the server and its transport gracefully.
|
|
43
|
-
*/
|
|
44
|
-
export interface McpServerHandle {
|
|
45
|
-
/** Closes the server and transport gracefully. */
|
|
46
|
-
readonly close: () => Promise<void>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Starts the MCP server with the given transport (defaults to stdio).
|
|
50
|
-
* @param injectedTransport - Optional transport (useful for testing)
|
|
51
|
-
* @param config - Optional server configuration
|
|
52
|
-
* @returns Shutdown handle
|
|
53
|
-
*/
|
|
54
|
-
export declare function startMcpServer(injectedTransport?: Transport, config?: McpServerConfig): Promise<McpServerHandle>;
|
|
55
|
-
/** Force reload schema from API (clears module cache). */
|
|
56
|
-
export { clearSchemaCache, loadSchema, McpServer };
|
|
57
|
-
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAA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