@cyanheads/openalex-mcp-server 0.7.15 → 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.
- package/AGENTS.md +2 -2
- package/CLAUDE.md +2 -2
- package/README.md +8 -6
- package/changelog/0.7.x/0.7.16.md +32 -0
- package/dist/mcp-server/tools/definitions/analyze-trends.tool.d.ts +3 -2
- package/dist/mcp-server/tools/definitions/analyze-trends.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/analyze-trends.tool.js +40 -14
- package/dist/mcp-server/tools/definitions/analyze-trends.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/citation-graph.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/citation-graph.tool.js +1 -1
- package/dist/mcp-server/tools/definitions/citation-graph.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/describe-fields.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/describe-fields.tool.js +82 -15
- package/dist/mcp-server/tools/definitions/describe-fields.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/resolve-name.tool.d.ts +7 -0
- package/dist/mcp-server/tools/definitions/resolve-name.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/resolve-name.tool.js +17 -6
- package/dist/mcp-server/tools/definitions/resolve-name.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/search-entities.tool.d.ts +10 -0
- package/dist/mcp-server/tools/definitions/search-entities.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-entities.tool.js +38 -10
- package/dist/mcp-server/tools/definitions/search-entities.tool.js.map +1 -1
- package/dist/mcp-server/tools/escape-markdown.d.ts +32 -0
- package/dist/mcp-server/tools/escape-markdown.d.ts.map +1 -0
- package/dist/mcp-server/tools/escape-markdown.js +389 -0
- package/dist/mcp-server/tools/escape-markdown.js.map +1 -0
- package/dist/mcp-server/tools/render-entity-record.d.ts +2 -1
- package/dist/mcp-server/tools/render-entity-record.d.ts.map +1 -1
- package/dist/mcp-server/tools/render-entity-record.js +24 -8
- package/dist/mcp-server/tools/render-entity-record.js.map +1 -1
- package/dist/services/openalex/html-entities.json +2237 -0
- package/dist/services/openalex/openalex-service.d.ts +1 -1
- package/dist/services/openalex/openalex-service.d.ts.map +1 -1
- package/dist/services/openalex/openalex-service.js +110 -76
- package/dist/services/openalex/openalex-service.js.map +1 -1
- package/dist/services/openalex/provider-text.d.ts +20 -0
- package/dist/services/openalex/provider-text.d.ts.map +1 -0
- package/dist/services/openalex/provider-text.js +276 -0
- package/dist/services/openalex/provider-text.js.map +1 -0
- package/dist/services/openalex/types.d.ts +5 -0
- package/dist/services/openalex/types.d.ts.map +1 -1
- package/package.json +4 -1
- package/server.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Developer Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** openalex-mcp-server
|
|
4
|
-
**Version:** 0.7.
|
|
4
|
+
**Version:** 0.7.16
|
|
5
5
|
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.6`
|
|
6
6
|
**Engines:** Bun ≥1.4.0, Node ≥24.0.0
|
|
7
7
|
**MCP SDK:** `@modelcontextprotocol/server` ^2.0.0
|
|
@@ -189,7 +189,7 @@ async handler(input, ctx) {
|
|
|
189
189
|
|
|
190
190
|
**Declare contracts inline on each tool, even when similar across tools.** The contract is part of the tool's documented public surface — reading one tool definition file should give the full picture. Don't extract a shared `errors[]` constant; per-tool repetition is the intended cost of locality.
|
|
191
191
|
|
|
192
|
-
The OpenAlex service throws factory errors (`notFound`, `rateLimited`, etc.) based on upstream status codes, carrying the contract `reason` on `data.reason` and the recovery via `ctx.recoveryFor(reason)`; those bubble through and are auto-classified. Every such entry carries `thrownBy: 'service'` — lint-only metadata that tells `error-contract-unthrown`, whose scan reads the handler body alone, to skip a reason produced a layer below it. Handler-local precondition throws stay inline and unmarked so the rule keeps checking them: `semantic_without_query`, `semantic_per_page_cap`, `semantic_with_cursor`, `page_without_semantic`, `sample_with_cursor`, `sample_with_page`, and `seed_without_sample` on `openalex_search_entities`; `reserved_filter_key` and the seed-lookup `entity_not_found` on `openalex_get_citation_graph`. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`, `RequestCancelled`) bubble freely without needing to be declared on a contract.
|
|
192
|
+
The OpenAlex service throws factory errors (`notFound`, `rateLimited`, etc.) based on upstream status codes, carrying the contract `reason` on `data.reason` and the recovery via `ctx.recoveryFor(reason)`; those bubble through and are auto-classified. Every such entry carries `thrownBy: 'service'` — lint-only metadata that tells `error-contract-unthrown`, whose scan reads the handler body alone, to skip a reason produced a layer below it. Handler-local precondition throws stay inline and unmarked so the rule keeps checking them: `semantic_without_query`, `semantic_per_page_cap`, `semantic_with_cursor`, `page_without_semantic`, `sample_with_cursor`, `sample_with_page`, `sample_with_semantic`, `sample_with_sort`, and `seed_without_sample` on `openalex_search_entities`; `reserved_filter_key` and the seed-lookup `entity_not_found` on `openalex_get_citation_graph`. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`, `RequestCancelled`) bubble freely without needing to be declared on a contract.
|
|
193
193
|
|
|
194
194
|
**Fallback for ad-hoc throws:** error factories or plain `Error`.
|
|
195
195
|
|
package/CLAUDE.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Developer Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** openalex-mcp-server
|
|
4
|
-
**Version:** 0.7.
|
|
4
|
+
**Version:** 0.7.16
|
|
5
5
|
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.13.6`
|
|
6
6
|
**Engines:** Bun ≥1.4.0, Node ≥24.0.0
|
|
7
7
|
**MCP SDK:** `@modelcontextprotocol/server` ^2.0.0
|
|
@@ -189,7 +189,7 @@ async handler(input, ctx) {
|
|
|
189
189
|
|
|
190
190
|
**Declare contracts inline on each tool, even when similar across tools.** The contract is part of the tool's documented public surface — reading one tool definition file should give the full picture. Don't extract a shared `errors[]` constant; per-tool repetition is the intended cost of locality.
|
|
191
191
|
|
|
192
|
-
The OpenAlex service throws factory errors (`notFound`, `rateLimited`, etc.) based on upstream status codes, carrying the contract `reason` on `data.reason` and the recovery via `ctx.recoveryFor(reason)`; those bubble through and are auto-classified. Every such entry carries `thrownBy: 'service'` — lint-only metadata that tells `error-contract-unthrown`, whose scan reads the handler body alone, to skip a reason produced a layer below it. Handler-local precondition throws stay inline and unmarked so the rule keeps checking them: `semantic_without_query`, `semantic_per_page_cap`, `semantic_with_cursor`, `page_without_semantic`, `sample_with_cursor`, `sample_with_page`, and `seed_without_sample` on `openalex_search_entities`; `reserved_filter_key` and the seed-lookup `entity_not_found` on `openalex_get_citation_graph`. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`, `RequestCancelled`) bubble freely without needing to be declared on a contract.
|
|
192
|
+
The OpenAlex service throws factory errors (`notFound`, `rateLimited`, etc.) based on upstream status codes, carrying the contract `reason` on `data.reason` and the recovery via `ctx.recoveryFor(reason)`; those bubble through and are auto-classified. Every such entry carries `thrownBy: 'service'` — lint-only metadata that tells `error-contract-unthrown`, whose scan reads the handler body alone, to skip a reason produced a layer below it. Handler-local precondition throws stay inline and unmarked so the rule keeps checking them: `semantic_without_query`, `semantic_per_page_cap`, `semantic_with_cursor`, `page_without_semantic`, `sample_with_cursor`, `sample_with_page`, `sample_with_semantic`, `sample_with_sort`, and `seed_without_sample` on `openalex_search_entities`; `reserved_filter_key` and the seed-lookup `entity_not_found` on `openalex_get_citation_graph`. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`, `RequestCancelled`) bubble freely without needing to be declared on a contract.
|
|
193
193
|
|
|
194
194
|
**Fallback for ad-hoc throws:** error factories or plain `Error`.
|
|
195
195
|
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
<div align="center">
|
|
9
9
|
|
|
10
|
-
[](./CHANGELOG.md) [](./LICENSE) [](https://github.com/users/cyanheads/packages/container/package/openalex-mcp-server) [](https://modelcontextprotocol.io/) [](https://www.npmjs.com/package/@cyanheads/openalex-mcp-server) [](https://www.typescriptlang.org/) [](https://bun.sh/)
|
|
11
11
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
@@ -53,11 +53,11 @@ Scholarly catalog data from [OpenAlex](https://openalex.org) — 270M+ works, 90
|
|
|
53
53
|
### `openalex_search_entities` <sub>tool</sub>
|
|
54
54
|
|
|
55
55
|
- Retrieve a single entity by ID — OpenAlex ID, DOI, ORCID, ROR, PMID, ISSN, or PMCID (bare or URL form), or a keyword by its slug or keyword URL. `id` takes precedence: search parameters passed alongside it are dropped, and the response names which ones. A PMCID resolves nothing (OpenAlex indexes none) — use the work's PMID or DOI instead
|
|
56
|
-
- Keyword search (boolean operators, quoted phrases, wildcards, fuzzy match) plus `exact` and `semantic` search modes — semantic ranks
|
|
56
|
+
- Keyword search (boolean operators, quoted phrases, wildcards, fuzzy match) plus `exact` and `semantic` search modes — semantic ranks a query-dependent candidate set at ~1 req/sec (up to 50 per page), and its `meta.count` reports the candidate count rather than a match total
|
|
57
57
|
- Rich filter syntax: AND across fields, OR within a field (`|`), NOT (`!`), ranges, comparisons; a comma inside a filter value is rejected (use `|`, or a `.search` filter for free text)
|
|
58
58
|
- `select` returns a curated per-entity-type default unless overridden, or `["*"]` for the full record; invalid field names error with the valid set
|
|
59
59
|
- Cursor pagination for keyword and exact search, up to 100 results per page (default 25); semantic search walks its candidates with `page` (1-based) instead, and mixing either knob with the wrong `search_mode` is rejected before the upstream call
|
|
60
|
-
- `sample` (up to 100, single page only — neither `cursor` nor `page` applies) plus a deterministic `seed` for reproducible random sampling
|
|
60
|
+
- `sample` (up to 100, single page only — neither `cursor` nor `page` applies) plus a deterministic `seed` for reproducible random sampling; keyword and exact modes only, and never alongside `sort` — OpenAlex does not sample a semantic search and refuses a sorted sample, so both combinations are rejected before the upstream call
|
|
61
61
|
- `display_name` is nullable for untitled records; every call reports OpenAlex daily-budget cost and remaining balance
|
|
62
62
|
|
|
63
63
|
---
|
|
@@ -66,8 +66,8 @@ Scholarly catalog data from [OpenAlex](https://openalex.org) — 270M+ works, 90
|
|
|
66
66
|
|
|
67
67
|
- Group any supported field for trend, distribution, or comparative analysis; combine with `filters` to scope the population before aggregation
|
|
68
68
|
- Up to 200 groups per page (default). `order: "count"` (default) returns the top-N by count with no further pages; `order: "key"` enumerates all distinct values key-ascending with cursor pagination
|
|
69
|
-
- `include_unknown` (default `false`) adds a group for entities with no value for the grouped field
|
|
70
|
-
- Not every field is groupable — raw date fields, `.search` operators,
|
|
69
|
+
- `include_unknown` (default `false`) adds a group for entities with no value for the grouped field, flagged `is_unknown: true` and labeled as unknown in the text output. OpenAlex keys it `-111`/`-111.0` (numeric fields), `unknown` (text fields and `order: "key"`), or an ID ending in `/unknown`; the key is a sentinel, not a filter value. Boolean fields have no such group — a missing value counts as `false`
|
|
70
|
+
- Not every field is groupable — raw date fields, `.search` operators, `from_*`/`to_*` range modifiers, decimal scores such as `fwci`, `display_name`, and external-ID fields such as `doi` are rejected; `openalex_describe_fields(entity_type, "group_by")` lists the fields that group
|
|
71
71
|
- Reports OpenAlex daily-budget cost and remaining balance — aggregation is priced far below paging the same entities
|
|
72
72
|
|
|
73
73
|
---
|
|
@@ -77,6 +77,7 @@ Scholarly catalog data from [OpenAlex](https://openalex.org) — 270M+ works, 90
|
|
|
77
77
|
- A name or partial name runs an autocomplete search: up to 10 matches with disambiguation hints (last institution, host organization, place, etc.)
|
|
78
78
|
- An identifier — OpenAlex ID, DOI, ORCID, ROR, PMID, ISSN, or keyword URL, bare or in URL form — resolves directly to the one record it addresses; no `entity_type` needed, since the identifier determines its own. A PMCID is recognized but resolves nothing — OpenAlex indexes none
|
|
79
79
|
- `filters` narrows autocomplete only; on an identifier lookup they're ignored and named in a notice
|
|
80
|
+
- With `entity_type` set, OpenAlex autocomplete fails on a name over 1,000 characters; that failure is reported once as `query_too_long` with advice to shorten the name, not retried as an outage
|
|
80
81
|
- Reports OpenAlex daily-budget cost and remaining balance
|
|
81
82
|
|
|
82
83
|
---
|
|
@@ -94,7 +95,7 @@ Scholarly catalog data from [OpenAlex](https://openalex.org) — 270M+ works, 90
|
|
|
94
95
|
### `openalex_describe_fields` <sub>tool</sub>
|
|
95
96
|
|
|
96
97
|
- Lists every valid field name for an entity type + context (`filter`, `group_by`, `select`) — the complete pool, never truncated
|
|
97
|
-
- `group_by` is the filter set minus raw date fields, `.search`/`.search.exact` operators,
|
|
98
|
+
- `group_by` is the filter set minus what OpenAlex rejects as an aggregation key: raw date fields, `.search`/`.search.exact` operators, `from_*`/`to_*` range modifiers, and a per-entity-type set found by grouping every listed field against the live API — decimal scores such as `fwci`, several source year fields, `display_name`, and external-ID fields among them
|
|
98
99
|
- Optional `query` reorders results by name similarity without dropping any field — a nested value's parent object stays reachable further down the list
|
|
99
100
|
- Backed by a generated field catalog — no live API calls
|
|
100
101
|
|
|
@@ -131,6 +132,7 @@ Agent-friendly output:
|
|
|
131
132
|
- Effective-query echo — search, trends, and citation-graph responses echo the criteria that actually ran, so an empty result is diagnosable without re-reading the request
|
|
132
133
|
- Discriminated output contracts — typed error reasons (`entity_not_found`, `upstream_budget_exhausted`, `semantic_per_page_cap`, `reserved_filter_key`, and more) each carrying an explicit recovery hint
|
|
133
134
|
- Response shaping — abstracts are reconstructed from OpenAlex's inverted-index encoding into plaintext, and `display_name` stays `null` for untitled or paratext records instead of being backfilled
|
|
135
|
+
- Clean provider text — OpenAlex passes titles, abstracts, and names through unsanitized; HTML entities are decoded against the full WHATWG table, comments and HTML/JATS/MathML formatting tags are removed, and literal text such as `A < B` is kept. The text output escapes that text for Markdown, so a stray `*`, `<tag>`, or `[x](y)` renders as written; IDs, and URLs that render as links, stay byte-identical
|
|
134
136
|
|
|
135
137
|
## Getting started
|
|
136
138
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "Provider text arrives clean on both surfaces (entities decoded, markup removed, Markdown escaped in content[]), plus a flagged unknown group_by bucket, local rejection of sample with semantic search or sort, and corrected group_by field lists and error reasons."
|
|
3
|
+
breaking: false
|
|
4
|
+
security: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.7.16 — 2026-09-24
|
|
8
|
+
|
|
9
|
+
## Added
|
|
10
|
+
|
|
11
|
+
- **`is_unknown`** on `openalex_analyze_trends` groups — set on the missing-value bucket `include_unknown` adds (keyed `-111`, `-111.0`, `unknown`, or an ID ending in `/unknown`). The text output labels it `unknown (no value; key …)` and renders it after the last year of a time series. ([#75](https://github.com/cyanheads/openalex-mcp-server/issues/75))
|
|
12
|
+
- **`sample_with_semantic`** and **`sample_with_sort`** error reasons on `openalex_search_entities` — `sample` with `search_mode: "semantic"` (which OpenAlex does not sample) or with any `sort` (which OpenAlex refuses) is rejected before the upstream call. `id` lookups still drop both with a notice. ([#83](https://github.com/cyanheads/openalex-mcp-server/issues/83), [#85](https://github.com/cyanheads/openalex-mcp-server/issues/85))
|
|
13
|
+
|
|
14
|
+
## Changed
|
|
15
|
+
|
|
16
|
+
- **Provider text in `structuredContent`** — string values now carry decoded HTML entities (full WHATWG table) with HTML comments removed and HTML/JATS/MathML formatting tags unwrapped; literal text such as `A < B` or `Fish <Actinopterygii>` is kept. Affected records return different values than before. ([#76](https://github.com/cyanheads/openalex-mcp-server/issues/76))
|
|
17
|
+
- **`content[]` escaping** — every `format()` backslash-escapes provider text for Markdown, so a stray `*`, `<tag>`, or `[x](y)` renders as written; IDs and URLs that render as links stay byte-identical. ([#76](https://github.com/cyanheads/openalex-mcp-server/issues/76))
|
|
18
|
+
- **`openalex_analyze_trends` group `key`** is passed through raw, exactly as OpenAlex returns it (it was entity-decoded before); `key_display_name` gets the provider-text normalization. ([#76](https://github.com/cyanheads/openalex-mcp-server/issues/76))
|
|
19
|
+
|
|
20
|
+
## Fixed
|
|
21
|
+
|
|
22
|
+
- **Named-entity decoding** no longer resolves `Object.prototype` names — `&constructor;` stays literal instead of becoming `function Object() { [native code] }`. ([#76](https://github.com/cyanheads/openalex-mcp-server/issues/76))
|
|
23
|
+
- **`openalex_describe_fields` `group_by` view** drops the fields OpenAlex refuses to aggregate — decimal scores such as `fwci`, several source year fields, `display_name`, external-ID fields, and the concept keys on authors — and five works fields whose grouping fails with an HTTP 500 on every attempt (`cites`, `has_embeddings`, and the three `raw_type` location fields), per a live sweep of every listed field on all eight entity types; they stay valid filters. ([#86](https://github.com/cyanheads/openalex-mcp-server/issues/86))
|
|
24
|
+
- **`group_by` rejections** on authors' concept keys (reported upstream as an invalid ID) and on `referenced_works` now surface as `upstream_ungroupable_group_by`, whose recovery points at `openalex_describe_fields`; an invalid-ID 400 quoting a value from the request's `filter` keeps `upstream_invalid_id_value`. ([#87](https://github.com/cyanheads/openalex-mcp-server/issues/87))
|
|
25
|
+
- **`openalex_resolve_name`** reports the HTTP 500 that typed autocomplete returns for a `query` over 1,000 code points as `query_too_long` after one attempt, instead of a retried `upstream_unavailable` outage. ([#81](https://github.com/cyanheads/openalex-mcp-server/issues/81))
|
|
26
|
+
- **Semantic `meta.count`** — descriptions and the runtime notice no longer claim a 50-candidate ceiling; the candidate count is query-dependent and can exceed 50 (the 50-per-page cap stands). ([#84](https://github.com/cyanheads/openalex-mcp-server/issues/84))
|
|
27
|
+
|
|
28
|
+
## Dependencies
|
|
29
|
+
|
|
30
|
+
- `mdast-util-from-markdown` ^2.0.3 (new devDependency)
|
|
31
|
+
- `mdast-util-gfm` ^3.1.0 (new devDependency)
|
|
32
|
+
- `micromark-extension-gfm` ^3.0.0 (new devDependency)
|
|
@@ -34,6 +34,7 @@ export declare const analyzeTrendsTool: import("@cyanheads/mcp-ts-core").ToolDef
|
|
|
34
34
|
key: z.ZodString;
|
|
35
35
|
key_display_name: z.ZodString;
|
|
36
36
|
count: z.ZodNumber;
|
|
37
|
+
is_unknown: z.ZodOptional<z.ZodLiteral<true>>;
|
|
37
38
|
}, z.core.$strip>>;
|
|
38
39
|
}, z.core.$strip>, readonly [{
|
|
39
40
|
readonly reason: "rate_limited";
|
|
@@ -96,8 +97,8 @@ export declare const analyzeTrendsTool: import("@cyanheads/mcp-ts-core").ToolDef
|
|
|
96
97
|
}, {
|
|
97
98
|
readonly reason: "upstream_ungroupable_group_by";
|
|
98
99
|
readonly code: JsonRpcErrorCode.InvalidParams;
|
|
99
|
-
readonly when: "group_by targets a raw date,
|
|
100
|
-
readonly recovery: "Group by a
|
|
100
|
+
readonly when: "group_by targets a field OpenAlex cannot aggregate — a raw date, a decimal score, a *.search operator, a field such as display_name, doi, or referenced_works, or a concept key on authors, which OpenAlex reports as an invalid OpenAlex ID (HTTP 400).";
|
|
101
|
+
readonly recovery: "Group by a field OpenAlex can aggregate, such as publication_year, type, or oa_status — call openalex_describe_fields(entity_type, \"group_by\") for the full groupable set of this entity type.";
|
|
101
102
|
readonly thrownBy: "service";
|
|
102
103
|
}, {
|
|
103
104
|
readonly reason: "upstream_invalid_params_other";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-trends.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/analyze-trends.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"analyze-trends.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/analyze-trends.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAMjE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwV5B,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
6
|
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { escapeMarkdown } from '../escape-markdown.js';
|
|
7
8
|
import { renderBudgetTrailer } from '../render-budget.js';
|
|
8
9
|
import { getOpenAlexService } from '../../../services/openalex/openalex-service.js';
|
|
9
10
|
import { ENTITY_TYPES } from '../../../services/openalex/types.js';
|
|
@@ -82,8 +83,8 @@ export const analyzeTrendsTool = tool('openalex_analyze_trends', {
|
|
|
82
83
|
{
|
|
83
84
|
reason: 'upstream_ungroupable_group_by',
|
|
84
85
|
code: JsonRpcErrorCode.InvalidParams,
|
|
85
|
-
when: 'group_by targets a raw date,
|
|
86
|
-
recovery: 'Group by a
|
|
86
|
+
when: 'group_by targets a field OpenAlex cannot aggregate — a raw date, a decimal score, a *.search operator, a field such as display_name, doi, or referenced_works, or a concept key on authors, which OpenAlex reports as an invalid OpenAlex ID (HTTP 400).',
|
|
87
|
+
recovery: 'Group by a field OpenAlex can aggregate, such as publication_year, type, or oa_status — call openalex_describe_fields(entity_type, "group_by") for the full groupable set of this entity type.',
|
|
87
88
|
thrownBy: 'service',
|
|
88
89
|
},
|
|
89
90
|
{
|
|
@@ -115,7 +116,7 @@ export const analyzeTrendsTool = tool('openalex_analyze_trends', {
|
|
|
115
116
|
group_by: z
|
|
116
117
|
.string()
|
|
117
118
|
.min(1)
|
|
118
|
-
.describe('Field to group by. Works examples: "publication_year", "type", "oa_status", "primary_topic.field.id", "authorships.institutions.country_code", "is_retracted". Authors: "last_known_institutions.country_code", "has_orcid". Sources: "type", "is_oa", "country_code". Not all fields support group_by —
|
|
119
|
+
.describe('Field to group by. Works examples: "publication_year", "type", "oa_status", "primary_topic.field.id", "authorships.institutions.country_code", "is_retracted". Authors: "last_known_institutions.country_code", "has_orcid". Sources: "type", "is_oa", "country_code". Not all fields support group_by — call openalex_describe_fields(entity_type, "group_by") for the groupable set.'),
|
|
119
120
|
filters: z
|
|
120
121
|
.record(z.string(), z.string())
|
|
121
122
|
.optional()
|
|
@@ -123,7 +124,7 @@ export const analyzeTrendsTool = tool('openalex_analyze_trends', {
|
|
|
123
124
|
include_unknown: z
|
|
124
125
|
.boolean()
|
|
125
126
|
.default(false)
|
|
126
|
-
.describe('
|
|
127
|
+
.describe('Add a group for entities with no value for the grouped field. Hidden by default. That group carries `is_unknown: true`; OpenAlex keys it -111 or -111.0 on numeric fields, "unknown" on text fields and under order "key", and an ID ending in /unknown on ID fields — a sentinel, not a measured value. The key is not a filter value: passing -111 as a filter matches a numeric range, not the entities with no value. Boolean fields have no separate group — a missing value counts as false.'),
|
|
127
128
|
per_page: z
|
|
128
129
|
.number()
|
|
129
130
|
.int()
|
|
@@ -155,9 +156,17 @@ export const analyzeTrendsTool = tool('openalex_analyze_trends', {
|
|
|
155
156
|
groups: z
|
|
156
157
|
.array(z
|
|
157
158
|
.object({
|
|
158
|
-
key: z
|
|
159
|
-
|
|
159
|
+
key: z
|
|
160
|
+
.string()
|
|
161
|
+
.describe('Group key (OpenAlex ID or raw value), exactly as OpenAlex returns it.'),
|
|
162
|
+
key_display_name: z
|
|
163
|
+
.string()
|
|
164
|
+
.describe('Human-readable group label as plain text, with HTML entities decoded and markup removed.'),
|
|
160
165
|
count: z.number().describe('Number of entities in this group.'),
|
|
166
|
+
is_unknown: z
|
|
167
|
+
.literal(true)
|
|
168
|
+
.optional()
|
|
169
|
+
.describe('Present only on the group include_unknown adds for entities with no value; its key is an OpenAlex sentinel (-111, -111.0, unknown, or an ID ending in /unknown), not a measured value.'),
|
|
161
170
|
})
|
|
162
171
|
.describe('A single aggregation group with its key, display label, and entity count.'))
|
|
163
172
|
.describe('Aggregation groups with counts.'),
|
|
@@ -262,15 +271,16 @@ export const analyzeTrendsTool = tool('openalex_analyze_trends', {
|
|
|
262
271
|
];
|
|
263
272
|
}
|
|
264
273
|
// Time-series groupings are returned upstream in count-desc — useful for "top N years"
|
|
265
|
-
// but jarring when reading a trend. Only the rendered text is reordered
|
|
266
|
-
// structuredContent stays in upstream order
|
|
267
|
-
const
|
|
268
|
-
|
|
274
|
+
// but jarring when reading a trend. Only the rendered text is reordered, with the
|
|
275
|
+
// unknown bucket after the last period; structuredContent stays in upstream order.
|
|
276
|
+
const known = result.groups.filter((g) => !g.is_unknown);
|
|
277
|
+
const renderOrder = isTimeSeriesGrouping(known)
|
|
278
|
+
? [
|
|
279
|
+
...known.sort((a, b) => a.key.localeCompare(b.key)),
|
|
280
|
+
...result.groups.filter((g) => g.is_unknown),
|
|
281
|
+
]
|
|
269
282
|
: result.groups;
|
|
270
|
-
const lines = renderOrder.map((g) => {
|
|
271
|
-
const label = g.key === g.key_display_name ? g.key_display_name : `${g.key_display_name} (${g.key})`;
|
|
272
|
-
return `${label}: ${g.count}`;
|
|
273
|
-
});
|
|
283
|
+
const lines = renderOrder.map((g) => `${renderGroupLabel(g)}: ${g.count}`);
|
|
274
284
|
const footer = result.meta.next_cursor
|
|
275
285
|
? `\n\n*More groups available — next_cursor: \`${result.meta.next_cursor}\`*`
|
|
276
286
|
: '';
|
|
@@ -286,6 +296,22 @@ const YEAR_OR_DATE_PATTERN = /^\d{4}(-\d{2}-\d{2})?$/;
|
|
|
286
296
|
function isTimeSeriesGrouping(groups) {
|
|
287
297
|
return groups.length > 1 && groups.every((g) => YEAR_OR_DATE_PATTERN.test(g.key));
|
|
288
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* The label a group line opens with. The unknown bucket is named as such — its key is a
|
|
301
|
+
* sentinel, and `-111.0: 48777` reads as a measured value. A label that begins the line is
|
|
302
|
+
* escaped for that position; the key is upstream's own and stays byte-identical unless it
|
|
303
|
+
* carries Markdown syntax.
|
|
304
|
+
*/
|
|
305
|
+
function renderGroupLabel(g) {
|
|
306
|
+
const key = escapeMarkdown(g.key);
|
|
307
|
+
if (g.is_unknown) {
|
|
308
|
+
const redundant = g.key_display_name === g.key || g.key_display_name.toLowerCase() === 'unknown';
|
|
309
|
+
const label = redundant ? '' : `, label ${escapeMarkdown(g.key_display_name)}`;
|
|
310
|
+
return `unknown (no value; key ${key}${label})`;
|
|
311
|
+
}
|
|
312
|
+
const display = escapeMarkdown(g.key_display_name, 'line-start');
|
|
313
|
+
return g.key === g.key_display_name ? display : `${display} (${key})`;
|
|
314
|
+
}
|
|
289
315
|
function buildAnalyzeEcho(input) {
|
|
290
316
|
const parts = [`entity_type=${input.entity_type}`, `group_by=${input.group_by}`];
|
|
291
317
|
if (input.filters && Object.keys(input.filters).length > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-trends.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/analyze-trends.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,yCAAyC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,yBAAyB,EAAE;IAC/D,WAAW,EACT,oXAAoX;IACtX,SAAS,EACP,oHAAoH;IACtH,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IAC9E,MAAM,EAAE;QACN;YACE,MAAM,EAAE,cAAc;YACtB,IAAI,EAAE,gBAAgB,CA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ACN,sOAAsO;YACxO,QAAQ,EAAE,SAAS;SACpB;QACD;YACE,MAAM,EAAE,2BAA2B;YACnC,IAAI,EAAE,gBAAgB,CAAC,aAAa;YACpC,IAAI,EAAE,8FAA8F;YACpG,QAAQ,EACN,6KAA6K;YAC/K,QAAQ,EAAE,SAAS;SACpB;QACD;YACE,MAAM,EAAE,+BAA+B;YACvC,IAAI,EAAE,gBAAgB,CAAC,aAAa;YACpC,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"analyze-trends.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/analyze-trends.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,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,yBAAyB,EAAE;IAC/D,WAAW,EACT,oXAAoX;IACtX,SAAS,EACP,oHAAoH;IACtH,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE;IAC9E,MAAM,EAAE;QACN;YACE,MAAM,EAAE,cAAc;YACtB,IAAI,EAAE,gBAAgB,CAAC,WAAW;YAClC,IAAI,EAAE,iFAAiF;YACvF,SAAS,EAAE,IAAI;YACf,QAAQ,EACN,sFAAsF;YACxF,QAAQ,EAAE,SAAS;SACpB;QACD;YACE,MAAM,EAAE,2BAA2B;YACnC,IAAI,EAAE,gBAAgB,CAAC,WAAW;YAClC,IAAI,EAAE,sDAAsD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":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AA2BjE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"citation-graph.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/citation-graph.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AA2BjE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqW/B,CAAC"}
|
|
@@ -178,7 +178,7 @@ export const getCitationGraphTool = tool('openalex_get_citation_graph', {
|
|
|
178
178
|
})
|
|
179
179
|
.passthrough()
|
|
180
180
|
.describe('A single OpenAlex work record on the citation graph. Additional fields vary by `select`.'))
|
|
181
|
-
.describe('Works on the citation graph in this direction.'),
|
|
181
|
+
.describe('Works on the citation graph in this direction. Text values are plain text — HTML entities decoded, HTML/JATS/MathML markup removed.'),
|
|
182
182
|
}),
|
|
183
183
|
// Agent-facing context for the success path — the query as parsed (seed + direction),
|
|
184
184
|
// the total edge count, and recovery guidance for empty traversals. Populated via
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"citation-graph.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/citation-graph.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,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gBAC9B,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW;aACrC;YACD,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;QACjB,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,cAAc,MAAM,CAAC,IAAI,CAAC,QAAQ,WAAW,CAAC;QACrF,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW;YACpC,CAAC,CAAC,KAAK,UAAU,uBAAuB,MAAM,CAAC,IAAI,CAAC,WAAW,IAAI;YACnE,CAAC,CAAC,KAAK,UAAU,IAAI,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnB,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe-fields.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/describe-fields.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"describe-fields.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/describe-fields.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AA4GjD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;wCAoE7B,CAAC"}
|
|
@@ -19,27 +19,92 @@ const NON_GROUPABLE_DATE_FIELDS = new Set([
|
|
|
19
19
|
'updated_date',
|
|
20
20
|
]);
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
22
|
+
* Filter fields OpenAlex answers with an HTTP 400 as a group_by target, beyond the rule-based
|
|
23
|
+
* exclusions in `isGroupableField`. Taken from a live sweep that grouped every field this view
|
|
24
|
+
* listed on all eight entity types (2026-09-23): "Cannot group by date, number, or search
|
|
25
|
+
* fields." (decimal scores, several source year fields, `topics_count`), "Cannot group by
|
|
26
|
+
* <field>." (`display_name`, external-ID and page fields), "Group by referenced_works is not
|
|
27
|
+
* supported at this time.", and — for the three concept keys on authors — an invalid-ID 400.
|
|
28
|
+
*
|
|
29
|
+
* Keyed by entity type because the same name can group on one type and fail on another
|
|
30
|
+
* (`concepts.id` fails on authors and groups on works). The catalog stores names only, and name
|
|
31
|
+
* shape does not predict the outcome — `summary_stats.2yr_mean_citedness` and `publication_year`
|
|
32
|
+
* group while `fwci` and sources' `first_publication_year` do not — so the sweep is the rule.
|
|
33
|
+
* Re-run it after regenerating the field catalog.
|
|
27
34
|
*/
|
|
28
|
-
const
|
|
35
|
+
const GROUP_BY_REJECTED_FIELDS = {
|
|
36
|
+
works: new Set([
|
|
37
|
+
'biblio.first_page',
|
|
38
|
+
'biblio.last_page',
|
|
39
|
+
'citation_normalized_percentile.value',
|
|
40
|
+
'cited_by',
|
|
41
|
+
'display_name',
|
|
42
|
+
'doi',
|
|
43
|
+
'fwci',
|
|
44
|
+
'ids.mag',
|
|
45
|
+
'ids.pmcid',
|
|
46
|
+
'ids.pmid',
|
|
47
|
+
'mag',
|
|
48
|
+
'pmcid',
|
|
49
|
+
'pmid',
|
|
50
|
+
'referenced_works',
|
|
51
|
+
'related_to',
|
|
52
|
+
'sustainable_development_goals.score',
|
|
53
|
+
'topics_count',
|
|
54
|
+
]),
|
|
55
|
+
authors: new Set(['concept.id', 'concepts.id', 'display_name', 'x_concepts.id']),
|
|
56
|
+
sources: new Set([
|
|
57
|
+
'apc_prices.price',
|
|
58
|
+
'display_name',
|
|
59
|
+
'first_publication_year',
|
|
60
|
+
'ids.mag',
|
|
61
|
+
'is_high_oa_rate_since_year',
|
|
62
|
+
'is_in_doaj_since_year',
|
|
63
|
+
'is_in_jstage_since_year',
|
|
64
|
+
'last_publication_year',
|
|
65
|
+
'oa_flip_year',
|
|
66
|
+
]),
|
|
67
|
+
institutions: new Set(['display_name']),
|
|
68
|
+
topics: new Set(['display_name']),
|
|
69
|
+
keywords: new Set(['display_name']),
|
|
70
|
+
publishers: new Set(['display_name']),
|
|
71
|
+
funders: new Set(['display_name']),
|
|
72
|
+
};
|
|
29
73
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
74
|
+
* Fields OpenAlex lists as valid filters but answers with an HTTP 500 on every group_by attempt
|
|
75
|
+
* — an upstream defect rather than a documented restriction. A 500 classifies as
|
|
76
|
+
* ServiceUnavailable, whose recovery tells the caller to wait and retry, so advertising these as
|
|
77
|
+
* groupable sends an agent into a loop that never clears. Fields that 500 only intermittently
|
|
78
|
+
* and group on a retry (`openalex`, `authorships.author.id`) stay listed. Drop an entry once
|
|
79
|
+
* upstream starts answering it.
|
|
34
80
|
*/
|
|
35
|
-
|
|
81
|
+
const GROUP_BY_UPSTREAM_FAILURES = {
|
|
82
|
+
works: new Set([
|
|
83
|
+
'best_oa_location.raw_type',
|
|
84
|
+
'cites',
|
|
85
|
+
'has_embeddings',
|
|
86
|
+
'locations.raw_type',
|
|
87
|
+
'primary_location.raw_type',
|
|
88
|
+
]),
|
|
89
|
+
sources: new Set(['is_preprint_repository']),
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Whether a filter field of `entityType` is also a valid group_by target. group_by is a subset of
|
|
93
|
+
* filter: OpenAlex rejects (HTTP 400) the `*.search`/`*.search.exact` text operators, the
|
|
94
|
+
* `from_*`/`to_*` range-modifier directives, the raw date fields, and the per-type sweep rejects
|
|
95
|
+
* above — all valid as filters but not as aggregation keys. Most integer count fields ARE
|
|
96
|
+
* groupable (bucketed) and are intentionally kept.
|
|
97
|
+
*/
|
|
98
|
+
function isGroupableField(entityType, field) {
|
|
36
99
|
if (field.endsWith('.search') || field.endsWith('.search.exact'))
|
|
37
100
|
return false;
|
|
38
101
|
if (field.startsWith('from_') || field.startsWith('to_'))
|
|
39
102
|
return false;
|
|
40
|
-
if (
|
|
103
|
+
if (NON_GROUPABLE_DATE_FIELDS.has(field))
|
|
104
|
+
return false;
|
|
105
|
+
if (GROUP_BY_REJECTED_FIELDS[entityType].has(field))
|
|
41
106
|
return false;
|
|
42
|
-
return !
|
|
107
|
+
return !GROUP_BY_UPSTREAM_FAILURES[entityType]?.has(field);
|
|
43
108
|
}
|
|
44
109
|
export const describeFieldsTool = tool('openalex_describe_fields', {
|
|
45
110
|
description: 'List valid field names for an OpenAlex entity type and context (filter, group_by, or select). Use proactively before constructing a filter or group_by to avoid invalid-field 400 errors. Pass `query` to rank the list by name similarity — useful when you have a partial or guessed field name. Ranking never drops a field: the full list comes back either way.',
|
|
@@ -49,7 +114,7 @@ export const describeFieldsTool = tool('openalex_describe_fields', {
|
|
|
49
114
|
entity_type: z.enum(ENTITY_TYPES).describe('OpenAlex entity type to list fields for.'),
|
|
50
115
|
context: z
|
|
51
116
|
.enum(CONTEXTS)
|
|
52
|
-
.describe('Field usage context. "filter": fields accepted in the filter param. "group_by": fields accepted in group_by — a subset of the filter set (raw
|
|
117
|
+
.describe('Field usage context. "filter": fields accepted in the filter param. "group_by": fields accepted in group_by — a subset of the filter set that leaves out what OpenAlex refuses to aggregate (raw dates, *.search operators, decimal scores, display_name, and external-ID fields among them). "select": fields accepted in select.'),
|
|
53
118
|
query: z
|
|
54
119
|
.string()
|
|
55
120
|
.optional()
|
|
@@ -70,7 +135,9 @@ export const describeFieldsTool = tool('openalex_describe_fields', {
|
|
|
70
135
|
// group_by accepts only a subset of the filter fields — drop the ones OpenAlex rejects as
|
|
71
136
|
// aggregation keys so the tool never advertises a field analyze_trends will 400 on. filter
|
|
72
137
|
// and select keep the full set (dates / *.search / range-modifiers are valid there).
|
|
73
|
-
const pool = input.context === 'group_by'
|
|
138
|
+
const pool = input.context === 'group_by'
|
|
139
|
+
? catalogPool.filter((field) => isGroupableField(input.entity_type, field))
|
|
140
|
+
: catalogPool;
|
|
74
141
|
const fields = input.query ? rankAllFields(input.query, pool) : pool;
|
|
75
142
|
ctx.log.info('Field catalog lookup', {
|
|
76
143
|
entityType: input.entity_type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe-fields.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/describe-fields.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"describe-fields.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/describe-fields.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;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C,WAAW;YAC7B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,WAAW,EAAE,IAAI,CAAC,MAAM;SACzB,CAAC,CAAC;QAEH,OAAO;YACL,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM;YACN,KAAK,EAAE,IAAI,CAAC,MAAM;SACnB,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;QACjB,MAAM,MAAM,GAAG,KAAK,MAAM,CAAC,WAAW,UAAU,MAAM,CAAC,OAAO,QAAQ,MAAM,CAAC,KAAK,eAAe,CAAC;QAClG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,iBAAiB,EAAE,CAAC,CAAC;QAC9D,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,QAAQ,IAAI,EAAE,EAAE,CAAC,CAAC;IAC3D,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -86,6 +86,13 @@ export declare const resolveNameTool: import("@cyanheads/mcp-ts-core").ToolDefin
|
|
|
86
86
|
readonly when: "A `filters` entry expecting an entity ID received a value that is not an OpenAlex ID — usually a name (HTTP 400).";
|
|
87
87
|
readonly recovery: "Resolve that name to an OpenAlex ID first — run this tool without the ID-valued filter, take the `id` from a match, then re-run with the ID.";
|
|
88
88
|
readonly thrownBy: "service";
|
|
89
|
+
}, {
|
|
90
|
+
readonly reason: "query_too_long";
|
|
91
|
+
readonly code: JsonRpcErrorCode.InvalidParams;
|
|
92
|
+
readonly when: "OpenAlex autocomplete failed (HTTP 500) on a `query` longer than the 1,000 characters it accepts when entity_type is set.";
|
|
93
|
+
readonly retryable: false;
|
|
94
|
+
readonly recovery: "Shorten `query` to 1,000 characters or fewer — pass the name itself, not a citation or abstract — and call again with the shorter text.";
|
|
95
|
+
readonly thrownBy: "service";
|
|
89
96
|
}, {
|
|
90
97
|
readonly reason: "upstream_invalid_params_other";
|
|
91
98
|
readonly code: JsonRpcErrorCode.InvalidParams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-name.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/resolve-name.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-name.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/resolve-name.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAUjE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiS1B,CAAC"}
|