@cyanheads/pubmed-mcp-server 1.3.5 → 1.4.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.
- package/README.md +24 -21
- package/dist/config/index.d.ts +11 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +75 -11
- package/dist/config/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/server.d.ts +13 -0
- package/dist/mcp-server/server.d.ts.map +1 -1
- package/dist/mcp-server/server.js +31 -13
- package/dist/mcp-server/server.js.map +1 -1
- package/dist/mcp-server/tools/pubmedArticleConnections/index.d.ts +7 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/index.js +7 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/index.js.map +1 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/citationFormatter.d.ts +10 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/citationFormatter.d.ts.map +1 -0
- package/dist/mcp-server/tools/{getPubMedArticleConnections → pubmedArticleConnections}/logic/citationFormatter.js +9 -7
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/citationFormatter.js.map +1 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/elinkHandler.d.ts +10 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/elinkHandler.d.ts.map +1 -0
- package/dist/mcp-server/tools/{getPubMedArticleConnections → pubmedArticleConnections}/logic/elinkHandler.js +9 -9
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/elinkHandler.js.map +1 -0
- package/dist/mcp-server/tools/{getPubMedArticleConnections → pubmedArticleConnections}/logic/index.d.ts +9 -9
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/{getPubMedArticleConnections → pubmedArticleConnections}/logic/index.js +14 -14
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/index.js.map +1 -0
- package/dist/mcp-server/tools/{getPubMedArticleConnections → pubmedArticleConnections}/logic/types.d.ts +4 -4
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/types.d.ts.map +1 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/types.js +6 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/logic/types.js.map +1 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/registration.d.ts +12 -0
- package/dist/mcp-server/tools/pubmedArticleConnections/registration.d.ts.map +1 -0
- package/dist/mcp-server/tools/{getPubMedArticleConnections → pubmedArticleConnections}/registration.js +11 -11
- package/dist/mcp-server/tools/pubmedArticleConnections/registration.js.map +1 -0
- package/dist/mcp-server/tools/pubmedFetchContents/index.d.ts +7 -0
- package/dist/mcp-server/tools/pubmedFetchContents/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/pubmedFetchContents/index.js +7 -0
- package/dist/mcp-server/tools/pubmedFetchContents/index.js.map +1 -0
- package/dist/mcp-server/tools/{fetchPubMedContent → pubmedFetchContents}/logic.d.ts +6 -6
- package/dist/mcp-server/tools/pubmedFetchContents/logic.d.ts.map +1 -0
- package/dist/mcp-server/tools/{fetchPubMedContent → pubmedFetchContents}/logic.js +18 -17
- package/dist/mcp-server/tools/pubmedFetchContents/logic.js.map +1 -0
- package/dist/mcp-server/tools/pubmedFetchContents/registration.d.ts +11 -0
- package/dist/mcp-server/tools/pubmedFetchContents/registration.d.ts.map +1 -0
- package/dist/mcp-server/tools/{fetchPubMedContent → pubmedFetchContents}/registration.js +12 -12
- package/dist/mcp-server/tools/pubmedFetchContents/registration.js.map +1 -0
- package/dist/mcp-server/tools/{generatePubMedChart → pubmedGenerateChart}/index.d.ts +2 -2
- package/dist/mcp-server/tools/pubmedGenerateChart/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/{generatePubMedChart → pubmedGenerateChart}/index.js +2 -2
- package/dist/mcp-server/tools/pubmedGenerateChart/index.js.map +1 -0
- package/dist/mcp-server/tools/{generatePubMedChart → pubmedGenerateChart}/logic.d.ts +4 -4
- package/dist/mcp-server/tools/{generatePubMedChart → pubmedGenerateChart}/logic.d.ts.map +1 -1
- package/dist/mcp-server/tools/{generatePubMedChart → pubmedGenerateChart}/logic.js +24 -20
- package/dist/mcp-server/tools/pubmedGenerateChart/logic.js.map +1 -0
- package/dist/mcp-server/tools/pubmedGenerateChart/registration.d.ts +8 -0
- package/dist/mcp-server/tools/{generatePubMedChart → pubmedGenerateChart}/registration.d.ts.map +1 -1
- package/dist/mcp-server/tools/{generatePubMedChart → pubmedGenerateChart}/registration.js +9 -13
- package/dist/mcp-server/tools/pubmedGenerateChart/registration.js.map +1 -0
- package/dist/mcp-server/tools/pubmedResearchAgent/logic/planOrchestrator.d.ts.map +1 -1
- package/dist/mcp-server/tools/pubmedResearchAgent/logic/planOrchestrator.js +7 -4
- package/dist/mcp-server/tools/pubmedResearchAgent/logic/planOrchestrator.js.map +1 -1
- package/dist/mcp-server/tools/pubmedResearchAgent/registration.js.map +1 -1
- package/dist/mcp-server/tools/pubmedSearchArticles/index.d.ts +7 -0
- package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/pubmedSearchArticles/index.js +7 -0
- package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/index.js.map +1 -1
- package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/logic.d.ts +9 -9
- package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/logic.d.ts.map +1 -1
- package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/logic.js +16 -14
- package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/logic.js.map +1 -1
- package/dist/mcp-server/tools/pubmedSearchArticles/registration.d.ts +11 -0
- package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/registration.d.ts.map +1 -1
- package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/registration.js +12 -12
- package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/registration.js.map +1 -1
- package/dist/mcp-server/transports/auth/index.d.ts +1 -1
- package/dist/mcp-server/transports/auth/index.d.ts.map +1 -1
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.d.ts.map +1 -1
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +4 -0
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js.map +1 -1
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts.map +1 -1
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +5 -0
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js.map +1 -1
- package/dist/mcp-server/transports/core/headerUtils.d.ts +20 -0
- package/dist/mcp-server/transports/core/headerUtils.d.ts.map +1 -0
- package/dist/mcp-server/transports/core/headerUtils.js +38 -0
- package/dist/mcp-server/transports/core/headerUtils.js.map +1 -0
- package/dist/mcp-server/transports/core/honoNodeBridge.d.ts +60 -7
- package/dist/mcp-server/transports/core/honoNodeBridge.d.ts.map +1 -1
- package/dist/mcp-server/transports/core/honoNodeBridge.js +99 -12
- package/dist/mcp-server/transports/core/honoNodeBridge.js.map +1 -1
- package/dist/mcp-server/transports/core/statefulTransportManager.d.ts +53 -8
- package/dist/mcp-server/transports/core/statefulTransportManager.d.ts.map +1 -1
- package/dist/mcp-server/transports/core/statefulTransportManager.js +180 -117
- package/dist/mcp-server/transports/core/statefulTransportManager.js.map +1 -1
- package/dist/mcp-server/transports/core/statelessTransportManager.d.ts +44 -7
- package/dist/mcp-server/transports/core/statelessTransportManager.d.ts.map +1 -1
- package/dist/mcp-server/transports/core/statelessTransportManager.js +84 -24
- package/dist/mcp-server/transports/core/statelessTransportManager.js.map +1 -1
- package/dist/mcp-server/transports/core/transportTypes.d.ts +58 -21
- package/dist/mcp-server/transports/core/transportTypes.d.ts.map +1 -1
- package/dist/mcp-server/transports/core/transportTypes.js +3 -1
- package/dist/mcp-server/transports/core/transportTypes.js.map +1 -1
- package/dist/mcp-server/transports/http/httpTransport.d.ts +3 -3
- package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/httpTransport.js +58 -20
- package/dist/mcp-server/transports/http/httpTransport.js.map +1 -1
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.d.ts +4 -3
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.js +28 -25
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.js.map +1 -1
- package/dist/services/NCBI/core/ncbiConstants.d.ts +1 -1
- package/dist/services/NCBI/core/ncbiConstants.d.ts.map +1 -1
- package/dist/services/NCBI/core/ncbiCoreApiClient.d.ts.map +1 -1
- package/dist/services/NCBI/core/ncbiCoreApiClient.js +5 -4
- package/dist/services/NCBI/core/ncbiCoreApiClient.js.map +1 -1
- package/dist/services/NCBI/core/ncbiRequestQueueManager.d.ts +4 -4
- package/dist/services/NCBI/core/ncbiRequestQueueManager.d.ts.map +1 -1
- package/dist/services/NCBI/core/ncbiRequestQueueManager.js +6 -5
- package/dist/services/NCBI/core/ncbiRequestQueueManager.js.map +1 -1
- package/dist/services/NCBI/core/ncbiResponseHandler.d.ts +1 -1
- package/dist/services/NCBI/core/ncbiResponseHandler.d.ts.map +1 -1
- package/dist/services/NCBI/core/ncbiResponseHandler.js +1 -1
- package/dist/services/NCBI/core/ncbiResponseHandler.js.map +1 -1
- package/dist/services/NCBI/core/ncbiService.d.ts +3 -3
- package/dist/services/NCBI/core/ncbiService.d.ts.map +1 -1
- package/dist/services/NCBI/parsing/eSummaryResultParser.d.ts.map +1 -1
- package/dist/services/NCBI/parsing/eSummaryResultParser.js +2 -1
- package/dist/services/NCBI/parsing/eSummaryResultParser.js.map +1 -1
- package/dist/services/NCBI/parsing/pubmedArticleStructureParser.js +1 -1
- package/dist/services/NCBI/parsing/pubmedArticleStructureParser.js.map +1 -1
- package/dist/services/NCBI/parsing/xmlGenericHelpers.d.ts +2 -2
- package/dist/services/NCBI/parsing/xmlGenericHelpers.d.ts.map +1 -1
- package/dist/services/NCBI/parsing/xmlGenericHelpers.js +17 -23
- package/dist/services/NCBI/parsing/xmlGenericHelpers.js.map +1 -1
- package/dist/types-global/pubmedXml.d.ts +9 -9
- package/dist/types-global/pubmedXml.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/internal/errorHandler.d.ts +0 -7
- package/dist/utils/internal/errorHandler.d.ts.map +1 -1
- package/dist/utils/internal/errorHandler.js +27 -11
- package/dist/utils/internal/errorHandler.js.map +1 -1
- package/dist/utils/internal/index.d.ts +1 -0
- package/dist/utils/internal/index.d.ts.map +1 -1
- package/dist/utils/internal/index.js +1 -0
- package/dist/utils/internal/index.js.map +1 -1
- package/dist/utils/internal/logger.d.ts.map +1 -1
- package/dist/utils/internal/logger.js +2 -0
- package/dist/utils/internal/logger.js.map +1 -1
- package/dist/utils/internal/performance.d.ts +22 -0
- package/dist/utils/internal/performance.d.ts.map +1 -0
- package/dist/utils/internal/performance.js +104 -0
- package/dist/utils/internal/performance.js.map +1 -0
- package/dist/utils/internal/requestContext.d.ts.map +1 -1
- package/dist/utils/internal/requestContext.js +10 -0
- package/dist/utils/internal/requestContext.js.map +1 -1
- package/dist/utils/metrics/tokenCounter.js +4 -4
- package/dist/utils/metrics/tokenCounter.js.map +1 -1
- package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -1
- package/dist/utils/network/fetchWithTimeout.js +18 -0
- package/dist/utils/network/fetchWithTimeout.js.map +1 -1
- package/dist/utils/parsing/dateParser.d.ts +2 -3
- package/dist/utils/parsing/dateParser.d.ts.map +1 -1
- package/dist/utils/parsing/dateParser.js +2 -2
- package/dist/utils/parsing/dateParser.js.map +1 -1
- package/dist/utils/parsing/jsonParser.d.ts +1 -1
- package/dist/utils/parsing/jsonParser.d.ts.map +1 -1
- package/dist/utils/parsing/jsonParser.js +5 -4
- package/dist/utils/parsing/jsonParser.js.map +1 -1
- package/dist/utils/security/idGenerator.d.ts.map +1 -1
- package/dist/utils/security/idGenerator.js +5 -1
- package/dist/utils/security/idGenerator.js.map +1 -1
- package/dist/utils/security/rateLimiter.d.ts.map +1 -1
- package/dist/utils/security/rateLimiter.js +22 -6
- package/dist/utils/security/rateLimiter.js.map +1 -1
- package/dist/utils/telemetry/instrumentation.d.ts +8 -0
- package/dist/utils/telemetry/instrumentation.d.ts.map +1 -0
- package/dist/utils/telemetry/instrumentation.js +179 -0
- package/dist/utils/telemetry/instrumentation.js.map +1 -0
- package/dist/utils/telemetry/semconv.d.ts +16 -0
- package/dist/utils/telemetry/semconv.d.ts.map +1 -0
- package/dist/utils/telemetry/semconv.js +16 -0
- package/dist/utils/telemetry/semconv.js.map +1 -0
- package/package.json +45 -17
- package/dist/mcp-server/tools/fetchPubMedContent/index.d.ts +0 -7
- package/dist/mcp-server/tools/fetchPubMedContent/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/fetchPubMedContent/index.js +0 -7
- package/dist/mcp-server/tools/fetchPubMedContent/index.js.map +0 -1
- package/dist/mcp-server/tools/fetchPubMedContent/logic.d.ts.map +0 -1
- package/dist/mcp-server/tools/fetchPubMedContent/logic.js.map +0 -1
- package/dist/mcp-server/tools/fetchPubMedContent/registration.d.ts +0 -11
- package/dist/mcp-server/tools/fetchPubMedContent/registration.d.ts.map +0 -1
- package/dist/mcp-server/tools/fetchPubMedContent/registration.js.map +0 -1
- package/dist/mcp-server/tools/generatePubMedChart/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/generatePubMedChart/index.js.map +0 -1
- package/dist/mcp-server/tools/generatePubMedChart/logic.js.map +0 -1
- package/dist/mcp-server/tools/generatePubMedChart/registration.d.ts +0 -8
- package/dist/mcp-server/tools/generatePubMedChart/registration.js.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/index.d.ts +0 -7
- package/dist/mcp-server/tools/getPubMedArticleConnections/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/index.js +0 -7
- package/dist/mcp-server/tools/getPubMedArticleConnections/index.js.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/citationFormatter.d.ts +0 -10
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/citationFormatter.d.ts.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/citationFormatter.js.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/elinkHandler.d.ts +0 -10
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/elinkHandler.d.ts.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/elinkHandler.js.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/index.js.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/types.d.ts.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/types.js +0 -6
- package/dist/mcp-server/tools/getPubMedArticleConnections/logic/types.js.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/registration.d.ts +0 -12
- package/dist/mcp-server/tools/getPubMedArticleConnections/registration.d.ts.map +0 -1
- package/dist/mcp-server/tools/getPubMedArticleConnections/registration.js.map +0 -1
- package/dist/mcp-server/tools/searchPubMedArticles/index.d.ts +0 -7
- package/dist/mcp-server/tools/searchPubMedArticles/index.js +0 -7
- package/dist/mcp-server/tools/searchPubMedArticles/registration.d.ts +0 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Handles ELink requests and enriches results with ESummary data
|
|
3
|
-
* for the
|
|
4
|
-
* @module src/mcp-server/tools/
|
|
3
|
+
* for the pubmedArticleConnections tool.
|
|
4
|
+
* @module src/mcp-server/tools/pubmedArticleConnections/logic/elinkHandler
|
|
5
5
|
*/
|
|
6
6
|
import { getNcbiService } from "../../../../services/NCBI/core/ncbiService.js";
|
|
7
7
|
import { logger } from "../../../../utils/index.js";
|
|
@@ -34,7 +34,7 @@ export async function handleELinkRelationships(input, outputData, context) {
|
|
|
34
34
|
Object.keys(eLinkParams).forEach((key) => tempUrl.searchParams.append(key, String(eLinkParams[key])));
|
|
35
35
|
outputData.eUtilityUrl = `https://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?${tempUrl.search.substring(1)}`;
|
|
36
36
|
const ncbiService = getNcbiService();
|
|
37
|
-
const eLinkResult = await ncbiService.eLink(eLinkParams, context);
|
|
37
|
+
const eLinkResult = (await ncbiService.eLink(eLinkParams, context));
|
|
38
38
|
// Log the full eLinkResult for debugging
|
|
39
39
|
logger.debug("Raw eLinkResult from ncbiService:", {
|
|
40
40
|
...context,
|
|
@@ -42,10 +42,10 @@ export async function handleELinkRelationships(input, outputData, context) {
|
|
|
42
42
|
});
|
|
43
43
|
// Use ensureArray for robust handling of potentially single or array eLinkResult
|
|
44
44
|
const eLinkResultsArray = ensureArray(eLinkResult?.eLinkResult);
|
|
45
|
-
const firstELinkResult = eLinkResultsArray[0];
|
|
45
|
+
const firstELinkResult = eLinkResultsArray[0];
|
|
46
46
|
// Use ensureArray for LinkSet as well
|
|
47
47
|
const linkSetsArray = ensureArray(firstELinkResult?.LinkSet);
|
|
48
|
-
const linkSet = linkSetsArray[0];
|
|
48
|
+
const linkSet = linkSetsArray[0];
|
|
49
49
|
let foundPmids = [];
|
|
50
50
|
if (firstELinkResult?.ERROR) {
|
|
51
51
|
const errorMsg = typeof firstELinkResult.ERROR === "string"
|
|
@@ -61,15 +61,15 @@ export async function handleELinkRelationships(input, outputData, context) {
|
|
|
61
61
|
const history = Array.isArray(linkSet.LinkSetDbHistory)
|
|
62
62
|
? linkSet.LinkSetDbHistory[0]
|
|
63
63
|
: linkSet.LinkSetDbHistory;
|
|
64
|
-
if (history?.QueryKey &&
|
|
64
|
+
if (history?.QueryKey && firstELinkResult?.LinkSet?.WebEnv) {
|
|
65
65
|
const eSearchParams = {
|
|
66
66
|
db: "pubmed",
|
|
67
67
|
query_key: history.QueryKey,
|
|
68
|
-
WebEnv:
|
|
68
|
+
WebEnv: firstELinkResult.LinkSet.WebEnv,
|
|
69
69
|
retmode: "xml",
|
|
70
70
|
retmax: input.maxRelatedResults * 2, // Fetch a bit more to allow filtering sourcePmid
|
|
71
71
|
};
|
|
72
|
-
const eSearchResult = await ncbiService.eSearch(eSearchParams, context);
|
|
72
|
+
const eSearchResult = (await ncbiService.eSearch(eSearchParams, context));
|
|
73
73
|
if (eSearchResult?.eSearchResult?.IdList?.Id) {
|
|
74
74
|
const ids = ensureArray(eSearchResult.eSearchResult.IdList.Id);
|
|
75
75
|
foundPmids = ids
|
|
@@ -159,7 +159,7 @@ export async function handleELinkRelationships(input, outputData, context) {
|
|
|
159
159
|
version: "2.0",
|
|
160
160
|
retmode: "xml",
|
|
161
161
|
};
|
|
162
|
-
const summaryResultContainer = await ncbiService.eSummary(summaryParams, context);
|
|
162
|
+
const summaryResultContainer = (await ncbiService.eSummary(summaryParams, context));
|
|
163
163
|
const summaryResult = summaryResultContainer?.eSummaryResult ||
|
|
164
164
|
summaryResultContainer?.result ||
|
|
165
165
|
summaryResultContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elinkHandler.js","sourceRoot":"","sources":["../../../../../src/mcp-server/tools/pubmedArticleConnections/logic/elinkHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAK/E,OAAO,EAAE,MAAM,EAAkB,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,wDAAwD,CAAC,CAAC,eAAe;AA0BrG,MAAM,CAAC,K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C;QACR,CAAC;IACH,CAAC;IACD,UAAU,CAAC,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC,MAAM,CAAC;AAChE,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Main logic handler for the '
|
|
2
|
+
* @fileoverview Main logic handler for the 'pubmed_article_connections' MCP tool.
|
|
3
3
|
* Orchestrates calls to ELink or citation formatting handlers.
|
|
4
|
-
* @module src/mcp-server/tools/
|
|
4
|
+
* @module src/mcp-server/tools/pubmedArticleConnections/logic/index
|
|
5
5
|
*/
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { RequestContext } from "../../../../utils/index.js";
|
|
8
8
|
import type { ToolOutputData } from "./types.js";
|
|
9
9
|
/**
|
|
10
|
-
* Zod schema for the input parameters of the '
|
|
10
|
+
* Zod schema for the input parameters of the 'pubmed_article_connections' tool.
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const PubMedArticleConnectionsInputSchema: z.ZodObject<{
|
|
13
13
|
sourcePmid: z.ZodString;
|
|
14
14
|
relationshipType: z.ZodDefault<z.ZodEnum<["pubmed_similar_articles", "pubmed_citedin", "pubmed_references", "citation_formats"]>>;
|
|
15
15
|
maxRelatedResults: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
@@ -26,14 +26,14 @@ export declare const GetPubMedArticleConnectionsInputSchema: z.ZodObject<{
|
|
|
26
26
|
citationStyles?: ("ris" | "bibtex" | "apa_string" | "mla_string")[] | undefined;
|
|
27
27
|
}>;
|
|
28
28
|
/**
|
|
29
|
-
* Type alias for the validated input of the '
|
|
29
|
+
* Type alias for the validated input of the 'pubmed_article_connections' tool.
|
|
30
30
|
*/
|
|
31
|
-
export type
|
|
31
|
+
export type PubMedArticleConnectionsInput = z.infer<typeof PubMedArticleConnectionsInputSchema>;
|
|
32
32
|
/**
|
|
33
|
-
* Main handler for the '
|
|
34
|
-
* @param {
|
|
33
|
+
* Main handler for the 'pubmed_article_connections' tool.
|
|
34
|
+
* @param {PubMedArticleConnectionsInput} input - Validated input parameters.
|
|
35
35
|
* @param {RequestContext} context - The request context for this tool invocation.
|
|
36
36
|
* @returns {Promise<ToolOutputData>} The result of the tool call.
|
|
37
37
|
*/
|
|
38
|
-
export declare function
|
|
38
|
+
export declare function handlePubMedArticleConnections(input: PubMedArticleConnectionsInput, context: RequestContext): Promise<ToolOutputData>;
|
|
39
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/tools/pubmedArticleConnections/logic/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEL,cAAc,EAGf,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;EAmC9C,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,mCAAmC,CAC3C,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAClD,KAAK,EAAE,6BAA6B,EACpC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CAsDzB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Main logic handler for the '
|
|
2
|
+
* @fileoverview Main logic handler for the 'pubmed_article_connections' MCP tool.
|
|
3
3
|
* Orchestrates calls to ELink or citation formatting handlers.
|
|
4
|
-
* @module src/mcp-server/tools/
|
|
4
|
+
* @module src/mcp-server/tools/pubmedArticleConnections/logic/index
|
|
5
5
|
*/
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { BaseErrorCode, McpError } from "../../../../types-global/errors.js";
|
|
@@ -9,9 +9,9 @@ import { logger, requestContextService, sanitizeInputForLogging, } from "../../.
|
|
|
9
9
|
import { handleCitationFormats } from "./citationFormatter.js";
|
|
10
10
|
import { handleELinkRelationships } from "./elinkHandler.js";
|
|
11
11
|
/**
|
|
12
|
-
* Zod schema for the input parameters of the '
|
|
12
|
+
* Zod schema for the input parameters of the 'pubmed_article_connections' tool.
|
|
13
13
|
*/
|
|
14
|
-
export const
|
|
14
|
+
export const PubMedArticleConnectionsInputSchema = z.object({
|
|
15
15
|
sourcePmid: z
|
|
16
16
|
.string()
|
|
17
17
|
.regex(/^\d+$/)
|
|
@@ -24,7 +24,7 @@ export const GetPubMedArticleConnectionsInputSchema = z.object({
|
|
|
24
24
|
"citation_formats",
|
|
25
25
|
])
|
|
26
26
|
.default("pubmed_similar_articles")
|
|
27
|
-
.describe("Specifies the type of connection or action:
|
|
27
|
+
.describe("Specifies the type of connection or action: 'pubmed_similar_articles' (finds similar articles), 'pubmed_citedin' (finds citing articles), 'pubmed_references' (finds referenced articles), or 'citation_formats' (retrieves formatted citations)."),
|
|
28
28
|
maxRelatedResults: z
|
|
29
29
|
.number()
|
|
30
30
|
.int()
|
|
@@ -32,27 +32,27 @@ export const GetPubMedArticleConnectionsInputSchema = z.object({
|
|
|
32
32
|
.max(50, "Maximum 50 related results can be requested.")
|
|
33
33
|
.optional()
|
|
34
34
|
.default(5)
|
|
35
|
-
.describe("Maximum number of related articles to retrieve
|
|
35
|
+
.describe("Maximum number of related articles to retrieve for relationship-based searches. Default is 5, max is 50."),
|
|
36
36
|
citationStyles: z
|
|
37
37
|
.array(z.enum(["ris", "bibtex", "apa_string", "mla_string"]))
|
|
38
38
|
.optional()
|
|
39
39
|
.default(["ris"])
|
|
40
|
-
.describe("An array of citation styles to format the source article into when 'relationshipType' is 'citation_formats'. Supported styles: 'ris', 'bibtex', 'apa_string', 'mla_string'. Default is ['ris'].
|
|
40
|
+
.describe("An array of citation styles to format the source article into when 'relationshipType' is 'citation_formats'. Supported styles: 'ris', 'bibtex', 'apa_string', 'mla_string'. Default is ['ris']."),
|
|
41
41
|
});
|
|
42
42
|
/**
|
|
43
|
-
* Main handler for the '
|
|
44
|
-
* @param {
|
|
43
|
+
* Main handler for the 'pubmed_article_connections' tool.
|
|
44
|
+
* @param {PubMedArticleConnectionsInput} input - Validated input parameters.
|
|
45
45
|
* @param {RequestContext} context - The request context for this tool invocation.
|
|
46
46
|
* @returns {Promise<ToolOutputData>} The result of the tool call.
|
|
47
47
|
*/
|
|
48
|
-
export async function
|
|
48
|
+
export async function handlePubMedArticleConnections(input, context) {
|
|
49
49
|
const toolLogicContext = requestContextService.createRequestContext({
|
|
50
50
|
parentRequestId: context.requestId,
|
|
51
|
-
operation: "
|
|
52
|
-
toolName: "
|
|
51
|
+
operation: "handlePubMedArticleConnections",
|
|
52
|
+
toolName: "pubmed_article_connections",
|
|
53
53
|
input: sanitizeInputForLogging(input),
|
|
54
54
|
});
|
|
55
|
-
logger.info("Executing
|
|
55
|
+
logger.info("Executing pubmed_article_connections tool", toolLogicContext);
|
|
56
56
|
const outputData = {
|
|
57
57
|
sourcePmid: input.sourcePmid,
|
|
58
58
|
relationshipType: input.relationshipType,
|
|
@@ -80,7 +80,7 @@ export async function handleGetPubMedArticleConnections(input, context) {
|
|
|
80
80
|
Object.keys(outputData.citations).length === 0)) {
|
|
81
81
|
outputData.message = "No results found for the given parameters.";
|
|
82
82
|
}
|
|
83
|
-
logger.notice("Successfully executed
|
|
83
|
+
logger.notice("Successfully executed pubmed_article_connections tool.", {
|
|
84
84
|
...toolLogicContext,
|
|
85
85
|
relationshipType: input.relationshipType,
|
|
86
86
|
retrievedCount: outputData.retrievedCount,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/mcp-server/tools/pubmedArticleConnections/logic/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAA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,GAAG,gBAAgB;QACnB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,cAAc,EAAE,UAAU,CAAC,cAAc;QACzC,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM;KAC7D,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Shared type definitions for the
|
|
3
|
-
* @module src/mcp-server/tools/
|
|
2
|
+
* @fileoverview Shared type definitions for the pubmedArticleConnections tool logic.
|
|
3
|
+
* @module src/mcp-server/tools/pubmedArticleConnections/logic/types
|
|
4
4
|
*/
|
|
5
|
-
import type {
|
|
5
|
+
import type { PubMedArticleConnectionsInput } from "./index.js";
|
|
6
6
|
export interface RelatedArticle {
|
|
7
7
|
pmid: string;
|
|
8
8
|
title?: string;
|
|
@@ -18,7 +18,7 @@ export interface CitationOutput {
|
|
|
18
18
|
}
|
|
19
19
|
export interface ToolOutputData {
|
|
20
20
|
sourcePmid: string;
|
|
21
|
-
relationshipType:
|
|
21
|
+
relationshipType: PubMedArticleConnectionsInput["relationshipType"];
|
|
22
22
|
relatedArticles: RelatedArticle[];
|
|
23
23
|
citations: CitationOutput;
|
|
24
24
|
retrievedCount: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/tools/pubmedArticleConnections/logic/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAGhE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,6BAA6B,CAAC,kBAAkB,CAAC,CAAC;IACpE,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,SAAS,EAAE,cAAc,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/mcp-server/tools/pubmedArticleConnections/logic/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Registers the 'pubmed_article_connections' tool with the MCP server.
|
|
3
|
+
* This tool finds articles related to a source PMID or retrieves citation formats.
|
|
4
|
+
* @module src/mcp-server/tools/pubmedArticleConnections/registration
|
|
5
|
+
*/
|
|
6
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
/**
|
|
8
|
+
* Registers the 'pubmed_article_connections' tool with the given MCP server instance.
|
|
9
|
+
* @param {McpServer} server - The MCP server instance.
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerPubMedArticleConnectionsTool(server: McpServer): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/pubmedArticleConnections/registration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAezE;;;GAGG;AACH,wBAAsB,oCAAoC,CACxD,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,IAAI,CAAC,CAmFf"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Registers the '
|
|
2
|
+
* @fileoverview Registers the 'pubmed_article_connections' tool with the MCP server.
|
|
3
3
|
* This tool finds articles related to a source PMID or retrieves citation formats.
|
|
4
|
-
* @module src/mcp-server/tools/
|
|
4
|
+
* @module src/mcp-server/tools/pubmedArticleConnections/registration
|
|
5
5
|
*/
|
|
6
6
|
import { BaseErrorCode, McpError } from "../../../types-global/errors.js";
|
|
7
7
|
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { PubMedArticleConnectionsInputSchema, handlePubMedArticleConnections, } from "./logic/index.js";
|
|
9
9
|
/**
|
|
10
|
-
* Registers the '
|
|
10
|
+
* Registers the 'pubmed_article_connections' tool with the given MCP server instance.
|
|
11
11
|
* @param {McpServer} server - The MCP server instance.
|
|
12
12
|
*/
|
|
13
|
-
export async function
|
|
14
|
-
const operation = "
|
|
15
|
-
const toolName = "
|
|
13
|
+
export async function registerPubMedArticleConnectionsTool(server) {
|
|
14
|
+
const operation = "registerPubMedArticleConnectionsTool";
|
|
15
|
+
const toolName = "pubmed_article_connections";
|
|
16
16
|
const toolDescription = "Finds articles related to a source PubMed ID (PMID) or retrieves formatted citations for it. Supports finding similar articles, articles that cite the source, articles referenced by the source (via NCBI ELink), or fetching data to generate citations in various styles (RIS, BibTeX, APA, MLA via NCBI EFetch and server-side formatting). Returns a JSON object detailing the connections or formatted citations.";
|
|
17
17
|
const context = requestContextService.createRequestContext({ operation });
|
|
18
18
|
await ErrorHandler.tryCatch(async () => {
|
|
19
|
-
server.tool(toolName, toolDescription,
|
|
19
|
+
server.tool(toolName, toolDescription, PubMedArticleConnectionsInputSchema.shape, async (input, mcpProvidedContext) => {
|
|
20
20
|
const richContext = requestContextService.createRequestContext({
|
|
21
21
|
parentRequestId: context.requestId,
|
|
22
|
-
operation: "
|
|
22
|
+
operation: "pubMedArticleConnectionsToolHandler",
|
|
23
23
|
mcpToolContext: mcpProvidedContext,
|
|
24
24
|
input,
|
|
25
25
|
});
|
|
26
26
|
try {
|
|
27
|
-
const result = await
|
|
27
|
+
const result = await handlePubMedArticleConnections(input, richContext);
|
|
28
28
|
return {
|
|
29
29
|
content: [
|
|
30
30
|
{ type: "text", text: JSON.stringify(result, null, 2) },
|
|
@@ -34,7 +34,7 @@ export async function registerGetPubMedArticleConnectionsTool(server) {
|
|
|
34
34
|
}
|
|
35
35
|
catch (error) {
|
|
36
36
|
const handledError = ErrorHandler.handleError(error, {
|
|
37
|
-
operation: "
|
|
37
|
+
operation: "pubMedArticleConnectionsToolHandler",
|
|
38
38
|
context: richContext,
|
|
39
39
|
input,
|
|
40
40
|
rethrow: false,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/pubmedArticleConnections/registration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EACL,YAAY,EACZ,MAAM,EAEN,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,mCAAmC,EACnC,8BAA8B,GAC/B,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oCAAoC,CACxD,MAAiB;IAEjB,MAAM,SAAS,GAAG,sCAAsC,CAAC;IACzD,MAAM,QAAQ,GAAG,4BAA4B,CAAC;IAC9C,MAAM,eAAe,GACnB,yZAAyZ,CAAC;IAC5Z,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAE1E,MAAM,YAAY,CAAC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AAO,EAAE,QAAQ,CAAC,OAAO;oCACzB,OAAO,EAAE,QAAQ,CAAC,OAAO;iCAC1B;6BACF,CAAC;yBACH;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;QACH,CAAC,CACF,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,SAAS,QAAQ,eAAe,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC,EACD;QACE,SAAS;QACT,OAAO;QACP,SAAS,EAAE,aAAa,CAAC,qBAAqB;QAC9C,QAAQ,EAAE,IAAI;KACf,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel file for the pubmed_fetch_contents tool.
|
|
3
|
+
* Exports the tool's registration function.
|
|
4
|
+
* @module src/mcp-server/tools/pubmedFetchContents/index
|
|
5
|
+
*/
|
|
6
|
+
export { registerPubMedFetchContentsTool } from "./registration.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/pubmedFetchContents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel file for the pubmed_fetch_contents tool.
|
|
3
|
+
* Exports the tool's registration function.
|
|
4
|
+
* @module src/mcp-server/tools/pubmedFetchContents/index
|
|
5
|
+
*/
|
|
6
|
+
export { registerPubMedFetchContentsTool } from "./registration.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/pubmedFetchContents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Logic for the
|
|
2
|
+
* @fileoverview Logic for the pubmed_fetch_contents MCP tool.
|
|
3
3
|
* Handles EFetch queries for specific PMIDs and formats the results.
|
|
4
4
|
* This tool can fetch various details from PubMed including abstracts, full XML,
|
|
5
5
|
* MEDLINE text, and citation data.
|
|
6
|
-
* @module src/mcp-server/tools/
|
|
6
|
+
* @module src/mcp-server/tools/pubmedFetchContents/logic
|
|
7
7
|
*/
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { RequestContext } from "../../../utils/index.js";
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const PubMedFetchContentsInputSchema: z.ZodEffects<z.ZodObject<{
|
|
11
11
|
pmids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
12
12
|
queryKey: z.ZodOptional<z.ZodString>;
|
|
13
13
|
webEnv: z.ZodOptional<z.ZodString>;
|
|
@@ -58,11 +58,11 @@ export declare const FetchPubMedContentInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
58
58
|
includeGrantInfo?: boolean | undefined;
|
|
59
59
|
outputFormat?: "json" | "raw_text" | undefined;
|
|
60
60
|
}>;
|
|
61
|
-
export type
|
|
62
|
-
export type
|
|
61
|
+
export type PubMedFetchContentsInput = z.infer<typeof PubMedFetchContentsInputSchema>;
|
|
62
|
+
export type PubMedFetchContentsOutput = {
|
|
63
63
|
content: string;
|
|
64
64
|
articlesReturned: number;
|
|
65
65
|
eFetchUrl: string;
|
|
66
66
|
};
|
|
67
|
-
export declare function
|
|
67
|
+
export declare function pubMedFetchContentsLogic(input: PubMedFetchContentsInput, parentRequestContext: RequestContext): Promise<PubMedFetchContentsOutput>;
|
|
68
68
|
//# sourceMappingURL=logic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/pubmedFetchContents/logic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,EAEL,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAgBjC,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8GvC,CAAC;AAEL,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AA8GF,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,wBAAwB,EAC/B,oBAAoB,EAAE,cAAc,GACnC,OAAO,CAAC,yBAAyB,CAAC,CA0KpC"}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Logic for the
|
|
2
|
+
* @fileoverview Logic for the pubmed_fetch_contents MCP tool.
|
|
3
3
|
* Handles EFetch queries for specific PMIDs and formats the results.
|
|
4
4
|
* This tool can fetch various details from PubMed including abstracts, full XML,
|
|
5
5
|
* MEDLINE text, and citation data.
|
|
6
|
-
* @module src/mcp-server/tools/
|
|
6
|
+
* @module src/mcp-server/tools/pubmedFetchContents/logic
|
|
7
7
|
*/
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { getNcbiService } from "../../../services/NCBI/core/ncbiService.js";
|
|
10
10
|
import { BaseErrorCode, McpError } from "../../../types-global/errors.js";
|
|
11
11
|
import { logger, requestContextService, sanitizeInputForLogging, } from "../../../utils/index.js";
|
|
12
12
|
import { ensureArray, extractAbstractText, extractArticleDates, extractAuthors, extractDoi, extractGrants, extractJournalInfo, extractKeywords, extractMeshTerms, extractPmid, extractPublicationTypes, getText, } from "../../../services/NCBI/parsing/index.js";
|
|
13
|
-
export const
|
|
13
|
+
export const PubMedFetchContentsInputSchema = z
|
|
14
14
|
.object({
|
|
15
15
|
pmids: z
|
|
16
16
|
.array(z.string().regex(/^\d+$/))
|
|
17
17
|
.max(200, "Max 200 PMIDs per call if not using history.")
|
|
18
18
|
.optional()
|
|
19
|
-
.describe("An array of PubMed Unique Identifiers (PMIDs)
|
|
19
|
+
.describe("An array of PubMed Unique Identifiers (PMIDs) to fetch. Use this OR queryKey/webEnv."),
|
|
20
20
|
queryKey: z
|
|
21
21
|
.string()
|
|
22
22
|
.optional()
|
|
23
|
-
.describe("Query key from ESearch history
|
|
23
|
+
.describe("Query key from ESearch history. Requires webEnv. Use this OR pmids."),
|
|
24
24
|
webEnv: z
|
|
25
25
|
.string()
|
|
26
26
|
.optional()
|
|
27
|
-
.describe("Web environment from ESearch history
|
|
27
|
+
.describe("Web environment from ESearch history. Requires queryKey. Use this OR pmids."),
|
|
28
28
|
retstart: z
|
|
29
29
|
.number()
|
|
30
30
|
.int()
|
|
31
31
|
.min(0)
|
|
32
32
|
.optional()
|
|
33
|
-
.describe("
|
|
33
|
+
.describe("0-based index of the first record to retrieve. Used with queryKey/webEnv."),
|
|
34
34
|
retmax: z
|
|
35
35
|
.number()
|
|
36
36
|
.int()
|
|
@@ -41,22 +41,22 @@ export const FetchPubMedContentInputSchema = z
|
|
|
41
41
|
.enum(["abstract_plus", "full_xml", "medline_text", "citation_data"])
|
|
42
42
|
.optional()
|
|
43
43
|
.default("abstract_plus")
|
|
44
|
-
.describe("Specifies the level of detail for the fetched content. Options: 'abstract_plus' (parsed details
|
|
44
|
+
.describe("Specifies the level of detail for the fetched content. Options: 'abstract_plus' (parsed details), 'full_xml' (raw PubMedArticle XML), 'medline_text' (MEDLINE format), 'citation_data' (minimal citation data). Defaults to 'abstract_plus'."),
|
|
45
45
|
includeMeshTerms: z
|
|
46
46
|
.boolean()
|
|
47
47
|
.optional()
|
|
48
48
|
.default(true)
|
|
49
|
-
.describe("
|
|
49
|
+
.describe("Include MeSH terms in 'abstract_plus' and 'citation_data' results. Default: true."),
|
|
50
50
|
includeGrantInfo: z
|
|
51
51
|
.boolean()
|
|
52
52
|
.optional()
|
|
53
53
|
.default(false)
|
|
54
|
-
.describe("
|
|
54
|
+
.describe("Include grant info in 'abstract_plus' results. Default: false."),
|
|
55
55
|
outputFormat: z
|
|
56
56
|
.enum(["json", "raw_text"])
|
|
57
57
|
.optional()
|
|
58
58
|
.default("json")
|
|
59
|
-
.describe("
|
|
59
|
+
.describe("Output format. 'json' (default) wraps data in a JSON object. 'raw_text' returns raw text for 'medline_text' or 'full_xml' detail levels."),
|
|
60
60
|
})
|
|
61
61
|
.superRefine((data, ctx) => {
|
|
62
62
|
if (data.queryKey && !data.webEnv) {
|
|
@@ -168,18 +168,18 @@ function parsePubMedArticleSet(xmlData, input, parentContext) {
|
|
|
168
168
|
}
|
|
169
169
|
return articles;
|
|
170
170
|
}
|
|
171
|
-
export async function
|
|
171
|
+
export async function pubMedFetchContentsLogic(input, parentRequestContext) {
|
|
172
172
|
const toolLogicContext = requestContextService.createRequestContext({
|
|
173
173
|
parentRequestId: parentRequestContext.requestId,
|
|
174
|
-
operation: "
|
|
174
|
+
operation: "pubMedFetchContentsLogic",
|
|
175
175
|
input: sanitizeInputForLogging(input),
|
|
176
176
|
});
|
|
177
|
-
const validationResult =
|
|
177
|
+
const validationResult = PubMedFetchContentsInputSchema.safeParse(input);
|
|
178
178
|
if (!validationResult.success) {
|
|
179
179
|
throw new McpError(BaseErrorCode.VALIDATION_ERROR, validationResult.error.errors[0]?.message || "Invalid input", { ...toolLogicContext, details: validationResult.error.flatten() });
|
|
180
180
|
}
|
|
181
181
|
const ncbiService = getNcbiService();
|
|
182
|
-
logger.info("Executing
|
|
182
|
+
logger.info("Executing pubmed_fetch_contents tool", toolLogicContext);
|
|
183
183
|
const eFetchParams = { db: "pubmed" };
|
|
184
184
|
if (input.queryKey && input.webEnv) {
|
|
185
185
|
eFetchParams.query_key = input.queryKey;
|
|
@@ -242,7 +242,8 @@ export async function fetchPubMedContentLogic(input, parentRequestContext) {
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
else if (input.detailLevel === "full_xml") {
|
|
245
|
-
const articlesXml = ensureArray(eFetchResponseData
|
|
245
|
+
const articlesXml = ensureArray(eFetchResponseData
|
|
246
|
+
?.PubmedArticleSet?.PubmedArticle || []);
|
|
246
247
|
articlesCount = articlesXml.length;
|
|
247
248
|
if (input.outputFormat === "raw_text") {
|
|
248
249
|
// Note: Raw XML output is requested, but we still parse to get an accurate count.
|
|
@@ -299,7 +300,7 @@ export async function fetchPubMedContentLogic(input, parentRequestContext) {
|
|
|
299
300
|
eFetchDetails: { urls: [eFetchUrl] },
|
|
300
301
|
});
|
|
301
302
|
}
|
|
302
|
-
logger.notice("Successfully executed
|
|
303
|
+
logger.notice("Successfully executed pubmed_fetch_contents tool.", {
|
|
303
304
|
...toolLogicContext,
|
|
304
305
|
articlesReturned: articlesCount,
|
|
305
306
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logic.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/pubmedFetchContents/logic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAM1E,OAAO,EACL,MAAM,EAEN,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,uBAAuB,EACvB,OAAO,GACR,MAAM,yCAAyC,CAAC;AAEjD,MAAM,CAAC,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AE,OAAO,CAAC,WAAW,EAAE,eAAe;oBACrD,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM;oBACnC,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK;oBACjC,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK;oBACjC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE,eAAe,EAAE,IAAI;iBACjD;gBACD,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,GAAG,CAAC,KAAK,CAAC,gBAAgB,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;aAChE,CAAC,CAAC,CAAC;QACN,CAAC;QACD,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC;YAC/B,cAAc,EAAE,KAAK,CAAC,KAAK,IAAI,qBAAqB;YACpD,QAAQ,EAAE,gBAAgB;YAC1B,aAAa;YACb,aAAa,EAAE,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE;SACrC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,mDAAmD,EAAE;QACjE,GAAG,gBAAgB;QACnB,gBAAgB,EAAE,aAAa;KAChC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,eAAe;QACxB,gBAAgB,EAAE,aAAa;QAC/B,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Registration for the pubmed_fetch_contents MCP tool.
|
|
3
|
+
* @module src/mcp-server/tools/pubmedFetchContents/registration
|
|
4
|
+
*/
|
|
5
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
/**
|
|
7
|
+
* Registers the pubmed_fetch_contents tool with the MCP server.
|
|
8
|
+
* @param server - The McpServer instance.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerPubMedFetchContentsTool(server: McpServer): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/pubmedFetchContents/registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAepE;;;GAGG;AACH,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,IAAI,CAAC,CAgFf"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Registration for the
|
|
3
|
-
* @module src/mcp-server/tools/
|
|
2
|
+
* @fileoverview Registration for the pubmed_fetch_contents MCP tool.
|
|
3
|
+
* @module src/mcp-server/tools/pubmedFetchContents/registration
|
|
4
4
|
*/
|
|
5
5
|
import { BaseErrorCode, McpError } from "../../../types-global/errors.js";
|
|
6
6
|
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { PubMedFetchContentsInputSchema, pubMedFetchContentsLogic, } from "./logic.js";
|
|
8
8
|
/**
|
|
9
|
-
* Registers the
|
|
9
|
+
* Registers the pubmed_fetch_contents tool with the MCP server.
|
|
10
10
|
* @param server - The McpServer instance.
|
|
11
11
|
*/
|
|
12
|
-
export async function
|
|
13
|
-
const operation = "
|
|
14
|
-
const toolName = "
|
|
15
|
-
const toolDescription = "Fetches detailed information from PubMed using NCBI EFetch. Can be used with a direct list of PMIDs or with queryKey/webEnv from an ESearch history entry. Supports pagination (retstart, retmax) when using history. Available 'detailLevel' options: 'abstract_plus' (parsed
|
|
12
|
+
export async function registerPubMedFetchContentsTool(server) {
|
|
13
|
+
const operation = "registerPubMedFetchContentsTool";
|
|
14
|
+
const toolName = "pubmed_fetch_contents";
|
|
15
|
+
const toolDescription = "Fetches detailed information from PubMed using NCBI EFetch. Can be used with a direct list of PMIDs or with queryKey/webEnv from an ESearch history entry. Supports pagination (retstart, retmax) when using history. Available 'detailLevel' options: 'abstract_plus' (parsed details), 'full_xml' (raw PubMedArticle XML), 'medline_text' (MEDLINE format), or 'citation_data' (minimal citation data). Returns a JSON object containing results, any PMIDs not found (if applicable), and EFetch details.";
|
|
16
16
|
const context = requestContextService.createRequestContext({ operation });
|
|
17
17
|
await ErrorHandler.tryCatch(async () => {
|
|
18
|
-
server.tool(toolName, toolDescription,
|
|
18
|
+
server.tool(toolName, toolDescription, PubMedFetchContentsInputSchema._def.schema.shape, async (input, toolContext) => {
|
|
19
19
|
const richContext = requestContextService.createRequestContext({
|
|
20
20
|
parentRequestId: context.requestId,
|
|
21
|
-
operation: "
|
|
21
|
+
operation: "pubMedFetchContentsToolHandler",
|
|
22
22
|
mcpToolContext: toolContext,
|
|
23
23
|
input,
|
|
24
24
|
});
|
|
25
25
|
try {
|
|
26
|
-
const result = await
|
|
26
|
+
const result = await pubMedFetchContentsLogic(input, richContext);
|
|
27
27
|
return {
|
|
28
28
|
content: [{ type: "text", text: result.content }],
|
|
29
29
|
isError: false,
|
|
@@ -31,7 +31,7 @@ export async function registerFetchPubMedContentTool(server) {
|
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
33
|
const handledError = ErrorHandler.handleError(error, {
|
|
34
|
-
operation: "
|
|
34
|
+
operation: "pubMedFetchContentsToolHandler",
|
|
35
35
|
context: richContext,
|
|
36
36
|
input,
|
|
37
37
|
rethrow: false,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/pubmedFetchContents/registration.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EACL,YAAY,EACZ,MAAM,EAEN,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,8BAA8B,EAC9B,wBAAwB,GACzB,MAAM,YAAY,CAAC;AAEpB;;;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