@cyanheads/openalex-mcp-server 0.7.14 → 0.7.16

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 (49) hide show
  1. package/AGENTS.md +8 -4
  2. package/CLAUDE.md +8 -4
  3. package/README.md +12 -9
  4. package/changelog/0.7.x/0.7.15.md +33 -0
  5. package/changelog/0.7.x/0.7.16.md +32 -0
  6. package/dist/mcp-server/prompts/definitions/literature-review.prompt.js +1 -1
  7. package/dist/mcp-server/prompts/definitions/literature-review.prompt.js.map +1 -1
  8. package/dist/mcp-server/tools/definitions/analyze-trends.tool.d.ts +22 -2
  9. package/dist/mcp-server/tools/definitions/analyze-trends.tool.d.ts.map +1 -1
  10. package/dist/mcp-server/tools/definitions/analyze-trends.tool.js +71 -17
  11. package/dist/mcp-server/tools/definitions/analyze-trends.tool.js.map +1 -1
  12. package/dist/mcp-server/tools/definitions/citation-graph.tool.d.ts +12 -1
  13. package/dist/mcp-server/tools/definitions/citation-graph.tool.d.ts.map +1 -1
  14. package/dist/mcp-server/tools/definitions/citation-graph.tool.js +56 -39
  15. package/dist/mcp-server/tools/definitions/citation-graph.tool.js.map +1 -1
  16. package/dist/mcp-server/tools/definitions/describe-fields.tool.d.ts.map +1 -1
  17. package/dist/mcp-server/tools/definitions/describe-fields.tool.js +82 -15
  18. package/dist/mcp-server/tools/definitions/describe-fields.tool.js.map +1 -1
  19. package/dist/mcp-server/tools/definitions/resolve-name.tool.d.ts +18 -0
  20. package/dist/mcp-server/tools/definitions/resolve-name.tool.d.ts.map +1 -1
  21. package/dist/mcp-server/tools/definitions/resolve-name.tool.js +29 -7
  22. package/dist/mcp-server/tools/definitions/resolve-name.tool.js.map +1 -1
  23. package/dist/mcp-server/tools/definitions/search-entities.tool.d.ts +50 -0
  24. package/dist/mcp-server/tools/definitions/search-entities.tool.d.ts.map +1 -1
  25. package/dist/mcp-server/tools/definitions/search-entities.tool.js +176 -41
  26. package/dist/mcp-server/tools/definitions/search-entities.tool.js.map +1 -1
  27. package/dist/mcp-server/tools/escape-markdown.d.ts +32 -0
  28. package/dist/mcp-server/tools/escape-markdown.d.ts.map +1 -0
  29. package/dist/mcp-server/tools/escape-markdown.js +389 -0
  30. package/dist/mcp-server/tools/escape-markdown.js.map +1 -0
  31. package/dist/mcp-server/tools/render-entity-record.d.ts +2 -1
  32. package/dist/mcp-server/tools/render-entity-record.d.ts.map +1 -1
  33. package/dist/mcp-server/tools/render-entity-record.js +24 -8
  34. package/dist/mcp-server/tools/render-entity-record.js.map +1 -1
  35. package/dist/services/openalex/html-entities.json +2237 -0
  36. package/dist/services/openalex/openalex-service.d.ts +17 -1
  37. package/dist/services/openalex/openalex-service.d.ts.map +1 -1
  38. package/dist/services/openalex/openalex-service.js +211 -101
  39. package/dist/services/openalex/openalex-service.js.map +1 -1
  40. package/dist/services/openalex/provider-text.d.ts +20 -0
  41. package/dist/services/openalex/provider-text.d.ts.map +1 -0
  42. package/dist/services/openalex/provider-text.js +276 -0
  43. package/dist/services/openalex/provider-text.js.map +1 -0
  44. package/dist/services/openalex/types.d.ts +16 -0
  45. package/dist/services/openalex/types.d.ts.map +1 -1
  46. package/dist/services/openalex/types.js +7 -0
  47. package/dist/services/openalex/types.js.map +1 -1
  48. package/package.json +6 -3
  49. package/server.json +3 -3
@@ -16,9 +16,9 @@ const SAMPLE_MAX = 100;
16
16
  * alone, so every parameter named here is dropped on that path — by OpenAlex itself, which
17
17
  * answers an entity-by-ID URL identically whether or not search params ride along.
18
18
  *
19
- * Pagination (`per_page`, `cursor`) is deliberately absent: a singleton lookup is one record by
20
- * definition, and `per_page` always carries its schema default, so a caller's intent there
21
- * cannot be told apart from the absence of one. Naming it would be noise, not a warning.
19
+ * Pagination (`per_page`, `cursor`, `page`) is deliberately absent: a singleton lookup is one
20
+ * record by definition, and `per_page` always carries its schema default, so a caller's intent
21
+ * there cannot be told apart from the absence of one. Naming it would be noise, not a warning.
22
22
  */
