@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.
Files changed (82) hide show
  1. package/CLAUDE.md +393 -0
  2. package/Dockerfile +99 -0
  3. package/LICENSE +201 -0
  4. package/README.md +367 -0
  5. package/dist/config/server-config.d.ts +14 -0
  6. package/dist/config/server-config.d.ts.map +1 -0
  7. package/dist/config/server-config.js +27 -0
  8. package/dist/config/server-config.js.map +1 -0
  9. package/dist/index.d.ts +7 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +53 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/mcp-server/resources/definitions/gbif-dataset.resource.d.ts +20 -0
  14. package/dist/mcp-server/resources/definitions/gbif-dataset.resource.d.ts.map +1 -0
  15. package/dist/mcp-server/resources/definitions/gbif-dataset.resource.js +50 -0
  16. package/dist/mcp-server/resources/definitions/gbif-dataset.resource.js.map +1 -0
  17. package/dist/mcp-server/resources/definitions/gbif-species.resource.d.ts +27 -0
  18. package/dist/mcp-server/resources/definitions/gbif-species.resource.d.ts.map +1 -0
  19. package/dist/mcp-server/resources/definitions/gbif-species.resource.js +67 -0
  20. package/dist/mcp-server/resources/definitions/gbif-species.resource.js.map +1 -0
  21. package/dist/mcp-server/tools/definitions/gbif-count-occurrences.tool.d.ts +15 -0
  22. package/dist/mcp-server/tools/definitions/gbif-count-occurrences.tool.d.ts.map +1 -0
  23. package/dist/mcp-server/tools/definitions/gbif-count-occurrences.tool.js +42 -0
  24. package/dist/mcp-server/tools/definitions/gbif-count-occurrences.tool.js.map +1 -0
  25. package/dist/mcp-server/tools/definitions/gbif-get-dataset.tool.d.ts +33 -0
  26. package/dist/mcp-server/tools/definitions/gbif-get-dataset.tool.d.ts.map +1 -0
  27. package/dist/mcp-server/tools/definitions/gbif-get-dataset.tool.js +143 -0
  28. package/dist/mcp-server/tools/definitions/gbif-get-dataset.tool.js.map +1 -0
  29. package/dist/mcp-server/tools/definitions/gbif-get-occurrence.tool.d.ts +58 -0
  30. package/dist/mcp-server/tools/definitions/gbif-get-occurrence.tool.d.ts.map +1 -0
  31. package/dist/mcp-server/tools/definitions/gbif-get-occurrence.tool.js +264 -0
  32. package/dist/mcp-server/tools/definitions/gbif-get-occurrence.tool.js.map +1 -0
  33. package/dist/mcp-server/tools/definitions/gbif-get-species-children.tool.d.ts +25 -0
  34. package/dist/mcp-server/tools/definitions/gbif-get-species-children.tool.d.ts.map +1 -0
  35. package/dist/mcp-server/tools/definitions/gbif-get-species-children.tool.js +91 -0
  36. package/dist/mcp-server/tools/definitions/gbif-get-species-children.tool.js.map +1 -0
  37. package/dist/mcp-server/tools/definitions/gbif-get-species-classification.tool.d.ts +22 -0
  38. package/dist/mcp-server/tools/definitions/gbif-get-species-classification.tool.d.ts.map +1 -0
  39. package/dist/mcp-server/tools/definitions/gbif-get-species-classification.tool.js +82 -0
  40. package/dist/mcp-server/tools/definitions/gbif-get-species-classification.tool.js.map +1 -0
  41. package/dist/mcp-server/tools/definitions/gbif-get-species.tool.d.ts +45 -0
  42. package/dist/mcp-server/tools/definitions/gbif-get-species.tool.d.ts.map +1 -0
  43. package/dist/mcp-server/tools/definitions/gbif-get-species.tool.js +182 -0
  44. package/dist/mcp-server/tools/definitions/gbif-get-species.tool.js.map +1 -0
  45. package/dist/mcp-server/tools/definitions/gbif-match-species.tool.d.ts +49 -0
  46. package/dist/mcp-server/tools/definitions/gbif-match-species.tool.d.ts.map +1 -0
  47. package/dist/mcp-server/tools/definitions/gbif-match-species.tool.js +148 -0
  48. package/dist/mcp-server/tools/definitions/gbif-match-species.tool.js.map +1 -0
  49. package/dist/mcp-server/tools/definitions/gbif-occurrence-facets.tool.d.ts +45 -0
  50. package/dist/mcp-server/tools/definitions/gbif-occurrence-facets.tool.d.ts.map +1 -0
  51. package/dist/mcp-server/tools/definitions/gbif-occurrence-facets.tool.js +116 -0
  52. package/dist/mcp-server/tools/definitions/gbif-occurrence-facets.tool.js.map +1 -0
  53. package/dist/mcp-server/tools/definitions/gbif-search-datasets.tool.d.ts +34 -0
  54. package/dist/mcp-server/tools/definitions/gbif-search-datasets.tool.d.ts.map +1 -0
  55. package/dist/mcp-server/tools/definitions/gbif-search-datasets.tool.js +112 -0
  56. package/dist/mcp-server/tools/definitions/gbif-search-datasets.tool.js.map +1 -0
  57. package/dist/mcp-server/tools/definitions/gbif-search-occurrences.tool.d.ts +66 -0
  58. package/dist/mcp-server/tools/definitions/gbif-search-occurrences.tool.d.ts.map +1 -0
  59. package/dist/mcp-server/tools/definitions/gbif-search-occurrences.tool.js +278 -0
  60. package/dist/mcp-server/tools/definitions/gbif-search-occurrences.tool.js.map +1 -0
  61. package/dist/mcp-server/tools/definitions/gbif-search-publishers.tool.d.ts +23 -0
  62. package/dist/mcp-server/tools/definitions/gbif-search-publishers.tool.d.ts.map +1 -0
  63. package/dist/mcp-server/tools/definitions/gbif-search-publishers.tool.js +90 -0
  64. package/dist/mcp-server/tools/definitions/gbif-search-publishers.tool.js.map +1 -0
  65. package/dist/mcp-server/tools/definitions/gbif-search-species.tool.d.ts +48 -0
  66. package/dist/mcp-server/tools/definitions/gbif-search-species.tool.d.ts.map +1 -0
  67. package/dist/mcp-server/tools/definitions/gbif-search-species.tool.js +151 -0
  68. package/dist/mcp-server/tools/definitions/gbif-search-species.tool.js.map +1 -0
  69. package/dist/mcp-server/tools/utils.d.ts +7 -0
  70. package/dist/mcp-server/tools/utils.d.ts.map +1 -0
  71. package/dist/mcp-server/tools/utils.js +20 -0
  72. package/dist/mcp-server/tools/utils.js.map +1 -0
  73. package/dist/services/gbif/gbif-service.d.ts +99 -0
  74. package/dist/services/gbif/gbif-service.d.ts.map +1 -0
  75. package/dist/services/gbif/gbif-service.js +255 -0
  76. package/dist/services/gbif/gbif-service.js.map +1 -0
  77. package/dist/services/gbif/types.d.ts +254 -0
  78. package/dist/services/gbif/types.d.ts.map +1 -0
  79. package/dist/services/gbif/types.js +6 -0
  80. package/dist/services/gbif/types.js.map +1 -0
  81. package/package.json +91 -0
  82. package/server.json +117 -0
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @fileoverview Fetch a taxon record by GBIF backbone key.
3
+ * @module mcp-server/tools/definitions/gbif-get-species
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 gbifGetSpecies = tool('gbif_get_species', {
9
+ title: 'Get Species Record',
10
+ description: 'Fetch a single backbone taxon by its GBIF taxon key. Returns full classification, authorship, ' +
11
+ 'taxonomic status, vernacular name, descendant count, and publication reference. ' +
12
+ 'Use after gbif_match_species when you need the complete record rather than the match summary. ' +
13
+ 'When taxonomicStatus is SYNONYM, acceptedKey and accepted fields identify the accepted taxon. ' +
14
+ 'The extinct field is absent (not false) on most records — only present on explicitly flagged taxa.',
15
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
16
+ input: z.object({
17
+ taxonKey: z
18
+ .number()
19
+ .describe('GBIF backbone taxon key from gbif_match_species or another taxonomy tool.'),
20
+ }),
21
+ output: z.object({
22
+ key: z.number().optional().describe('GBIF backbone taxon key.'),
23
+ scientificName: z.string().optional().describe('Full scientific name with authorship.'),
24
+ canonicalName: z.string().optional().describe('Scientific name without authorship.'),
25
+ authorship: z.string().optional().describe('Taxonomic authorship of the name.'),
26
+ vernacularName: z.string().optional().describe('English common name when available.'),
27
+ rank: z.string().optional().describe('Taxonomic rank (SPECIES, GENUS, FAMILY, etc.).'),
28
+ taxonomicStatus: z
29
+ .string()
30
+ .optional()
31
+ .describe('ACCEPTED, SYNONYM, DOUBTFUL, etc. SYNONYM means acceptedKey/accepted are populated.'),
32
+ numDescendants: z
33
+ .number()
34
+ .optional()
35
+ .describe('Count of child taxa in the backbone under this taxon.'),
36
+ numOccurrences: z.number().optional().describe('Occurrence record count in GBIF.'),
37
+ publishedIn: z.string().optional().describe('Original description citation when available.'),
38
+ extinct: z
39
+ .boolean()
40
+ .optional()
41
+ .describe('True when the taxon is explicitly flagged as extinct. Absent on most records.'),
42
+ kingdom: z.string().optional().describe('Kingdom classification.'),
43
+ phylum: z.string().optional().describe('Phylum classification.'),
44
+ class: z.string().optional().describe('Class classification.'),
45
+ order: z.string().optional().describe('Order classification.'),
46
+ family: z.string().optional().describe('Family classification.'),
47
+ genus: z.string().optional().describe('Genus classification.'),
48
+ species: z.string().optional().describe('Species canonical name.'),
49
+ kingdomKey: z.number().optional().describe('Taxon key for the kingdom.'),
50
+ phylumKey: z.number().optional().describe('Taxon key for the phylum.'),
51
+ classKey: z.number().optional().describe('Taxon key for the class.'),
52
+ orderKey: z.number().optional().describe('Taxon key for the order.'),
53
+ familyKey: z.number().optional().describe('Taxon key for the family.'),
54
+ genusKey: z.number().optional().describe('Taxon key for the genus.'),
55
+ speciesKey: z.number().optional().describe('Taxon key for the species.'),
56
+ acceptedKey: z
57
+ .number()
58
+ .optional()
59
+ .describe('Backbone key of the accepted taxon when this record is a synonym.'),
60
+ accepted: z
61
+ .string()
62
+ .optional()
63
+ .describe('Scientific name of the accepted taxon when this record is a synonym.'),
64
+ parentKey: z.number().optional().describe('Taxon key of the immediate parent.'),
65
+ parent: z.string().optional().describe('Name of the immediate parent taxon.'),
66
+ }),
67
+ errors: [
68
+ {
69
+ reason: 'not_found',
70
+ code: JsonRpcErrorCode.NotFound,
71
+ when: 'The taxonKey does not exist in the GBIF backbone.',
72
+ recovery: 'Use gbif_match_species to resolve a name to a valid backbone key, or gbif_search_species to browse.',
73
+ },
74
+ ],
75
+ async handler(input, ctx) {
76
+ ctx.log.info('Fetching species record', { taxonKey: input.taxonKey });
77
+ let raw;
78
+ try {
79
+ raw = await getGbifService().getSpecies(input.taxonKey, ctx);
80
+ }
81
+ catch (err) {
82
+ if (err instanceof McpError && err.code === -32001) {
83
+ throw ctx.fail('not_found', `Taxon key ${input.taxonKey} not found in the GBIF backbone.`, {
84
+ ...ctx.recoveryFor('not_found'),
85
+ });
86
+ }
87
+ throw err;
88
+ }
89
+ if (!raw.key) {
90
+ throw ctx.fail('not_found', `Taxon key ${input.taxonKey} not found in the GBIF backbone.`, {
91
+ ...ctx.recoveryFor('not_found'),
92
+ });
93
+ }
94
+ return {
95
+ key: raw.key,
96
+ scientificName: raw.scientificName,
97
+ canonicalName: raw.canonicalName,
98
+ authorship: raw.authorship,
99
+ vernacularName: raw.vernacularName,
100
+ rank: raw.rank,
101
+ taxonomicStatus: raw.taxonomicStatus,
102
+ numDescendants: raw.numDescendants,
103
+ numOccurrences: raw.numOccurrences,
104
+ publishedIn: raw.publishedIn,
105
+ kingdom: raw.kingdom,
106
+ phylum: raw.phylum,
107
+ // GBIF API uses 'clazz' to avoid reserved word; we normalize to 'class'
108
+ class: raw.clazz,
109
+ order: raw.order,
110
+ family: raw.family,
111
+ genus: raw.genus,
112
+ species: raw.species,
113
+ kingdomKey: raw.kingdomKey,
114
+ phylumKey: raw.phylumKey,
115
+ classKey: raw.classKey,
116
+ orderKey: raw.orderKey,
117
+ familyKey: raw.familyKey,
118
+ genusKey: raw.genusKey,
119
+ speciesKey: raw.speciesKey,
120
+ acceptedKey: raw.acceptedKey,
121
+ accepted: raw.accepted,
122
+ parentKey: raw.parentKey,
123
+ parent: raw.parent,
124
+ ...(typeof raw.extinct === 'boolean' && { extinct: raw.extinct }),
125
+ };
126
+ },
127
+ format: (result) => {
128
+ const lines = [];
129
+ if (result.canonicalName || result.scientificName) {
130
+ lines.push(`## ${result.canonicalName ?? result.scientificName}`);
131
+ }
132
+ if (result.key != null)
133
+ lines.push(`**Taxon key:** ${result.key}`);
134
+ if (result.scientificName)
135
+ lines.push(`**Scientific name:** ${result.scientificName}`);
136
+ if (result.authorship)
137
+ lines.push(`**Authorship:** ${result.authorship}`);
138
+ if (result.vernacularName)
139
+ lines.push(`**Common name:** ${result.vernacularName}`);
140
+ if (result.rank)
141
+ lines.push(`**Rank:** ${result.rank}`);
142
+ if (result.taxonomicStatus)
143
+ lines.push(`**Status:** ${result.taxonomicStatus}`);
144
+ if (result.accepted)
145
+ lines.push(`**Accepted name:** ${result.accepted}${result.acceptedKey != null ? ` (key: ${result.acceptedKey})` : ''}`);
146
+ else if (result.acceptedKey != null)
147
+ lines.push(`**Accepted key:** ${result.acceptedKey}`);
148
+ if (result.parent)
149
+ lines.push(`**Parent:** ${result.parent}${result.parentKey != null ? ` (key: ${result.parentKey})` : ''}`);
150
+ else if (result.parentKey != null)
151
+ lines.push(`**Parent key:** ${result.parentKey}`);
152
+ if (result.numDescendants != null)
153
+ lines.push(`**Descendants:** ${result.numDescendants}`);
154
+ if (result.numOccurrences != null)
155
+ lines.push(`**Occurrences:** ${result.numOccurrences}`);
156
+ if (typeof result.extinct === 'boolean') {
157
+ lines.push(`**Extinct:** ${result.extinct ? 'Yes' : 'No'}`);
158
+ }
159
+ if (result.publishedIn)
160
+ lines.push(`**Published in:** ${result.publishedIn}`);
161
+ const classificationParts = [];
162
+ if (result.kingdom)
163
+ classificationParts.push(`Kingdom: ${result.kingdom}${result.kingdomKey ? ` (${result.kingdomKey})` : ''}`);
164
+ if (result.phylum)
165
+ classificationParts.push(`Phylum: ${result.phylum}${result.phylumKey ? ` (${result.phylumKey})` : ''}`);
166
+ if (result.class)
167
+ classificationParts.push(`Class: ${result.class}${result.classKey ? ` (${result.classKey})` : ''}`);
168
+ if (result.order)
169
+ classificationParts.push(`Order: ${result.order}${result.orderKey ? ` (${result.orderKey})` : ''}`);
170
+ if (result.family)
171
+ classificationParts.push(`Family: ${result.family}${result.familyKey ? ` (${result.familyKey})` : ''}`);
172
+ if (result.genus)
173
+ classificationParts.push(`Genus: ${result.genus}${result.genusKey ? ` (${result.genusKey})` : ''}`);
174
+ if (result.species)
175
+ classificationParts.push(`Species: ${result.species}${result.speciesKey ? ` (${result.speciesKey})` : ''}`);
176
+ if (classificationParts.length > 0) {
177
+ lines.push(`**Classification:** ${classificationParts.join(' › ')}`);
178
+ }
179
+ return [{ type: 'text', text: lines.join('\n') }];
180
+ },
181
+ });
182
+ //# sourceMappingURL=gbif-get-species.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gbif-get-species.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-get-species.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,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,EAAE;IACrD,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EACT,gGAAgG;QAChG,kFAAkF;QAClF,gGAAgG;QAChG,gGAAgG;QAChG,oGAAoG;IACtG,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;IAC/E,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,QAAQ,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,CAAC,2EAA2E,CAAC;KACzF,CAAC;IACF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;QAC/D,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;QACvF,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;QACpF,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;QAC/E,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CAAC,CAAC,KAAK,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1E,CAAC;QACJ,IAAI,MAAM,CAAC,MAAM;YACf,mBAAmB,CAAC,IAAI,CACtB,WAAW,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9E,CAAC;QACJ,IAAI,MAAM,CAAC,KAAK;YACd,mBAAmB,CAAC,IAAI,CACtB,UAAU,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1E,CAAC;QACJ,IAAI,MAAM,CAAC,OAAO;YAChB,mBAAmB,CAAC,IAAI,CACtB,YAAY,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAClF,CAAC;QACJ,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,KAAK,CAAC,IAAI,CAAC,uBAAuB,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvE,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,49 @@
1
+ /**
2
+ * @fileoverview Match a species name against the GBIF backbone taxonomy.
3
+ * @module mcp-server/tools/definitions/gbif-match-species
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ export declare const gbifMatchSpecies: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
8
+ name: z.ZodString;
9
+ strict: z.ZodDefault<z.ZodBoolean>;
10
+ kingdom: z.ZodOptional<z.ZodString>;
11
+ rank: z.ZodOptional<z.ZodEnum<{
12
+ KINGDOM: "KINGDOM";
13
+ PHYLUM: "PHYLUM";
14
+ CLASS: "CLASS";
15
+ ORDER: "ORDER";
16
+ FAMILY: "FAMILY";
17
+ GENUS: "GENUS";
18
+ SPECIES: "SPECIES";
19
+ SUBSPECIES: "SUBSPECIES";
20
+ }>>;
21
+ }, z.core.$strip>, z.ZodObject<{
22
+ taxonKey: z.ZodOptional<z.ZodNumber>;
23
+ scientificName: z.ZodOptional<z.ZodString>;
24
+ canonicalName: z.ZodOptional<z.ZodString>;
25
+ rank: z.ZodOptional<z.ZodString>;
26
+ status: z.ZodOptional<z.ZodString>;
27
+ confidence: z.ZodOptional<z.ZodNumber>;
28
+ matchType: z.ZodOptional<z.ZodString>;
29
+ kingdom: z.ZodOptional<z.ZodString>;
30
+ phylum: z.ZodOptional<z.ZodString>;
31
+ class: z.ZodOptional<z.ZodString>;
32
+ order: z.ZodOptional<z.ZodString>;
33
+ family: z.ZodOptional<z.ZodString>;
34
+ genus: z.ZodOptional<z.ZodString>;
35
+ species: z.ZodOptional<z.ZodString>;
36
+ kingdomKey: z.ZodOptional<z.ZodNumber>;
37
+ phylumKey: z.ZodOptional<z.ZodNumber>;
38
+ classKey: z.ZodOptional<z.ZodNumber>;
39
+ orderKey: z.ZodOptional<z.ZodNumber>;
40
+ familyKey: z.ZodOptional<z.ZodNumber>;
41
+ genusKey: z.ZodOptional<z.ZodNumber>;
42
+ speciesKey: z.ZodOptional<z.ZodNumber>;
43
+ }, z.core.$strip>, readonly [{
44
+ readonly reason: "no_match";
45
+ readonly code: JsonRpcErrorCode.NotFound;
46
+ readonly when: "matchType is NONE — no candidate met the match threshold.";
47
+ readonly recovery: "Try a broader name, remove the strict flag, or search with gbif_search_species instead.";
48
+ }]>;
49
+ //# sourceMappingURL=gbif-match-species.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gbif-match-species.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-match-species.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsK3B,CAAC"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * @fileoverview Match a species name against the GBIF backbone taxonomy.
3
+ * @module mcp-server/tools/definitions/gbif-match-species
4
+ */
5
+ import { tool, z } from '@cyanheads/mcp-ts-core';
6
+ import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
7
+ import { getGbifService } from '../../../services/gbif/gbif-service.js';
8
+ export const gbifMatchSpecies = tool('gbif_match_species', {
9
+ title: 'Match Species Name',
10
+ description: 'Match a scientific name against the GBIF backbone taxonomy. ' +
11
+ 'Returns the best-matching taxon with full classification and a confidence score (0–100). ' +
12
+ 'This is the mandatory first step for any GBIF workflow — it resolves synonyms and returns ' +
13
+ 'the backbone taxonKey required by gbif_search_occurrences, gbif_count_occurrences, and ' +
14
+ 'gbif_occurrence_facets. Below confidence 80, the match should be reviewed. ' +
15
+ 'matchType NONE means no usable match was found — try removing the strict flag or broadening the name.',
16
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
17
+ input: z.object({
18
+ name: z
19
+ .string()
20
+ .describe('Scientific name to match. Examples: "Parus major", "Agaricus bisporus", "Homo sapiens". Fuzzy matching handles minor spelling variations. Common names are not supported — use gbif_search_species for vernacular name searches.'),
21
+ strict: z
22
+ .boolean()
23
+ .default(false)
24
+ .describe('When true, only return an exact match. When false (default), GBIF applies fuzzy matching — useful for minor spelling variations and abbreviated names.'),
25
+ kingdom: z
26
+ .string()
27
+ .optional()
28
+ .describe('Narrow the match to a specific kingdom (e.g., "Animalia", "Plantae", "Fungi") to disambiguate names that appear in multiple kingdoms.'),
29
+ rank: z
30
+ .enum(['KINGDOM', 'PHYLUM', 'CLASS', 'ORDER', 'FAMILY', 'GENUS', 'SPECIES', 'SUBSPECIES'])
31
+ .optional()
32
+ .describe('Expected taxonomic rank. Use to avoid matching a genus when you expect a species.'),
33
+ }),
34
+ output: z.object({
35
+ taxonKey: z
36
+ .number()
37
+ .optional()
38
+ .describe('GBIF backbone taxon key. Use this in downstream tools. Absent when matchType is NONE.'),
39
+ scientificName: z.string().optional().describe('Full scientific name with authorship.'),
40
+ canonicalName: z.string().optional().describe('Scientific name without authorship.'),
41
+ rank: z.string().optional().describe('Taxonomic rank of the matched taxon.'),
42
+ status: z.string().optional().describe('Taxonomic status: ACCEPTED, SYNONYM, or DOUBTFUL.'),
43
+ confidence: z
44
+ .number()
45
+ .optional()
46
+ .describe('Match confidence score 0–100. Below 80 warrants review.'),
47
+ matchType: z
48
+ .string()
49
+ .optional()
50
+ .describe('EXACT, FUZZY, HIGHERORDER, or NONE. NONE means no usable match.'),
51
+ kingdom: z.string().optional().describe('Kingdom of the matched taxon.'),
52
+ phylum: z.string().optional().describe('Phylum of the matched taxon.'),
53
+ class: z.string().optional().describe('Class of the matched taxon.'),
54
+ order: z.string().optional().describe('Order of the matched taxon.'),
55
+ family: z.string().optional().describe('Family of the matched taxon.'),
56
+ genus: z.string().optional().describe('Genus of the matched taxon.'),
57
+ species: z.string().optional().describe('Species canonical name of the matched taxon.'),
58
+ kingdomKey: z.number().optional().describe('Backbone taxon key for the kingdom.'),
59
+ phylumKey: z.number().optional().describe('Backbone taxon key for the phylum.'),
60
+ classKey: z.number().optional().describe('Backbone taxon key for the class.'),
61
+ orderKey: z.number().optional().describe('Backbone taxon key for the order.'),
62
+ familyKey: z.number().optional().describe('Backbone taxon key for the family.'),
63
+ genusKey: z.number().optional().describe('Backbone taxon key for the genus.'),
64
+ speciesKey: z.number().optional().describe('Backbone taxon key for the species.'),
65
+ }),
66
+ errors: [
67
+ {
68
+ reason: 'no_match',
69
+ code: JsonRpcErrorCode.NotFound,
70
+ when: 'matchType is NONE — no candidate met the match threshold.',
71
+ recovery: 'Try a broader name, remove the strict flag, or search with gbif_search_species instead.',
72
+ },
73
+ ],
74
+ async handler(input, ctx) {
75
+ ctx.log.info('Matching species name', { name: input.name, strict: input.strict });
76
+ const raw = await getGbifService().matchSpecies({
77
+ name: input.name,
78
+ strict: input.strict,
79
+ ...(input.kingdom?.trim() && { kingdom: input.kingdom }),
80
+ ...(input.rank && { rank: input.rank }),
81
+ }, ctx);
82
+ if (raw.matchType === 'NONE' || !raw.usageKey) {
83
+ throw ctx.fail('no_match', `No backbone match for "${input.name}"`, {
84
+ ...ctx.recoveryFor('no_match'),
85
+ });
86
+ }
87
+ return {
88
+ taxonKey: raw.usageKey,
89
+ scientificName: raw.scientificName,
90
+ canonicalName: raw.canonicalName,
91
+ rank: raw.rank,
92
+ status: raw.status,
93
+ confidence: raw.confidence,
94
+ matchType: raw.matchType,
95
+ kingdom: raw.kingdom,
96
+ phylum: raw.phylum,
97
+ class: raw.class,
98
+ order: raw.order,
99
+ family: raw.family,
100
+ genus: raw.genus,
101
+ species: raw.species,
102
+ kingdomKey: raw.kingdomKey,
103
+ phylumKey: raw.phylumKey,
104
+ classKey: raw.classKey,
105
+ orderKey: raw.orderKey,
106
+ familyKey: raw.familyKey,
107
+ genusKey: raw.genusKey,
108
+ speciesKey: raw.speciesKey,
109
+ };
110
+ },
111
+ format: (result) => {
112
+ const lines = [];
113
+ if (result.canonicalName)
114
+ lines.push(`## ${result.canonicalName}`);
115
+ if (result.scientificName)
116
+ lines.push(`**Scientific name:** ${result.scientificName}`);
117
+ if (result.taxonKey != null)
118
+ lines.push(`**Taxon key:** ${result.taxonKey}`);
119
+ if (result.rank)
120
+ lines.push(`**Rank:** ${result.rank}`);
121
+ if (result.status)
122
+ lines.push(`**Status:** ${result.status}`);
123
+ if (result.matchType)
124
+ lines.push(`**Match type:** ${result.matchType}`);
125
+ if (result.confidence != null)
126
+ lines.push(`**Confidence:** ${result.confidence}/100`);
127
+ const classificationParts = [];
128
+ if (result.kingdom)
129
+ classificationParts.push(`Kingdom: ${result.kingdom}${result.kingdomKey ? ` (${result.kingdomKey})` : ''}`);
130
+ if (result.phylum)
131
+ classificationParts.push(`Phylum: ${result.phylum}${result.phylumKey ? ` (${result.phylumKey})` : ''}`);
132
+ if (result.class)
133
+ classificationParts.push(`Class: ${result.class}${result.classKey ? ` (${result.classKey})` : ''}`);
134
+ if (result.order)
135
+ classificationParts.push(`Order: ${result.order}${result.orderKey ? ` (${result.orderKey})` : ''}`);
136
+ if (result.family)
137
+ classificationParts.push(`Family: ${result.family}${result.familyKey ? ` (${result.familyKey})` : ''}`);
138
+ if (result.genus)
139
+ classificationParts.push(`Genus: ${result.genus}${result.genusKey ? ` (${result.genusKey})` : ''}`);
140
+ if (result.species)
141
+ classificationParts.push(`Species: ${result.species}${result.speciesKey ? ` (${result.speciesKey})` : ''}`);
142
+ if (classificationParts.length > 0) {
143
+ lines.push(`**Classification:** ${classificationParts.join(' › ')}`);
144
+ }
145
+ return [{ type: 'text', text: lines.join('\n') }];
146
+ },
147
+ });
148
+ //# sourceMappingURL=gbif-match-species.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gbif-match-species.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-match-species.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,EAAE;IACzD,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EACT,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,CAAC,EAAE,EAAE,CAC1E,CAAC;QACJ,IAAI,MAAM,CAAC,MAAM;YACf,mBAAmB,CAAC,IAAI,CACtB,WAAW,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9E,CAAC;QACJ,IAAI,MAAM,CAAC,KAAK;YACd,mBAAmB,CAAC,IAAI,CACtB,UAAU,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1E,CAAC;QACJ,IAAI,MAAM,CAAC,OAAO;YAChB,mBAAmB,CAAC,IAAI,CACtB,YAAY,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAClF,CAAC;QACJ,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,KAAK,CAAC,IAAI,CAAC,uBAAuB,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvE,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,45 @@
1
+ /**
2
+ * @fileoverview Aggregate GBIF occurrence counts by a facet dimension.
3
+ * @module mcp-server/tools/definitions/gbif-occurrence-facets
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ export declare const gbifOccurrenceFacets: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
7
+ facet: z.ZodEnum<{
8
+ BASIS_OF_RECORD: "BASIS_OF_RECORD";
9
+ COUNTRY: "COUNTRY";
10
+ YEAR: "YEAR";
11
+ DATASET_KEY: "DATASET_KEY";
12
+ KINGDOM_KEY: "KINGDOM_KEY";
13
+ PHYLUM_KEY: "PHYLUM_KEY";
14
+ CLASS_KEY: "CLASS_KEY";
15
+ ORDER_KEY: "ORDER_KEY";
16
+ FAMILY_KEY: "FAMILY_KEY";
17
+ GENUS_KEY: "GENUS_KEY";
18
+ SPECIES_KEY: "SPECIES_KEY";
19
+ PUBLISHING_COUNTRY: "PUBLISHING_COUNTRY";
20
+ MONTH: "MONTH";
21
+ }>;
22
+ taxonKey: z.ZodOptional<z.ZodNumber>;
23
+ country: z.ZodOptional<z.ZodString>;
24
+ year: z.ZodOptional<z.ZodString>;
25
+ basisOfRecord: z.ZodOptional<z.ZodEnum<{
26
+ HUMAN_OBSERVATION: "HUMAN_OBSERVATION";
27
+ MACHINE_OBSERVATION: "MACHINE_OBSERVATION";
28
+ PRESERVED_SPECIMEN: "PRESERVED_SPECIMEN";
29
+ LIVING_SPECIMEN: "LIVING_SPECIMEN";
30
+ MATERIAL_SAMPLE: "MATERIAL_SAMPLE";
31
+ MATERIAL_CITATION: "MATERIAL_CITATION";
32
+ OCCURRENCE: "OCCURRENCE";
33
+ LITERATURE: "LITERATURE";
34
+ }>>;
35
+ geometry: z.ZodOptional<z.ZodString>;
36
+ facetLimit: z.ZodDefault<z.ZodNumber>;
37
+ }, z.core.$strip>, z.ZodObject<{
38
+ facet: z.ZodString;
39
+ totalOccurrences: z.ZodNumber;
40
+ counts: z.ZodArray<z.ZodObject<{
41
+ name: z.ZodString;
42
+ count: z.ZodNumber;
43
+ }, z.core.$strip>>;
44
+ }, z.core.$strip>, undefined>;
45
+ //# sourceMappingURL=gbif-occurrence-facets.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gbif-occurrence-facets.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-occurrence-facets.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AA8BjD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA+F/B,CAAC"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @fileoverview Aggregate GBIF occurrence counts by a facet dimension.
3
+ * @module mcp-server/tools/definitions/gbif-occurrence-facets
4
+ */
5
+ import { tool, z } from '@cyanheads/mcp-ts-core';
6
+ import { getGbifService } from '../../../services/gbif/gbif-service.js';
7
+ const BASIS_OF_RECORD_VALUES = [
8
+ 'HUMAN_OBSERVATION',
9
+ 'MACHINE_OBSERVATION',
10
+ 'PRESERVED_SPECIMEN',
11
+ 'LIVING_SPECIMEN',
12
+ 'MATERIAL_SAMPLE',
13
+ 'MATERIAL_CITATION',
14
+ 'OCCURRENCE',
15
+ 'LITERATURE',
16
+ ];
17
+ const FACET_VALUES = [
18
+ 'BASIS_OF_RECORD',
19
+ 'COUNTRY',
20
+ 'YEAR',
21
+ 'DATASET_KEY',
22
+ 'KINGDOM_KEY',
23
+ 'PHYLUM_KEY',
24
+ 'CLASS_KEY',
25
+ 'ORDER_KEY',
26
+ 'FAMILY_KEY',
27
+ 'GENUS_KEY',
28
+ 'SPECIES_KEY',
29
+ 'PUBLISHING_COUNTRY',
30
+ 'MONTH',
31
+ ];
32
+ export const gbifOccurrenceFacets = tool('gbif_occurrence_facets', {
33
+ title: 'Occurrence Facet Aggregation',
34
+ description: 'Aggregate occurrence counts across a dimension (COUNTRY, YEAR, BASIS_OF_RECORD, DATASET_KEY, ' +
35
+ 'KINGDOM_KEY, etc.). Returns the top-N facet values ranked by count — no record payloads returned. ' +
36
+ 'Core tool for distribution analysis and trend queries: "which countries have the most records ' +
37
+ 'for this species?", "how has observation volume changed since 2010?". ' +
38
+ 'Scope the aggregation with taxonKey, country, year, geometry, or basisOfRecord filters.',
39
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
40
+ input: z.object({
41
+ facet: z
42
+ .enum(FACET_VALUES)
43
+ .describe('Dimension to aggregate by (e.g., COUNTRY, YEAR, BASIS_OF_RECORD, SPECIES_KEY).'),
44
+ taxonKey: z.number().optional().describe('Backbone taxon key to scope the aggregation.'),
45
+ country: z
46
+ .string()
47
+ .optional()
48
+ .describe('ISO 3166-1 alpha-2 country code to scope to one country.'),
49
+ year: z
50
+ .string()
51
+ .optional()
52
+ .describe('Year or year range (e.g., "2020,2024") to scope the aggregation.'),
53
+ basisOfRecord: z
54
+ .enum(BASIS_OF_RECORD_VALUES)
55
+ .optional()
56
+ .describe('Scope to a specific basis of record.'),
57
+ geometry: z
58
+ .string()
59
+ .optional()
60
+ .describe('WKT polygon to scope the aggregation to a geographic area (e.g., POLYGON((8 47, 9 47, 9 48, 8 48, 8 47))). Coordinates are longitude latitude.'),
61
+ facetLimit: z
62
+ .number()
63
+ .min(1)
64
+ .max(100)
65
+ .default(10)
66
+ .describe('Maximum number of facet values to return (default 10, max 100).'),
67
+ }),
68
+ output: z.object({
69
+ facet: z.string().describe('The facet dimension aggregated.'),
70
+ totalOccurrences: z.number().describe('Total matching occurrences across all facet values.'),
71
+ counts: z
72
+ .array(z
73
+ .object({
74
+ name: z.string().describe('Facet value (country code, year, basisOfRecord, etc.).'),
75
+ count: z.number().describe('Occurrence count for this facet value.'),
76
+ })
77
+ .describe('A facet value with its occurrence count.'))
78
+ .describe('Facet values ranked by count descending (top facetLimit entries).'),
79
+ }),
80
+ async handler(input, ctx) {
81
+ ctx.log.info('Fetching occurrence facets', { facet: input.facet, taxonKey: input.taxonKey });
82
+ const raw = await getGbifService().getOccurrenceFacets({
83
+ facet: input.facet,
84
+ ...(input.taxonKey !== undefined && { taxonKey: input.taxonKey }),
85
+ ...(input.country?.trim() && { country: input.country }),
86
+ ...(input.year?.trim() && { year: input.year }),
87
+ ...(input.basisOfRecord && { basisOfRecord: input.basisOfRecord }),
88
+ ...(input.geometry?.trim() && { geometry: input.geometry }),
89
+ facetLimit: input.facetLimit,
90
+ }, ctx);
91
+ const facetData = raw.facets?.find((f) => f.field?.toUpperCase() === input.facet.toUpperCase());
92
+ const counts = (facetData?.counts ?? []).map((c) => ({
93
+ name: c.name ?? '',
94
+ count: c.count ?? 0,
95
+ }));
96
+ return {
97
+ facet: input.facet,
98
+ totalOccurrences: raw.count ?? 0,
99
+ counts,
100
+ };
101
+ },
102
+ format: (result) => {
103
+ const lines = [
104
+ `## ${result.facet} Facet`,
105
+ `**Total occurrences in scope:** ${result.totalOccurrences}`,
106
+ `**Top ${result.counts.length} values:**`,
107
+ ];
108
+ const maxCount = result.counts[0]?.count ?? 1;
109
+ for (const entry of result.counts) {
110
+ const pct = ((entry.count / maxCount) * 100).toFixed(0);
111
+ lines.push(`- **${entry.name}**: ${entry.count.toLocaleString()} (${pct}% of top)`);
112
+ }
113
+ return [{ type: 'text', text: lines.join('\n') }];
114
+ },
115
+ });
116
+ //# sourceMappingURL=gbif-occurrence-facets.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gbif-occurrence-facets.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-occurrence-facets.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,sBAAsB,GAAG;IAC7B,mBAAmB;IACnB,qBAAqB;IACrB,oBAAoB;IACpB,iBAAiB;IACjB,iBAAiB;IACjB,mBAAmB;IACnB,YAAY;IACZ,YAAY;CACJ,CAAC;AAEX,MAAM,YAAY,GAAG;IACnB,iBAAiB;IACjB,SAAS;IACT,MAAM;IACN,aAAa;IACb,aAAa;IACb,YAAY;IACZ,WAAW;IACX,WAAW;IACX,YAAY;IACZ,WAAW;IACX,aAAa;IACb,oBAAoB;IACpB,OAAO;CACC,CAAC;AAEX,MAAM,CAAC,MAAM,oBAAoB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EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @fileoverview Search GBIF datasets by keyword, type, or country.
3
+ * @module mcp-server/tools/definitions/gbif-search-datasets
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ export declare const gbifSearchDatasets: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
7
+ q: z.ZodOptional<z.ZodString>;
8
+ type: z.ZodOptional<z.ZodEnum<{
9
+ OCCURRENCE: "OCCURRENCE";
10
+ CHECKLIST: "CHECKLIST";
11
+ METADATA: "METADATA";
12
+ SAMPLING_EVENT: "SAMPLING_EVENT";
13
+ }>>;
14
+ publishingCountry: z.ZodOptional<z.ZodString>;
15
+ hostingOrg: z.ZodOptional<z.ZodString>;
16
+ limit: z.ZodDefault<z.ZodNumber>;
17
+ offset: z.ZodDefault<z.ZodNumber>;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ datasets: z.ZodArray<z.ZodObject<{
20
+ key: z.ZodOptional<z.ZodString>;
21
+ title: z.ZodOptional<z.ZodString>;
22
+ type: z.ZodOptional<z.ZodString>;
23
+ description: z.ZodOptional<z.ZodString>;
24
+ license: z.ZodOptional<z.ZodString>;
25
+ doi: z.ZodOptional<z.ZodString>;
26
+ publishingCountry: z.ZodOptional<z.ZodString>;
27
+ recordCount: z.ZodOptional<z.ZodNumber>;
28
+ }, z.core.$strip>>;
29
+ totalCount: z.ZodNumber;
30
+ offset: z.ZodNumber;
31
+ limit: z.ZodNumber;
32
+ endOfRecords: z.ZodBoolean;
33
+ }, z.core.$strip>, undefined>;
34
+ //# sourceMappingURL=gbif-search-datasets.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gbif-search-datasets.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/gbif-search-datasets.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAIjD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA4G7B,CAAC"}