medical-terminologies-mcp 4.3.2 → 4.3.3

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 (2) hide show
  1. package/dist/index.js +46 -39
  2. package/package.json +4 -2
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ function unknownCursorError(message) {
30
30
  var package_default = {
31
31
  name: "medical-terminologies-mcp",
32
32
  mcpName: "io.github.SidneyBissoli/medical-terminologies-mcp",
33
- version: "4.3.2",
33
+ version: "4.3.3",
34
34
  description: "Unified MCP server for seven medical terminologies (ICD-11, ICF, LOINC, RxNorm, MeSH, ATC, CID-10) with authoritative WHO ICD-10\u2192ICD-11 mapping. 37 tools, hosted endpoint available, MIT.",
35
35
  author: "Sidney da Silva Pereira Bissoli",
36
36
  license: "MIT",
@@ -84,7 +84,9 @@ var package_default = {
84
84
  typecheck: "tsc --noEmit",
85
85
  prepublishOnly: "npm run build",
86
86
  "build:worker-lib": 'esbuild src/worker-lib.ts --bundle --platform=browser --target=es2022 --format=esm --outfile=dist/worker-lib.js --tree-shaking=false --conditions=workerd,browser --define:process.env.NODE_ENV=\\"production\\" --external:node:* --external:cloudflare:* --external:@modelcontextprotocol/* --external:zod --alias:events=node:events --alias:stream=node:stream --alias:buffer=node:buffer --alias:util=node:util --alias:path=node:path --alias:os=node:os --alias:fs=node:fs --alias:url=node:url --alias:crypto=node:crypto',
87
- "manifest:lhm": "node scripts/gen-lhm-manifest.mjs"
87
+ "manifest:lhm": "node scripts/gen-lhm-manifest.mjs",
88
+ "fixtures:record": "tsx scripts/record-tool-fixtures.ts",
89
+ "eval:answers": "tsx src/evals/run-answers.ts"
88
90
  },
89
91
  dependencies: {
90
92
  "@modelcontextprotocol/server": "^2.0.0",
@@ -5106,21 +5108,21 @@ var MeSHClient = class {
5106
5108
  async fetchTermLabel(uri, language) {
5107
5109
  const lang = language ?? "en";
5108
5110
  const cacheKey = `mesh:term:label:${uri}:${lang}`;
5109
- return cache.getOrSet(
5110
- CACHE_PREFIX.MESH,
5111
- cacheKey,
5112
- async () => {
5113
- try {
5114
- const path = uriToPath(uri);
5115
- if (!path) return "";
5111
+ const path = uriToPath(uri);
5112
+ if (!path) return "";
5113
+ try {
5114
+ return await cache.getOrSet(
5115
+ CACHE_PREFIX.MESH,
5116
+ cacheKey,
5117
+ async () => {
5116
5118
  const raw = await this.request(path, {}, language);
5117
5119
  return this.extractValue(raw?.prefLabel, language) || this.extractValue(raw?.label, language);
5118
- } catch {
5119
- return "";
5120
- }
5121
- },
5122
- DEFAULT_TTL.STATIC
5123
- );
5120
+ },
5121
+ DEFAULT_TTL.STATIC
5122
+ );
5123
+ } catch {
5124
+ return "";
5125
+ }
5124
5126
  }
5125
5127
  /**
5126
5128
  * Fetches a tree number resource. The "label" of a tree number IS the
@@ -5130,21 +5132,22 @@ var MeSHClient = class {
5130
5132
  async fetchTreeNumberLabel(uri, language) {
5131
5133
  const lang = language ?? "en";
5132
5134
  const cacheKey = `mesh:tree:label:${uri}:${lang}`;
5133
- return cache.getOrSet(
5134
- CACHE_PREFIX.MESH,
5135
- cacheKey,
5136
- async () => {
5137
- try {
5138
- const path = uriToPath(uri);
5139
- if (!path) return "";
5135
+ const path = uriToPath(uri);
5136
+ if (!path) return "";
5137
+ try {
5138
+ const label = await cache.getOrSet(
5139
+ CACHE_PREFIX.MESH,
5140
+ cacheKey,
5141
+ async () => {
5140
5142
  const raw = await this.request(path, {}, language);
5141
5143
  return this.extractValue(raw?.label, language);
5142
- } catch {
5143
- return "";
5144
- }
5145
- },
5146
- DEFAULT_TTL.STATIC
5147
- );
5144
+ },
5145
+ DEFAULT_TTL.STATIC
5146
+ );
5147
+ return label || treeNumberFromUri(uri);
5148
+ } catch {
5149
+ return treeNumberFromUri(uri);
5150
+ }
5148
5151
  }
5149
5152
  /**
5150
5153
  * Fetches a qualifier's label. STATIC TTL — qualifiers are part of
@@ -5154,23 +5157,23 @@ var MeSHClient = class {
5154
5157
  async fetchQualifierLabel(qualifierId, language) {
5155
5158
  const lang = language ?? "en";
5156
5159
  const cacheKey = `mesh:qlabel:${qualifierId}:${lang}`;
5157
- return cache.getOrSet(
5158
- CACHE_PREFIX.MESH,
5159
- cacheKey,
5160
- async () => {
5161
- try {
5160
+ try {
5161
+ return await cache.getOrSet(
5162
+ CACHE_PREFIX.MESH,
5163
+ cacheKey,
5164
+ async () => {
5162
5165
  const raw = await this.request(
5163
5166
  `/${qualifierId}.json`,
5164
5167
  {},
5165
5168
  language
5166
5169
  );
5167
5170
  return this.extractValue(raw?.label, language);
5168
- } catch {
5169
- return "";
5170
- }
5171
- },
5172
- DEFAULT_TTL.STATIC
5173
- );
5171
+ },
5172
+ DEFAULT_TTL.STATIC
5173
+ );
5174
+ } catch {
5175
+ return "";
5176
+ }
5174
5177
  }
5175
5178
  // ===========================================================================
5176
5179
  // Internal: resolvers (fan-out across multiple sub-resources in parallel)
@@ -5264,6 +5267,10 @@ function toUriArray(v) {
5264
5267
  if (Array.isArray(v)) return v.filter((x) => typeof x === "string");
5265
5268
  return [];
5266
5269
  }
5270
+ function treeNumberFromUri(uri) {
5271
+ const tail = uri.replace(/^https?:\/\/id\.nlm\.nih\.gov\/mesh\//, "");
5272
+ return /^[A-Z]\d{2}(\.\d{3})*$/.test(tail) ? tail : "";
5273
+ }
5267
5274
  function uriToPath(uri) {
5268
5275
  if (!uri) return "";
5269
5276
  const stripped = uri.replace(/^https?:\/\/id\.nlm\.nih\.gov\/mesh/, "");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "medical-terminologies-mcp",
3
3
  "mcpName": "io.github.SidneyBissoli/medical-terminologies-mcp",
4
- "version": "4.3.2",
4
+ "version": "4.3.3",
5
5
  "description": "Unified MCP server for seven medical terminologies (ICD-11, ICF, LOINC, RxNorm, MeSH, ATC, CID-10) with authoritative WHO ICD-10→ICD-11 mapping. 37 tools, hosted endpoint available, MIT.",
6
6
  "author": "Sidney da Silva Pereira Bissoli",
7
7
  "license": "MIT",
@@ -55,7 +55,9 @@
55
55
  "typecheck": "tsc --noEmit",
56
56
  "prepublishOnly": "npm run build",
57
57
  "build:worker-lib": "esbuild src/worker-lib.ts --bundle --platform=browser --target=es2022 --format=esm --outfile=dist/worker-lib.js --tree-shaking=false --conditions=workerd,browser --define:process.env.NODE_ENV=\\\"production\\\" --external:node:* --external:cloudflare:* --external:@modelcontextprotocol/* --external:zod --alias:events=node:events --alias:stream=node:stream --alias:buffer=node:buffer --alias:util=node:util --alias:path=node:path --alias:os=node:os --alias:fs=node:fs --alias:url=node:url --alias:crypto=node:crypto",
58
- "manifest:lhm": "node scripts/gen-lhm-manifest.mjs"
58
+ "manifest:lhm": "node scripts/gen-lhm-manifest.mjs",
59
+ "fixtures:record": "tsx scripts/record-tool-fixtures.ts",
60
+ "eval:answers": "tsx src/evals/run-answers.ts"
59
61
  },
60
62
  "dependencies": {
61
63
  "@modelcontextprotocol/server": "^2.0.0",