23
23
  function searchOnlyParams(input) {
24
24
  const parts = [];
@@ -51,31 +51,16 @@ function buildSearchEcho(input) {
51
51
  return [...parts, ...searchOnlyParams(input).map((part) => part.rendered)].join(' | ');
52
52
  }
53
53
  /**
54
- * Reject list-query parameter combinations OpenAlex cannot serve. All three checks constrain a
55
- * *list* query. `id` takes the singleton path in `OpenAlexService.search()`, which reads only
56
- * `entity_type`, `id`, and `select` — so search_mode, per_page, cursor, sample, and seed are
57
- * unread there, and rejecting an ID lookup over how they relate to each other fails it on
58
- * constraints it never met. The handler's dropped-parameter notice reports them instead. The
59
- * `id` predicate is truthiness, not `!== undefined`, to match the service branch: an
60
- * empty-string `id` parses and lists.
54
+ * Is this call continuing a paginated traversal rather than opening one? A `cursor` is the
55
+ * keyword/exact signal — the schema rejects a blank one, so its presence is always a real
56
+ * continuation rather than a mistake OpenAlex answers with page 1; a `page` past the first is
57
+ * the semantic signal, and `page` only survives the handler's preconditions under semantic
58
+ * mode. Only on a continuing call does a page of
59
+ * zero results mean the traversal is finished — on a first call it means nothing matched, and
60
+ * the two want opposite advice.
61
61
  */
62
- function assertListQueryConstraints(input, ctx) {
63
- if (input.id)
64
- return;
65
- if (input.search_mode === 'semantic' && input.per_page > SEMANTIC_PER_PAGE_CAP) {
66
- throw ctx.fail('semantic_per_page_cap', `Semantic search supports at most ${SEMANTIC_PER_PAGE_CAP} results per page. Reduce per_page or switch search_mode.`, {
67
- ...ctx.recoveryFor('semantic_per_page_cap'),
68
- searchMode: input.search_mode,
69
- perPage: input.per_page,
70
- cap: SEMANTIC_PER_PAGE_CAP,
71
- });
72
- }
73
- if (input.sample !== undefined && input.cursor !== undefined) {
74
- throw ctx.fail('sample_with_cursor', 'Sampling returns one page only — `sample` cannot be combined with `cursor` pagination.', { ...ctx.recoveryFor('sample_with_cursor'), sample: input.sample, cursor: input.cursor });
75
- }
76
- if (input.seed !== undefined && input.sample === undefined) {
77
- throw ctx.fail('seed_without_sample', '`seed` is only meaningful with `sample` — pass `sample` to enable random sampling.', { ...ctx.recoveryFor('seed_without_sample'), seed: input.seed });
78
- }
62
+ function isContinuationPage(input) {
63
+ return input.cursor !== undefined || (input.page ?? 1) > 1;
79
64
  }
80
65
  export const searchEntitiesTool = tool('openalex_search_entities', {
81
66
  description: 'Search, filter, sort, or retrieve by ID. Covers all OpenAlex entity types (works, authors, sources, institutions, topics, keywords, publishers, funders). Pass `id` to retrieve a single entity. Otherwise, use `query` and/or `filters` for discovery. Supports keyword search with boolean operators, exact phrase matching, and AI semantic search. Use openalex_resolve_name to resolve names to IDs before filtering. Searches and ID lookups return a curated set of fields by default; pass `select` to override with specific fields, or `["*"]` for the full record.',
@@ -88,12 +73,48 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
88
73
  when: `A search (no \`id\`) set per_page above the semantic-search cap of ${SEMANTIC_PER_PAGE_CAP}.`,
89
74
  recovery: `Reduce per_page to ${SEMANTIC_PER_PAGE_CAP} or less, or switch search_mode to keyword.`,
90
75
  },
76
+ {
77
+ reason: 'semantic_without_query',
78
+ code: JsonRpcErrorCode.ValidationError,
79
+ when: 'A search set search_mode to "semantic" without supplying the `query` it embeds.',
80
+ recovery: 'Pass the text to match in `query`, or switch search_mode to keyword for a filter-only listing.',
81
+ },
82
+ {
83
+ reason: 'semantic_with_cursor',
84
+ code: JsonRpcErrorCode.ValidationError,
85
+ when: 'A search set search_mode to "semantic" and supplied `cursor`, which OpenAlex rejects on a semantic query.',
86
+ recovery: 'Drop `cursor` and walk semantic results with `page` (1-based), or switch search_mode to keyword or exact, which paginate by cursor.',
87
+ },
88
+ {
89
+ reason: 'page_without_semantic',
90
+ code: JsonRpcErrorCode.ValidationError,
91
+ when: 'A search supplied `page` under a search_mode other than "semantic".',
92
+ recovery: 'Drop `page` and paginate with `cursor`, or set search_mode to "semantic" — the only mode `page` applies to.',
93
+ },
91
94
  {
92
95
  reason: 'sample_with_cursor',
93
96
  code: JsonRpcErrorCode.ValidationError,
94
97
  when: 'A search (no `id`) provided both `sample` and `cursor`.',
95
98
  recovery: 'Sampling returns a single page only; remove `cursor` or remove `sample`.',
96
99
  },
100
+ {
101
+ reason: 'sample_with_page',
102
+ code: JsonRpcErrorCode.ValidationError,
103
+ when: 'A search (no `id`) provided both `sample` and `page`.',
104
+ recovery: 'Sampling returns a single page only; remove `page` or remove `sample`.',
105
+ },
106
+ {
107
+ reason: 'sample_with_semantic',
108
+ code: JsonRpcErrorCode.ValidationError,
109
+ when: 'A search (no `id`) provided `sample` with search_mode "semantic", which OpenAlex does not sample — it returns the same ranked candidates under every seed.',
110
+ recovery: 'Switch search_mode to keyword or exact to draw a random sample, or remove `sample` and walk the semantic candidates with `page`.',
111
+ },
112
+ {
113
+ reason: 'sample_with_sort',
114
+ code: JsonRpcErrorCode.ValidationError,
115
+ when: 'A search (no `id`) provided both `sample` and `sort`, which OpenAlex refuses together.',
116
+ recovery: 'A random sample has no order to sort by; remove `sort` or remove `sample`.',
117
+ },
97
118
  {
98
119
  reason: 'seed_without_sample',
99
120
  code: JsonRpcErrorCode.ValidationError,
@@ -105,6 +126,7 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
105
126
  code: JsonRpcErrorCode.NotFound,
106
127
  when: 'Lookup by id matched no OpenAlex entity.',
107
128
  recovery: 'Verify the ID format or call openalex_resolve_name to find the correct ID.',
129
+ thrownBy: 'service',
108
130
  },
109
131
  {
110
132
  reason: 'rate_limited',
@@ -112,6 +134,7 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
112
134
  when: 'OpenAlex throttled the request for exceeding its per-second ceiling (HTTP 429).',
113
135
  retryable: true,
114
136
  recovery: 'Wait several seconds and retry; consider lowering request frequency for this caller.',
137
+ thrownBy: 'service',
115
138
  },
116
139
  {
117
140
  reason: 'upstream_budget_exhausted',
@@ -119,6 +142,7 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
119
142
  when: 'The OpenAlex daily usage budget is spent (HTTP 429).',
120
143
  retryable: false,
121
144
  recovery: 'The daily budget refills at midnight UTC — retrying sooner will not succeed. Set OPENALEX_API_KEY to a free key (https://openalex.org/settings/api) for a larger daily budget than anonymous access, or wait for the reset.',
145
+ thrownBy: 'service',
122
146
  },
123
147
  {
124
148
  reason: 'upstream_timeout',
@@ -126,6 +150,7 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
126
150
  when: 'OpenAlex did not respond within the request deadline.',
127
151
  retryable: true,
128
152
  recovery: 'Retry after a short delay; if timeouts persist, narrow the request with tighter filters to reduce upstream load.',
153
+ thrownBy: 'service',
129
154
  },
130
155
  {
131
156
  reason: 'upstream_unavailable',
@@ -133,54 +158,70 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
133
158
  when: 'OpenAlex was unreachable or unusable — HTTP 503, a connection failure, or a body that was empty, HTML, or unparseable JSON.',
134
159
  retryable: true,
135
160
  recovery: 'Wait and retry; check https://openalex.org for service status if the outage persists.',
161
+ thrownBy: 'service',
136
162
  },
137
163
  {
138
164
  reason: 'upstream_unauthorized',
139
165
  code: JsonRpcErrorCode.Unauthorized,
140
166
  when: 'OpenAlex rejected the API key (HTTP 401).',
141
167
  recovery: 'Check that OPENALEX_API_KEY is set to a valid OpenAlex account API key (free from https://openalex.org/settings/api).',
168
+ thrownBy: 'service',
142
169
  },
143
170
  {
144
171
  reason: 'upstream_forbidden',
145
172
  code: JsonRpcErrorCode.Forbidden,
146
173
  when: 'OpenAlex denied access to the requested resource (HTTP 403).',
147
174
  recovery: 'Confirm the API key has access to this entity type or endpoint, then retry the request.',
175
+ thrownBy: 'service',
148
176
  },
149
177
  {
150
178
  reason: 'comma_in_filter_value',
151
179
  code: JsonRpcErrorCode.InvalidParams,
152
180
  when: 'A filter value contains a comma, which collides with the OpenAlex filter separator.',
153
181
  recovery: 'Use `|` for OR within a filter value (e.g. "2020|2021"), or use a `.search` filter or the `query` parameter for free-text phrases that contain commas.',
182
+ thrownBy: 'service',
154
183
  },
155
184
  {
156
185
  reason: 'upstream_invalid_params',
157
186
  code: JsonRpcErrorCode.InvalidParams,
158
187
  when: 'OpenAlex rejected an invalid filter, select, or sort field name (HTTP 400).',
159
188
  recovery: 'The upstream message names the rejected field and suggests close matches. Use openalex_describe_fields(entity_type, context) to browse all valid fields for the given entity type and context.',
189
+ thrownBy: 'service',
160
190
  },
161
191
  {
162
192
  reason: 'upstream_invalid_id_value',
163
193
  code: JsonRpcErrorCode.InvalidParams,
164
194
  when: 'An entity-ID filter received a value that is not an OpenAlex ID — usually a name (HTTP 400).',
165
195
  recovery: 'Call openalex_resolve_name to turn the name into an OpenAlex ID, then filter by that ID. Entity filters such as authorships.author.id, primary_topic.id, and cites accept IDs only.',
196
+ thrownBy: 'service',
166
197
  },
167
198
  {
168
199
  reason: 'upstream_sort_requires_search',
169
200
  code: JsonRpcErrorCode.InvalidParams,
170
201
  when: 'sort=-relevance_score was used without an active search (HTTP 400).',
171
202
  recovery: 'Sorting by relevance_score requires an active search — add a `query` or a `*.search` filter (e.g. title.search), or choose a concrete sort field such as -cited_by_count or -publication_date.',
203
+ thrownBy: 'service',
204
+ },
205
+ {
206
+ reason: 'query_too_long',
207
+ code: JsonRpcErrorCode.InvalidParams,
208
+ when: 'OpenAlex rejected `query` as longer than the search length it accepts (HTTP 400).',
209
+ recovery: 'Shorten `query` to the character limit the upstream message names, or split the text into several shorter searches and merge their results.',
210
+ thrownBy: 'service',
172
211
  },
173
212
  {
174
213
  reason: 'upstream_invalid_params_other',
175
214
  code: JsonRpcErrorCode.InvalidParams,
176
215
  when: 'OpenAlex rejected the request (HTTP 400) for a reason other than an invalid field name.',
177
216
  recovery: 'Read the upstream message in the error above and adjust the request — check filter operators, value formats, and cursor/per_page bounds.',
217
+ thrownBy: 'service',
178
218
  },
179
219
  {
180
220
  reason: 'upstream_validation_failed',
181
221
  code: JsonRpcErrorCode.ValidationError,
182
222
  when: 'OpenAlex rejected the request as semantically invalid (HTTP 422).',
183
223
  recovery: 'Read the upstream message for the specific field, then adjust the request to satisfy validation.',
224
+ thrownBy: 'service',
184
225
  },
185
226
  ],
186
227
  inputAliases: { search: 'query', filter: 'filters' },
@@ -188,24 +229,26 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
188
229
  entity_type: z.enum(ENTITY_TYPES).describe('Type of scholarly entity to search.'),
189
230
  id: z
190
231
  .string()
232
+ .min(1)
191
233
  .optional()
192
- .describe('Retrieve a single entity by ID. Supports: OpenAlex ID ("W2741809807"), DOI ("10.1038/nature12373"), ORCID ("0000-0002-1825-0097"), ROR ("https://ror.org/00hx57361"), PMID ("12345678" or "https://pubmed.ncbi.nlm.nih.gov/12345678"), ISSN ("1234-5678"). A PMCID is recognized too, bare ("PMC1234567") or as a PubMed Central URL, but OpenAlex indexes no PMCIDs, so it resolves nothing — pass the work\'s PMID or DOI instead. When provided, `query`, `search_mode`, `filters`, `sort`, `sample`, and `seed` are not applied — the returned record is the entity at that ID regardless of them, and the response `notice` names any you passed. `select` still applies: the curated per-entity-type default is returned unless you pass `select` (use `["*"]` for the complete record). To filter, drop `id` and search. Use openalex_resolve_name to find the ID if unknown.'),
234
+ .describe('Retrieve a single entity by ID. Supports: OpenAlex ID ("W2741809807"), DOI ("10.1038/nature12373"), ORCID ("0000-0002-1825-0097"), ROR ("https://ror.org/00hx57361"), PMID ("12345678" or "https://pubmed.ncbi.nlm.nih.gov/12345678"), ISSN ("1234-5678"). Keywords are identified by slug rather than a native ID — pass either the slug ("groundwater") or the URL a search returns ("https://openalex.org/keywords/groundwater"). A PMCID is recognized too, bare ("PMC1234567") or as a PubMed Central URL, but OpenAlex indexes no PMCIDs, so it resolves nothing — pass the work\'s PMID or DOI instead. When provided, `query`, `search_mode`, `filters`, `sort`, `sample`, and `seed` are not applied — the returned record is the entity at that ID regardless of them, and the response `notice` names any you passed. `select` still applies: the curated per-entity-type default is returned unless you pass `select` (use `["*"]` for the complete record). To filter, drop `id` and search. Use openalex_resolve_name to find the ID if unknown.'),
193
235
  query: z
194
236
  .string()
237
+ .min(1)
195
238
  .optional()
196
- .describe('Text search query. Supports boolean operators (AND, OR, NOT), quoted phrases ("exact match"), wildcards (machin*), fuzzy matching (machin~1), and proximity ("climate change"~5). Omit for filter-only queries.'),
239
+ .describe('Text search query. Supports boolean operators (AND, OR, NOT), quoted phrases ("exact match"), wildcards (machin*), fuzzy matching (machin~1), and proximity ("climate change"~5). Omit for filter-only queries — an empty string is rejected, since a blank search is a mistake rather than a request for the whole catalog.'),
197
240
  search_mode: z
198
241
  .enum(['keyword', 'exact', 'semantic'])
199
242
  .default('keyword')
200
- .describe('Search strategy. "keyword": stemmed full-text (default). "exact": no stemming, matches individual words (use quoted phrases for multi-word exact match). "semantic": AI embedding similarity (max 50 results, 1 req/sec).'),
243
+ .describe(`Search strategy. "keyword": stemmed full-text (default). "exact": no stemming, matches individual words (use quoted phrases for multi-word exact match). "semantic": AI embedding similarity over a query-dependent candidate set whose size \`meta.count\` reports, at ~1 req/sec, up to ${SEMANTIC_PER_PAGE_CAP} per page, and paginated with \`page\` rather than \`cursor\`.`),
201
244
  filters: z
202
245
  .record(z.string(), z.string())
203
246
  .optional()
204
- .describe('Filter criteria as field:value pairs. AND across fields (multiple keys). OR within field: pipe-separate ("us|gb"). NOT: prefix "!" ("!us"). Range: "2020-2024". Comparison: ">100", "<50". AND within same field: "+"-separate. Use OpenAlex IDs (not names) for entity filters — resolve names first. Common keys: `openalex` (filter by entity ID, e.g. {"openalex": "W123|W456"}), `cites` (works citing a given work), `publication_year` (range "2020-2024"), `authorships.author.id`, `type`, `is_oa`.'),
247
+ .describe('Filter criteria as field:value pairs. AND across fields (multiple keys). OR within field: pipe-separate ("us|gb"). NOT: prefix "!" ("!us"). Range: "2020-2024". Comparison: ">100", "<50". AND within same field: "+"-separate. Two keys that resolve to the same upstream field (an alias and its canonical name, e.g. `year` and `publication_year`) are both applied and AND\'d, so they narrow rather than override each other. Use OpenAlex IDs (not names) for entity filters — resolve names first. Common keys: `openalex` (filter by entity ID, e.g. {"openalex": "W123|W456"}), `cites` (works citing a given work), `publication_year` (range "2020-2024"), `authorships.author.id`, `type`, `is_oa`.'),
205
248
  sort: z
206
249
  .string()
207
250
  .optional()
208
- .describe('Sort field. Prefix with "-" for descending. Comma-separate for a multi-key sort, applied left to right, with the "-" prefix set per key ("-publication_year,cited_by_count" sorts by year descending, then citations ascending). Common: "cited_by_count", "-publication_date", "-relevance_score" (default when query present). Note: when combined with a keyword query, an explicit sort overrides relevance ranking entirely — top results may be highly cited but only tangentially on-topic. Use "-relevance_score" or omit sort to keep the most relevant results first. "-relevance_score" requires an active search via "query" or a "filter:search" filter — passing it without one will fail.'),
251
+ .describe('Sort field. Prefix with "-" for descending. Comma-separate for a multi-key sort, applied left to right, with the "-" prefix set per key ("-publication_year,cited_by_count" sorts by year descending, then citations ascending). Common: "cited_by_count", "-publication_date", "-relevance_score" (default when query present). Note: when combined with a keyword query, an explicit sort overrides relevance ranking entirely — top results may be highly cited but only tangentially on-topic. Use "-relevance_score" or omit sort to keep the most relevant results first. "-relevance_score" requires an active search via "query" or a "filter:search" filter — passing it without one will fail. Not combinable with `sample` — a search passing both is rejected.'),
209
252
  select: z
210
253
  .array(z.string())
211
254
  .optional()
@@ -219,15 +262,22 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
219
262
  .describe('Results per page (1-100). Default 25. Semantic search caps at 50 — when search_mode="semantic", set per_page ≤ 50 (also subject to a 1 req/sec rate limit upstream). The cap applies to searches only; an `id` lookup returns its one record regardless of both.'),
220
263
  cursor: z
221
264
  .string()
265
+ .min(1)
266
+ .optional()
267
+ .describe('Pagination cursor from a previous response. Pass to get the next page. Omit it on the first call — an empty string is rejected, since a supplied-but-blank cursor is a caller mistake rather than a request for page 1. Keyword and exact modes only — semantic search walks its candidates with `page`, and a `cursor` sent with it is rejected.'),
268
+ page: z
269
+ .number()
270
+ .int()
271
+ .min(1)
222
272
  .optional()
223
- .describe('Pagination cursor from a previous response. Pass to get the next page.'),
273
+ .describe('Page number (1-based) for semantic search, the one mode that paginates with `page` instead of `cursor`. Semantic search ranks a query-dependent candidate set whose size `meta.count` reports, so the last reachable page is ceil(meta.count / per_page) — e.g. page 14 for a count of 70 with per_page=5. Passing it under any other search_mode is rejected.'),
224
274
  sample: z
225
275
  .number()
226
276
  .int()
227
277
  .min(1)
228
278
  .max(SAMPLE_MAX)
229
279
  .optional()
230
- .describe(`Return a random sample of this many entities matching the filters (1-${SAMPLE_MAX}). Single page only — pagination via \`cursor\` is not supported with sampling. Overrides \`per_page\`. Useful for unbiased exploration: spot-checking filter correctness, stratified review prompts, or generating exploration sets without bias toward most-cited.`),
280
+ .describe(`Return a random sample of this many entities matching the filters (1-${SAMPLE_MAX}). Single page only — neither \`cursor\` nor \`page\` pagination applies to sampling, and a search that passes either alongside it is rejected. Keyword and exact modes only: OpenAlex does not sample a semantic search, so \`sample\` with search_mode "semantic" is rejected. Cannot be combined with \`sort\` — a sample has no order, and a search passing both is rejected. Overrides \`per_page\`. Useful for unbiased exploration: spot-checking filter correctness, stratified review prompts, or generating exploration sets without bias toward most-cited.`),
231
281
  seed: z
232
282
  .string()
233
283
  .optional()
@@ -236,8 +286,12 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
236
286
  output: z.object({
237
287
  meta: z
238
288
  .object({
239
- count: z.number().describe('Total results matching the query/filters.'),
240
- per_page: z.number().describe('Results on this page.'),
289
+ count: z
290
+ .number()
291
+ .describe('Total results matching the query/filters. Under search_mode "semantic" it is instead the size of the ranked candidate set — the most results `page` can reach — not an exhaustive match total.'),
292
+ per_page: z
293
+ .number()
294
+ .describe('Page size OpenAlex echoed for this request — the requested per_page, not the number of records returned. A short or exhausted page carries fewer records than this.'),
241
295
  next_cursor: z
242
296
  .string()
243
297
  .nullable()
@@ -255,7 +309,7 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
255
309
  })
256
310
  .passthrough()
257
311
  .describe('A single OpenAlex entity record. `id` is always present and `display_name` is always returned (though it may be null); additional fields vary by entity_type and `select`.'))
258
- .describe('OpenAlex entity objects passed through unchanged. Additional fields depend on entity_type and select.'),
312
+ .describe('OpenAlex entity objects. Text values are plain text — HTML entities decoded, HTML/JATS/MathML markup removed — and an abstract arrives reconstructed as `abstract`. Additional fields depend on entity_type and select.'),
259
313
  }),
260
314
  // Agent-facing context for the success path — the query/filters as parsed, the
261
315
  // total match count, and recovery guidance for empty results. Populated via
@@ -268,7 +322,7 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
268
322
  notice: z
269
323
  .string()
270
324
  .optional()
271
- .describe('Guidance notice. Set when results are empty (echoes the criteria and suggests how to broaden) or when an `id` lookup was passed search criteria it does not apply (names them). Absent otherwise.'),
325
+ .describe('Guidance notice. Set when a first call returns no results (echoes the criteria and suggests how to broaden), when a paginated call ran past its last page (says the traversal is finished instead of advising a broader query), when an `id` lookup was passed search criteria it does not apply (names them), and on every semantic search to disclose that `meta.count` is a candidate total rather than a match total. Absent otherwise.'),
272
326
  budget: z
273
327
  .object({
274
328
  costUsd: z
@@ -292,7 +346,76 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
292
346
  budget: { render: renderBudgetTrailer },
293
347
  },
294
348
  async handler(input, ctx) {
295
- assertListQueryConstraints(input, ctx);
349
+ /**
350
+ * Reject list-query parameter combinations OpenAlex cannot serve. Every check here
351
+ * constrains a *list* query. `id` takes the singleton path in `OpenAlexService.search()`,
352
+ * which reads only `entity_type`, `id`, and `select` — so search_mode, per_page, cursor,
353
+ * page, sample, and seed are unread there, and rejecting an ID lookup over how they relate
354
+ * to each other fails it on constraints it never met. The dropped-parameter notice below
355
+ * reports them instead. The `id` predicate mirrors the service's own truthiness branch.
356
+ */
357
+ if (!input.id) {
358
+ // Semantic search matches an embedding of the query text, so with no query there is
359
+ // nothing to embed — the request silently degraded to a plain unfiltered listing whose
360
+ // echo still advertised `search_mode=semantic`.
361
+ if (input.search_mode === 'semantic' && !input.query) {
362
+ throw ctx.fail('semantic_without_query', 'Semantic search needs `query` text to embed — none was supplied.', { ...ctx.recoveryFor('semantic_without_query'), searchMode: input.search_mode });
363
+ }
364
+ if (input.search_mode === 'semantic' && input.per_page > SEMANTIC_PER_PAGE_CAP) {
365
+ throw ctx.fail('semantic_per_page_cap', `Semantic search supports at most ${SEMANTIC_PER_PAGE_CAP} results per page. Reduce per_page or switch search_mode.`, {
366
+ ...ctx.recoveryFor('semantic_per_page_cap'),
367
+ searchMode: input.search_mode,
368
+ perPage: input.per_page,
369
+ cap: SEMANTIC_PER_PAGE_CAP,
370
+ });
371
+ }
372
+ // OpenAlex answers `search.semantic` plus a cursor with a 400 ("Cursor pagination is not
373
+ // supported with semantic search"), so forwarding it spends a round trip to learn that.
374
+ if (input.search_mode === 'semantic' && input.cursor !== undefined) {
375
+ throw ctx.fail('semantic_with_cursor', 'Semantic search does not accept `cursor` — walk its candidates with `page` (1-based) instead.', {
376
+ ...ctx.recoveryFor('semantic_with_cursor'),
377
+ searchMode: input.search_mode,
378
+ cursor: input.cursor,
379
+ });
380
+ }
381
+ // The inverse: `page` is the semantic-only knob, and OpenAlex ignores it on a cursor
382
+ // traversal — silently returning page 1 again rather than the page that was asked for.
383
+ if (input.page !== undefined && input.search_mode !== 'semantic') {
384
+ throw ctx.fail('page_without_semantic', `\`page\` applies to semantic search only — search_mode is "${input.search_mode}", which paginates with \`cursor\`.`, {
385
+ ...ctx.recoveryFor('page_without_semantic'),
386
+ searchMode: input.search_mode,
387
+ page: input.page,
388
+ });
389
+ }
390
+ if (input.sample !== undefined && input.cursor !== undefined) {
391
+ throw ctx.fail('sample_with_cursor', 'Sampling returns one page only — `sample` cannot be combined with `cursor` pagination.', { ...ctx.recoveryFor('sample_with_cursor'), sample: input.sample, cursor: input.cursor });
392
+ }
393
+ // Sampling pins `per_page` to `sample` and returns that one page, so there is no second
394
+ // page for `page` to address — the same exclusion `cursor` has above. Reachable under
395
+ // semantic mode alone; every other mode rejects `page` at the check before this one.
396
+ if (input.sample !== undefined && input.page !== undefined) {
397
+ throw ctx.fail('sample_with_page', 'Sampling returns one page only — `sample` cannot be combined with `page` pagination.', { ...ctx.recoveryFor('sample_with_page'), sample: input.sample, page: input.page });
398
+ }
399
+ // OpenAlex ignores `sample` and `seed` under `search.semantic` and returns the ranked page,
400
+ // so forwarding the pair would label a relevance ranking as a random sample. The population
401
+ // request would also carry `cursor=*` beside `search.semantic`, which upstream rejects.
402
+ // Checked after `sample_with_page`, which is reachable under semantic mode alone.
403
+ if (input.sample !== undefined && input.search_mode === 'semantic') {
404
+ throw ctx.fail('sample_with_semantic', 'Semantic search does not sample — OpenAlex returns the same ranked candidates under every seed.', {
405
+ ...ctx.recoveryFor('sample_with_semantic'),
406
+ sample: input.sample,
407
+ searchMode: input.search_mode,
408
+ });
409
+ }
410
+ // OpenAlex answers any sort beside `sample` with a 400 ("sample does not work with sort").
411
+ // A blank or whitespace-only sort is never sent upstream, so it is no conflict.
412
+ if (input.sample !== undefined && input.sort?.trim()) {
413
+ throw ctx.fail('sample_with_sort', 'A random sample cannot be sorted — `sample` cannot be combined with `sort`.', { ...ctx.recoveryFor('sample_with_sort'), sample: input.sample, sort: input.sort });
414
+ }
415
+ if (input.seed !== undefined && input.sample === undefined) {
416
+ throw ctx.fail('seed_without_sample', '`seed` is only meaningful with `sample` — pass `sample` to enable random sampling.', { ...ctx.recoveryFor('seed_without_sample'), seed: input.seed });
417
+ }
418
+ }
296
419
  const service = getOpenAlexService();
297
420
  const result = await service.search({
298
421
  entityType: input.entity_type,
@@ -304,6 +427,7 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
304
427
  select: input.select,
305
428
  perPage: input.per_page,
306
429
  cursor: input.cursor,
430
+ page: input.page,
307
431
  sample: input.sample,
308
432
  seed: input.seed,
309
433
  }, ctx);
@@ -316,17 +440,28 @@ export const searchEntitiesTool = tool('openalex_search_entities', {
316
440
  });
317
441
  const echo = buildSearchEcho(input);
318
442
  ctx.enrich({ echo, totalCount: result.meta.count });
443
+ const notices = [];
319
444
  // An `id` lookup always returns its one record or throws, so it never reaches the
320
445
  // empty-results notice — the two branches are exclusive, and the dropped-parameter
321
446
  // warning is the more useful of the two on that path.
322
447
  const ignored = input.id ? searchOnlyParams(input).map((part) => part.name) : [];
323
448
  if (ignored.length > 0) {
324
449
  const [verb, pronoun] = ignored.length === 1 ? ['was', 'it'] : ['were', 'them'];
325
- ctx.enrich.notice(`\`id\` takes precedence — ${ignored.join(', ')} ${verb} not applied, and the record below is the entity at that ID regardless of ${pronoun}. Drop \`id\` to run ${pronoun} as a search.`);
450
+ notices.push(`\`id\` takes precedence — ${ignored.join(', ')} ${verb} not applied, and the record below is the entity at that ID regardless of ${pronoun}. Drop \`id\` to run ${pronoun} as a search.`);
326
451
  }
327
452
  else if (result.results.length === 0) {
328
- ctx.enrich.notice(`No matches for ${echo}. Try broadening the query, removing filters, or switching search_mode.`);
453
+ notices.push(isContinuationPage(input)
454
+ ? `Pagination exhausted for ${echo} — the previous page was the last, so this one came back empty. Stop paging rather than broadening the search.`
455
+ : `No matches for ${echo}. Try broadening the query, removing filters, or switching search_mode.`);
456
+ }
457
+ // `meta.count` reports the ranked candidate set under semantic search, not the population
458
+ // matching the query. Its size is query-dependent (OpenAlex serves 70 for some queries,
459
+ // 50 for others), so the notice states the count it got rather than a fixed ceiling.
460
+ if (!input.id && input.search_mode === 'semantic') {
461
+ notices.push(`Semantic search ranks a candidate set rather than every match, so \`meta.count\` (${result.meta.count}) is the number of candidates \`page\` can reach, not the total number of matching records. Reach the rest of the candidates with \`page\`.`);
329
462
  }
463
+ if (notices.length > 0)
464
+ ctx.enrich.notice(notices.join(' '));
330
465
  return {
331
466
  meta: {
332
467
  count: result.meta.count,
@@ -1 +1 @@
1
- {"version":3,"file":"search-entities.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-entities.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,kBAA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,EAAE,CAAC;YAChC,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpD,CAAC;QAED,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,MAAsB,CAAC,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"search-entities.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-entities.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAqB,MAAM,8BAA8B,CAAC;AAE/E,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,MAAM,UAAU,GAAG,GAAG,CAAC;AAavB;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CAAC,KAAsB;IAC9C,MAAM,KAAK,GAAyC,EAAE,CAAC;IACvD,IAAI,KAAK,CAAC,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;IACnF,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,C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OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpD,CAAC;QAED,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,MAAsB,CAAC,CAAC,CAAC;QAC5D,CAAC;QAED,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @fileoverview Markdown escaping for provider text at the `content[]` boundary. Every `format()`
3
+ * that interpolates OpenAlex text routes it through `escapeMarkdown`, so the surfaces cannot
4
+ * drift. Escapes use backslashes, never HTML entities, and cover only what a CommonMark + GFM
5
+ * renderer would read as structure; a URL that GFM links cleanly renders byte-identical, as the
6
+ * autolink it is. `structuredContent` never passes through here — it carries the plain text.
7
+ * @module mcp-server/tools/escape-markdown
8
+ */
9
+ /**
10
+ * Where the text lands. `inline` is mid-line (after a label, inside bold, in a list item);
11
+ * `line-start` begins a line, where block syntax (`#`, `- `, `1. `, `>`, `[label]:`) applies;
12
+ * `heading` follows `### `, where a trailing `#` run would close the heading.
13
+ */
14
+ export type MarkdownPosition = 'inline' | 'line-start' | 'heading';
15
+ /**
16
+ * Escape provider text for Markdown so a renderer shows exactly the characters it holds.
17
+ *
18
+ * Escaped everywhere: `*`, backticks, `~` (GFM strikethrough), `<` before a letter, `/`, `!`, or
19
+ * `?`, `_` unless it sits between two letters or digits, `&` when it starts a character reference
20
+ * a renderer would decode, a backslash before punctuation or at the end, a `<` that opens an
21
+ * email autolink, and any `[` ahead of a `](` pair (a link needs it to open its label) or never
22
+ * closed. Closed citation brackets with no `](` after them stay as they are. At a line start,
23
+ * also the block markers; in a heading, a trailing `#` run. Line breaks and tabs collapse to a
24
+ * space.
25
+ *
26
+ * A span GFM links as an autolink literal passes through untouched. When it cannot — trailing
27
+ * punctuation that needs an escape would join the link, an open `[` or an email literal holds
28
+ * it, or GFM would not link it at all — the `:` or `.` of its prefix is escaped instead, which
29
+ * reads the same but links nothing in any renderer, and the span is escaped like any other text.
30
+ */
31
+ export declare function escapeMarkdown(text: string, position?: MarkdownPosition): string;
32
+ //# sourceMappingURL=escape-markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape-markdown.d.ts","sourceRoot":"","sources":["../../../src/mcp-server/tools/escape-markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC;AAoQnE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,gBAA2B,GAAG,MAAM,CA4F1F"}