@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/tools/kwq.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* KWQ (Keyword Query) tools for the MCP server.
|
|
3
|
-
* Provides structured query building and RRF ensemble fusion via the Dimensions API.
|
|
4
|
-
* @module mcp/tools/kwq
|
|
5
|
-
*/
|
|
6
|
-
import type { DimensionsClient } from "@digital-science/dimensions-dsl";
|
|
7
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
-
import type { SchemaStore } from "../schema/index.js";
|
|
9
|
-
/**
|
|
10
|
-
* Registers KWQ tools with the MCP server.
|
|
11
|
-
* - build_query: always registered (pure computation)
|
|
12
|
-
* - ensemble_queries: always registered (uses Dimensions API via client)
|
|
13
|
-
*
|
|
14
|
-
* @param server - MCP server instance
|
|
15
|
-
* @param client - Dimensions API client (for ensemble query execution)
|
|
16
|
-
* @param schemaStore - Loaded describe schema for search index hints
|
|
17
|
-
*/
|
|
18
|
-
export declare function registerKwqTools(server: McpServer, client: DimensionsClient, schemaStore: SchemaStore): void;
|
|
19
|
-
//# sourceMappingURL=kwq.d.ts.map
|
package/dist/tools/kwq.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kwq.d.ts","sourceRoot":"","sources":["../../src/tools/kwq.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA+BtD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,WAAW,GACvB,IAAI,CA2IN"}
|
package/dist/tools/kwq.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* KWQ (Keyword Query) tools for the MCP server.
|
|
3
|
-
* Provides structured query building and RRF ensemble fusion via the Dimensions API.
|
|
4
|
-
* @module mcp/tools/kwq
|
|
5
|
-
*/
|
|
6
|
-
import { buildQuery, conceptGroupsToQuerySpec, ensembleQueries, } from "@digital-science/dimensions-kwq";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import { formatErrorResult, formatToolResult } from "../utils.js";
|
|
9
|
-
// #region Shared schemas
|
|
10
|
-
const ENTITY_ENUM = z.enum([
|
|
11
|
-
"publications",
|
|
12
|
-
"grants",
|
|
13
|
-
"researchers",
|
|
14
|
-
"patents",
|
|
15
|
-
"clinical_trials",
|
|
16
|
-
"datasets",
|
|
17
|
-
"policy_documents",
|
|
18
|
-
"organizations",
|
|
19
|
-
]);
|
|
20
|
-
const ConceptGroupSchema = z.object({
|
|
21
|
-
terms: z.array(z.string()).min(1).describe("Terms OR'd together (synonyms)"),
|
|
22
|
-
role: z.enum(["include", "exclude"]).describe("include = AND into query, exclude = NOT"),
|
|
23
|
-
});
|
|
24
|
-
const FilterSchema = z.object({
|
|
25
|
-
field: z.string(),
|
|
26
|
-
op: z.string(),
|
|
27
|
-
value: z.union([z.string(), z.number(), z.array(z.string()), z.array(z.number())]),
|
|
28
|
-
});
|
|
29
|
-
// #endregion
|
|
30
|
-
// #region Tool registration
|
|
31
|
-
/**
|
|
32
|
-
* Registers KWQ tools with the MCP server.
|
|
33
|
-
* - build_query: always registered (pure computation)
|
|
34
|
-
* - ensemble_queries: always registered (uses Dimensions API via client)
|
|
35
|
-
*
|
|
36
|
-
* @param server - MCP server instance
|
|
37
|
-
* @param client - Dimensions API client (for ensemble query execution)
|
|
38
|
-
* @param schemaStore - Loaded describe schema for search index hints
|
|
39
|
-
*/
|
|
40
|
-
export function registerKwqTools(server, client, schemaStore) {
|
|
41
|
-
const indexHints = ENTITY_ENUM.options
|
|
42
|
-
.map((entity) => `${entity}: ${schemaStore.searchIndexes(entity).join(", ") || "default"}`)
|
|
43
|
-
.join("; ");
|
|
44
|
-
// --- build_query ---
|
|
45
|
-
server.registerTool("build_query", {
|
|
46
|
-
description: `Build a validated Dimensions DSL query from structured concept groups.
|
|
47
|
-
|
|
48
|
-
Use concept_groups for the common pattern: groups of synonym terms, AND'd together, with optional exclusions.
|
|
49
|
-
Each group's terms are OR'd (synonyms), include groups are AND'd, exclude groups are NOT'd.
|
|
50
|
-
|
|
51
|
-
Search indexes by entity: ${indexHints}
|
|
52
|
-
|
|
53
|
-
For advanced nested boolean logic, use search_json with a SearchExpr tree instead.
|
|
54
|
-
Returns the validated DSL string, validation status, human-readable description, and complexity metrics.`,
|
|
55
|
-
inputSchema: {
|
|
56
|
-
entity: ENTITY_ENUM.describe("Target entity type"),
|
|
57
|
-
concept_groups: z
|
|
58
|
-
.array(ConceptGroupSchema)
|
|
59
|
-
.optional()
|
|
60
|
-
.describe("Concept groups: include groups AND'd, each group's terms OR'd, exclude groups NOT'd"),
|
|
61
|
-
search_json: z
|
|
62
|
-
.string()
|
|
63
|
-
.optional()
|
|
64
|
-
.describe("Advanced: raw SearchExpr JSON tree (overrides concept_groups). Use for nested boolean logic."),
|
|
65
|
-
index: z
|
|
66
|
-
.string()
|
|
67
|
-
.optional()
|
|
68
|
-
.describe("Search index (e.g. title_abstract_only, full_data, title_only)"),
|
|
69
|
-
filters: z.array(FilterSchema).optional().describe("WHERE clause filters"),
|
|
70
|
-
fields: z.array(z.string()).optional().describe("Fields to return"),
|
|
71
|
-
sort_by: z.string().optional().describe("Sort field"),
|
|
72
|
-
sort_order: z.enum(["asc", "desc"]).optional().describe("Sort order"),
|
|
73
|
-
limit: z
|
|
74
|
-
.number()
|
|
75
|
-
.int()
|
|
76
|
-
.min(1)
|
|
77
|
-
.max(1000)
|
|
78
|
-
.optional()
|
|
79
|
-
.default(20)
|
|
80
|
-
.describe("Result limit (default 20, max 1000)"),
|
|
81
|
-
skip: z.number().int().min(0).optional().describe("Result offset"),
|
|
82
|
-
},
|
|
83
|
-
annotations: {
|
|
84
|
-
readOnlyHint: true,
|
|
85
|
-
destructiveHint: false,
|
|
86
|
-
idempotentHint: true,
|
|
87
|
-
openWorldHint: false,
|
|
88
|
-
},
|
|
89
|
-
}, async (args) => {
|
|
90
|
-
try {
|
|
91
|
-
if (args.concept_groups && args.search_json) {
|
|
92
|
-
return formatErrorResult(new Error("Provide either concept_groups or search_json, not both."));
|
|
93
|
-
}
|
|
94
|
-
const spec = conceptGroupsToQuerySpec(args);
|
|
95
|
-
const result = buildQuery(spec);
|
|
96
|
-
return formatToolResult({
|
|
97
|
-
dsl: result.dsl,
|
|
98
|
-
valid: result.validation._tag === "valid",
|
|
99
|
-
errors: result.validation._tag === "invalid" ? result.validation.errors : undefined,
|
|
100
|
-
warnings: result.validation._tag === "valid" && result.validation.warnings.length > 0
|
|
101
|
-
? result.validation.warnings
|
|
102
|
-
: undefined,
|
|
103
|
-
description: result.description,
|
|
104
|
-
complexity: result.complexity,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
return formatErrorResult(error);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
// --- ensemble_queries ---
|
|
112
|
-
server.registerTool("ensemble_queries", {
|
|
113
|
-
description: `Execute 2-10 query specs in parallel and fuse results using Reciprocal Rank Fusion (RRF).
|
|
114
|
-
|
|
115
|
-
Each spec uses the same concept_groups model as build_query. RRF produces a
|
|
116
|
-
variance-reduced ranking by combining multiple retrieval strategies — different
|
|
117
|
-
keyword formulations, different indexes, or different filter configurations.
|
|
118
|
-
|
|
119
|
-
RRF score: score(d) = Σ 1/(k + rank_i(d)) across all lists containing document d.
|
|
120
|
-
Higher k (default 60) weights more evenly; lower k favors top-ranked documents.`,
|
|
121
|
-
inputSchema: {
|
|
122
|
-
specs: z
|
|
123
|
-
.array(z.object({
|
|
124
|
-
entity: ENTITY_ENUM.default("publications"),
|
|
125
|
-
concept_groups: z.array(ConceptGroupSchema).optional(),
|
|
126
|
-
search_json: z.string().optional(),
|
|
127
|
-
index: z.string().optional(),
|
|
128
|
-
filters: z.array(FilterSchema).optional(),
|
|
129
|
-
fields: z.array(z.string()).optional(),
|
|
130
|
-
limit: z.number().int().optional().default(100).describe("Per-query result limit"),
|
|
131
|
-
}))
|
|
132
|
-
.min(2)
|
|
133
|
-
.max(10)
|
|
134
|
-
.describe("2-10 query specs to execute and fuse"),
|
|
135
|
-
k: z.number().int().optional().default(60).describe("RRF k parameter (default 60)"),
|
|
136
|
-
limit: z.number().int().optional().default(100).describe("Max fused results to return"),
|
|
137
|
-
},
|
|
138
|
-
annotations: {
|
|
139
|
-
readOnlyHint: true,
|
|
140
|
-
destructiveHint: false,
|
|
141
|
-
idempotentHint: false,
|
|
142
|
-
openWorldHint: true,
|
|
143
|
-
},
|
|
144
|
-
}, async (args) => {
|
|
145
|
-
try {
|
|
146
|
-
const querySpecs = args.specs.map((spec) => conceptGroupsToQuerySpec(spec));
|
|
147
|
-
const result = await ensembleQueries((dsl) => client.rawQuery(dsl), querySpecs, { k: args.k, limit: args.limit });
|
|
148
|
-
return formatToolResult(result);
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
return formatErrorResult(error);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
// #endregion
|
|
156
|
-
//# sourceMappingURL=kwq.js.map
|
package/dist/tools/kwq.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kwq.js","sourceRoot":"","sources":["../../src/tools/kwq.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,UAAU,EACV,wBAAwB,EACxB,eAAe,GAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,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ACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC;YAE5E,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAqC,EACjE,UAAU,EACV,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CACjC,CAAC;YAEF,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,aAAa"}
|
package/dist/tools/lookup.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lookup tools for the MCP server.
|
|
3
|
-
* Provides direct lookup by identifiers (DOI, PMID, Dimensions ID).
|
|
4
|
-
* @module mcp/tools/lookup
|
|
5
|
-
*/
|
|
6
|
-
import { type DimensionsClient } from "@digital-science/dimensions-dsl";
|
|
7
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
-
/**
|
|
9
|
-
* Registers all lookup tools with the MCP server.
|
|
10
|
-
* @param server - MCP server instance
|
|
11
|
-
* @param client - Dimensions client instance
|
|
12
|
-
*/
|
|
13
|
-
export declare function registerLookupTools(server: McpServer, client: DimensionsClient): void;
|
|
14
|
-
//# sourceMappingURL=lookup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/tools/lookup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAWzE;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAkPrF"}
|
package/dist/tools/lookup.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lookup tools for the MCP server.
|
|
3
|
-
* Provides direct lookup by identifiers (DOI, PMID, Dimensions ID).
|
|
4
|
-
* @module mcp/tools/lookup
|
|
5
|
-
*/
|
|
6
|
-
import { EntitySchema, } from "@digital-science/dimensions-dsl";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import { withFieldAliases } from "../middleware/field-aliases.js";
|
|
9
|
-
import { asArray, formatErrorResult, formatToolResult, READ_ONLY_API_ANNOTATIONS, withTruncationWarning, } from "../utils.js";
|
|
10
|
-
/**
|
|
11
|
-
* Registers all lookup tools with the MCP server.
|
|
12
|
-
* @param server - MCP server instance
|
|
13
|
-
* @param client - Dimensions client instance
|
|
14
|
-
*/
|
|
15
|
-
export function registerLookupTools(server, client) {
|
|
16
|
-
// Get publication by DOI
|
|
17
|
-
server.registerTool("get_by_doi", {
|
|
18
|
-
description: "Retrieve a publication by its Digital Object Identifier (DOI). Returns full publication details including abstract, citations, and authors.",
|
|
19
|
-
inputSchema: {
|
|
20
|
-
doi: z.string().describe("The DOI to look up (e.g., '10.1038/nature12373')"),
|
|
21
|
-
fields: z
|
|
22
|
-
.array(z.string())
|
|
23
|
-
.optional()
|
|
24
|
-
.describe("Fields to return (e.g., ['id', 'title', 'abstract', 'times_cited'])"),
|
|
25
|
-
},
|
|
26
|
-
outputSchema: {
|
|
27
|
-
found: z.boolean().describe("Whether the entity was found"),
|
|
28
|
-
publication: z.record(z.string(), z.unknown()).optional().describe("The found entity"),
|
|
29
|
-
message: z.string().optional().describe("Message when not found"),
|
|
30
|
-
},
|
|
31
|
-
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
32
|
-
}, withFieldAliases({ entitySource: { kind: "static", entity: "publications" }, fieldArrayArgs: ["fields"] }, async (args) => {
|
|
33
|
-
try {
|
|
34
|
-
const qb = client
|
|
35
|
-
.createQueryBuilder()
|
|
36
|
-
.search("publications")
|
|
37
|
-
.where("doi", "=", args.doi)
|
|
38
|
-
.limit(1);
|
|
39
|
-
if (args.fields?.length)
|
|
40
|
-
qb.fields(args.fields);
|
|
41
|
-
const dsl = qb.build();
|
|
42
|
-
const response = await client.rawQuery(dsl);
|
|
43
|
-
const publications = asArray(response.publications);
|
|
44
|
-
if (publications.length === 0) {
|
|
45
|
-
return formatToolResult({
|
|
46
|
-
found: false,
|
|
47
|
-
message: `No publication found with DOI: ${args.doi}`,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return formatToolResult({
|
|
51
|
-
found: true,
|
|
52
|
-
publication: publications[0],
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
return formatErrorResult(error);
|
|
57
|
-
}
|
|
58
|
-
}));
|
|
59
|
-
// Get publication by PubMed ID
|
|
60
|
-
server.registerTool("get_by_pmid", {
|
|
61
|
-
description: "Retrieve a publication by its PubMed ID (PMID). Returns full publication details from Dimensions.",
|
|
62
|
-
inputSchema: {
|
|
63
|
-
pmid: z.string().describe("The PubMed ID to look up (e.g., '23846567')"),
|
|
64
|
-
fields: z
|
|
65
|
-
.array(z.string())
|
|
66
|
-
.optional()
|
|
67
|
-
.describe("Fields to return (e.g., ['id', 'title', 'abstract', 'times_cited'])"),
|
|
68
|
-
},
|
|
69
|
-
outputSchema: {
|
|
70
|
-
found: z.boolean().describe("Whether the entity was found"),
|
|
71
|
-
publication: z.record(z.string(), z.unknown()).optional().describe("The found entity"),
|
|
72
|
-
message: z.string().optional().describe("Message when not found"),
|
|
73
|
-
},
|
|
74
|
-
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
75
|
-
}, withFieldAliases({ entitySource: { kind: "static", entity: "publications" }, fieldArrayArgs: ["fields"] }, async (args) => {
|
|
76
|
-
try {
|
|
77
|
-
const qb = client
|
|
78
|
-
.createQueryBuilder()
|
|
79
|
-
.search("publications")
|
|
80
|
-
.where("pmid", "=", args.pmid)
|
|
81
|
-
.limit(1);
|
|
82
|
-
if (args.fields?.length)
|
|
83
|
-
qb.fields(args.fields);
|
|
84
|
-
const dsl = qb.build();
|
|
85
|
-
const response = await client.rawQuery(dsl);
|
|
86
|
-
const publications = asArray(response.publications);
|
|
87
|
-
if (publications.length === 0) {
|
|
88
|
-
return formatToolResult({
|
|
89
|
-
found: false,
|
|
90
|
-
message: `No publication found with PMID: ${args.pmid}`,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
return formatToolResult({
|
|
94
|
-
found: true,
|
|
95
|
-
publication: publications[0],
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
return formatErrorResult(error);
|
|
100
|
-
}
|
|
101
|
-
}));
|
|
102
|
-
// Get entity by Dimensions ID
|
|
103
|
-
server.registerTool("get_by_id", {
|
|
104
|
-
description: "Retrieve any entity by its Dimensions ID. Supports publications, grants, patents, clinical trials, datasets, policy documents, researchers, and organizations.",
|
|
105
|
-
inputSchema: {
|
|
106
|
-
entityType: EntitySchema.describe("The type of entity to look up"),
|
|
107
|
-
id: z.string().describe("The Dimensions ID to look up"),
|
|
108
|
-
fields: z.array(z.string()).optional().describe("Fields to return"),
|
|
109
|
-
},
|
|
110
|
-
outputSchema: {
|
|
111
|
-
found: z.boolean().describe("Whether the entity was found"),
|
|
112
|
-
entity: z.record(z.string(), z.unknown()).optional().describe("The found entity"),
|
|
113
|
-
entityType: z.string().optional().describe("The type of the found entity"),
|
|
114
|
-
message: z.string().optional().describe("Message when not found"),
|
|
115
|
-
},
|
|
116
|
-
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
117
|
-
}, withFieldAliases({ entitySource: { kind: "dynamic", argName: "entityType" }, fieldArrayArgs: ["fields"] }, async (args) => {
|
|
118
|
-
try {
|
|
119
|
-
const qb = client
|
|
120
|
-
.createQueryBuilder()
|
|
121
|
-
.search(args.entityType)
|
|
122
|
-
.where("id", "=", args.id)
|
|
123
|
-
.limit(1);
|
|
124
|
-
if (args.fields?.length)
|
|
125
|
-
qb.fields(args.fields);
|
|
126
|
-
const dsl = qb.build();
|
|
127
|
-
const response = await client.rawQuery(dsl);
|
|
128
|
-
const entities = asArray(response[args.entityType]);
|
|
129
|
-
if (entities.length === 0) {
|
|
130
|
-
return formatToolResult({
|
|
131
|
-
found: false,
|
|
132
|
-
message: `No ${args.entityType.slice(0, -1)} found with ID: ${args.id}`,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
return formatToolResult({
|
|
136
|
-
found: true,
|
|
137
|
-
entity: entities[0],
|
|
138
|
-
entityType: args.entityType,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
return formatErrorResult(error);
|
|
143
|
-
}
|
|
144
|
-
}));
|
|
145
|
-
// Get recent high impact publications
|
|
146
|
-
server.registerTool("recent_high_impact", {
|
|
147
|
-
description: "Find the most cited publications in a topic area from recent years. Useful for identifying influential recent research.",
|
|
148
|
-
inputSchema: {
|
|
149
|
-
query: z
|
|
150
|
-
.string()
|
|
151
|
-
.describe("Search query for the topic area (e.g., 'deep learning', 'immunotherapy')"),
|
|
152
|
-
years: z
|
|
153
|
-
.number()
|
|
154
|
-
.int()
|
|
155
|
-
.min(1)
|
|
156
|
-
.max(10)
|
|
157
|
-
.default(5)
|
|
158
|
-
.describe("Number of recent years to consider (default: 5)"),
|
|
159
|
-
limit: z
|
|
160
|
-
.number()
|
|
161
|
-
.int()
|
|
162
|
-
.min(1)
|
|
163
|
-
.max(100)
|
|
164
|
-
.default(20)
|
|
165
|
-
.describe("Number of publications to return (max 100)"),
|
|
166
|
-
fields: z.array(z.string()).optional().describe("Fields to return"),
|
|
167
|
-
},
|
|
168
|
-
outputSchema: {
|
|
169
|
-
query: z.string().describe("The search query used"),
|
|
170
|
-
yearRange: z.string().describe("Year range searched (e.g., '2020-2025')"),
|
|
171
|
-
totalCount: z.number().describe("Total matching records"),
|
|
172
|
-
returnedCount: z.number().describe("Records returned in this response"),
|
|
173
|
-
truncated: z.boolean().optional().describe("True when results are truncated"),
|
|
174
|
-
truncationWarning: z.string().optional().describe("Warning message when truncated"),
|
|
175
|
-
publications: z.array(z.record(z.string(), z.unknown())).describe("Result records"),
|
|
176
|
-
},
|
|
177
|
-
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
178
|
-
}, withFieldAliases({ entitySource: { kind: "static", entity: "publications" }, fieldArrayArgs: ["fields"] }, async (args) => {
|
|
179
|
-
try {
|
|
180
|
-
const currentYear = new Date().getFullYear();
|
|
181
|
-
const startYear = currentYear - args.years;
|
|
182
|
-
const qb = client
|
|
183
|
-
.createQueryBuilder()
|
|
184
|
-
.search("publications")
|
|
185
|
-
.for(args.query)
|
|
186
|
-
.where("year", ">=", startYear)
|
|
187
|
-
.sort("times_cited", "desc")
|
|
188
|
-
.limit(args.limit);
|
|
189
|
-
if (args.fields?.length) {
|
|
190
|
-
qb.fields(args.fields);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
qb.fields(["id", "title", "doi", "year", "times_cited", "authors", "journal"]);
|
|
194
|
-
}
|
|
195
|
-
const dsl = qb.build();
|
|
196
|
-
const response = await client.rawQuery(dsl);
|
|
197
|
-
const publications = asArray(response.publications);
|
|
198
|
-
const totalCount = response._stats?.total_count ?? publications.length;
|
|
199
|
-
const returnedCount = publications.length;
|
|
200
|
-
return formatToolResult(withTruncationWarning({
|
|
201
|
-
query: args.query,
|
|
202
|
-
yearRange: `${startYear}-${currentYear}`,
|
|
203
|
-
totalCount,
|
|
204
|
-
returnedCount,
|
|
205
|
-
publications,
|
|
206
|
-
}, totalCount, returnedCount));
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
return formatErrorResult(error);
|
|
210
|
-
}
|
|
211
|
-
}));
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=lookup.js.map
|
package/dist/tools/lookup.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/tools/lookup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,YAAY,GAEb,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,MAAwB;IAC7E,yBAAyB;IACzB,MAAM,CAAC,YAAY,CACjB,YAAY,EACZ;QACE,WAAW,EACT,6IAA6I;QAC/I,WAAW,EAAE;YACX,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;YAC5E,MAAM,EAAE,CAAC;iBACN,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;iBACjB,QAAQ,EAAE;iBACV,QAAQ,CAAC,qEAAqE,CAAC;SACnF;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;YAC3D,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YACtF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,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CAAC,GAAG,CAAC,CAAC;YAC5C,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YAEpD,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAE,WAAW,IAAI,YAAY,CAAC,MAAM,CAAC;YACvE,MAAM,aAAa,GAAG,YAAY,CAAC,MAAM,CAAC;YAC1C,OAAO,gBAAgB,CACrB,qBAAqB,CACnB;gBACE,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,SAAS,EAAE,GAAG,SAAS,IAAI,WAAW,EAAE;gBACxC,UAAU;gBACV,aAAa;gBACb,YAAY;aACb,EACD,UAAU,EACV,aAAa,CACd,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,CACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Policy document profile tool for the MCP server.
|
|
3
|
-
* Provides deep profiling of policy documents including structural links
|
|
4
|
-
* to cited publications and their supporting grants.
|
|
5
|
-
* @module mcp/tools/policy-profile
|
|
6
|
-
*/
|
|
7
|
-
import type { DimensionsClient } from "@digital-science/dimensions-dsl";
|
|
8
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
-
/**
|
|
10
|
-
* Registers the policy_document_profile tool with the MCP server.
|
|
11
|
-
* @param server - MCP server instance
|
|
12
|
-
* @param client - Dimensions client instance
|
|
13
|
-
*/
|
|
14
|
-
export declare function registerPolicyProfileTools(server: McpServer, client: DimensionsClient): void;
|
|
15
|
-
//# sourceMappingURL=policy-profile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policy-profile.d.ts","sourceRoot":"","sources":["../../src/tools/policy-profile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAUzE;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAiL5F"}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Policy document profile tool for the MCP server.
|
|
3
|
-
* Provides deep profiling of policy documents including structural links
|
|
4
|
-
* to cited publications and their supporting grants.
|
|
5
|
-
* @module mcp/tools/policy-profile
|
|
6
|
-
*/
|
|
7
|
-
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
import { asArray, formatErrorResult, formatToolResult, READ_ONLY_API_ANNOTATIONS, } from "../utils.js";
|
|
10
|
-
/**
|
|
11
|
-
* Registers the policy_document_profile tool with the MCP server.
|
|
12
|
-
* @param server - MCP server instance
|
|
13
|
-
* @param client - Dimensions client instance
|
|
14
|
-
*/
|
|
15
|
-
export function registerPolicyProfileTools(server, client) {
|
|
16
|
-
server.registerTool("policy_document_profile", {
|
|
17
|
-
description: "Get a comprehensive profile for a policy document including its cited publications and their supporting grants. Uses structural links (publication_ids) rather than free-text search to trace the evidence chain from policy back to funded research.",
|
|
18
|
-
inputSchema: {
|
|
19
|
-
policyDocId: z.string().optional().describe("Dimensions policy document ID"),
|
|
20
|
-
query: z
|
|
21
|
-
.string()
|
|
22
|
-
.optional()
|
|
23
|
-
.describe("Search term to find policy documents (used when policyDocId is not known)"),
|
|
24
|
-
includeLinkedPublications: z
|
|
25
|
-
.boolean()
|
|
26
|
-
.default(true)
|
|
27
|
-
.describe("Include cited publications and their supporting grants"),
|
|
28
|
-
publicationLimit: z
|
|
29
|
-
.number()
|
|
30
|
-
.int()
|
|
31
|
-
.min(1)
|
|
32
|
-
.max(50)
|
|
33
|
-
.default(20)
|
|
34
|
-
.describe("Max linked publications to return"),
|
|
35
|
-
},
|
|
36
|
-
outputSchema: {
|
|
37
|
-
found: z.boolean().describe("Whether the policy document was found"),
|
|
38
|
-
profile: z
|
|
39
|
-
.record(z.string(), z.unknown())
|
|
40
|
-
.optional()
|
|
41
|
-
.describe("Policy document profile with linked entities"),
|
|
42
|
-
message: z.string().optional().describe("Message when not found"),
|
|
43
|
-
},
|
|
44
|
-
annotations: READ_ONLY_API_ANNOTATIONS,
|
|
45
|
-
}, async (args) => {
|
|
46
|
-
if (!args.policyDocId && !args.query) {
|
|
47
|
-
throw new McpError(ErrorCode.InvalidParams, "Must provide at least one of: policyDocId or query");
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
// Step 1: Find the policy document
|
|
51
|
-
let policyDsl;
|
|
52
|
-
if (args.policyDocId) {
|
|
53
|
-
policyDsl = client
|
|
54
|
-
.createQueryBuilder()
|
|
55
|
-
.search("policy_documents")
|
|
56
|
-
.where("id", "=", args.policyDocId)
|
|
57
|
-
.fields([
|
|
58
|
-
"id",
|
|
59
|
-
"title",
|
|
60
|
-
"year",
|
|
61
|
-
"publisher_org",
|
|
62
|
-
"linkout",
|
|
63
|
-
"publisher_org",
|
|
64
|
-
"publication_ids",
|
|
65
|
-
])
|
|
66
|
-
.limit(1)
|
|
67
|
-
.build();
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
policyDsl = client
|
|
71
|
-
.createQueryBuilder()
|
|
72
|
-
.search("policy_documents")
|
|
73
|
-
.for(args.query)
|
|
74
|
-
.fields([
|
|
75
|
-
"id",
|
|
76
|
-
"title",
|
|
77
|
-
"year",
|
|
78
|
-
"publisher_org",
|
|
79
|
-
"linkout",
|
|
80
|
-
"publisher_org",
|
|
81
|
-
"publication_ids",
|
|
82
|
-
])
|
|
83
|
-
.limit(5)
|
|
84
|
-
.build();
|
|
85
|
-
}
|
|
86
|
-
const policyResponse = await client.rawQuery(policyDsl);
|
|
87
|
-
const policyDocs = asArray(policyResponse.policy_documents);
|
|
88
|
-
if (policyDocs.length === 0) {
|
|
89
|
-
return formatToolResult({
|
|
90
|
-
found: false,
|
|
91
|
-
message: args.policyDocId
|
|
92
|
-
? `No policy document found with ID: ${args.policyDocId}`
|
|
93
|
-
: `No policy document found matching: ${args.query}`,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
const policyDoc = policyDocs[0];
|
|
97
|
-
const profile = {
|
|
98
|
-
policyDocument: policyDoc,
|
|
99
|
-
matchCount: policyDocs.length,
|
|
100
|
-
};
|
|
101
|
-
// Extract structural link IDs
|
|
102
|
-
const publicationIds = Array.isArray(policyDoc.publication_ids)
|
|
103
|
-
? policyDoc.publication_ids
|
|
104
|
-
: undefined;
|
|
105
|
-
// Step 2: Fetch linked publications
|
|
106
|
-
if (args.includeLinkedPublications !== false &&
|
|
107
|
-
publicationIds &&
|
|
108
|
-
publicationIds.length > 0) {
|
|
109
|
-
const pubSlice = publicationIds.slice(0, args.publicationLimit);
|
|
110
|
-
const pubDsl = client
|
|
111
|
-
.createQueryBuilder()
|
|
112
|
-
.search("publications")
|
|
113
|
-
.whereIn("id", pubSlice)
|
|
114
|
-
.fields([
|
|
115
|
-
"id",
|
|
116
|
-
"title",
|
|
117
|
-
"doi",
|
|
118
|
-
"year",
|
|
119
|
-
"times_cited",
|
|
120
|
-
"journal",
|
|
121
|
-
"authors",
|
|
122
|
-
"research_orgs",
|
|
123
|
-
"funders",
|
|
124
|
-
"supporting_grant_ids",
|
|
125
|
-
])
|
|
126
|
-
.limit(args.publicationLimit)
|
|
127
|
-
.build();
|
|
128
|
-
const pubResponse = await client.rawQuery(pubDsl);
|
|
129
|
-
const publications = asArray(pubResponse.publications);
|
|
130
|
-
profile.linkedPublications = {
|
|
131
|
-
totalLinked: publicationIds.length,
|
|
132
|
-
returnedCount: publications.length,
|
|
133
|
-
items: publications,
|
|
134
|
-
};
|
|
135
|
-
// Second-wave: fetch grants behind the publications
|
|
136
|
-
const allGrantIds = new Set();
|
|
137
|
-
for (const pub of publications) {
|
|
138
|
-
if (Array.isArray(pub.supporting_grant_ids)) {
|
|
139
|
-
for (const gid of pub.supporting_grant_ids) {
|
|
140
|
-
if (typeof gid === "string") {
|
|
141
|
-
allGrantIds.add(gid);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (allGrantIds.size > 0) {
|
|
147
|
-
const grantIds = [...allGrantIds].slice(0, 50);
|
|
148
|
-
const grantDsl = client
|
|
149
|
-
.createQueryBuilder()
|
|
150
|
-
.search("grants")
|
|
151
|
-
.whereIn("id", grantIds)
|
|
152
|
-
.fields(["id", "title", "funding_usd", "funder_org_name", "start_year"])
|
|
153
|
-
.limit(50)
|
|
154
|
-
.build();
|
|
155
|
-
const grantResponse = await client.rawQuery(grantDsl);
|
|
156
|
-
const grants = asArray(grantResponse.grants);
|
|
157
|
-
profile.supportingGrants = {
|
|
158
|
-
totalLinked: allGrantIds.size,
|
|
159
|
-
returnedCount: grants.length,
|
|
160
|
-
items: grants,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return formatToolResult({
|
|
165
|
-
found: true,
|
|
166
|
-
profile,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
catch (error) {
|
|
170
|
-
return formatErrorResult(error);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
//# sourceMappingURL=policy-profile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policy-profile.js","sourceRoot":"","sources":["../../src/tools/policy-profile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB;;;;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AAC"}
|
package/dist/tools/profile.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Profile tools for the MCP server.
|
|
3
|
-
* Provides researcher and organization profile aggregation.
|
|
4
|
-
* @module mcp/tools/profile
|
|
5
|
-
*/
|
|
6
|
-
import type { DimensionsClient } from "@digital-science/dimensions-dsl";
|
|
7
|
-
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
-
/**
|
|
9
|
-
* Registers all profile tools with the MCP server.
|
|
10
|
-
* @param server - MCP server instance
|
|
11
|
-
* @param client - Dimensions client instance
|
|
12
|
-
*/
|
|
13
|
-
export declare function registerProfileTools(server: McpServer, client: DimensionsClient): void;
|
|
14
|
-
//# sourceMappingURL=profile.d.ts.map
|