@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.
Files changed (218) hide show
  1. package/CHANGELOG.md +4 -56
  2. package/README.md +1 -5
  3. package/dist/client/deployment-config.d.ts +20 -2
  4. package/dist/client/deployment-config.d.ts.map +1 -1
  5. package/dist/client/deployment-config.js +26 -2
  6. package/dist/client/deployment-config.js.map +1 -1
  7. package/dist/client/internal-dsl-client.d.ts +1 -1
  8. package/dist/client/internal-dsl-client.d.ts.map +1 -1
  9. package/dist/client/internal-dsl-client.js +2 -5
  10. package/dist/client/internal-dsl-client.js.map +1 -1
  11. package/dist/dsl/create-client.d.ts +1 -1
  12. package/dist/dsl/create-client.js +1 -1
  13. package/dist/dsl/fluent-query-builder.d.ts +1 -1
  14. package/dist/dsl/fluent-query-builder.js +1 -1
  15. package/dist/dsl/schema/cache.d.ts +2 -2
  16. package/dist/dsl/schema/cache.d.ts.map +1 -1
  17. package/dist/dsl/schema/cache.js +8 -14
  18. package/dist/dsl/schema/cache.js.map +1 -1
  19. package/dist/dsl/schema/load.d.ts +0 -1
  20. package/dist/dsl/schema/load.d.ts.map +1 -1
  21. package/dist/dsl/schema/load.js +1 -3
  22. package/dist/dsl/schema/load.js.map +1 -1
  23. package/dist/mcp/tools/schema.d.ts +0 -2
  24. package/dist/mcp/tools/schema.d.ts.map +1 -1
  25. package/dist/mcp/tools/schema.js.map +1 -1
  26. package/dist/mcp/utils.d.ts +0 -4
  27. package/dist/mcp/utils.d.ts.map +1 -1
  28. package/dist/mcp/utils.js +0 -7
  29. package/dist/mcp/utils.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/client/deployment-config.ts +39 -2
  32. package/src/client/internal-dsl-client.ts +2 -6
  33. package/src/dsl/create-client.ts +1 -1
  34. package/src/dsl/fluent-query-builder.ts +1 -1
  35. package/src/dsl/schema/cache.ts +8 -13
  36. package/src/dsl/schema/load.ts +1 -4
  37. package/src/mcp/tools/schema.ts +0 -3
  38. package/src/mcp/utils.ts +0 -12
  39. package/test/client/deployment-config.test.ts +25 -1
  40. package/test/client/http-client.test.ts +2 -2
  41. package/test/client/internal-dsl-client.test.ts +3 -0
  42. package/test/dsl/schema/cache.test.ts +2 -4
  43. package/test/helpers/tool-test-harness.ts +2 -19
  44. package/test/middleware/field-aliases.test.ts +1 -1
  45. package/test/tools/analytics.test.ts +2 -2
  46. package/tsconfig.tsbuildinfo +1 -1
  47. package/dist/examples/dsl-examples.d.ts +0 -11
  48. package/dist/examples/dsl-examples.d.ts.map +0 -1
  49. package/dist/examples/dsl-examples.js +0 -49
  50. package/dist/examples/dsl-examples.js.map +0 -1
  51. package/dist/examples/usage-scenarios.d.ts +0 -22
  52. package/dist/examples/usage-scenarios.d.ts.map +0 -1
  53. package/dist/examples/usage-scenarios.js +0 -173
  54. package/dist/examples/usage-scenarios.js.map +0 -1
  55. package/dist/funder-org-names.d.ts +0 -12
  56. package/dist/funder-org-names.d.ts.map +0 -1
  57. package/dist/funder-org-names.js +0 -30
  58. package/dist/funder-org-names.js.map +0 -1
  59. package/dist/http.d.ts +0 -29
  60. package/dist/http.d.ts.map +0 -1
  61. package/dist/http.js +0 -173
  62. package/dist/http.js.map +0 -1
  63. package/dist/kwq/build-query.d.ts +0 -26
  64. package/dist/kwq/build-query.d.ts.map +0 -1
  65. package/dist/kwq/build-query.js +0 -37
  66. package/dist/kwq/build-query.js.map +0 -1
  67. package/dist/kwq/concept-groups.d.ts +0 -49
  68. package/dist/kwq/concept-groups.d.ts.map +0 -1
  69. package/dist/kwq/concept-groups.js +0 -55
  70. package/dist/kwq/concept-groups.js.map +0 -1
  71. package/dist/kwq/dsl-assembler.d.ts +0 -28
  72. package/dist/kwq/dsl-assembler.d.ts.map +0 -1
  73. package/dist/kwq/dsl-assembler.js +0 -124
  74. package/dist/kwq/dsl-assembler.js.map +0 -1
  75. package/dist/kwq/ensemble.d.ts +0 -38
  76. package/dist/kwq/ensemble.d.ts.map +0 -1
  77. package/dist/kwq/ensemble.js +0 -107
  78. package/dist/kwq/ensemble.js.map +0 -1
  79. package/dist/kwq/index.d.ts +0 -16
  80. package/dist/kwq/index.d.ts.map +0 -1
  81. package/dist/kwq/index.js +0 -14
  82. package/dist/kwq/index.js.map +0 -1
  83. package/dist/kwq/types.d.ts +0 -120
  84. package/dist/kwq/types.d.ts.map +0 -1
  85. package/dist/kwq/types.js +0 -11
  86. package/dist/kwq/types.js.map +0 -1
  87. package/dist/lambda.d.ts +0 -10
  88. package/dist/lambda.d.ts.map +0 -1
  89. package/dist/lambda.js +0 -4
  90. package/dist/lambda.js.map +0 -1
  91. package/dist/mcp/tools/concept-profile.d.ts +0 -14
  92. package/dist/mcp/tools/concept-profile.d.ts.map +0 -1
  93. package/dist/mcp/tools/concept-profile.js +0 -130
  94. package/dist/mcp/tools/concept-profile.js.map +0 -1
  95. package/dist/mcp/tools/dataset-profile.d.ts +0 -15
  96. package/dist/mcp/tools/dataset-profile.d.ts.map +0 -1
  97. package/dist/mcp/tools/dataset-profile.js +0 -194
  98. package/dist/mcp/tools/dataset-profile.js.map +0 -1
  99. package/dist/mcp/tools/impact-chain.d.ts +0 -15
  100. package/dist/mcp/tools/impact-chain.d.ts.map +0 -1
  101. package/dist/mcp/tools/impact-chain.js +0 -96
  102. package/dist/mcp/tools/impact-chain.js.map +0 -1
  103. package/dist/mcp/tools/kwq.d.ts +0 -19
  104. package/dist/mcp/tools/kwq.d.ts.map +0 -1
  105. package/dist/mcp/tools/kwq.js +0 -156
  106. package/dist/mcp/tools/kwq.js.map +0 -1
  107. package/dist/mcp/tools/policy-profile.d.ts +0 -15
  108. package/dist/mcp/tools/policy-profile.d.ts.map +0 -1
  109. package/dist/mcp/tools/policy-profile.js +0 -174
  110. package/dist/mcp/tools/policy-profile.js.map +0 -1
  111. package/dist/mcp/tools/profile.d.ts +0 -14
  112. package/dist/mcp/tools/profile.d.ts.map +0 -1
  113. package/dist/mcp/tools/profile.js +0 -349
  114. package/dist/mcp/tools/profile.js.map +0 -1
  115. package/dist/middleware/field-aliases.d.ts +0 -97
  116. package/dist/middleware/field-aliases.d.ts.map +0 -1
  117. package/dist/middleware/field-aliases.js +0 -208
  118. package/dist/middleware/field-aliases.js.map +0 -1
  119. package/dist/resources/schema.d.ts +0 -13
  120. package/dist/resources/schema.d.ts.map +0 -1
  121. package/dist/resources/schema.js +0 -204
  122. package/dist/resources/schema.js.map +0 -1
  123. package/dist/schema/context.d.ts +0 -10
  124. package/dist/schema/context.d.ts.map +0 -1
  125. package/dist/schema/context.js +0 -6
  126. package/dist/schema/context.js.map +0 -1
  127. package/dist/schema/index.d.ts +0 -9
  128. package/dist/schema/index.d.ts.map +0 -1
  129. package/dist/schema/index.js +0 -6
  130. package/dist/schema/index.js.map +0 -1
  131. package/dist/schema/load.d.ts +0 -43
  132. package/dist/schema/load.d.ts.map +0 -1
  133. package/dist/schema/load.js +0 -139
  134. package/dist/schema/load.js.map +0 -1
  135. package/dist/schema/store.d.ts +0 -112
  136. package/dist/schema/store.d.ts.map +0 -1
  137. package/dist/schema/store.js +0 -173
  138. package/dist/schema/store.js.map +0 -1
  139. package/dist/schema/structured-entities.d.ts +0 -21
  140. package/dist/schema/structured-entities.d.ts.map +0 -1
  141. package/dist/schema/structured-entities.js +0 -39
  142. package/dist/schema/structured-entities.js.map +0 -1
  143. package/dist/schema/types.d.ts +0 -36
  144. package/dist/schema/types.d.ts.map +0 -1
  145. package/dist/schema/types.js +0 -6
  146. package/dist/schema/types.js.map +0 -1
  147. package/dist/server.d.ts +0 -57
  148. package/dist/server.d.ts.map +0 -1
  149. package/dist/server.js +0 -144
  150. package/dist/server.js.map +0 -1
  151. package/dist/telemetry.d.ts +0 -172
  152. package/dist/telemetry.d.ts.map +0 -1
  153. package/dist/telemetry.js +0 -233
  154. package/dist/telemetry.js.map +0 -1
  155. package/dist/tools/analytics-filters.d.ts +0 -18
  156. package/dist/tools/analytics-filters.d.ts.map +0 -1
  157. package/dist/tools/analytics-filters.js +0 -35
  158. package/dist/tools/analytics-filters.js.map +0 -1
  159. package/dist/tools/analytics.d.ts +0 -16
  160. package/dist/tools/analytics.d.ts.map +0 -1
  161. package/dist/tools/analytics.js +0 -381
  162. package/dist/tools/analytics.js.map +0 -1
  163. package/dist/tools/concept-profile.d.ts +0 -14
  164. package/dist/tools/concept-profile.d.ts.map +0 -1
  165. package/dist/tools/concept-profile.js +0 -130
  166. package/dist/tools/concept-profile.js.map +0 -1
  167. package/dist/tools/dataset-profile.d.ts +0 -15
  168. package/dist/tools/dataset-profile.d.ts.map +0 -1
  169. package/dist/tools/dataset-profile.js +0 -194
  170. package/dist/tools/dataset-profile.js.map +0 -1
  171. package/dist/tools/functions.d.ts +0 -14
  172. package/dist/tools/functions.d.ts.map +0 -1
  173. package/dist/tools/functions.js +0 -294
  174. package/dist/tools/functions.js.map +0 -1
  175. package/dist/tools/impact-chain.d.ts +0 -15
  176. package/dist/tools/impact-chain.d.ts.map +0 -1
  177. package/dist/tools/impact-chain.js +0 -96
  178. package/dist/tools/impact-chain.js.map +0 -1
  179. package/dist/tools/kwq.d.ts +0 -19
  180. package/dist/tools/kwq.d.ts.map +0 -1
  181. package/dist/tools/kwq.js +0 -156
  182. package/dist/tools/kwq.js.map +0 -1
  183. package/dist/tools/lookup.d.ts +0 -14
  184. package/dist/tools/lookup.d.ts.map +0 -1
  185. package/dist/tools/lookup.js +0 -213
  186. package/dist/tools/lookup.js.map +0 -1
  187. package/dist/tools/policy-profile.d.ts +0 -15
  188. package/dist/tools/policy-profile.d.ts.map +0 -1
  189. package/dist/tools/policy-profile.js +0 -174
  190. package/dist/tools/policy-profile.js.map +0 -1
  191. package/dist/tools/profile.d.ts +0 -14
  192. package/dist/tools/profile.d.ts.map +0 -1
  193. package/dist/tools/profile.js +0 -349
  194. package/dist/tools/profile.js.map +0 -1
  195. package/dist/tools/query.d.ts +0 -16
  196. package/dist/tools/query.d.ts.map +0 -1
  197. package/dist/tools/query.js +0 -53
  198. package/dist/tools/query.js.map +0 -1
  199. package/dist/tools/schema.d.ts +0 -23
  200. package/dist/tools/schema.d.ts.map +0 -1
  201. package/dist/tools/schema.js +0 -124
  202. package/dist/tools/schema.js.map +0 -1
  203. package/dist/tools/search-entity-metadata.d.ts +0 -18
  204. package/dist/tools/search-entity-metadata.d.ts.map +0 -1
  205. package/dist/tools/search-entity-metadata.js +0 -221
  206. package/dist/tools/search-entity-metadata.js.map +0 -1
  207. package/dist/tools/search.d.ts +0 -23
  208. package/dist/tools/search.d.ts.map +0 -1
  209. package/dist/tools/search.js +0 -110
  210. package/dist/tools/search.js.map +0 -1
  211. package/dist/tools/solr-fields.d.ts +0 -39
  212. package/dist/tools/solr-fields.d.ts.map +0 -1
  213. package/dist/tools/solr-fields.js +0 -40
  214. package/dist/tools/solr-fields.js.map +0 -1
  215. package/dist/utils.d.ts +0 -70
  216. package/dist/utils.d.ts.map +0 -1
  217. package/dist/utils.js +0 -104
  218. package/dist/utils.js.map +0 -1
