@cyanheads/zenodo-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 +435 -0
- package/CLAUDE.md +435 -0
- package/Dockerfile +140 -0
- package/LICENSE +201 -0
- package/README.md +292 -0
- package/changelog/0.1.x/0.1.1.md +21 -0
- package/changelog/template.md +151 -0
- package/dist/config/server-config.d.ts +13 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +19 -0
- package/dist/config/server-config.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-record.tool.d.ts +186 -0
- package/dist/mcp-server/tools/definitions/get-record.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-record.tool.js +568 -0
- package/dist/mcp-server/tools/definitions/get-record.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/index.d.ts +721 -0
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/index.js +21 -0
- package/dist/mcp-server/tools/definitions/index.js.map +1 -0
- package/dist/mcp-server/tools/definitions/list-files.tool.d.ts +108 -0
- package/dist/mcp-server/tools/definitions/list-files.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/list-files.tool.js +348 -0
- package/dist/mcp-server/tools/definitions/list-files.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/list-versions.tool.d.ts +92 -0
- package/dist/mcp-server/tools/definitions/list-versions.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/list-versions.tool.js +268 -0
- package/dist/mcp-server/tools/definitions/list-versions.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/lookup-vocabulary.tool.d.ts +99 -0
- package/dist/mcp-server/tools/definitions/lookup-vocabulary.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/lookup-vocabulary.tool.js +324 -0
- package/dist/mcp-server/tools/definitions/lookup-vocabulary.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/read-file.tool.d.ts +104 -0
- package/dist/mcp-server/tools/definitions/read-file.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/read-file.tool.js +370 -0
- package/dist/mcp-server/tools/definitions/read-file.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/search-records.tool.d.ts +181 -0
- package/dist/mcp-server/tools/definitions/search-records.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/search-records.tool.js +531 -0
- package/dist/mcp-server/tools/definitions/search-records.tool.js.map +1 -0
- package/dist/mcp-server/tools/record-miss.d.ts +37 -0
- package/dist/mcp-server/tools/record-miss.d.ts.map +1 -0
- package/dist/mcp-server/tools/record-miss.js +51 -0
- package/dist/mcp-server/tools/record-miss.js.map +1 -0
- package/dist/mcp-server/tools/render.d.ts +31 -0
- package/dist/mcp-server/tools/render.d.ts.map +1 -0
- package/dist/mcp-server/tools/render.js +53 -0
- package/dist/mcp-server/tools/render.js.map +1 -0
- package/dist/mcp-server/tools/schema-helpers.d.ts +20 -0
- package/dist/mcp-server/tools/schema-helpers.d.ts.map +1 -0
- package/dist/mcp-server/tools/schema-helpers.js +44 -0
- package/dist/mcp-server/tools/schema-helpers.js.map +1 -0
- package/dist/services/zenodo/cache.d.ts +25 -0
- package/dist/services/zenodo/cache.d.ts.map +1 -0
- package/dist/services/zenodo/cache.js +58 -0
- package/dist/services/zenodo/cache.js.map +1 -0
- package/dist/services/zenodo/html-to-text.d.ts +23 -0
- package/dist/services/zenodo/html-to-text.d.ts.map +1 -0
- package/dist/services/zenodo/html-to-text.js +148 -0
- package/dist/services/zenodo/html-to-text.js.map +1 -0
- package/dist/services/zenodo/http.d.ts +73 -0
- package/dist/services/zenodo/http.d.ts.map +1 -0
- package/dist/services/zenodo/http.js +378 -0
- package/dist/services/zenodo/http.js.map +1 -0
- package/dist/services/zenodo/identifiers.d.ts +104 -0
- package/dist/services/zenodo/identifiers.d.ts.map +1 -0
- package/dist/services/zenodo/identifiers.js +261 -0
- package/dist/services/zenodo/identifiers.js.map +1 -0
- package/dist/services/zenodo/normalize.d.ts +29 -0
- package/dist/services/zenodo/normalize.d.ts.map +1 -0
- package/dist/services/zenodo/normalize.js +324 -0
- package/dist/services/zenodo/normalize.js.map +1 -0
- package/dist/services/zenodo/query-builder.d.ts +87 -0
- package/dist/services/zenodo/query-builder.d.ts.map +1 -0
- package/dist/services/zenodo/query-builder.js +221 -0
- package/dist/services/zenodo/query-builder.js.map +1 -0
- package/dist/services/zenodo/resource-types.d.ts +34 -0
- package/dist/services/zenodo/resource-types.d.ts.map +1 -0
- package/dist/services/zenodo/resource-types.js +97 -0
- package/dist/services/zenodo/resource-types.js.map +1 -0
- package/dist/services/zenodo/text-preview.d.ts +56 -0
- package/dist/services/zenodo/text-preview.d.ts.map +1 -0
- package/dist/services/zenodo/text-preview.js +151 -0
- package/dist/services/zenodo/text-preview.js.map +1 -0
- package/dist/services/zenodo/types.d.ts +517 -0
- package/dist/services/zenodo/types.d.ts.map +1 -0
- package/dist/services/zenodo/types.js +8 -0
- package/dist/services/zenodo/types.js.map +1 -0
- package/dist/services/zenodo/zenodo-service.d.ts +98 -0
- package/dist/services/zenodo/zenodo-service.d.ts.map +1 -0
- package/dist/services/zenodo/zenodo-service.js +392 -0
- package/dist/services/zenodo/zenodo-service.js.map +1 -0
- package/package.json +110 -0
- package/server.json +113 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview zenodo_read_file — reads a byte-capped UTF-8 excerpt of one text
|
|
3
|
+
* file in a Zenodo deposit, or of one member of a .zip file, without downloading
|
|
4
|
+
* the archive. Content is depositor-supplied, rendered fenced as untrusted data,
|
|
5
|
+
* and carries the deposit's license.
|
|
6
|
+
* @module mcp-server/tools/definitions/read-file
|
|
7
|
+
*/
|
|
8
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
9
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
10
|
+
import { downloadUrl, hasDotSegment, parseRecordRef, recordUrl, } from '../../../services/zenodo/identifiers.js';
|
|
11
|
+
import { cutPreview, isZip, languageHint, looksLikeText, previewMode, } from '../../../services/zenodo/text-preview.js';
|
|
12
|
+
import { getZenodoService } from '../../../services/zenodo/zenodo-service.js';
|
|
13
|
+
import { fence, inline } from '../render.js';
|
|
14
|
+
import { blankToUndefined } from '../schema-helpers.js';
|
|
15
|
+
const STATUSES = ['text', 'not_text', 'restricted', 'empty'];
|
|
16
|
+
/** The largest max_bytes a call accepts. */
|
|
17
|
+
const MAX_READ_BYTES = 65_536;
|
|
18
|
+
/**
|
|
19
|
+
* Guidance when a ZIP member read stops at max_bytes. A member cannot be continued
|
|
20
|
+
* at an offset, so the next step depends on whether one larger read covers it.
|
|
21
|
+
*/
|
|
22
|
+
function memberTruncationNotice(end, size, maxBytes) {
|
|
23
|
+
const shown = `Showing bytes 0–${end} of ${size ?? 'an unknown total'}`;
|
|
24
|
+
if (size !== undefined && size <= MAX_READ_BYTES) {
|
|
25
|
+
return `${shown}; call zenodo_read_file again with max_bytes ${size} to read the whole member.`;
|
|
26
|
+
}
|
|
27
|
+
if (size === undefined && maxBytes < MAX_READ_BYTES) {
|
|
28
|
+
return `${shown}; call zenodo_read_file again with max_bytes ${MAX_READ_BYTES} to read more of this member, and download the archive from download_url if that still stops short.`;
|
|
29
|
+
}
|
|
30
|
+
return `${shown}; the member is larger than the ${MAX_READ_BYTES}-byte read cap, so download the archive from download_url for the rest${maxBytes < MAX_READ_BYTES ? ` (max_bytes ${MAX_READ_BYTES} shows more of its start)` : ''}.`;
|
|
31
|
+
}
|
|
32
|
+
export const readFile = tool('zenodo_read_file', {
|
|
33
|
+
title: 'Read a Zenodo file excerpt',
|
|
34
|
+
description: 'Read a bounded UTF-8 excerpt (up to 64 KiB per call) of one text file in a Zenodo deposit — a README, CITATION.cff, CSV head, notebook, or script — or of one member inside a .zip file, without downloading the archive. Continue a top-level file from next_offset. A file with a text MIME type or extension is read directly; an extensionless file Zenodo types application/octet-stream (LICENSE, COPYING, Makefile) is read and returned only when its content is UTF-8 text. Binary files, restricted files, and other types return metadata and the download URL without content. File content is depositor-supplied and carries the deposit’s license.',
|
|
35
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
|
|
36
|
+
input: z.object({
|
|
37
|
+
id: z
|
|
38
|
+
.string()
|
|
39
|
+
.trim()
|
|
40
|
+
.min(1)
|
|
41
|
+
.max(500)
|
|
42
|
+
.describe('The deposit: a record id (22705923), a Zenodo DOI (10.5281/zenodo.22705923), another DOI registered to a Zenodo record, or a zenodo.org/records or doi.org URL. A concept id reads from the latest version.'),
|
|
43
|
+
key: z
|
|
44
|
+
.string()
|
|
45
|
+
.min(1)
|
|
46
|
+
.max(1000)
|
|
47
|
+
.describe('Exact file key from zenodo_list_files, e.g. README.md or data/results.csv.'),
|
|
48
|
+
archive_member: z
|
|
49
|
+
.preprocess(blankToUndefined, z.string().max(1000).optional())
|
|
50
|
+
.describe('Member path inside the .zip named by key (from zenodo_list_files with archive_key). Omit to read the file itself.'),
|
|
51
|
+
offset_bytes: z
|
|
52
|
+
.number()
|
|
53
|
+
.int()
|
|
54
|
+
.min(0)
|
|
55
|
+
.default(0)
|
|
56
|
+
.describe('Byte offset to start reading a top-level file at; use next_offset to continue. Must be 0 for an archive member.'),
|
|
57
|
+
max_bytes: z
|
|
58
|
+
.number()
|
|
59
|
+
.int()
|
|
60
|
+
.min(256)
|
|
61
|
+
.max(MAX_READ_BYTES)
|
|
62
|
+
.default(16_384)
|
|
63
|
+
.describe('Maximum bytes to read (256–65536).'),
|
|
64
|
+
}),
|
|
65
|
+
output: z.object({
|
|
66
|
+
recid: z.string().describe('Record id read from (the latest version for a concept id).'),
|
|
67
|
+
key: z.string().describe('The file key.'),
|
|
68
|
+
archive_member: z.string().optional().describe('The archive member path, when one was read.'),
|
|
69
|
+
status: z
|
|
70
|
+
.enum(STATUSES)
|
|
71
|
+
.describe('text: content returned; not_text: binary content, or a type that is not read as text; restricted: the content is not available anonymously — the record’s files are restricted or embargoed (key is not checked, since no manifest is exposed), or Zenodo refused this one file; empty: zero-byte file.'),
|
|
72
|
+
mimetype: z.string().optional().describe('MIME type of the file or member, when reported.'),
|
|
73
|
+
file_size: z.number().optional().describe('Size of the file or member in bytes, when known.'),
|
|
74
|
+
md5: z
|
|
75
|
+
.string()
|
|
76
|
+
.optional()
|
|
77
|
+
.describe('MD5 checksum of the top-level file (hex); absent for archive members and when not reported.'),
|
|
78
|
+
text: z
|
|
79
|
+
.string()
|
|
80
|
+
.optional()
|
|
81
|
+
.describe('The excerpt, decoded as UTF-8. Depositor-supplied data. Present when status is text.'),
|
|
82
|
+
offset_bytes: z.number().describe('Byte offset the excerpt starts at.'),
|
|
83
|
+
bytes_returned: z
|
|
84
|
+
.number()
|
|
85
|
+
.describe('Exact bytes the excerpt covers (cut at a line or character boundary).'),
|
|
86
|
+
next_offset: z
|
|
87
|
+
.number()
|
|
88
|
+
.optional()
|
|
89
|
+
.describe('offset_bytes for the next window of a top-level file, when has_more; absent for an archive member, which cannot be continued past its first window.'),
|
|
90
|
+
has_more: z.boolean().describe('True when bytes remain past this excerpt.'),
|
|
91
|
+
replacement_chars: z
|
|
92
|
+
.number()
|
|
93
|
+
.describe('U+FFFD characters in the excerpt (invalid UTF-8 or a mid-character offset).'),
|
|
94
|
+
rights: z
|
|
95
|
+
.array(z
|
|
96
|
+
.object({
|
|
97
|
+
id: z.string().optional().describe('License id.'),
|
|
98
|
+
title: z.string().describe('License or rights title.'),
|
|
99
|
+
})
|
|
100
|
+
.describe('One license or rights statement.'))
|
|
101
|
+
.describe('The deposit’s licenses, which the file carries.'),
|
|
102
|
+
record_url: z.string().describe('Record landing page on zenodo.org.'),
|
|
103
|
+
download_url: z
|
|
104
|
+
.string()
|
|
105
|
+
.describe('Direct download URL of the top-level file (the .zip itself for a member).'),
|
|
106
|
+
files_access: z
|
|
107
|
+
.string()
|
|
108
|
+
.optional()
|
|
109
|
+
.describe('File access: public or restricted; absent when Zenodo does not report it.'),
|
|
110
|
+
}),
|
|
111
|
+
enrichment: {
|
|
112
|
+
notice: z
|
|
113
|
+
.string()
|
|
114
|
+
.optional()
|
|
115
|
+
.describe('Why no text was returned, or how to read the rest of the file.'),
|
|
116
|
+
},
|
|
117
|
+
errors: [
|
|
118
|
+
{
|
|
119
|
+
reason: 'invalid_identifier',
|
|
120
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
121
|
+
when: 'id matches no accepted form, or is a GitHub-badge latestdoi id or a non-zenodo.org host',
|
|
122
|
+
recovery: 'Pass a Zenodo record id (22705923), a DOI (10.5281/zenodo.22705923), or a zenodo.org/records URL as id; for a title or keyword, use zenodo_search_records.',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
reason: 'record_not_found',
|
|
126
|
+
code: JsonRpcErrorCode.NotFound,
|
|
127
|
+
when: 'The record 404s, its metadata is restricted, or a non-Zenodo DOI is not registered to a record',
|
|
128
|
+
recovery: 'Check the id with zenodo_get_record, or find the deposit with zenodo_search_records.',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
reason: 'record_deleted',
|
|
132
|
+
code: JsonRpcErrorCode.NotFound,
|
|
133
|
+
when: 'The record was deleted from Zenodo; only its removal tombstone remains',
|
|
134
|
+
recovery: 'Call zenodo_get_record with this id for the removal date and reason, then find a replacement deposit with zenodo_search_records.',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
reason: 'file_not_found',
|
|
138
|
+
code: JsonRpcErrorCode.NotFound,
|
|
139
|
+
when: "key is not in the record's manifest, or Zenodo serves no content for it",
|
|
140
|
+
recovery: 'Call zenodo_list_files with this id to see the record’s exact file keys.',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
reason: 'not_an_archive',
|
|
144
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
145
|
+
when: 'archive_member is set but key is not a .zip',
|
|
146
|
+
recovery: 'Drop archive_member to read the file itself, or pick a .zip key from zenodo_list_files.',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
reason: 'member_not_found',
|
|
150
|
+
code: JsonRpcErrorCode.NotFound,
|
|
151
|
+
when: 'Zenodo has no member at archive_member inside the .zip',
|
|
152
|
+
recovery: 'Call zenodo_list_files with archive_key set to this key to see the member paths.',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
reason: 'member_offset_unsupported',
|
|
156
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
157
|
+
when: 'offset_bytes is above 0 together with archive_member',
|
|
158
|
+
recovery: 'Read the member from offset_bytes 0 with a larger max_bytes (up to 65536), or download the archive from download_url.',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
reason: 'offset_out_of_range',
|
|
162
|
+
code: JsonRpcErrorCode.ValidationError,
|
|
163
|
+
when: 'offset_bytes is at or past the end of the file',
|
|
164
|
+
recovery: 'Call zenodo_read_file again with an offset_bytes below the file’s size (size in zenodo_list_files, file_size in a prior zenodo_read_file result).',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
reason: 'archive_unavailable',
|
|
168
|
+
code: JsonRpcErrorCode.ServiceUnavailable,
|
|
169
|
+
when: 'Zenodo cannot open the .zip named by key: its member listing or the member read answered HTTP 500 after one retry, or no complete response arrived in time',
|
|
170
|
+
thrownBy: 'service',
|
|
171
|
+
recovery: 'Zenodo cannot open every .zip; download the archive from the URL in the error message and extract the member locally, or read the record’s top-level files with zenodo_read_file.',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
reason: 'record_unavailable',
|
|
175
|
+
code: JsonRpcErrorCode.ServiceUnavailable,
|
|
176
|
+
when: 'Zenodo could not serve this record: HTTP 500 after one retry, HTTP 500 while resolving a non-Zenodo DOI, or no complete response within the time budget (its gateway cuts off near 30 s, which deposits with about 10,000 or more files hit)',
|
|
177
|
+
thrownBy: 'service',
|
|
178
|
+
recovery: 'Read the deposit’s metadata from zenodo_search_records with query doi:"<its DOI>" (all_versions true); withdrawn legacy records and deposits with more than about 10,000 files fail on the record endpoint, so their files cannot be read, and if a keyword search also fails, Zenodo is degraded.',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
reason: 'rate_limited',
|
|
182
|
+
code: JsonRpcErrorCode.RateLimited,
|
|
183
|
+
when: "Zenodo answered HTTP 429, or this server's shared Zenodo request budget is spent for the current window",
|
|
184
|
+
retryable: true,
|
|
185
|
+
thrownBy: 'service',
|
|
186
|
+
recovery: 'Wait for the retryAfter seconds in the error data, then call zenodo_read_file again with the same arguments.',
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
async handler(input, ctx) {
|
|
190
|
+
const ref = parseRecordRef(input.id);
|
|
191
|
+
if (ref.kind === 'invalid') {
|
|
192
|
+
throw ctx.fail('invalid_identifier', ref.message, ctx.recoveryFor('invalid_identifier'));
|
|
193
|
+
}
|
|
194
|
+
const service = getZenodoService();
|
|
195
|
+
let record;
|
|
196
|
+
if (ref.kind === 'external_doi') {
|
|
197
|
+
const resolution = await service.resolveDoi(ref.doi, ref.strippedDoi, ctx);
|
|
198
|
+
if (resolution.status === 'not_on_zenodo') {
|
|
199
|
+
throw ctx.fail('record_not_found', `DOI ${ref.strippedDoi ?? ref.doi} is not registered to a Zenodo record.`, ctx.recoveryFor('record_not_found'));
|
|
200
|
+
}
|
|
201
|
+
record = resolution.record;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
const lookup = await service.getRecord(ref.recid, ctx);
|
|
205
|
+
if (lookup.status === 'deleted') {
|
|
206
|
+
throw ctx.fail('record_deleted', `Record ${ref.recid} was deleted from Zenodo; only its tombstone remains.`, ctx.recoveryFor('record_deleted'));
|
|
207
|
+
}
|
|
208
|
+
if (lookup.status !== 'found') {
|
|
209
|
+
throw ctx.fail('record_not_found', lookup.status === 'restricted'
|
|
210
|
+
? `Record ${ref.recid} exists but its metadata is restricted and cannot be read anonymously.`
|
|
211
|
+
: `No Zenodo record has id ${ref.recid}.`, ctx.recoveryFor('record_not_found'));
|
|
212
|
+
}
|
|
213
|
+
record = lookup.record;
|
|
214
|
+
}
|
|
215
|
+
const { access, files, recid } = record;
|
|
216
|
+
const member = input.archive_member;
|
|
217
|
+
const entry = files.entries.find((e) => e.key === input.key);
|
|
218
|
+
const displayName = inline(member ?? input.key);
|
|
219
|
+
const restrictedNotice = () => `Files are ${access.status}${access.embargo_until ? ` until ${access.embargo_until}` : ''}; content is not available anonymously.`;
|
|
220
|
+
const base = {
|
|
221
|
+
recid,
|
|
222
|
+
key: input.key,
|
|
223
|
+
...(member ? { archive_member: member } : {}),
|
|
224
|
+
offset_bytes: input.offset_bytes,
|
|
225
|
+
bytes_returned: 0,
|
|
226
|
+
has_more: false,
|
|
227
|
+
replacement_chars: 0,
|
|
228
|
+
rights: record.rights.map((r) => ({ ...(r.id ? { id: r.id } : {}), title: r.title })),
|
|
229
|
+
record_url: recordUrl(recid),
|
|
230
|
+
download_url: entry?.download_url ?? downloadUrl(recid, input.key),
|
|
231
|
+
...(access.files ? { files_access: access.files } : {}),
|
|
232
|
+
};
|
|
233
|
+
const described = (status, meta) => ({
|
|
234
|
+
...base,
|
|
235
|
+
status,
|
|
236
|
+
...(meta.mimetype ? { mimetype: meta.mimetype } : {}),
|
|
237
|
+
...(meta.size !== undefined ? { file_size: meta.size } : {}),
|
|
238
|
+
...(entry?.md5 && !member ? { md5: entry.md5 } : {}),
|
|
239
|
+
});
|
|
240
|
+
const withoutText = (status, notice, meta) => {
|
|
241
|
+
ctx.enrich.notice(notice);
|
|
242
|
+
return described(status, meta);
|
|
243
|
+
};
|
|
244
|
+
if (files.enabled && access.files === 'restricted') {
|
|
245
|
+
return withoutText('restricted', restrictedNotice(), {});
|
|
246
|
+
}
|
|
247
|
+
if (!entry) {
|
|
248
|
+
throw ctx.fail('file_not_found', files.enabled
|
|
249
|
+
? `Record ${recid} has no file with key "${inline(input.key)}".`
|
|
250
|
+
: `Record ${recid} is a metadata-only deposit with no files.`, ctx.recoveryFor('file_not_found'));
|
|
251
|
+
}
|
|
252
|
+
let meta;
|
|
253
|
+
let mode;
|
|
254
|
+
let read;
|
|
255
|
+
const notPreviewable = () => withoutText('not_text', `${displayName} is not a previewable text file (${meta.mimetype ?? 'unknown type'}); download it from download_url.`, meta);
|
|
256
|
+
if (member) {
|
|
257
|
+
if (!isZip(entry.key, entry.mimetype)) {
|
|
258
|
+
throw ctx.fail('not_an_archive', `"${inline(input.key)}" is not a .zip file, so archive_member cannot be read from it.`, ctx.recoveryFor('not_an_archive'));
|
|
259
|
+
}
|
|
260
|
+
if (input.offset_bytes > 0) {
|
|
261
|
+
throw ctx.fail('member_offset_unsupported', 'Zenodo serves ZIP members only from their first byte; offset_bytes must be 0 with archive_member.', ctx.recoveryFor('member_offset_unsupported'));
|
|
262
|
+
}
|
|
263
|
+
if (hasDotSegment(member)) {
|
|
264
|
+
throw ctx.fail('member_not_found', `"${displayName}" has a "." or ".." path segment, so it names no member of the .zip "${inline(input.key)}".`, ctx.recoveryFor('member_not_found'));
|
|
265
|
+
}
|
|
266
|
+
const container = await service.getContainer(recid, entry.key, ctx);
|
|
267
|
+
const listed = container.status === 'ok'
|
|
268
|
+
? container.listing.members.find((m) => m.path === member)
|
|
269
|
+
: undefined;
|
|
270
|
+
meta = {
|
|
271
|
+
...(listed?.mimetype ? { mimetype: listed.mimetype } : {}),
|
|
272
|
+
...(listed?.size !== undefined ? { size: listed.size } : {}),
|
|
273
|
+
};
|
|
274
|
+
if (meta.size === 0)
|
|
275
|
+
return withoutText('empty', `${displayName} is empty.`, meta);
|
|
276
|
+
mode = previewMode(member, meta.mimetype);
|
|
277
|
+
if (mode === 'binary')
|
|
278
|
+
return notPreviewable();
|
|
279
|
+
read = await service.readMember(recid, entry.key, member, input.max_bytes, ctx);
|
|
280
|
+
if (read.status === 'not_found') {
|
|
281
|
+
throw ctx.fail('member_not_found', `The .zip "${inline(input.key)}" in record ${recid} has no member "${displayName}".`, ctx.recoveryFor('member_not_found'));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
meta = {
|
|
286
|
+
...(entry.mimetype ? { mimetype: entry.mimetype } : {}),
|
|
287
|
+
...(entry.size !== undefined ? { size: entry.size } : {}),
|
|
288
|
+
};
|
|
289
|
+
if (meta.size !== undefined && input.offset_bytes >= meta.size && meta.size > 0) {
|
|
290
|
+
throw ctx.fail('offset_out_of_range', `offset_bytes ${input.offset_bytes} is at or past the end of ${displayName} (${meta.size} bytes).`, ctx.recoveryFor('offset_out_of_range'));
|
|
291
|
+
}
|
|
292
|
+
if (meta.size === 0) {
|
|
293
|
+
if (input.offset_bytes > 0) {
|
|
294
|
+
throw ctx.fail('offset_out_of_range', `${displayName} is empty, so offset_bytes ${input.offset_bytes} is past its end.`, ctx.recoveryFor('offset_out_of_range'));
|
|
295
|
+
}
|
|
296
|
+
return withoutText('empty', `${displayName} is empty.`, meta);
|
|
297
|
+
}
|
|
298
|
+
mode = previewMode(entry.key, meta.mimetype);
|
|
299
|
+
if (mode === 'binary')
|
|
300
|
+
return notPreviewable();
|
|
301
|
+
read = await service.readContent(recid, entry.key, input.offset_bytes, input.max_bytes, ctx);
|
|
302
|
+
if (read.status === 'range_not_satisfiable') {
|
|
303
|
+
throw ctx.fail('offset_out_of_range', `offset_bytes ${input.offset_bytes} is past the end of ${displayName}.`, ctx.recoveryFor('offset_out_of_range'));
|
|
304
|
+
}
|
|
305
|
+
if (read.status === 'not_found') {
|
|
306
|
+
throw ctx.fail('file_not_found', `Zenodo has no content for "${displayName}" in record ${recid}.`, ctx.recoveryFor('file_not_found'));
|
|
307
|
+
}
|
|
308
|
+
if (meta.size === undefined && read.fileSize !== undefined)
|
|
309
|
+
meta.size = read.fileSize;
|
|
310
|
+
}
|
|
311
|
+
if (read.status === 'forbidden') {
|
|
312
|
+
// The files-restricted case returned above, so this is a per-file refusal on a readable record.
|
|
313
|
+
return withoutText('restricted', `Zenodo refused anonymous access to ${displayName} (HTTP 403) although the record's files are ${access.files ?? access.status}; its content cannot be previewed here. zenodo_get_record shows the record's access details.`, meta);
|
|
314
|
+
}
|
|
315
|
+
if (read.bytes.length === 0) {
|
|
316
|
+
// No bytes past a positive offset means the offset is past the end, not an empty file.
|
|
317
|
+
if (input.offset_bytes > 0) {
|
|
318
|
+
throw ctx.fail('offset_out_of_range', `offset_bytes ${input.offset_bytes} is past the end of ${displayName}.`, ctx.recoveryFor('offset_out_of_range'));
|
|
319
|
+
}
|
|
320
|
+
return withoutText('empty', `${displayName} is empty.`, meta);
|
|
321
|
+
}
|
|
322
|
+
const cut = cutPreview(read.bytes, {
|
|
323
|
+
atStart: input.offset_bytes === 0,
|
|
324
|
+
moreRemains: read.moreRemains,
|
|
325
|
+
});
|
|
326
|
+
if (cut.binary) {
|
|
327
|
+
return withoutText('not_text', `${displayName} is not a previewable text file (${meta.mimetype ?? 'binary content'}); download it from download_url.`, meta);
|
|
328
|
+
}
|
|
329
|
+
if (mode === 'sniff' && !looksLikeText(read.bytes, input.offset_bytes === 0)) {
|
|
330
|
+
return withoutText('not_text', `${displayName} has no file extension and its content is not UTF-8 text (${meta.mimetype ?? 'no MIME type'}); download it from download_url.`, meta);
|
|
331
|
+
}
|
|
332
|
+
const hasMore = read.moreRemains;
|
|
333
|
+
const nextOffset = input.offset_bytes + cut.bytesKept;
|
|
334
|
+
if (hasMore) {
|
|
335
|
+
const end = nextOffset - 1;
|
|
336
|
+
ctx.enrich.notice(member
|
|
337
|
+
? memberTruncationNotice(end, meta.size, input.max_bytes)
|
|
338
|
+
: `Showing bytes ${input.offset_bytes}–${end} of ${meta.size ?? 'an unknown total'}; call zenodo_read_file again with offset_bytes ${nextOffset}.`);
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
...described('text', meta),
|
|
342
|
+
text: cut.text,
|
|
343
|
+
bytes_returned: cut.bytesKept,
|
|
344
|
+
has_more: hasMore,
|
|
345
|
+
...(hasMore && !member ? { next_offset: nextOffset } : {}),
|
|
346
|
+
replacement_chars: cut.replacementChars,
|
|
347
|
+
};
|
|
348
|
+
},
|
|
349
|
+
format: (result) => {
|
|
350
|
+
const name = result.archive_member
|
|
351
|
+
? `${inline(result.archive_member)} (in ${inline(result.key)})`
|
|
352
|
+
: inline(result.key);
|
|
353
|
+
const lines = [
|
|
354
|
+
`## ${name} — record ${result.recid}`,
|
|
355
|
+
`**Status:** ${result.status} | **MIME type:** ${inline(result.mimetype ?? 'unknown')} | **File size:** ${result.file_size ?? 'unknown'} bytes${result.md5 ? ` | **MD5:** ${inline(result.md5)}` : ''}`,
|
|
356
|
+
`**Offset:** ${result.offset_bytes} | **Bytes returned:** ${result.bytes_returned} | **Has more:** ${result.has_more}${result.next_offset !== undefined ? ` | **Next offset:** ${result.next_offset}` : ''} | **Replacement chars:** ${result.replacement_chars}`,
|
|
357
|
+
`**License:** ${result.rights.length ? result.rights.map((r) => `${inline(r.title)}${r.id ? ` (${inline(r.id)})` : ''}`).join('; ') : 'not stated'} — record ${result.record_url}`,
|
|
358
|
+
`**Download:** ${result.download_url}${result.files_access ? ` | **Files access:** ${inline(result.files_access)}` : ''}`,
|
|
359
|
+
];
|
|
360
|
+
if (result.text !== undefined) {
|
|
361
|
+
lines.push('', fence(result.text, {
|
|
362
|
+
key: result.archive_member ?? result.key,
|
|
363
|
+
lang: languageHint(result.archive_member ?? result.key),
|
|
364
|
+
recid: result.recid,
|
|
365
|
+
}));
|
|
366
|
+
}
|
|
367
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
//# sourceMappingURL=read-file.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/read-file.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,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Ac,IAAI,MAAM,CAAC,GAAG;gBACxC,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,cAAc,IAAI,MAAM,CAAC,GAAG,CAAC;gBACvD,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC,CACH,CAAC;QACJ,CAAC;QACD,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,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview zenodo_search_records — keyword search over Zenodo deposits with
|
|
3
|
+
* verified filters (resource type, community, funder, award, creator ORCID, file
|
|
4
|
+
* type, license, access status, publication date), returning manifest-free
|
|
5
|
+
* summaries plus facet counts over the full match set, every filter applied.
|
|
6
|
+
* @module mcp-server/tools/definitions/search-records
|
|
7
|
+
*/
|
|
8
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
9
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
10
|
+
export declare const searchRecords: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
11
|
+
query: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
12
|
+
resource_type: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
13
|
+
[x: string]: string;
|
|
14
|
+
}>>>, unknown>;
|
|
15
|
+
community: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
16
|
+
funder: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
17
|
+
award: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
18
|
+
creator_orcid: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
19
|
+
file_type: z.ZodPreprocess<z.ZodOptional<z.ZodArray<z.ZodString>>, unknown>;
|
|
20
|
+
license: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
21
|
+
access_status: z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
|
|
22
|
+
embargoed: "embargoed";
|
|
23
|
+
"metadata-only": "metadata-only";
|
|
24
|
+
open: "open";
|
|
25
|
+
restricted: "restricted";
|
|
26
|
+
}>>, unknown>;
|
|
27
|
+
published_from: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
28
|
+
published_to: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
|
|
29
|
+
all_versions: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
sort: z.ZodPreprocess<z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
bestmatch: "bestmatch";
|
|
32
|
+
mostdownloaded: "mostdownloaded";
|
|
33
|
+
mostviewed: "mostviewed";
|
|
34
|
+
newest: "newest";
|
|
35
|
+
oldest: "oldest";
|
|
36
|
+
"updated-asc": "updated-asc";
|
|
37
|
+
"updated-desc": "updated-desc";
|
|
38
|
+
}>>, unknown>;
|
|
39
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
40
|
+
size: z.ZodDefault<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
42
|
+
total: z.ZodNumber;
|
|
43
|
+
reachable: z.ZodNumber;
|
|
44
|
+
page: z.ZodNumber;
|
|
45
|
+
size: z.ZodNumber;
|
|
46
|
+
has_more: z.ZodBoolean;
|
|
47
|
+
next_page: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
hits: z.ZodArray<z.ZodObject<{
|
|
49
|
+
recid: z.ZodString;
|
|
50
|
+
doi: z.ZodOptional<z.ZodString>;
|
|
51
|
+
doi_provider: z.ZodOptional<z.ZodString>;
|
|
52
|
+
concept_recid: z.ZodOptional<z.ZodString>;
|
|
53
|
+
concept_doi: z.ZodOptional<z.ZodString>;
|
|
54
|
+
title: z.ZodString;
|
|
55
|
+
publication_date: z.ZodOptional<z.ZodString>;
|
|
56
|
+
resource_type: z.ZodOptional<z.ZodObject<{
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
title: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>>;
|
|
60
|
+
version: z.ZodOptional<z.ZodString>;
|
|
61
|
+
is_latest: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
version_index: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
creators: z.ZodArray<z.ZodObject<{
|
|
64
|
+
name: z.ZodString;
|
|
65
|
+
orcid: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>>;
|
|
67
|
+
creator_count: z.ZodNumber;
|
|
68
|
+
license_ids: z.ZodArray<z.ZodString>;
|
|
69
|
+
access: z.ZodObject<{
|
|
70
|
+
status: z.ZodString;
|
|
71
|
+
files: z.ZodOptional<z.ZodString>;
|
|
72
|
+
embargo_until: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
communities: z.ZodArray<z.ZodString>;
|
|
75
|
+
file_count: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
total_bytes: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
views: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
downloads: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
description_snippet: z.ZodOptional<z.ZodString>;
|
|
80
|
+
zenodo_url: z.ZodString;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
facets: z.ZodObject<{
|
|
83
|
+
resource_type: z.ZodArray<z.ZodObject<{
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
label: z.ZodString;
|
|
86
|
+
count: z.ZodNumber;
|
|
87
|
+
subtypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
88
|
+
id: z.ZodString;
|
|
89
|
+
label: z.ZodString;
|
|
90
|
+
count: z.ZodNumber;
|
|
91
|
+
}, z.core.$strip>>>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
access_status: z.ZodArray<z.ZodObject<{
|
|
94
|
+
id: z.ZodString;
|
|
95
|
+
label: z.ZodString;
|
|
96
|
+
count: z.ZodNumber;
|
|
97
|
+
}, z.core.$strip>>;
|
|
98
|
+
file_type: z.ZodArray<z.ZodObject<{
|
|
99
|
+
id: z.ZodString;
|
|
100
|
+
label: z.ZodString;
|
|
101
|
+
count: z.ZodNumber;
|
|
102
|
+
}, z.core.$strip>>;
|
|
103
|
+
subject: z.ZodArray<z.ZodObject<{
|
|
104
|
+
label: z.ZodString;
|
|
105
|
+
count: z.ZodNumber;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
publication_year: z.ZodArray<z.ZodObject<{
|
|
108
|
+
year: z.ZodString;
|
|
109
|
+
count: z.ZodNumber;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
}, z.core.$strip>, readonly [{
|
|
113
|
+
readonly reason: "query_is_identifier";
|
|
114
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
115
|
+
readonly when: "The query is a single DOI, doi.org URL, or zenodo.org record URL";
|
|
116
|
+
readonly recovery: "Pass this identifier to zenodo_get_record as id instead of searching for it.";
|
|
117
|
+
}, {
|
|
118
|
+
readonly reason: "query_syntax";
|
|
119
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
120
|
+
readonly when: "The query has an unpaired unescaped / outside quotes";
|
|
121
|
+
readonly recovery: "Escape the slash as \\/ or wrap that term in double quotes, then call zenodo_search_records again.";
|
|
122
|
+
}, {
|
|
123
|
+
readonly reason: "query_failed";
|
|
124
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
125
|
+
readonly when: "Zenodo answered HTTP 500 for a query that passed the local checks";
|
|
126
|
+
readonly retryable: false;
|
|
127
|
+
readonly thrownBy: "service";
|
|
128
|
+
readonly recovery: "Simplify the query (quote phrases, escape : and / with a backslash, or move identifiers into the dedicated filters) and call zenodo_search_records again; if a plain keyword query also fails, Zenodo is degraded, so retry in a few minutes.";
|
|
129
|
+
}, {
|
|
130
|
+
readonly reason: "upstream_timeout";
|
|
131
|
+
readonly code: JsonRpcErrorCode.Timeout;
|
|
132
|
+
readonly when: "The search attempt got no complete response within its time budget";
|
|
133
|
+
readonly retryable: false;
|
|
134
|
+
readonly thrownBy: "service";
|
|
135
|
+
readonly recovery: "Call zenodo_search_records again with a smaller size (5) or narrower filters so the page holds fewer large deposits.";
|
|
136
|
+
}, {
|
|
137
|
+
readonly reason: "unknown_community";
|
|
138
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
139
|
+
readonly when: "community resolves to no Zenodo community";
|
|
140
|
+
readonly recovery: "Find the community’s slug with zenodo_lookup_vocabulary (vocabulary: communities), then pass it as community.";
|
|
141
|
+
}, {
|
|
142
|
+
readonly reason: "unknown_funder";
|
|
143
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
144
|
+
readonly when: "funder is not a known ROR id and no funder carries that Crossref Funder DOI";
|
|
145
|
+
readonly recovery: "Resolve the funder with zenodo_lookup_vocabulary (vocabulary: funders) and pass the returned ROR id as funder.";
|
|
146
|
+
}, {
|
|
147
|
+
readonly reason: "invalid_date_range";
|
|
148
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
149
|
+
readonly when: "The expanded published_from is after published_to";
|
|
150
|
+
readonly recovery: "Set published_from to a date on or before published_to and call zenodo_search_records again.";
|
|
151
|
+
}, {
|
|
152
|
+
readonly reason: "result_window_exceeded";
|
|
153
|
+
readonly code: JsonRpcErrorCode.ValidationError;
|
|
154
|
+
readonly when: "page × size exceeds 10,000";
|
|
155
|
+
readonly recovery: "Zenodo serves only the first 10,000 matches; add filters or a published_from/published_to range to zenodo_search_records instead of paging deeper.";
|
|
156
|
+
}, {
|
|
157
|
+
readonly reason: "rate_limited";
|
|
158
|
+
readonly code: JsonRpcErrorCode.RateLimited;
|
|
159
|
+
readonly when: "Zenodo answered HTTP 429, or this server's shared Zenodo request budget is spent for the current window";
|
|
160
|
+
readonly retryable: true;
|
|
161
|
+
readonly thrownBy: "service";
|
|
162
|
+
readonly recovery: "Wait for the retryAfter seconds in the error data, then call zenodo_search_records again with the same arguments.";
|
|
163
|
+
}], {
|
|
164
|
+
readonly truncated: z.ZodBoolean;
|
|
165
|
+
readonly shown: z.ZodNumber;
|
|
166
|
+
readonly cap: z.ZodNumber;
|
|
167
|
+
readonly totalCount: z.ZodNumber;
|
|
168
|
+
readonly effectiveQuery: z.ZodOptional<z.ZodString>;
|
|
169
|
+
readonly appliedSort: z.ZodEnum<{
|
|
170
|
+
bestmatch: "bestmatch";
|
|
171
|
+
mostdownloaded: "mostdownloaded";
|
|
172
|
+
mostviewed: "mostviewed";
|
|
173
|
+
newest: "newest";
|
|
174
|
+
oldest: "oldest";
|
|
175
|
+
"updated-asc": "updated-asc";
|
|
176
|
+
"updated-desc": "updated-desc";
|
|
177
|
+
}>;
|
|
178
|
+
readonly allVersions: z.ZodBoolean;
|
|
179
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
180
|
+
}>;
|
|
181
|
+
//# sourceMappingURL=search-records.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-records.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/search-records.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AA2LjE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsexB,CAAC"}
|