@cyanheads/gbif-biodiversity-mcp-server 0.2.0
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/CLAUDE.md +393 -0
- package/Dockerfile +99 -0
- package/LICENSE +201 -0
- package/README.md +367 -0
- package/dist/config/server-config.d.ts +14 -0
- package/dist/config/server-config.d.ts.map +1 -0
- package/dist/config/server-config.js +27 -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 +53 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/gbif-dataset.resource.d.ts +20 -0
- package/dist/mcp-server/resources/definitions/gbif-dataset.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/gbif-dataset.resource.js +50 -0
- package/dist/mcp-server/resources/definitions/gbif-dataset.resource.js.map +1 -0
- package/dist/mcp-server/resources/definitions/gbif-species.resource.d.ts +27 -0
- package/dist/mcp-server/resources/definitions/gbif-species.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/gbif-species.resource.js +67 -0
- package/dist/mcp-server/resources/definitions/gbif-species.resource.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-count-occurrences.tool.d.ts +15 -0
- package/dist/mcp-server/tools/definitions/gbif-count-occurrences.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-count-occurrences.tool.js +42 -0
- package/dist/mcp-server/tools/definitions/gbif-count-occurrences.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-dataset.tool.d.ts +33 -0
- package/dist/mcp-server/tools/definitions/gbif-get-dataset.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-dataset.tool.js +143 -0
- package/dist/mcp-server/tools/definitions/gbif-get-dataset.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-occurrence.tool.d.ts +58 -0
- package/dist/mcp-server/tools/definitions/gbif-get-occurrence.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-occurrence.tool.js +264 -0
- package/dist/mcp-server/tools/definitions/gbif-get-occurrence.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species-children.tool.d.ts +25 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species-children.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species-children.tool.js +91 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species-children.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species-classification.tool.d.ts +22 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species-classification.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species-classification.tool.js +82 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species-classification.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species.tool.d.ts +45 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species.tool.js +182 -0
- package/dist/mcp-server/tools/definitions/gbif-get-species.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-match-species.tool.d.ts +49 -0
- package/dist/mcp-server/tools/definitions/gbif-match-species.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-match-species.tool.js +148 -0
- package/dist/mcp-server/tools/definitions/gbif-match-species.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-occurrence-facets.tool.d.ts +45 -0
- package/dist/mcp-server/tools/definitions/gbif-occurrence-facets.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-occurrence-facets.tool.js +116 -0
- package/dist/mcp-server/tools/definitions/gbif-occurrence-facets.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-search-datasets.tool.d.ts +34 -0
- package/dist/mcp-server/tools/definitions/gbif-search-datasets.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-search-datasets.tool.js +112 -0
- package/dist/mcp-server/tools/definitions/gbif-search-datasets.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-search-occurrences.tool.d.ts +66 -0
- package/dist/mcp-server/tools/definitions/gbif-search-occurrences.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-search-occurrences.tool.js +278 -0
- package/dist/mcp-server/tools/definitions/gbif-search-occurrences.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-search-publishers.tool.d.ts +23 -0
- package/dist/mcp-server/tools/definitions/gbif-search-publishers.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-search-publishers.tool.js +90 -0
- package/dist/mcp-server/tools/definitions/gbif-search-publishers.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-search-species.tool.d.ts +48 -0
- package/dist/mcp-server/tools/definitions/gbif-search-species.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/gbif-search-species.tool.js +151 -0
- package/dist/mcp-server/tools/definitions/gbif-search-species.tool.js.map +1 -0
- package/dist/mcp-server/tools/utils.d.ts +7 -0
- package/dist/mcp-server/tools/utils.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils.js +20 -0
- package/dist/mcp-server/tools/utils.js.map +1 -0
- package/dist/services/gbif/gbif-service.d.ts +99 -0
- package/dist/services/gbif/gbif-service.d.ts.map +1 -0
- package/dist/services/gbif/gbif-service.js +255 -0
- package/dist/services/gbif/gbif-service.js.map +1 -0
- package/dist/services/gbif/types.d.ts +254 -0
- package/dist/services/gbif/types.d.ts.map +1 -0
- package/dist/services/gbif/types.js +6 -0
- package/dist/services/gbif/types.js.map +1 -0
- package/package.json +91 -0
- package/server.json +117 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Fetch a single GBIF occurrence record by key.
|
|
3
|
+
* @module mcp-server/tools/definitions/gbif-get-occurrence
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode, McpError } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getGbifService } from '../../../services/gbif/gbif-service.js';
|
|
8
|
+
export const gbifGetOccurrence = tool('gbif_get_occurrence', {
|
|
9
|
+
title: 'Get Occurrence Record',
|
|
10
|
+
description: 'Fetch a single occurrence record by its GBIF occurrence key. Returns the complete Darwin Core ' +
|
|
11
|
+
'record — all coordinates, administrative geography (GADM), dates, collections metadata, ' +
|
|
12
|
+
'collector identifiers, media links, and quality issue flags. Use the occurrence key from ' +
|
|
13
|
+
'gbif_search_occurrences results to fetch full detail.',
|
|
14
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
15
|
+
input: z.object({
|
|
16
|
+
occurrenceKey: z.number().describe('GBIF occurrence key from gbif_search_occurrences results.'),
|
|
17
|
+
}),
|
|
18
|
+
output: z.object({
|
|
19
|
+
key: z.number().optional().describe('GBIF occurrence key.'),
|
|
20
|
+
datasetKey: z.string().optional().describe('UUID of the source dataset.'),
|
|
21
|
+
taxonKey: z.number().optional().describe('Backbone taxon key.'),
|
|
22
|
+
scientificName: z.string().optional().describe('Scientific name from occurrence record.'),
|
|
23
|
+
canonicalName: z.string().optional().describe('Canonical name without authorship.'),
|
|
24
|
+
kingdom: z.string().optional().describe('Kingdom classification.'),
|
|
25
|
+
phylum: z.string().optional().describe('Phylum classification.'),
|
|
26
|
+
order: z.string().optional().describe('Order classification.'),
|
|
27
|
+
family: z.string().optional().describe('Family classification.'),
|
|
28
|
+
genus: z.string().optional().describe('Genus classification.'),
|
|
29
|
+
species: z.string().optional().describe('Species canonical name.'),
|
|
30
|
+
taxonRank: z.string().optional().describe('Taxonomic rank of the identified taxon.'),
|
|
31
|
+
decimalLatitude: z
|
|
32
|
+
.number()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe('Latitude in decimal degrees (WGS84). May be absent.'),
|
|
35
|
+
decimalLongitude: z
|
|
36
|
+
.number()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Longitude in decimal degrees (WGS84). May be absent.'),
|
|
39
|
+
coordinateUncertaintyInMeters: z
|
|
40
|
+
.number()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe('Coordinate uncertainty radius in meters. May be absent.'),
|
|
43
|
+
continent: z.string().optional().describe('Continent name. May be absent.'),
|
|
44
|
+
country: z.string().optional().describe('Country name. May be absent.'),
|
|
45
|
+
countryCode: z.string().optional().describe('ISO 3166-1 alpha-2 country code. May be absent.'),
|
|
46
|
+
stateProvince: z.string().optional().describe('State or province. May be absent.'),
|
|
47
|
+
locality: z.string().optional().describe('Locality description. May be absent.'),
|
|
48
|
+
publishingCountry: z
|
|
49
|
+
.string()
|
|
50
|
+
.optional()
|
|
51
|
+
.describe('Country code of the publishing organization.'),
|
|
52
|
+
eventDate: z
|
|
53
|
+
.string()
|
|
54
|
+
.optional()
|
|
55
|
+
.describe('Observation date as ISO 8601 string. May be absent.'),
|
|
56
|
+
year: z.number().optional().describe('Observation year. May be absent.'),
|
|
57
|
+
month: z.number().optional().describe('Observation month (1–12). May be absent.'),
|
|
58
|
+
day: z.number().optional().describe('Observation day. May be absent.'),
|
|
59
|
+
basisOfRecord: z.string().optional().describe('How the occurrence was recorded.'),
|
|
60
|
+
institutionCode: z
|
|
61
|
+
.string()
|
|
62
|
+
.optional()
|
|
63
|
+
.describe('Code of the contributing institution. May be absent.'),
|
|
64
|
+
collectionCode: z
|
|
65
|
+
.string()
|
|
66
|
+
.optional()
|
|
67
|
+
.describe('Collection code within the institution. May be absent.'),
|
|
68
|
+
catalogNumber: z
|
|
69
|
+
.string()
|
|
70
|
+
.optional()
|
|
71
|
+
.describe('Catalog number within the collection. May be absent.'),
|
|
72
|
+
recordedBy: z.string().optional().describe('Collector name(s). May be absent.'),
|
|
73
|
+
identifiedBy: z.string().optional().describe('Identifier name(s). May be absent.'),
|
|
74
|
+
individualCount: z.number().optional().describe('Number of individuals. May be absent.'),
|
|
75
|
+
sex: z.string().optional().describe('Sex of the individual(s). May be absent.'),
|
|
76
|
+
lifeStage: z.string().optional().describe('Life stage of the individual(s). May be absent.'),
|
|
77
|
+
issues: z.array(z.string()).optional().describe('GBIF data quality issue flags.'),
|
|
78
|
+
media: z
|
|
79
|
+
.array(z
|
|
80
|
+
.object({
|
|
81
|
+
type: z.string().optional().describe('Media type (StillImage, Sound, etc.).'),
|
|
82
|
+
format: z.string().optional().describe('MIME format of the media.'),
|
|
83
|
+
identifier: z.string().optional().describe('URL to the media file.'),
|
|
84
|
+
title: z.string().optional().describe('Media title.'),
|
|
85
|
+
license: z.string().optional().describe('License for the media.'),
|
|
86
|
+
})
|
|
87
|
+
.describe('A media item (image, audio, video) associated with the occurrence.'))
|
|
88
|
+
.optional()
|
|
89
|
+
.describe('Associated media (images, audio, video). May be absent.'),
|
|
90
|
+
}),
|
|
91
|
+
errors: [
|
|
92
|
+
{
|
|
93
|
+
reason: 'not_found',
|
|
94
|
+
code: JsonRpcErrorCode.NotFound,
|
|
95
|
+
when: 'The occurrenceKey does not exist in GBIF.',
|
|
96
|
+
recovery: 'Use gbif_search_occurrences to find valid occurrence keys.',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
async handler(input, ctx) {
|
|
100
|
+
ctx.log.info('Fetching occurrence record', { occurrenceKey: input.occurrenceKey });
|
|
101
|
+
let raw;
|
|
102
|
+
try {
|
|
103
|
+
raw = await getGbifService().getOccurrence(input.occurrenceKey, ctx);
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
if (err instanceof McpError && err.code === -32001) {
|
|
107
|
+
throw ctx.fail('not_found', `Occurrence key ${input.occurrenceKey} not found in GBIF.`, {
|
|
108
|
+
...ctx.recoveryFor('not_found'),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
if (!raw.key) {
|
|
114
|
+
throw ctx.fail('not_found', `Occurrence key ${input.occurrenceKey} not found in GBIF.`, {
|
|
115
|
+
...ctx.recoveryFor('not_found'),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
key: raw.key,
|
|
120
|
+
datasetKey: raw.datasetKey,
|
|
121
|
+
taxonKey: raw.taxonKey,
|
|
122
|
+
scientificName: raw.scientificName,
|
|
123
|
+
canonicalName: raw.canonicalName,
|
|
124
|
+
kingdom: raw.kingdom,
|
|
125
|
+
phylum: raw.phylum,
|
|
126
|
+
order: raw.order,
|
|
127
|
+
family: raw.family,
|
|
128
|
+
genus: raw.genus,
|
|
129
|
+
species: raw.species,
|
|
130
|
+
taxonRank: raw.taxonRank,
|
|
131
|
+
decimalLatitude: raw.decimalLatitude,
|
|
132
|
+
decimalLongitude: raw.decimalLongitude,
|
|
133
|
+
coordinateUncertaintyInMeters: raw.coordinateUncertaintyInMeters,
|
|
134
|
+
continent: raw.continent,
|
|
135
|
+
country: raw.country,
|
|
136
|
+
countryCode: raw.countryCode,
|
|
137
|
+
stateProvince: raw.stateProvince,
|
|
138
|
+
locality: raw.locality,
|
|
139
|
+
publishingCountry: raw.publishingCountry,
|
|
140
|
+
eventDate: raw.eventDate,
|
|
141
|
+
year: raw.year,
|
|
142
|
+
month: raw.month,
|
|
143
|
+
day: raw.day,
|
|
144
|
+
basisOfRecord: raw.basisOfRecord,
|
|
145
|
+
institutionCode: raw.institutionCode,
|
|
146
|
+
collectionCode: raw.collectionCode,
|
|
147
|
+
catalogNumber: raw.catalogNumber,
|
|
148
|
+
recordedBy: raw.recordedBy,
|
|
149
|
+
identifiedBy: raw.identifiedBy,
|
|
150
|
+
individualCount: raw.individualCount,
|
|
151
|
+
sex: raw.sex,
|
|
152
|
+
lifeStage: raw.lifeStage,
|
|
153
|
+
issues: raw.issues?.length ? raw.issues : undefined,
|
|
154
|
+
media: raw.media?.length
|
|
155
|
+
? raw.media.map((m) => ({
|
|
156
|
+
type: m.type,
|
|
157
|
+
format: m.format,
|
|
158
|
+
identifier: m.identifier,
|
|
159
|
+
title: m.title,
|
|
160
|
+
license: m.license,
|
|
161
|
+
}))
|
|
162
|
+
: undefined,
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
format: (result) => {
|
|
166
|
+
const lines = [];
|
|
167
|
+
const canonical = result.canonicalName ?? result.scientificName ?? 'Unknown taxon';
|
|
168
|
+
const sci = result.scientificName && result.scientificName !== canonical
|
|
169
|
+
? ` [${result.scientificName}]`
|
|
170
|
+
: '';
|
|
171
|
+
lines.push(`## ${canonical}${sci}`);
|
|
172
|
+
if (result.key != null)
|
|
173
|
+
lines.push(`**Occurrence key:** ${result.key}`);
|
|
174
|
+
if (result.taxonKey != null)
|
|
175
|
+
lines.push(`**Taxon key:** ${result.taxonKey}`);
|
|
176
|
+
if (result.taxonRank)
|
|
177
|
+
lines.push(`**Rank:** ${result.taxonRank}`);
|
|
178
|
+
if (result.basisOfRecord)
|
|
179
|
+
lines.push(`**Basis of record:** ${result.basisOfRecord}`);
|
|
180
|
+
// Taxonomy
|
|
181
|
+
const taxParts = [];
|
|
182
|
+
if (result.kingdom)
|
|
183
|
+
taxParts.push(`Kingdom: ${result.kingdom}`);
|
|
184
|
+
if (result.phylum)
|
|
185
|
+
taxParts.push(`Phylum: ${result.phylum}`);
|
|
186
|
+
if (result.order)
|
|
187
|
+
taxParts.push(`Order: ${result.order}`);
|
|
188
|
+
if (result.family)
|
|
189
|
+
taxParts.push(`Family: ${result.family}`);
|
|
190
|
+
if (result.genus)
|
|
191
|
+
taxParts.push(`Genus: ${result.genus}`);
|
|
192
|
+
if (result.species)
|
|
193
|
+
taxParts.push(`Species: ${result.species}`);
|
|
194
|
+
if (taxParts.length > 0)
|
|
195
|
+
lines.push(`**Taxonomy:** ${taxParts.join(' › ')}`);
|
|
196
|
+
lines.push('');
|
|
197
|
+
if (result.eventDate) {
|
|
198
|
+
lines.push(`**Date:** ${result.eventDate}`);
|
|
199
|
+
}
|
|
200
|
+
else if (result.year == null) {
|
|
201
|
+
lines.push('**Date:** Not available');
|
|
202
|
+
}
|
|
203
|
+
if (result.year != null)
|
|
204
|
+
lines.push(`**Year:** ${result.year}`);
|
|
205
|
+
if (result.month != null)
|
|
206
|
+
lines.push(`**Month:** ${result.month}`);
|
|
207
|
+
if (result.day != null)
|
|
208
|
+
lines.push(`**Day:** ${result.day}`);
|
|
209
|
+
if (result.decimalLatitude != null && result.decimalLongitude != null) {
|
|
210
|
+
lines.push(`**Coordinates:** ${result.decimalLatitude}, ${result.decimalLongitude}${result.coordinateUncertaintyInMeters != null ? ` (±${result.coordinateUncertaintyInMeters}m)` : ''}`);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
lines.push('**Coordinates:** Not available');
|
|
214
|
+
}
|
|
215
|
+
const geo = [];
|
|
216
|
+
if (result.locality)
|
|
217
|
+
geo.push(result.locality);
|
|
218
|
+
if (result.stateProvince)
|
|
219
|
+
geo.push(result.stateProvince);
|
|
220
|
+
if (result.country)
|
|
221
|
+
geo.push(result.country);
|
|
222
|
+
if (result.continent)
|
|
223
|
+
geo.push(result.continent);
|
|
224
|
+
if (geo.length > 0)
|
|
225
|
+
lines.push(`**Location:** ${geo.join(', ')}${result.countryCode ? ` (${result.countryCode})` : ''}`);
|
|
226
|
+
else if (result.countryCode)
|
|
227
|
+
lines.push(`**Country code:** ${result.countryCode}`);
|
|
228
|
+
if (result.recordedBy)
|
|
229
|
+
lines.push(`**Recorded by:** ${result.recordedBy}`);
|
|
230
|
+
if (result.identifiedBy)
|
|
231
|
+
lines.push(`**Identified by:** ${result.identifiedBy}`);
|
|
232
|
+
if (result.individualCount != null)
|
|
233
|
+
lines.push(`**Individual count:** ${result.individualCount}`);
|
|
234
|
+
if (result.sex)
|
|
235
|
+
lines.push(`**Sex:** ${result.sex}`);
|
|
236
|
+
if (result.lifeStage)
|
|
237
|
+
lines.push(`**Life stage:** ${result.lifeStage}`);
|
|
238
|
+
lines.push('');
|
|
239
|
+
if (result.institutionCode)
|
|
240
|
+
lines.push(`**Institution:** ${result.institutionCode}`);
|
|
241
|
+
if (result.collectionCode)
|
|
242
|
+
lines.push(`**Collection:** ${result.collectionCode}`);
|
|
243
|
+
if (result.catalogNumber)
|
|
244
|
+
lines.push(`**Catalog number:** ${result.catalogNumber}`);
|
|
245
|
+
if (result.datasetKey)
|
|
246
|
+
lines.push(`**Dataset key:** ${result.datasetKey}`);
|
|
247
|
+
if (result.publishingCountry)
|
|
248
|
+
lines.push(`**Publishing country:** ${result.publishingCountry}`);
|
|
249
|
+
if (result.media?.length) {
|
|
250
|
+
lines.push(`\n**Media:** ${result.media.length} item(s)`);
|
|
251
|
+
for (const m of result.media) {
|
|
252
|
+
const mediaType = m.type ?? 'Media';
|
|
253
|
+
const mediaTitle = m.title ? ` — ${m.title}` : '';
|
|
254
|
+
const mediaFmt = m.format ? ` (${m.format})` : '';
|
|
255
|
+
const mediaLicense = m.license ? ` [${m.license}]` : '';
|
|
256
|
+
lines.push(` - ${mediaType}${mediaTitle}${mediaFmt}${mediaLicense}${m.identifier ? `: ${m.identifier}` : ''}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (result.issues?.length)
|
|
260
|
+
lines.push(`\n**Quality issues:** ${result.issues.join(', ')}`);
|
|
261
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
262
|
+
},
|
|
263
|
+
});
|
|
264
|
+
//# sourceMappingURL=gbif-get-occurrence.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gbif-get-occurrence.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-get-occurrence.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGjE,MA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AE,CAAC;gBACxD,KAAK,CAAC,IAAI,CACR,OAAO,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CACpG,CAAC;YACJ,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,yBAAyB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC3F,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,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview List direct children of a backbone taxon.
|
|
3
|
+
* @module mcp-server/tools/definitions/gbif-get-species-children
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
export declare const gbifGetSpeciesChildren: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
7
|
+
taxonKey: z.ZodNumber;
|
|
8
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
9
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
children: z.ZodArray<z.ZodObject<{
|
|
12
|
+
key: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
scientificName: z.ZodOptional<z.ZodString>;
|
|
14
|
+
canonicalName: z.ZodOptional<z.ZodString>;
|
|
15
|
+
rank: z.ZodOptional<z.ZodString>;
|
|
16
|
+
taxonomicStatus: z.ZodOptional<z.ZodString>;
|
|
17
|
+
vernacularName: z.ZodOptional<z.ZodString>;
|
|
18
|
+
numOccurrences: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
numDescendants: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
offset: z.ZodNumber;
|
|
22
|
+
limit: z.ZodNumber;
|
|
23
|
+
endOfRecords: z.ZodBoolean;
|
|
24
|
+
}, z.core.$strip>, undefined>;
|
|
25
|
+
//# sourceMappingURL=gbif-get-species-children.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gbif-get-species-children.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-get-species-children.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAGjD,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;6BA2FjC,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview List direct children of a backbone taxon.
|
|
3
|
+
* @module mcp-server/tools/definitions/gbif-get-species-children
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { getGbifService } from '../../../services/gbif/gbif-service.js';
|
|
7
|
+
export const gbifGetSpeciesChildren = tool('gbif_get_species_children', {
|
|
8
|
+
title: 'Get Species Children',
|
|
9
|
+
description: 'List direct children of a backbone taxon — genera within a family, species within a genus, ' +
|
|
10
|
+
'subspecies within a species. Paginated. Use gbif_match_species to get the taxonKey first, ' +
|
|
11
|
+
'then iterate with offset for large groups.',
|
|
12
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
13
|
+
input: z.object({
|
|
14
|
+
taxonKey: z
|
|
15
|
+
.number()
|
|
16
|
+
.describe('GBIF backbone taxon key from gbif_match_species or another taxonomy tool.'),
|
|
17
|
+
limit: z
|
|
18
|
+
.number()
|
|
19
|
+
.min(1)
|
|
20
|
+
.max(1000)
|
|
21
|
+
.default(20)
|
|
22
|
+
.describe('Number of children to return (default 20, max 1000).'),
|
|
23
|
+
offset: z.number().min(0).default(0).describe('Pagination offset.'),
|
|
24
|
+
}),
|
|
25
|
+
output: z.object({
|
|
26
|
+
children: z
|
|
27
|
+
.array(z
|
|
28
|
+
.object({
|
|
29
|
+
key: z.number().optional().describe('GBIF backbone taxon key.'),
|
|
30
|
+
scientificName: z.string().optional().describe('Full scientific name with authorship.'),
|
|
31
|
+
canonicalName: z.string().optional().describe('Scientific name without authorship.'),
|
|
32
|
+
rank: z.string().optional().describe('Taxonomic rank.'),
|
|
33
|
+
taxonomicStatus: z.string().optional().describe('ACCEPTED, SYNONYM, DOUBTFUL, etc.'),
|
|
34
|
+
vernacularName: z.string().optional().describe('Common name when available.'),
|
|
35
|
+
numOccurrences: z.number().optional().describe('Occurrence record count.'),
|
|
36
|
+
numDescendants: z.number().optional().describe('Count of child taxa under this node.'),
|
|
37
|
+
})
|
|
38
|
+
.describe('A direct child taxon with key, name, rank, and status.'))
|
|
39
|
+
.describe('Direct child taxa.'),
|
|
40
|
+
offset: z.number().describe('Current pagination offset.'),
|
|
41
|
+
limit: z.number().describe('Records returned in this page.'),
|
|
42
|
+
endOfRecords: z.boolean().describe('True when there are no more results after this page.'),
|
|
43
|
+
}),
|
|
44
|
+
async handler(input, ctx) {
|
|
45
|
+
ctx.log.info('Fetching species children', { taxonKey: input.taxonKey });
|
|
46
|
+
const raw = await getGbifService().getSpeciesChildren(input.taxonKey, { limit: input.limit, offset: input.offset }, ctx);
|
|
47
|
+
const children = (raw.results ?? []).map((r) => ({
|
|
48
|
+
key: r.key,
|
|
49
|
+
scientificName: r.scientificName,
|
|
50
|
+
canonicalName: r.canonicalName,
|
|
51
|
+
rank: r.rank,
|
|
52
|
+
taxonomicStatus: r.taxonomicStatus,
|
|
53
|
+
vernacularName: r.vernacularName,
|
|
54
|
+
numOccurrences: r.numOccurrences,
|
|
55
|
+
numDescendants: r.numDescendants,
|
|
56
|
+
}));
|
|
57
|
+
return {
|
|
58
|
+
children,
|
|
59
|
+
offset: raw.offset ?? input.offset,
|
|
60
|
+
limit: raw.limit ?? input.limit,
|
|
61
|
+
endOfRecords: raw.endOfRecords ?? true,
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
format: (result) => {
|
|
65
|
+
const lines = [
|
|
66
|
+
`**Showing:** ${result.children.length} | **Limit:** ${result.limit} | **End of records:** ${result.endOfRecords} (offset ${result.offset})`,
|
|
67
|
+
];
|
|
68
|
+
for (const child of result.children) {
|
|
69
|
+
const name = child.canonicalName ?? 'Unknown';
|
|
70
|
+
const sci = child.scientificName && child.scientificName !== name ? ` [${child.scientificName}]` : '';
|
|
71
|
+
lines.push(`\n- **${name}**${sci}`);
|
|
72
|
+
if (child.key != null)
|
|
73
|
+
lines.push(` Key: ${child.key}`);
|
|
74
|
+
if (child.rank)
|
|
75
|
+
lines.push(` Rank: ${child.rank}`);
|
|
76
|
+
if (child.taxonomicStatus)
|
|
77
|
+
lines.push(` Status: ${child.taxonomicStatus}`);
|
|
78
|
+
if (child.vernacularName)
|
|
79
|
+
lines.push(` Common name: ${child.vernacularName}`);
|
|
80
|
+
if (child.numOccurrences != null)
|
|
81
|
+
lines.push(` Occurrences: ${child.numOccurrences}`);
|
|
82
|
+
if (child.numDescendants != null)
|
|
83
|
+
lines.push(` Descendants: ${child.numDescendants}`);
|
|
84
|
+
}
|
|
85
|
+
if (!result.endOfRecords) {
|
|
86
|
+
lines.push(`\n*More results available — use offset ${result.offset + result.limit} to continue.*`);
|
|
87
|
+
}
|
|
88
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=gbif-get-species-children.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gbif-get-species-children.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-get-species-children.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,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I,CAAC,WAAW,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YACpD,IAAI,KAAK,CAAC,eAAe;gBAAE,KAAK,CAAC,IAAI,CAAC,aAAa,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;YAC5E,IAAI,KAAK,CAAC,cAAc;gBAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;YAC/E,IAAI,KAAK,CAAC,cAAc,IAAI,IAAI;gBAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;YACvF,IAAI,KAAK,CAAC,cAAc,IAAI,IAAI;gBAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CACR,0CAA0C,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,gBAAgB,CACvF,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,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Return the full parent chain for a GBIF taxon.
|
|
3
|
+
* @module mcp-server/tools/definitions/gbif-get-species-classification
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const gbifGetSpeciesClassification: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
taxonKey: z.ZodNumber;
|
|
9
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
10
|
+
classification: z.ZodArray<z.ZodObject<{
|
|
11
|
+
key: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
rank: z.ZodOptional<z.ZodString>;
|
|
13
|
+
name: z.ZodOptional<z.ZodString>;
|
|
14
|
+
scientificName: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
}, z.core.$strip>, readonly [{
|
|
17
|
+
readonly reason: "not_found";
|
|
18
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
19
|
+
readonly when: "The taxonKey does not exist in the GBIF backbone.";
|
|
20
|
+
readonly recovery: "Use gbif_match_species to resolve a name to a valid backbone taxon key.";
|
|
21
|
+
}]>;
|
|
22
|
+
//# sourceMappingURL=gbif-get-species-classification.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gbif-get-species-classification.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-get-species-classification.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAY,MAAM,+BAA+B,CAAC;AAG3E,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;GAyFvC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Return the full parent chain for a GBIF taxon.
|
|
3
|
+
* @module mcp-server/tools/definitions/gbif-get-species-classification
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode, McpError } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getGbifService } from '../../../services/gbif/gbif-service.js';
|
|
8
|
+
export const gbifGetSpeciesClassification = tool('gbif_get_species_classification', {
|
|
9
|
+
title: 'Get Species Classification',
|
|
10
|
+
description: 'Return the complete parent chain for a taxon — from kingdom (or domain) down to the taxon ' +
|
|
11
|
+
'itself — as an ordered array. Each entry has its rank, canonical name, and taxon key. ' +
|
|
12
|
+
'The array is returned root-first (kingdom → phylum → class → … → parent of given taxon). ' +
|
|
13
|
+
'Useful for building taxonomic trees or understanding placement without navigating the backbone level-by-level.',
|
|
14
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
15
|
+
input: z.object({
|
|
16
|
+
taxonKey: z
|
|
17
|
+
.number()
|
|
18
|
+
.describe('GBIF backbone taxon key from gbif_match_species or another taxonomy tool.'),
|
|
19
|
+
}),
|
|
20
|
+
output: z.object({
|
|
21
|
+
classification: z
|
|
22
|
+
.array(z
|
|
23
|
+
.object({
|
|
24
|
+
key: z.number().optional().describe('Backbone taxon key for this rank.'),
|
|
25
|
+
rank: z.string().optional().describe('Taxonomic rank (KINGDOM, PHYLUM, CLASS, etc.).'),
|
|
26
|
+
name: z.string().optional().describe('Canonical name at this rank.'),
|
|
27
|
+
scientificName: z.string().optional().describe('Full scientific name with authorship.'),
|
|
28
|
+
})
|
|
29
|
+
.describe('A single rank entry in the classification chain.'))
|
|
30
|
+
.describe('Classification chain ordered from root (kingdom) to the immediate parent of the queried taxon.'),
|
|
31
|
+
}),
|
|
32
|
+
errors: [
|
|
33
|
+
{
|
|
34
|
+
reason: 'not_found',
|
|
35
|
+
code: JsonRpcErrorCode.NotFound,
|
|
36
|
+
when: 'The taxonKey does not exist in the GBIF backbone.',
|
|
37
|
+
recovery: 'Use gbif_match_species to resolve a name to a valid backbone taxon key.',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
async handler(input, ctx) {
|
|
41
|
+
ctx.log.info('Fetching species classification', { taxonKey: input.taxonKey });
|
|
42
|
+
const raw = await getGbifService().getSpeciesParents(input.taxonKey, ctx);
|
|
43
|
+
if (!Array.isArray(raw)) {
|
|
44
|
+
throw ctx.fail('not_found', `Taxon key ${input.taxonKey} not found in the GBIF backbone.`, {
|
|
45
|
+
...ctx.recoveryFor('not_found'),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// GBIF /species/{key}/parents returns [] for both nonexistent keys and kingdom-level taxa.
|
|
49
|
+
// When empty, verify the taxon exists to distinguish the two cases.
|
|
50
|
+
if (raw.length === 0) {
|
|
51
|
+
try {
|
|
52
|
+
await getGbifService().getSpecies(input.taxonKey, ctx);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
if (err instanceof McpError && err.code === -32001) {
|
|
56
|
+
throw ctx.fail('not_found', `Taxon key ${input.taxonKey} not found in the GBIF backbone.`, { ...ctx.recoveryFor('not_found') });
|
|
57
|
+
}
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const classification = raw.map((node) => ({
|
|
62
|
+
key: node.key,
|
|
63
|
+
rank: node.rank,
|
|
64
|
+
name: node.canonicalName,
|
|
65
|
+
scientificName: node.scientificName,
|
|
66
|
+
}));
|
|
67
|
+
return { classification };
|
|
68
|
+
},
|
|
69
|
+
format: (result) => {
|
|
70
|
+
const lines = [`**Classification chain** (${result.classification.length} ranks):\n`];
|
|
71
|
+
for (const [i, node] of result.classification.entries()) {
|
|
72
|
+
const indent = ' '.repeat(i);
|
|
73
|
+
const name = node.name ?? 'Unknown';
|
|
74
|
+
const rank = node.rank ?? '';
|
|
75
|
+
const key = node.key != null ? ` (key: ${node.key})` : '';
|
|
76
|
+
const sci = node.scientificName && node.scientificName !== name ? ` [${node.scientificName}]` : '';
|
|
77
|
+
lines.push(`${indent}${rank}: **${name}**${sci}${key}`);
|
|
78
|
+
}
|
|
79
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=gbif-get-species-classification.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gbif-get-species-classification.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-get-species-classification.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA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/definitions/gbif-get-species
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const gbifGetSpecies: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
taxonKey: z.ZodNumber;
|
|
9
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
10
|
+
key: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
scientificName: z.ZodOptional<z.ZodString>;
|
|
12
|
+
canonicalName: z.ZodOptional<z.ZodString>;
|
|
13
|
+
authorship: z.ZodOptional<z.ZodString>;
|
|
14
|
+
vernacularName: z.ZodOptional<z.ZodString>;
|
|
15
|
+
rank: z.ZodOptional<z.ZodString>;
|
|
16
|
+
taxonomicStatus: z.ZodOptional<z.ZodString>;
|
|
17
|
+
numDescendants: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
numOccurrences: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
publishedIn: z.ZodOptional<z.ZodString>;
|
|
20
|
+
extinct: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
kingdom: z.ZodOptional<z.ZodString>;
|
|
22
|
+
phylum: z.ZodOptional<z.ZodString>;
|
|
23
|
+
class: z.ZodOptional<z.ZodString>;
|
|
24
|
+
order: z.ZodOptional<z.ZodString>;
|
|
25
|
+
family: z.ZodOptional<z.ZodString>;
|
|
26
|
+
genus: z.ZodOptional<z.ZodString>;
|
|
27
|
+
species: z.ZodOptional<z.ZodString>;
|
|
28
|
+
kingdomKey: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
phylumKey: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
classKey: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
orderKey: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
familyKey: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
genusKey: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
speciesKey: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
acceptedKey: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
accepted: z.ZodOptional<z.ZodString>;
|
|
37
|
+
parentKey: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
parent: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>, readonly [{
|
|
40
|
+
readonly reason: "not_found";
|
|
41
|
+
readonly code: JsonRpcErrorCode.NotFound;
|
|
42
|
+
readonly when: "The taxonKey does not exist in the GBIF backbone.";
|
|
43
|
+
readonly recovery: "Use gbif_match_species to resolve a name to a valid backbone key, or gbif_search_species to browse.";
|
|
44
|
+
}]>;
|
|
45
|
+
//# sourceMappingURL=gbif-get-species.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gbif-get-species.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-get-species.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAY,MAAM,+BAA+B,CAAC;AAI3E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4LzB,CAAC"}
|