@cyanheads/cern-inspire-mcp-server 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +504 -0
- package/CLAUDE.md +504 -0
- package/Dockerfile +177 -0
- package/LICENSE +201 -0
- package/README.md +311 -0
- package/changelog/0.1.x/0.1.0.md +9 -0
- package/changelog/0.1.x/0.1.1.md +22 -0
- package/changelog/template.md +151 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/index.d.ts +106 -0
- package/dist/mcp-server/resources/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/index.js +7 -0
- package/dist/mcp-server/resources/definitions/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/inspire-literature.resource.d.ts +110 -0
- package/dist/mcp-server/resources/definitions/inspire-literature.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/inspire-literature.resource.js +69 -0
- package/dist/mcp-server/resources/definitions/inspire-literature.resource.js.map +1 -0
- package/dist/mcp-server/tools/definitions/export-citations.tool.d.ts +65 -0
- package/dist/mcp-server/tools/definitions/export-citations.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/export-citations.tool.js +120 -0
- package/dist/mcp-server/tools/definitions/export-citations.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-citation-summary.tool.d.ts +159 -0
- package/dist/mcp-server/tools/definitions/get-citation-summary.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-citation-summary.tool.js +262 -0
- package/dist/mcp-server/tools/definitions/get-citation-summary.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-paper.tool.d.ts +195 -0
- package/dist/mcp-server/tools/definitions/get-paper.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-paper.tool.js +356 -0
- package/dist/mcp-server/tools/definitions/get-paper.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/index.d.ts +675 -0
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/index.js +23 -0
- package/dist/mcp-server/tools/definitions/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/list-reference.tool.d.ts +33 -0
- package/dist/mcp-server/tools/definitions/list-reference.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/list-reference.tool.js +312 -0
- package/dist/mcp-server/tools/definitions/list-reference.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-authors.tool.d.ts +92 -0
- package/dist/mcp-server/tools/definitions/search-authors.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-authors.tool.js +298 -0
- package/dist/mcp-server/tools/definitions/search-authors.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-experiments.tool.d.ts +80 -0
- package/dist/mcp-server/tools/definitions/search-experiments.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-experiments.tool.js +223 -0
- package/dist/mcp-server/tools/definitions/search-experiments.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-hepdata.tool.d.ts +81 -0
- package/dist/mcp-server/tools/definitions/search-hepdata.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-hepdata.tool.js +225 -0
- package/dist/mcp-server/tools/definitions/search-hepdata.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-literature.tool.d.ts +127 -0
- package/dist/mcp-server/tools/definitions/search-literature.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-literature.tool.js +331 -0
- package/dist/mcp-server/tools/definitions/search-literature.tool.js.map +1 -0
- package/dist/mcp-server/tools/inputs.d.ts +80 -0
- package/dist/mcp-server/tools/inputs.d.ts.map +1 -0
- package/dist/mcp-server/tools/inputs.js +100 -0
- package/dist/mcp-server/tools/inputs.js.map +1 -0
- package/dist/services/http/fetch-bounded.d.ts +45 -0
- package/dist/services/http/fetch-bounded.d.ts.map +1 -0
- package/dist/services/http/fetch-bounded.js +79 -0
- package/dist/services/http/fetch-bounded.js.map +1 -0
- package/dist/services/inspire/identifiers.d.ts +55 -0
- package/dist/services/inspire/identifiers.d.ts.map +1 -0
- package/dist/services/inspire/identifiers.js +98 -0
- package/dist/services/inspire/identifiers.js.map +1 -0
- package/dist/services/inspire/inspire-service.d.ts +104 -0
- package/dist/services/inspire/inspire-service.d.ts.map +1 -0
- package/dist/services/inspire/inspire-service.js +525 -0
- package/dist/services/inspire/inspire-service.js.map +1 -0
- package/dist/services/inspire/normalize.d.ts +30 -0
- package/dist/services/inspire/normalize.d.ts.map +1 -0
- package/dist/services/inspire/normalize.js +438 -0
- package/dist/services/inspire/normalize.js.map +1 -0
- package/dist/services/inspire/types.d.ts +505 -0
- package/dist/services/inspire/types.d.ts.map +1 -0
- package/dist/services/inspire/types.js +8 -0
- package/dist/services/inspire/types.js.map +1 -0
- package/dist/services/inspire/vocabulary.d.ts +22 -0
- package/dist/services/inspire/vocabulary.d.ts.map +1 -0
- package/dist/services/inspire/vocabulary.js +68 -0
- package/dist/services/inspire/vocabulary.js.map +1 -0
- package/dist/utils/render.d.ts +40 -0
- package/dist/utils/render.d.ts.map +1 -0
- package/dist/utils/render.js +112 -0
- package/dist/utils/render.js.map +1 -0
- package/package.json +112 -0
- package/server.json +100 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview cern_inspire_search_hepdata — one page of HEPData measurement
|
|
3
|
+
* records from INSPIRE's `data` collection, found by physics content (process,
|
|
4
|
+
* observable, energy, collaboration) without knowing the paper. Each hit names
|
|
5
|
+
* its paper recids, HEPData record DOI, latest version, and table count; this
|
|
6
|
+
* path never reads hepdata.net itself.
|
|
7
|
+
* @module mcp-server/tools/definitions/search-hepdata.tool
|
|
8
|
+
*/
|
|
9
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
10
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
11
|
+
export declare const searchHepdataTool: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
12
|
+
query: z.ZodString;
|
|
13
|
+
sort: z.ZodPreprocess<z.ZodDefault<z.ZodEnum<{
|
|
14
|
+
mostrecent: "mostrecent";
|
|
15
|
+
relevance: "relevance";
|
|
16
|
+
}>>, unknown>;
|
|
17
|
+
page: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
18
|
+
size: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
records: z.ZodArray<z.ZodObject<{
|
|
21
|
+
inspireDataRecid: z.ZodString;
|
|
22
|
+
title: z.ZodString;
|
|
23
|
+
paperRecids: z.ZodArray<z.ZodString>;
|
|
24
|
+
collaborations: z.ZodArray<z.ZodString>;
|
|
25
|
+
experiments: z.ZodArray<z.ZodString>;
|
|
26
|
+
keywords: z.ZodArray<z.ZodString>;
|
|
27
|
+
abstractSnippet: z.ZodOptional<z.ZodString>;
|
|
28
|
+
abstractTruncated: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
recordDoi: z.ZodOptional<z.ZodString>;
|
|
30
|
+
hepdataRecid: z.ZodOptional<z.ZodString>;
|
|
31
|
+
latestVersion: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
tableCount: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
hepdataUrl: z.ZodOptional<z.ZodString>;
|
|
34
|
+
created: z.ZodOptional<z.ZodString>;
|
|
35
|
+
citationCount: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
page: z.ZodNumber;
|
|
38
|
+
size: z.ZodNumber;
|
|
39
|
+
hasMore: z.ZodBoolean;
|
|
40
|
+
}, z.core.$strip>, readonly [{
|
|
41
|
+
readonly reason: "beyond_result_window";
|
|
42
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
43
|
+
readonly when: "page × size exceeds the 10,000 results INSPIRE serves for one query.";
|
|
44
|
+
readonly recovery: "Narrow the query with tighter terms, a collaborations.value:<name> clause, or an energy until it matches under 10,000 records, then page again with cern_inspire_search_hepdata.";
|
|
45
|
+
readonly severity: "notice";
|
|
46
|
+
}, {
|
|
47
|
+
readonly reason: "invalid_query";
|
|
48
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
49
|
+
readonly when: "INSPIRE answered 400 to a parameter value it refuses.";
|
|
50
|
+
readonly recovery: "Check the query against cern_inspire_list_reference topic search_syntax, then retry cern_inspire_search_hepdata with corrected values.";
|
|
51
|
+
readonly severity: "notice";
|
|
52
|
+
readonly thrownBy: "service";
|
|
53
|
+
}, {
|
|
54
|
+
readonly reason: "inspire_rate_limited";
|
|
55
|
+
readonly code: JsonRpcErrorCode.RateLimited;
|
|
56
|
+
readonly when: "INSPIRE returned 429 after the pacer and retries.";
|
|
57
|
+
readonly recovery: "Wait the retry-after seconds this error states (at least 5), then retry this call; INSPIRE allows 15 requests per 5 seconds from one address.";
|
|
58
|
+
readonly retryable: true;
|
|
59
|
+
readonly thrownBy: "service";
|
|
60
|
+
}, {
|
|
61
|
+
readonly reason: "pacer_shed";
|
|
62
|
+
readonly code: JsonRpcErrorCode.RateLimited;
|
|
63
|
+
readonly when: "The server's outbound INSPIRE queue could not start the request within the call's remaining budget.";
|
|
64
|
+
readonly recovery: "This server's INSPIRE request queue is saturated; wait the seconds in this error's retryAfter field (about 5 when it is not shown), then retry this call with fewer cern_inspire calls running in parallel.";
|
|
65
|
+
readonly retryable: true;
|
|
66
|
+
readonly thrownBy: "service";
|
|
67
|
+
}, {
|
|
68
|
+
readonly reason: "upstream_unreadable";
|
|
69
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
70
|
+
readonly when: "The INSPIRE body exceeded the byte ceiling, was HTML where JSON was expected, or was invalid JSON.";
|
|
71
|
+
readonly recovery: "Retry this call in a few seconds; if it fails again, retry cern_inspire_search_hepdata with a smaller size.";
|
|
72
|
+
readonly thrownBy: "service";
|
|
73
|
+
}], {
|
|
74
|
+
readonly totalCount: z.ZodNumber;
|
|
75
|
+
readonly truncated: z.ZodBoolean;
|
|
76
|
+
readonly shown: z.ZodNumber;
|
|
77
|
+
readonly cap: z.ZodNumber;
|
|
78
|
+
readonly nextPage: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}>;
|
|
81
|
+
//# sourceMappingURL=search-hepdata.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-hepdata.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-hepdata.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAgGjE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqK5B,CAAC"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview cern_inspire_search_hepdata — one page of HEPData measurement
|
|
3
|
+
* records from INSPIRE's `data` collection, found by physics content (process,
|
|
4
|
+
* observable, energy, collaboration) without knowing the paper. Each hit names
|
|
5
|
+
* its paper recids, HEPData record DOI, latest version, and table count; this
|
|
6
|
+
* path never reads hepdata.net itself.
|
|
7
|
+
* @module mcp-server/tools/definitions/search-hepdata.tool
|
|
8
|
+
*/
|
|
9
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
10
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
11
|
+
import { blankAsUnset } from '../inputs.js';
|
|
12
|
+
import { getInspireService } from '../../../services/inspire/inspire-service.js';
|
|
13
|
+
import { inline, printUrl, quote } from '../../../utils/render.js';
|
|
14
|
+
/** INSPIRE serves at most this many results of one query (`page × size`). */
|
|
15
|
+
const RESULT_WINDOW = 10_000;
|
|
16
|
+
const SORTS = ['relevance', 'mostrecent'];
|
|
17
|
+
const hepdataRecordSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
inspireDataRecid: z
|
|
20
|
+
.string()
|
|
21
|
+
.describe("Record ID of the HEPData entry in INSPIRE's data collection."),
|
|
22
|
+
title: z.string().describe('Title of the HEPData submission (usually the paper title).'),
|
|
23
|
+
paperRecids: z
|
|
24
|
+
.array(z.string().describe('INSPIRE literature record ID.'))
|
|
25
|
+
.describe('Literature records the data belongs to; pass to cern_inspire_get_paper. HEPData addresses the same paper as ins<recid>.'),
|
|
26
|
+
collaborations: z
|
|
27
|
+
.array(z.string().describe('Collaboration name.'))
|
|
28
|
+
.describe('Collaborations credited.'),
|
|
29
|
+
experiments: z
|
|
30
|
+
.array(z.string().describe('INSPIRE experiment legacy name.'))
|
|
31
|
+
.describe('Experiments credited, by INSPIRE legacy name.'),
|
|
32
|
+
keywords: z
|
|
33
|
+
.array(z.string().describe('Keyword as INSPIRE stores it, e.g. "cmenergies: 13000.0-13000.0".'))
|
|
34
|
+
.describe('HEPData keywords: reactions, observables, phrases, centre-of-mass energies.'),
|
|
35
|
+
abstractSnippet: z
|
|
36
|
+
.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Start of the abstract, up to 300 characters at a word boundary.'),
|
|
39
|
+
abstractTruncated: z
|
|
40
|
+
.boolean()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe('True when the abstract continues past the snippet.'),
|
|
43
|
+
recordDoi: z.string().optional().describe('HEPData record DOI; cite it when reusing the data.'),
|
|
44
|
+
hepdataRecid: z
|
|
45
|
+
.string()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe('HEPData record number, parsed from the record DOI.'),
|
|
48
|
+
latestVersion: z.number().optional().describe('Latest HEPData record version.'),
|
|
49
|
+
tableCount: z.number().optional().describe('Number of tables in the latest version.'),
|
|
50
|
+
hepdataUrl: z
|
|
51
|
+
.string()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe('The HEPData record page on hepdata.net, where the table values are read.'),
|
|
54
|
+
created: z.string().optional().describe('Date INSPIRE created the data record.'),
|
|
55
|
+
citationCount: z.number().optional().describe('Citations INSPIRE counts for the data record.'),
|
|
56
|
+
})
|
|
57
|
+
.describe('One matching HEPData record.');
|
|
58
|
+
function renderRecord(r, position) {
|
|
59
|
+
const lines = [`### ${position}. ${inline(r.title) || '(untitled)'}`];
|
|
60
|
+
lines.push([
|
|
61
|
+
`**INSPIRE data recid:** ${r.inspireDataRecid}`,
|
|
62
|
+
r.created && `**Created:** ${inline(r.created)}`,
|
|
63
|
+
r.citationCount !== undefined && `**Citations:** ${r.citationCount}`,
|
|
64
|
+
]
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.join(' · '));
|
|
67
|
+
lines.push(`**Paper recids:** ${r.paperRecids.length > 0 ? r.paperRecids.map(inline).join(', ') : 'Not available'}`);
|
|
68
|
+
const credits = [
|
|
69
|
+
r.collaborations.length > 0 && `**Collaborations:** ${r.collaborations.map(inline).join(', ')}`,
|
|
70
|
+
r.experiments.length > 0 && `**Experiments:** ${r.experiments.map(inline).join(', ')}`,
|
|
71
|
+
].filter(Boolean);
|
|
72
|
+
if (credits.length > 0)
|
|
73
|
+
lines.push(credits.join(' · '));
|
|
74
|
+
const hepdata = [
|
|
75
|
+
r.recordDoi && `**Record DOI:** ${inline(r.recordDoi)}`,
|
|
76
|
+
r.hepdataRecid && `**HEPData recid:** ${inline(r.hepdataRecid)}`,
|
|
77
|
+
r.latestVersion !== undefined && `**Latest version:** ${r.latestVersion}`,
|
|
78
|
+
r.tableCount !== undefined && `**Tables:** ${r.tableCount}`,
|
|
79
|
+
].filter(Boolean);
|
|
80
|
+
if (hepdata.length > 0)
|
|
81
|
+
lines.push(hepdata.join(' · '));
|
|
82
|
+
if (r.hepdataUrl)
|
|
83
|
+
lines.push(`**Record page:** ${printUrl(r.hepdataUrl)}`);
|
|
84
|
+
if (r.keywords.length > 0)
|
|
85
|
+
lines.push(`**Keywords:** ${r.keywords.map(inline).join('; ')}`);
|
|
86
|
+
if (r.abstractSnippet) {
|
|
87
|
+
lines.push(r.abstractTruncated ? '**Abstract** (truncated):' : '**Abstract:**', quote(r.abstractSnippet));
|
|
88
|
+
}
|
|
89
|
+
return lines;
|
|
90
|
+
}
|
|
91
|
+
export const searchHepdataTool = tool('cern_inspire_search_hepdata', {
|
|
92
|
+
title: 'Search HEPData records',
|
|
93
|
+
description: 'Find HEPData measurement records by physics content — process, observable, energy, collaboration — when the paper is unknown, through INSPIRE-HEP\'s index of every HEPData submission. Each hit carries the paper recids (pass to cern_inspire_get_paper), collaborations, keywords (reactions such as "P P --> TOP TOPBAR X", observables, centre-of-mass energies), the HEPData record DOI (recordDoi, the citation for the data), latest version, table count, and hepdataUrl, the hepdata.net record page that holds the table values; this tool does not return the values themselves. Only the first 10,000 results of a query are reachable.',
|
|
94
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
95
|
+
input: z.object({
|
|
96
|
+
query: z
|
|
97
|
+
.string()
|
|
98
|
+
.trim()
|
|
99
|
+
.min(1)
|
|
100
|
+
.max(1000)
|
|
101
|
+
.describe('Free text or INSPIRE syntax over HEPData records, e.g. top pair differential cross section 13 TeV; collaborations.value:LHCb; keywords.value:"Inclusive"; or literature.control_number:<recid> for one paper\'s data. INSPIRE does not reject malformed syntax; see cern_inspire_list_reference topic search_syntax.'),
|
|
102
|
+
sort: blankAsUnset(z.enum(SORTS).default('relevance')).describe('Result order: relevance (default) or mostrecent.'),
|
|
103
|
+
page: blankAsUnset(z.number().int().min(1).default(1)).describe('Page number, starting at 1. page × size may not exceed 10,000.'),
|
|
104
|
+
size: blankAsUnset(z.number().int().min(1).max(50).default(10)).describe('Records per page (1–50, default 10).'),
|
|
105
|
+
}),
|
|
106
|
+
output: z.object({
|
|
107
|
+
records: z
|
|
108
|
+
.array(hepdataRecordSchema)
|
|
109
|
+
.describe('The HEPData records on this page, in the requested order.'),
|
|
110
|
+
page: z.number().describe('The page returned.'),
|
|
111
|
+
size: z.number().describe('The page size requested.'),
|
|
112
|
+
hasMore: z.boolean().describe('True when INSPIRE has a further page of results.'),
|
|
113
|
+
}),
|
|
114
|
+
enrichment: {
|
|
115
|
+
totalCount: z.number().describe('Total HEPData records the query matched.'),
|
|
116
|
+
truncated: z.boolean().describe('True when more results exist beyond this page.'),
|
|
117
|
+
shown: z.number().describe('Number of records on this page.'),
|
|
118
|
+
cap: z.number().describe('The page size applied.'),
|
|
119
|
+
nextPage: z
|
|
120
|
+
.number()
|
|
121
|
+
.optional()
|
|
122
|
+
.describe('The page number to request next, when one exists within the 10,000-result window.'),
|
|
123
|
+
notice: z.string().optional().describe('Guidance on an empty or paged result.'),
|
|
124
|
+
},
|
|
125
|
+
enrichmentTrailer: {
|
|
126
|
+
nextPage: { label: 'Next page' },
|
|
127
|
+
},
|
|
128
|
+
errors: [
|
|
129
|
+
{
|
|
130
|
+
reason: 'beyond_result_window',
|
|
131
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
132
|
+
when: 'page × size exceeds the 10,000 results INSPIRE serves for one query.',
|
|
133
|
+
recovery: 'Narrow the query with tighter terms, a collaborations.value:<name> clause, or an energy until it matches under 10,000 records, then page again with cern_inspire_search_hepdata.',
|
|
134
|
+
severity: 'notice',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
reason: 'invalid_query',
|
|
138
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
139
|
+
when: 'INSPIRE answered 400 to a parameter value it refuses.',
|
|
140
|
+
recovery: 'Check the query against cern_inspire_list_reference topic search_syntax, then retry cern_inspire_search_hepdata with corrected values.',
|
|
141
|
+
severity: 'notice',
|
|
142
|
+
thrownBy: 'service',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
reason: 'inspire_rate_limited',
|
|
146
|
+
code: JsonRpcErrorCode.RateLimited,
|
|
147
|
+
when: 'INSPIRE returned 429 after the pacer and retries.',
|
|
148
|
+
recovery: 'Wait the retry-after seconds this error states (at least 5), then retry this call; INSPIRE allows 15 requests per 5 seconds from one address.',
|
|
149
|
+
retryable: true,
|
|
150
|
+
thrownBy: 'service',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
reason: 'pacer_shed',
|
|
154
|
+
code: JsonRpcErrorCode.RateLimited,
|
|
155
|
+
when: "The server's outbound INSPIRE queue could not start the request within the call's remaining budget.",
|
|
156
|
+
recovery: "This server's INSPIRE request queue is saturated; wait the seconds in this error's retryAfter field (about 5 when it is not shown), then retry this call with fewer cern_inspire calls running in parallel.",
|
|
157
|
+
retryable: true,
|
|
158
|
+
thrownBy: 'service',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
reason: 'upstream_unreadable',
|
|
162
|
+
code: JsonRpcErrorCode.ServiceUnavailable,
|
|
163
|
+
when: 'The INSPIRE body exceeded the byte ceiling, was HTML where JSON was expected, or was invalid JSON.',
|
|
164
|
+
recovery: 'Retry this call in a few seconds; if it fails again, retry cern_inspire_search_hepdata with a smaller size.',
|
|
165
|
+
thrownBy: 'service',
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
async handler(input, ctx) {
|
|
169
|
+
ctx.enrich({ truncated: false, shown: 0, cap: input.size });
|
|
170
|
+
ctx.enrich.total(0);
|
|
171
|
+
if (input.page * input.size > RESULT_WINDOW) {
|
|
172
|
+
throw ctx.fail('beyond_result_window', `page ${input.page} × size ${input.size} reaches past the first 10,000 results, which is all INSPIRE serves for one query.`, { page: input.page, size: input.size });
|
|
173
|
+
}
|
|
174
|
+
const inspire = getInspireService();
|
|
175
|
+
const result = await inspire.searchHepdata({ query: input.query, sort: input.sort, page: input.page, size: input.size }, inspire.beginCall(ctx));
|
|
176
|
+
ctx.enrich.total(result.total);
|
|
177
|
+
ctx.enrich({ shown: result.records.length });
|
|
178
|
+
ctx.log.info('HEPData search completed', {
|
|
179
|
+
total: result.total,
|
|
180
|
+
shown: result.records.length,
|
|
181
|
+
page: input.page,
|
|
182
|
+
});
|
|
183
|
+
const notices = [];
|
|
184
|
+
if (result.records.length === 0) {
|
|
185
|
+
notices.push(result.total > 0
|
|
186
|
+
? `Page ${input.page} is past the last page (${Math.ceil(result.total / input.size)}); request a lower page.`
|
|
187
|
+
: `No HEPData record matched "${inline(input.query)}". HEPData keywords use phrases like "Inclusive", "Differential Cross Section", and reactions like "P P --> TOP TOPBAR X"; try fewer words or a collaborations.value:<name> clause, or find the paper with cern_inspire_search_literature.`);
|
|
188
|
+
}
|
|
189
|
+
if (result.hasMore) {
|
|
190
|
+
const nextPage = input.page + 1;
|
|
191
|
+
const reachable = nextPage * input.size <= RESULT_WINDOW;
|
|
192
|
+
if (reachable)
|
|
193
|
+
ctx.enrich({ nextPage });
|
|
194
|
+
notices.unshift(reachable
|
|
195
|
+
? `More results: request page ${nextPage} for the next ${input.size}.`
|
|
196
|
+
: 'INSPIRE serves only the first 10,000 results of a query; narrow it with tighter terms, a collaboration, or an energy to reach the rest.');
|
|
197
|
+
ctx.enrich.truncated({
|
|
198
|
+
shown: result.records.length,
|
|
199
|
+
cap: input.size,
|
|
200
|
+
guidance: notices.join(' '),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
else if (notices.length > 0) {
|
|
204
|
+
ctx.enrich.notice(notices.join(' '));
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
records: result.records,
|
|
208
|
+
page: input.page,
|
|
209
|
+
size: input.size,
|
|
210
|
+
hasMore: result.hasMore,
|
|
211
|
+
};
|
|
212
|
+
},
|
|
213
|
+
format: (result) => {
|
|
214
|
+
const lines = [
|
|
215
|
+
`## HEPData records, page ${result.page}`,
|
|
216
|
+
`**Page:** ${result.page} · **Size:** ${result.size} · **Records on this page:** ${result.records.length} · **More pages:** ${result.hasMore ? 'yes' : 'no'}`,
|
|
217
|
+
];
|
|
218
|
+
const offset = (result.page - 1) * result.size;
|
|
219
|
+
result.records.forEach((record, i) => {
|
|
220
|
+
lines.push('', ...renderRecord(record, offset + i + 1));
|
|
221
|
+
});
|
|
222
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
//# sourceMappingURL=search-hepdata.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-hepdata.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-hepdata.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE5D,6EAA6E;AAC7E,MAAM,aAAa,GAAG,MAAM,CAAC;AAE7B,MAAM,KAAK,GAAG,CAAC,WAAW,EAAE,YAAY,CAAU,CAAC;AAEnD,MAAM,mBAAmB,GAAG,CAAC;KAC1B,MAAM,CAAC;IACN,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,QAAQ,CAAC,8DAA8D,CAAC;IAC3E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4DAA4D,CAAC;IACxF,WAAW,EAAE,CAAC;SACX,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAC;SAC3D,QAAQ,CACP,yHAAyH,CAC1H;IACH,cAAc,EAAE,CAAC;SACd,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,q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,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;QACjB,MAAM,KAAK,GAAG;YACZ,4BAA4B,MAAM,CAAC,IAAI,EAAE;YACzC,aAAa,MAAM,CAAC,IAAI,gBAAgB,MAAM,CAAC,IAAI,gCAAgC,MAAM,CAAC,OAAO,CAAC,MAAM,sBAAsB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;SAC9J,CAAC;QACF,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC;QAC/C,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QACH,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,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview cern_inspire_search_literature — one page of INSPIRE-HEP
|
|
3
|
+
* literature search results for INSPIRE query syntax or free text, filtered by
|
|
4
|
+
* document type, subject, and year, sorted by relevance, recency, or citations.
|
|
5
|
+
* @module mcp-server/tools/definitions/search-literature.tool
|
|
6
|
+
*/
|
|
7
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
8
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
9
|
+
export declare const searchLiteratureTool: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
10
|
+
query: z.ZodString;
|
|
11
|
+
sort: z.ZodPreprocess<z.ZodDefault<z.ZodEnum<{
|
|
12
|
+
mostcited: "mostcited";
|
|
13
|
+
mostrecent: "mostrecent";
|
|
14
|
+
relevance: "relevance";
|
|
15
|
+
}>>, unknown>;
|
|
16
|
+
document_types: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
17
|
+
"activity report": "activity report";
|
|
18
|
+
article: "article";
|
|
19
|
+
book: "book";
|
|
20
|
+
"book chapter": "book chapter";
|
|
21
|
+
"conference paper": "conference paper";
|
|
22
|
+
introductory: "introductory";
|
|
23
|
+
lectures: "lectures";
|
|
24
|
+
note: "note";
|
|
25
|
+
proceedings: "proceedings";
|
|
26
|
+
published: "published";
|
|
27
|
+
report: "report";
|
|
28
|
+
review: "review";
|
|
29
|
+
thesis: "thesis";
|
|
30
|
+
}>>>, unknown>;
|
|
31
|
+
subjects: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
32
|
+
Accelerators: "Accelerators";
|
|
33
|
+
Astrophysics: "Astrophysics";
|
|
34
|
+
Computing: "Computing";
|
|
35
|
+
"Condensed Matter": "Condensed Matter";
|
|
36
|
+
"Data Analysis and Statistics": "Data Analysis and Statistics";
|
|
37
|
+
"Experiment-HEP": "Experiment-HEP";
|
|
38
|
+
"Experiment-Nucl": "Experiment-Nucl";
|
|
39
|
+
"General Physics": "General Physics";
|
|
40
|
+
"Gravitation and Cosmology": "Gravitation and Cosmology";
|
|
41
|
+
Instrumentation: "Instrumentation";
|
|
42
|
+
Lattice: "Lattice";
|
|
43
|
+
"Math and Math Physics": "Math and Math Physics";
|
|
44
|
+
Other: "Other";
|
|
45
|
+
"Phenomenology-HEP": "Phenomenology-HEP";
|
|
46
|
+
"Quantum Physics": "Quantum Physics";
|
|
47
|
+
"Theory-HEP": "Theory-HEP";
|
|
48
|
+
"Theory-Nucl": "Theory-Nucl";
|
|
49
|
+
Unknown: "Unknown";
|
|
50
|
+
}>>>, unknown>;
|
|
51
|
+
year_from: z.ZodPreprocess<z.ZodOptional<z.ZodNumber>, unknown>;
|
|
52
|
+
year_to: z.ZodPreprocess<z.ZodOptional<z.ZodNumber>, unknown>;
|
|
53
|
+
page: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
54
|
+
size: z.ZodPreprocess<z.ZodDefault<z.ZodNumber>, unknown>;
|
|
55
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
56
|
+
papers: z.ZodArray<z.ZodObject<{
|
|
57
|
+
recid: z.ZodString;
|
|
58
|
+
title: z.ZodString;
|
|
59
|
+
firstAuthor: z.ZodOptional<z.ZodObject<{
|
|
60
|
+
name: z.ZodString;
|
|
61
|
+
recid: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
authorCount: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
collaborations: z.ZodArray<z.ZodString>;
|
|
65
|
+
date: z.ZodOptional<z.ZodString>;
|
|
66
|
+
documentTypes: z.ZodArray<z.ZodString>;
|
|
67
|
+
citationCount: z.ZodNumber;
|
|
68
|
+
citationCountWithoutSelf: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
arxivId: z.ZodOptional<z.ZodString>;
|
|
70
|
+
arxivCategories: z.ZodArray<z.ZodString>;
|
|
71
|
+
doi: z.ZodOptional<z.ZodString>;
|
|
72
|
+
publication: z.ZodOptional<z.ZodString>;
|
|
73
|
+
abstractSnippet: z.ZodOptional<z.ZodString>;
|
|
74
|
+
abstractTruncated: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
page: z.ZodNumber;
|
|
77
|
+
size: z.ZodNumber;
|
|
78
|
+
hasMore: z.ZodBoolean;
|
|
79
|
+
}, z.core.$strip>, readonly [{
|
|
80
|
+
readonly reason: "beyond_result_window";
|
|
81
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
82
|
+
readonly when: "page × size exceeds the 10,000 results INSPIRE serves for one query.";
|
|
83
|
+
readonly recovery: "Narrow the query with year_from/year_to, document_types, or tighter terms until it matches under 10,000 records, then page again with cern_inspire_search_literature.";
|
|
84
|
+
readonly severity: "notice";
|
|
85
|
+
}, {
|
|
86
|
+
readonly reason: "invalid_year_range";
|
|
87
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
88
|
+
readonly when: "year_from is later than year_to.";
|
|
89
|
+
readonly recovery: "Swap year_from and year_to so the range runs forward, or drop one bound for an open range, then retry this call.";
|
|
90
|
+
readonly severity: "notice";
|
|
91
|
+
}, {
|
|
92
|
+
readonly reason: "invalid_query";
|
|
93
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
94
|
+
readonly when: "INSPIRE answered 400 to a parameter value it refuses.";
|
|
95
|
+
readonly recovery: "Check the query and filters against cern_inspire_list_reference topic search_syntax, then retry cern_inspire_search_literature with corrected values.";
|
|
96
|
+
readonly severity: "notice";
|
|
97
|
+
readonly thrownBy: "service";
|
|
98
|
+
}, {
|
|
99
|
+
readonly reason: "inspire_rate_limited";
|
|
100
|
+
readonly code: JsonRpcErrorCode.RateLimited;
|
|
101
|
+
readonly when: "INSPIRE returned 429 after the pacer and retries.";
|
|
102
|
+
readonly recovery: "Wait the retry-after seconds this error states (at least 5), then retry this call; INSPIRE allows 15 requests per 5 seconds from one address.";
|
|
103
|
+
readonly retryable: true;
|
|
104
|
+
readonly thrownBy: "service";
|
|
105
|
+
}, {
|
|
106
|
+
readonly reason: "pacer_shed";
|
|
107
|
+
readonly code: JsonRpcErrorCode.RateLimited;
|
|
108
|
+
readonly when: "The server's outbound INSPIRE queue could not start the request within the call's remaining budget.";
|
|
109
|
+
readonly recovery: "This server's INSPIRE request queue is saturated; wait the seconds in this error's retryAfter field (about 5 when it is not shown), then retry this call with fewer cern_inspire calls running in parallel.";
|
|
110
|
+
readonly retryable: true;
|
|
111
|
+
readonly thrownBy: "service";
|
|
112
|
+
}, {
|
|
113
|
+
readonly reason: "upstream_unreadable";
|
|
114
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
115
|
+
readonly when: "The INSPIRE body exceeded the byte ceiling, was HTML where JSON was expected, or was invalid JSON.";
|
|
116
|
+
readonly recovery: "Retry this call in a few seconds; if it fails again, retry cern_inspire_search_literature with a smaller size.";
|
|
117
|
+
readonly thrownBy: "service";
|
|
118
|
+
}], {
|
|
119
|
+
readonly totalCount: z.ZodNumber;
|
|
120
|
+
readonly truncated: z.ZodBoolean;
|
|
121
|
+
readonly shown: z.ZodNumber;
|
|
122
|
+
readonly cap: z.ZodNumber;
|
|
123
|
+
readonly nextPage: z.ZodOptional<z.ZodNumber>;
|
|
124
|
+
readonly appliedFilters: z.ZodString;
|
|
125
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}>;
|
|
127
|
+
//# sourceMappingURL=search-literature.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-literature.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-literature.tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAmLjE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsM/B,CAAC"}
|