@@ -1,221 +0,0 @@
1
- /**
2
- * Per-entity search tool metadata (descriptions, convenience filters, sort hints).
3
- * @module mcp/tools/search-entity-metadata
4
- */
5
- import { z } from "zod";
6
- import { resolveFunderOrgName } from "../funder-org-names.js";
7
- const noop = () => { };
8
- function yearRange(fromKey, toKey, field) {
9
- return (builder, args) => {
10
- const from = args[fromKey];
11
- const to = args[toKey];
12
- if (typeof from === "number") {
13
- builder.where(field, ">=", from);
14
- }
15
- if (typeof to === "number") {
16
- builder.where(field, "<=", to);
17
- }
18
- };
19
- }
20
- /** Metadata for all structured search tools. */
21
- export const SEARCH_ENTITY_METADATA = [
22
- {
23
- source: "publications",
24
- description: "Search research publications in the Dimensions database. Returns articles, preprints, books, and other scholarly works with citation metrics, author information, and metadata.",
25
- applyConvenienceFilters: (builder, args) => {
26
- yearRange("yearFrom", "yearTo", "year")(builder, args);
27
- if (typeof args.type === "string") {
28
- builder.where("type", "=", args.type);
29
- }
30
- },
31
- extraInputSchema: {
32
- yearFrom: z
33
- .number()
34
- .int()
35
- .optional()
36
- .describe("Filter publications from this year (inclusive)"),
37
- yearTo: z
38
- .number()
39
- .int()
40
- .optional()
41
- .describe("Filter publications up to this year (inclusive)"),
42
- type: z
43
- .enum(["article", "chapter", "proceeding", "monograph", "preprint", "book"])
44
- .optional()
45
- .describe("Filter by publication type"),
46
- sortBy: z
47
- .enum([
48
- "times_cited",
49
- "total_citations",
50
- "recent_citations",
51
- "relative_citation_ratio",
52
- "field_citation_ratio",
53
- "citation_ratio",
54
- "altmetric",
55
- "altmetric_score",
56
- "year",
57
- "date",
58
- ])
59
- .optional()
60
- .describe("Sort results by this field (total_citations = times_cited, citation_ratio = field_citation_ratio, altmetric_score = altmetric)"),
61
- },
62
- },
63
- {
64
- source: "grants",
65
- description: "Search research grants and funding awards in the Dimensions database. Returns grant information including funding amounts, funders, and research organizations. " +
66
- "funderOrgName must match an exact Dimensions funder name (acronyms like NCI and NSF are resolved automatically). " +
67
- "Umbrella labels such as NIH often match no grants — discover institute names with facet_query or aggregate_query on facetField funder_orgs.",
68
- applyConvenienceFilters: (builder, args) => {
69
- yearRange("startYearFrom", "startYearTo", "start_year")(builder, args);
70
- if (typeof args.funderOrgName === "string") {
71
- builder.where("funder_org_name", "=", resolveFunderOrgName(args.funderOrgName));
72
- }
73
- },
74
- extraInputSchema: {
75
- startYearFrom: z
76
- .number()
77
- .int()
78
- .optional()
79
- .describe("Filter grants starting from this year (inclusive)"),
80
- startYearTo: z
81
- .number()
82
- .int()
83
- .optional()
84
- .describe("Filter grants starting up to this year (inclusive)"),
85
- funderOrgName: z
86
- .string()
87
- .optional()
88
- .describe("Filter by funder organization name. Acronyms NCI, NSF, NEH resolve automatically; use facet_query/aggregate_query on funder_orgs to discover exact names."),
89
- sortBy: z
90
- .enum([
91
- "funding_usd",
92
- "funding_eur",
93
- "funding_amount_usd",
94
- "funding_amount_eur",
95
- "start_year",
96
- "start_date",
97
- "end_date",
98
- ])
99
- .optional()
100
- .describe("Sort results by this field (funding_amount_usd = funding_usd, funding_amount_eur = funding_eur)"),
101
- },
102
- },
103
- {
104
- source: "researchers",
105
- description: "Search researcher profiles by name in the Dimensions database. The query matches researcher names, not research topics — " +
106
- "for topic→researcher discovery use facet_query with entityType publications and facetField researchers.",
107
- applyConvenienceFilters: noop,
108
- extraInputSchema: {
109
- sortBy: z
110
- .enum(["total_publications", "total_grants"])
111
- .optional()
112
- .describe("Sort results by this field"),
113
- },
114
- },
115
- {
116
- source: "patents",
117
- description: "Search patents in the Dimensions database. Returns patent information including titles, abstracts, assignees, and filing dates.",
118
- applyConvenienceFilters: (builder, args) => {
119
- yearRange("filingYearFrom", "filingYearTo", "year")(builder, args);
120
- },
121
- extraInputSchema: {
122
- filingYearFrom: z
123
- .number()
124
- .int()
125
- .optional()
126
- .describe("Filter patents filed from this year (inclusive)"),
127
- filingYearTo: z
128
- .number()
129
- .int()
130
- .optional()
131
- .describe("Filter patents filed up to this year (inclusive)"),
132
- sortBy: z
133
- .enum(["filing_date", "publication_date", "granted_date"])
134
- .optional()
135
- .describe("Sort results by this field"),
136
- },
137
- },
138
- {
139
- source: "clinical_trials",
140
- description: "Search clinical trials in the Dimensions database. Returns trial information including phases, conditions studied, and status.",
141
- applyConvenienceFilters: (builder, args) => {
142
- if (typeof args.phase === "string") {
143
- builder.where("phase", "=", args.phase);
144
- }
145
- if (typeof args.overallStatus === "string") {
146
- builder.where("overall_status", "=", args.overallStatus);
147
- }
148
- yearRange("yearFrom", "yearTo", "year")(builder, args);
149
- },
150
- extraInputSchema: {
151
- phase: z.string().optional().describe("Filter by trial phase (e.g., 'Phase 3')"),
152
- overallStatus: z
153
- .string()
154
- .optional()
155
- .describe("Filter by trial status (e.g., 'Completed', 'Recruiting')"),
156
- yearFrom: z
157
- .number()
158
- .int()
159
- .optional()
160
- .describe("Filter trials starting from this year (inclusive)"),
161
- yearTo: z
162
- .number()
163
- .int()
164
- .optional()
165
- .describe("Filter trials starting up to this year (inclusive)"),
166
- sortBy: z.enum(["start_date"]).optional().describe("Sort results by this field"),
167
- },
168
- },
169
- {
170
- source: "datasets",
171
- description: "Search research datasets in the Dimensions database. Returns dataset information including descriptions, repositories, and associated publications.",
172
- applyConvenienceFilters: (builder, args) => {
173
- yearRange("yearFrom", "yearTo", "year")(builder, args);
174
- if (typeof args.repository === "string") {
175
- builder.where("repository", "=", args.repository);
176
- }
177
- },
178
- extraInputSchema: {
179
- yearFrom: z.number().int().optional().describe("Filter datasets from this year (inclusive)"),
180
- yearTo: z.number().int().optional().describe("Filter datasets up to this year (inclusive)"),
181
- repository: z.string().optional().describe("Filter by repository name"),
182
- sortBy: z.enum(["year"]).optional().describe("Sort results by this field"),
183
- },
184
- },
185
- {
186
- source: "policy_documents",
187
- description: "Search policy documents in the Dimensions database. Returns policy briefs, reports, and government documents that cite research.",
188
- applyConvenienceFilters: (builder, args) => {
189
- yearRange("yearFrom", "yearTo", "year")(builder, args);
190
- },
191
- extraInputSchema: {
192
- yearFrom: z.number().int().optional().describe("Filter documents from this year (inclusive)"),
193
- yearTo: z.number().int().optional().describe("Filter documents up to this year (inclusive)"),
194
- sortBy: z.enum(["year"]).optional().describe("Sort results by this field"),
195
- },
196
- },
197
- {
198
- source: "organizations",
199
- description: "Search research organizations in the Dimensions database. Returns universities, research institutes, hospitals, and companies with research output.",
200
- applyConvenienceFilters: (builder, args) => {
201
- if (typeof args.orgType === "string") {
202
- builder.where("types", "=", args.orgType);
203
- }
204
- if (typeof args.country === "string") {
205
- builder.where("country_name", "=", args.country);
206
- }
207
- },
208
- extraInputSchema: {
209
- orgType: z
210
- .string()
211
- .optional()
212
- .describe("Filter by organization type (e.g., 'Education', 'Healthcare', 'Company')"),
213
- country: z
214
- .string()
215
- .optional()
216
- .describe("Filter by country (e.g., 'United States', 'Germany')"),
217
- sortBy: z.enum(["name"]).optional().describe("Sort results by this field"),
218
- },
219
- },
220
- ];
221
- //# sourceMappingURL=search-entity-metadata.js.map
@@ -1 +0,0 @@
1
-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5F,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;SAC3E;KACF;IACD;QACE,MAAM,EAAE,eAAe;QACvB,WAAW,EACT,qJAAqJ;QACvJ,uBAAuB,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;YACzC,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACrC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC5C,CAAC;YACD,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACrC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,gBAAgB,EAAE;YAChB,OAAO,EAAE,CAAC;iBACP,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,0EAA0E,CAAC;YACvF,OAAO,EAAE,CAAC;iBACP,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,sDAAsD,CAAC;YACnE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;SAC3E;KACF;CACF,CAAC"}
@@ -1,23 +0,0 @@
1
- /**
2
- * Search tools for the MCP server.
3
- * Registers `search_{source}` tools from describe schema and shared QueryBuilder handlers.
4
- * @module mcp/tools/search
5
- */
6
- import type { DimensionsClient } from "@digital-science/dimensions-dsl";
7
- import { type SchemaStore, type StructuredEntityType } from "@digital-science/dimensions-dsl";
8
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9
- /**
10
- * Builds DSL for a structured search from tool arguments.
11
- * @param source - Dimensions source name
12
- * @param args - Tool arguments (after field-alias resolution)
13
- * @returns DSL query string
14
- */
15
- export declare function buildStructuredSearchDsl(client: DimensionsClient, source: StructuredEntityType, args: Record<string, unknown>): string;
16
- /**
17
- * Registers structured search tools for sources present in the schema store.
18
- * @param server - MCP server instance
19
- * @param client - Dimensions client instance
20
- * @param schemaStore - Loaded describe schema
21
- */
22
- export declare function registerSearchTools(server: McpServer, client: DimensionsClient, schemaStore: SchemaStore): void;
23
- //# sourceMappingURL=search.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAG1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAsCzE;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,CA4BR;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,WAAW,GACvB,IAAI,CAyDN"}
@@ -1,110 +0,0 @@
1
- /**
2
- * Search tools for the MCP server.
3
- * Registers `search_{source}` tools from describe schema and shared QueryBuilder handlers.
4
- * @module mcp/tools/search
5
- */
6
- import { applyFilters, ExtendedWhereFilterSchema, parseEntityResponse, searchResultKey, searchToolName, } from "@digital-science/dimensions-dsl";
7
- import { z } from "zod";
8
- import { withFieldAliases } from "../middleware/field-aliases.js";
9
- import { formatErrorResult, formatToolResult, READ_ONLY_API_ANNOTATIONS, withTruncationWarning, } from "../utils.js";
10
- import { SEARCH_ENTITY_METADATA } from "./search-entity-metadata.js";
11
- const metadataBySource = new Map(SEARCH_ENTITY_METADATA.map((meta) => [meta.source, meta]));
12
- const SHARED_SEARCH_INPUT = {
13
- query: z
14
- .string()
15
- .describe("Search query terms (omit with filters-only search if the API allows)"),
16
- limit: z
17
- .number()
18
- .int()
19
- .min(1)
20
- .max(1000)
21
- .default(100)
22
- .describe("Maximum results to return (max 1000)"),
23
- fields: z
24
- .array(z.string())
25
- .optional()
26
- .describe("Fields to return. Accepts aliases or DSL names. Use dimensions://fields/{entity} for the full list."),
27
- filters: z
28
- .array(ExtendedWhereFilterSchema)
29
- .optional()
30
- .describe("Additional where-clause filters"),
31
- };
32
- /**
33
- * Builds DSL for a structured search from tool arguments.
34
- * @param source - Dimensions source name
35
- * @param args - Tool arguments (after field-alias resolution)
36
- * @returns DSL query string
37
- */
38
- export function buildStructuredSearchDsl(client, source, args) {
39
- const meta = metadataBySource.get(source);
40
- const builder = client.createQueryBuilder().search(source);
41
- if (typeof args.query === "string" && args.query.length > 0) {
42
- builder.for(args.query);
43
- }
44
- meta?.applyConvenienceFilters(builder, args);
45
- const filters = args.filters;
46
- if (filters?.length) {
47
- applyFilters(builder, filters);
48
- }
49
- const fields = args.fields;
50
- if (fields?.length) {
51
- builder.fields(fields);
52
- }
53
- if (typeof args.sortBy === "string") {
54
- builder.sort(args.sortBy, "desc");
55
- }
56
- const limit = typeof args.limit === "number" ? args.limit : 100;
57
- builder.limit(limit);
58
- return builder.build();
59
- }
60
- /**
61
- * Registers structured search tools for sources present in the schema store.
62
- * @param server - MCP server instance
63
- * @param client - Dimensions client instance
64
- * @param schemaStore - Loaded describe schema
65
- */
66
- export function registerSearchTools(server, client, schemaStore) {
67
- for (const source of schemaStore.structuredEntityTypes()) {
68
- const meta = metadataBySource.get(source);
69
- if (!meta)
70
- continue;
71
- const resultKey = searchResultKey(source);
72
- const toolName = searchToolName(source);
73
- server.registerTool(toolName, {
74
- description: meta.description,
75
- inputSchema: {
76
- ...SHARED_SEARCH_INPUT,
77
- ...meta.extraInputSchema,
78
- },
79
- outputSchema: {
80
- totalCount: z.number().describe("Total matching records"),
81
- returnedCount: z.number().describe("Records returned in this response"),
82
- truncated: z.boolean().optional().describe("True when results are truncated"),
83
- truncationWarning: z.string().optional().describe("Warning message when truncated"),
84
- [resultKey]: z.array(z.record(z.string(), z.unknown())).describe("Result records"),
85
- },
86
- annotations: READ_ONLY_API_ANNOTATIONS,
87
- }, withFieldAliases({
88
- entitySource: { kind: "static", entity: source },
89
- fieldArrayArgs: ["fields"],
90
- fieldStringArgs: ["sortBy"],
91
- filterArrayArgs: ["filters"],
92
- }, async (args) => {
93
- try {
94
- const dsl = buildStructuredSearchDsl(client, source, args);
95
- const response = (await client.rawQuery(dsl));
96
- const parsed = parseEntityResponse(response, source);
97
- const rows = parsed.data;
98
- return formatToolResult(withTruncationWarning({
99
- totalCount: parsed.totalCount,
100
- returnedCount: rows.length,
101
- [resultKey]: rows,
102
- }, parsed.totalCount, rows.length));
103
- }
104
- catch (error) {
105
- return formatErrorResult(error);
106
- }
107
- }));
108
- }
109
- }
110
- //# sourceMappingURL=search.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,YAAY,EAEZ,yBAAyB,EACzB,mBAAmB,EAGnB,eAAe,EACf,cAAc,GACf,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,sBAAsB,CAAC,GAAG,CAAC,CAAC,IAAI,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f,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CACF,CACF,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,39 +0,0 @@
1
- /**
2
- * Shared SOLR field name constants and entity-to-collection mapping.
3
- * Field names are derived from the authoritative Python DSL wiring in
4
- * misc/dim-dsl/dsl/wiring/sources/ — each constant cites its source.
5
- * @module mcp/tools/solr-fields
6
- */
7
- /**
8
- * SOLR field for `researchers.id` in the publications collection.
9
- * Source: misc/dim-dsl/dsl/wiring/sources/publications.py:360
10
- */
11
- export declare const RESEARCHER_DIM_ID = "researcher_dim_id";
12
- /**
13
- * SOLR field for `research_orgs.id` in the publications collection.
14
- * Source: misc/dim-dsl/dsl/wiring/sources/publications.py:334
15
- */
16
- export declare const AFF_ORG_ID = "aff_org_id";
17
- /**
18
- * Maps DSL entity type names to their SOLR collection paths.
19
- *
20
- * This map bridges two naming conventions that meet in the MCP tools: the
21
- * DSL/AST `EntityType` is snake_case (`clinical_trials`), while the Solr
22
- * package's `LogicalCollectionName` is camelCase (`clinicalTrials`).
23
- * `resolveDefaultCollection` only accepts the camelCase form, so the
24
- * snake_case-keyed map is the case-conversion layer.
25
- *
26
- * Scope: only the six document-corpus entities used by the MCP fan-out tools
27
- * ({@link concept-profile}, {@link impact-chain}, etc.). `researchers` and
28
- * `organizations` are intentionally omitted — none of the consumer tools
29
- * query those collections.
30
- */
31
- export declare const ENTITY_COLLECTION_MAP: {
32
- readonly publications: string;
33
- readonly grants: string;
34
- readonly patents: string;
35
- readonly clinical_trials: string;
36
- readonly policy_documents: string;
37
- readonly datasets: string;
38
- };
39
- //# sourceMappingURL=solr-fields.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"solr-fields.d.ts","sourceRoot":"","sources":["../../src/tools/solr-fields.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qBAAqB;;;;;;;CAOxB,CAAC"}
@@ -1,40 +0,0 @@
1
- /**
2
- * Shared SOLR field name constants and entity-to-collection mapping.
3
- * Field names are derived from the authoritative Python DSL wiring in
4
- * misc/dim-dsl/dsl/wiring/sources/ — each constant cites its source.
5
- * @module mcp/tools/solr-fields
6
- */
7
- import { resolveDefaultCollection } from "@digital-science/dimensions-solr";
8
- /**
9
- * SOLR field for `researchers.id` in the publications collection.
10
- * Source: misc/dim-dsl/dsl/wiring/sources/publications.py:360
11
- */
12
- export const RESEARCHER_DIM_ID = "researcher_dim_id";
13
- /**
14
- * SOLR field for `research_orgs.id` in the publications collection.
15
- * Source: misc/dim-dsl/dsl/wiring/sources/publications.py:334
16
- */
17
- export const AFF_ORG_ID = "aff_org_id";
18
- /**
19
- * Maps DSL entity type names to their SOLR collection paths.
20
- *
21
- * This map bridges two naming conventions that meet in the MCP tools: the
22
- * DSL/AST `EntityType` is snake_case (`clinical_trials`), while the Solr
23
- * package's `LogicalCollectionName` is camelCase (`clinicalTrials`).
24
- * `resolveDefaultCollection` only accepts the camelCase form, so the
25
- * snake_case-keyed map is the case-conversion layer.
26
- *
27
- * Scope: only the six document-corpus entities used by the MCP fan-out tools
28
- * ({@link concept-profile}, {@link impact-chain}, etc.). `researchers` and
29
- * `organizations` are intentionally omitted — none of the consumer tools
30
- * query those collections.
31
- */
32
- export const ENTITY_COLLECTION_MAP = {
33
- publications: resolveDefaultCollection("publications"),
34
- grants: resolveDefaultCollection("grants"),
35
- patents: resolveDefaultCollection("patents"),
36
- clinical_trials: resolveDefaultCollection("clinicalTrials"),
37
- policy_documents: resolveDefaultCollection("policyDocuments"),
38
- datasets: resolveDefaultCollection("datasets"),
39
- };
40
- //# sourceMappingURL=solr-fields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"solr-fields.js","sourceRoot":"","sources":["../../src/tools/solr-fields.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAE5E;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AAEvC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,YAAY,EAAE,wBAAwB,CAAC,cAAc,CAAC;IACtD,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC;IAC1C,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC;IAC5C,eAAe,EAAE,wBAAwB,CAAC,gBAAgB,CAAC;IAC3D,gBAAgB,EAAE,wBAAwB,CAAC,iBAAiB,CAAC;IAC7D,QAAQ,EAAE,wBAAwB,CAAC,UAAU,CAAC;CACtC,CAAC"}
package/dist/utils.d.ts DELETED
@@ -1,70 +0,0 @@
1
- /**
2
- * Utility functions for MCP tools.
3
- * @module mcp/utils
4
- */
5
- import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
- import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
7
- /** Annotations for read-only tools that call external APIs. */
8
- export declare const READ_ONLY_API_ANNOTATIONS: ToolAnnotations;
9
- /**
10
- * Coerces an unknown value to an array of records, returning `[]` if not an array.
11
- * Replaces unsafe `as Array<Record<string, unknown>>` casts from API responses.
12
- * @param value - Unknown value from a DSL response property
13
- * @returns The value as an array of records, or empty array if not an array
14
- */
15
- export declare function asArray(value: unknown): Array<Record<string, unknown>>;
16
- /**
17
- * MCP tool result format.
18
- * Includes index signature for MCP SDK compatibility.
19
- */
20
- export interface ToolResult {
21
- [key: string]: unknown;
22
- content: Array<{
23
- type: "text";
24
- text: string;
25
- }>;
26
- structuredContent?: Record<string, unknown>;
27
- isError?: boolean;
28
- }
29
- /**
30
- * Formats a successful tool result.
31
- * Populates both `content` (text/JSON) and `structuredContent` for SDK output schema validation.
32
- * @param data - The data to return
33
- * @returns Formatted tool result
34
- */
35
- export declare function formatToolResult(data: unknown): ToolResult;
36
- /**
37
- * Builds a JSON-serializable error payload for MCP tool responses.
38
- * Surfaces Dimensions API metadata (status codes, client rate-limit hints) when available.
39
- * @param error - The error that occurred
40
- * @returns Error payload object
41
- */
42
- export declare function formatErrorPayload(error: unknown): Record<string, unknown>;
43
- /**
44
- * Formats an error tool result.
45
- * @param error - The error that occurred
46
- * @returns Formatted error result
47
- */
48
- export declare function formatErrorResult(error: unknown): ToolResult;
49
- /**
50
- * Augments a result object with truncation warning when results are incomplete.
51
- * @param data - The result data object
52
- * @param totalCount - Total matching records from the API
53
- * @param returnedCount - Records actually returned
54
- * @returns The data object, augmented with truncation fields if applicable
55
- */
56
- export declare function withTruncationWarning<T extends Record<string, unknown>>(data: T, totalCount: number, returnedCount: number): T & {
57
- truncated?: boolean;
58
- truncationWarning?: string;
59
- };
60
- /** Logging levels supported by the MCP protocol (syslog severity). */
61
- export type McpLogLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
62
- /**
63
- * Sends a structured log message via the MCP protocol with stderr fallback.
64
- * @param server - MCP server instance
65
- * @param level - Log severity level
66
- * @param data - Structured log data (any JSON-serializable value)
67
- * @param logger - Optional logger namespace (e.g., "search", "schema")
68
- */
69
- export declare function mcpLog(server: McpServer, level: McpLogLevel, data: unknown, logger?: string): void;
70
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE1E,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,EAAE,eAK9B,CAAC;AAEX;;;;;GAKG;AACH,wBAAg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dist/utils.js DELETED
@@ -1,104 +0,0 @@
1
- /**
2
- * Utility functions for MCP tools.
3
- * @module mcp/utils
4
- */
5
- import { DimensionsError } from "@digital-science/dimensions-dsl";
6
- /** Annotations for read-only tools that call external APIs. */
7
- export const READ_ONLY_API_ANNOTATIONS = {
8
- readOnlyHint: true,
9
- destructiveHint: false,
10
- idempotentHint: true,
11
- openWorldHint: true,
12
- };
13
- /**
14
- * Coerces an unknown value to an array of records, returning `[]` if not an array.
15
- * Replaces unsafe `as Array<Record<string, unknown>>` casts from API responses.
16
- * @param value - Unknown value from a DSL response property
17
- * @returns The value as an array of records, or empty array if not an array
18
- */
19
- export function asArray(value) {
20
- return Array.isArray(value) ? value : [];
21
- }
22
- /**
23
- * Formats a successful tool result.
24
- * Populates both `content` (text/JSON) and `structuredContent` for SDK output schema validation.
25
- * @param data - The data to return
26
- * @returns Formatted tool result
27
- */
28
- export function formatToolResult(data) {
29
- return {
30
- content: [
31
- {
32
- type: "text",
33
- text: JSON.stringify(data, null, 2),
34
- },
35
- ],
36
- structuredContent: data,
37
- };
38
- }
39
- /**
40
- * Builds a JSON-serializable error payload for MCP tool responses.
41
- * Surfaces Dimensions API metadata (status codes, client rate-limit hints) when available.
42
- * @param error - The error that occurred
43
- * @returns Error payload object
44
- */
45
- export function formatErrorPayload(error) {
46
- if (error instanceof DimensionsError) {
47
- const json = error.toJSON();
48
- return {
49
- ...json,
50
- error: json.message,
51
- type: json.name,
52
- };
53
- }
54
- return {
55
- error: error instanceof Error ? error.message : String(error),
56
- type: error instanceof Error ? error.name : "Error",
57
- };
58
- }
59
- /**
60
- * Formats an error tool result.
61
- * @param error - The error that occurred
62
- * @returns Formatted error result
63
- */
64
- export function formatErrorResult(error) {
65
- return {
66
- content: [
67
- {
68
- type: "text",
69
- text: JSON.stringify(formatErrorPayload(error), null, 2),
70
- },
71
- ],
72
- isError: true,
73
- };
74
- }
75
- /**
76
- * Augments a result object with truncation warning when results are incomplete.
77
- * @param data - The result data object
78
- * @param totalCount - Total matching records from the API
79
- * @param returnedCount - Records actually returned
80
- * @returns The data object, augmented with truncation fields if applicable
81
- */
82
- export function withTruncationWarning(data, totalCount, returnedCount) {
83
- if (totalCount > returnedCount) {
84
- return {
85
- ...data,
86
- truncated: true,
87
- truncationWarning: `Only ${returnedCount} of ${totalCount} results returned. Narrow your query with additional filters or use execute_dsl with pagination.`,
88
- };
89
- }
90
- return data;
91
- }
92
- /**
93
- * Sends a structured log message via the MCP protocol with stderr fallback.
94
- * @param server - MCP server instance
95
- * @param level - Log severity level
96
- * @param data - Structured log data (any JSON-serializable value)
97
- * @param logger - Optional logger namespace (e.g., "search", "schema")
98
- */
99
- export function mcpLog(server, level, data, logger) {
100
- server.sendLoggingMessage({ level, data, logger }).catch(() => {
101
- console.error(`[${level}]${logger ? ` [${logger}]` : ""} ${typeof data === "string" ? data : JSON.stringify(data)}`);
102
- });
103
- }
104
- //# sourceMappingURL=utils.js.map
package/dist/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAIlE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,IAAI;CACX,CAAC;AAEX;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAAwC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/E,CAAC;AAgBD;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAa;IAC5C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CA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