@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,29 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Registration for the
|
|
3
|
-
* @module src/mcp-server/tools/
|
|
2
|
+
* @fileoverview Registration for the pubmed_search_articles MCP tool.
|
|
3
|
+
* @module src/mcp-server/tools/pubmedSearchArticles/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 { PubMedSearchArticlesInputSchema, pubmedSearchArticlesLogic, } from "./logic.js";
|
|
8
8
|
/**
|
|
9
|
-
* Registers the
|
|
9
|
+
* Registers the pubmed_search_articles 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 = "Searches PubMed for articles using a query term and optional filters (max results, sort, date range, publication types). Uses NCBI ESearch to find PMIDs and ESummary (optional) for brief summaries. Returns a JSON object with search parameters, ESearch term, result counts, PMIDs, optional summaries
|
|
12
|
+
export async function registerPubMedSearchArticlesTool(server) {
|
|
13
|
+
const operation = "registerPubMedSearchArticlesTool";
|
|
14
|
+
const toolName = "pubmed_search_articles";
|
|
15
|
+
const toolDescription = "Searches PubMed for articles using a query term and optional filters (max results, sort, date range, publication types). Uses NCBI ESearch to find PMIDs and ESummary (optional) for brief summaries. Returns a JSON object with search parameters, ESearch term, result counts, PMIDs, optional summaries, and E-utility URLs.";
|
|
16
16
|
const context = requestContextService.createRequestContext({ operation });
|
|
17
17
|
await ErrorHandler.tryCatch(async () => {
|
|
18
|
-
server.tool(toolName, toolDescription,
|
|
18
|
+
server.tool(toolName, toolDescription, PubMedSearchArticlesInputSchema.shape, async (input, mcpProvidedContext) => {
|
|
19
19
|
const richContext = requestContextService.createRequestContext({
|
|
20
20
|
parentRequestId: context.requestId,
|
|
21
|
-
operation: "
|
|
21
|
+
operation: "pubmedSearchArticlesToolHandler",
|
|
22
22
|
mcpToolContext: mcpProvidedContext,
|
|
23
23
|
input,
|
|
24
24
|
});
|
|
25
25
|
try {
|
|
26
|
-
const result = await
|
|
26
|
+
const result = await pubmedSearchArticlesLogic(input, richContext);
|
|
27
27
|
return {
|
|
28
28
|
content: [
|
|
29
29
|
{ type: "text", text: JSON.stringify(result, null, 2) },
|
|
@@ -33,7 +33,7 @@ export async function registerSearchPubMedArticlesTool(server) {
|
|
|
33
33
|
}
|
|
34
34
|
catch (error) {
|
|
35
35
|
const handledError = ErrorHandler.handleError(error, {
|
|
36
|
-
operation: "
|
|
36
|
+
operation: "pubmedSearchArticlesToolHandler",
|
|
37
37
|
context: richContext,
|
|
38
38
|
input,
|
|
39
39
|
rethrow: false,
|
package/dist/mcp-server/tools/{searchPubMedArticles → pubmedSearchArticles}/registration.js.map
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/
|
|
1
|
+
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/pubmedSearchArticles/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,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,MAAiB;IAEjB,MAAM,SAAS,GAAG,kCAAkC,CAAC;IACrD,MAAM,QAAQ,GAAG,wBAAwB,CAAC;IAC1C,MAAM,eAAe,GACnB,iUAAiU,CAAC;IACpU,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAE1E,MAAM,YAAY,CAAC,QAAQ,CACzB,KAAK,IAAI,EAAE;QACT,MAAM,CAAC,IAAI,CACT,QAAQ,EACR,eAAe,EACf,+BAA+B,CAAC,KAAK,EACrC,KAAK,EACH,KAAgC,EAChC,kBAA2B,EACF,EAAE;YAC3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H,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"}
|
|
@@ -8,7 +8,7 @@ export { withRequiredScopes } from "./lib/authUtils.js";
|
|
|
8
8
|
export type { AuthInfo } from "./lib/authTypes.js";
|
|
9
9
|
export { createAuthStrategy } from "./authFactory.js";
|
|
10
10
|
export { createAuthMiddleware } from "./authMiddleware.js";
|
|
11
|
-
export { AuthStrategy } from "./strategies/authStrategy.js";
|
|
11
|
+
export type { AuthStrategy } from "./strategies/authStrategy.js";
|
|
12
12
|
export { JwtStrategy } from "./strategies/jwtStrategy.js";
|
|
13
13
|
export { OauthStrategy } from "./strategies/oauthStrategy.js";
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwtStrategy.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/jwtStrategy.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,qBAAa,WAAY,YAAW,YAAY;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;;IAkCxC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"jwtStrategy.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/jwtStrategy.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,qBAAa,WAAY,YAAW,YAAY;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;;IAkCxC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CAkH/C"}
|
|
@@ -94,6 +94,10 @@ export class JwtStrategy {
|
|
|
94
94
|
return authInfo;
|
|
95
95
|
}
|
|
96
96
|
catch (error) {
|
|
97
|
+
// If the error is already a structured McpError, re-throw it directly.
|
|
98
|
+
if (error instanceof McpError) {
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
97
101
|
const message = error instanceof Error && error.name === "JWTExpired"
|
|
98
102
|
? "Token has expired."
|
|
99
103
|
: "Token verification failed.";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwtStrategy.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/jwtStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,MAAM,EACN,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAIpC,MAAM,OAAO,WAAW;IACL,SAAS,CAAoB;IAE9C;QACE,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,SAAS,EAAE,yBAAyB;SACrC,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;QAErD,IAAI,MAAM,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;YACjC,IAAI,WAAW,KAAK,YAAY,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;gBAC7D,MAAM,CAAC,KAAK,CACV,sEAAsE,EACtE,OAAO,CACR,CAAC;gBACF,MAAM,IAAI,QAAQ,CAChB,aAAa,CAAC,mBAAmB,EACjC,6DAA6D,EAC7D,OAAO,CACR,CAAC;YACJ,CAAC;iBAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;gBACpC,MAAM,CAAC,OAAO,CACZ,uEAAuE,EACvE,OAAO,CACR,CAAC;gBACF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACxB,CAAC;iBAAM,CAAC;gBACN,MAAM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,8BAA8B,EAAE;gBAC1C,GAAG,OAAO;gBACV,QAAQ;gBACR,MAAM;aACP,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;gBACnD,CAAC,CAAC,oBAAoB;gBACtB,CAAC,CAAC,4BAA4B,CAAC;YAEnC,MAAM,CAAC,OAAO,CAAC,4BAA4B,OAAO,EAAE,EAAE;gBACpD,GAAG,OAAO;gBACV,SAAS,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;aAC3D,CAAC,CAAC;YAEH,MAAM,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE;gBACpC,SAAS,EAAE,oBAAoB;gBAC/B,OAAO;gBACP,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,aAAa,CAAC,YAAY;gBACrC,WAAW,EAAE,GAAG,EAAE,CAChB,IAAI,QAAQ,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC;aAC7D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"jwtStrategy.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/jwtStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,MAAM,EACN,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAIpC,MAAM,OAAO,WAAW;IACL,SAAS,CAAoB;IAE9C;QACE,MAAM,OAAO,GAAG,qBAAqB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ACpC,SAAS,EAAE,oBAAoB;gBAC/B,OAAO;gBACP,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,aAAa,CAAC,YAAY;gBACrC,WAAW,EAAE,GAAG,EAAE,CAChB,IAAI,QAAQ,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC;aAC7D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauthStrategy.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/oauthStrategy.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,qBAAa,aAAc,YAAW,YAAY;IAChD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAwC;;IAoDvD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"oauthStrategy.d.ts","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/oauthStrategy.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,qBAAa,aAAc,YAAW,YAAY;IAChD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAwC;;IAoDvD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;CAgF/C"}
|
|
@@ -83,6 +83,10 @@ export class OauthStrategy {
|
|
|
83
83
|
return authInfo;
|
|
84
84
|
}
|
|
85
85
|
catch (error) {
|
|
86
|
+
// If the error is already a structured McpError, re-throw it directly.
|
|
87
|
+
if (error instanceof McpError) {
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
86
90
|
const message = error instanceof Error && error.name === "JWTExpired"
|
|
87
91
|
? "Token has expired."
|
|
88
92
|
: "OAuth token verification failed.";
|
|
@@ -90,6 +94,7 @@ export class OauthStrategy {
|
|
|
90
94
|
...context,
|
|
91
95
|
errorName: error instanceof Error ? error.name : "Unknown",
|
|
92
96
|
});
|
|
97
|
+
// For all other errors, use the ErrorHandler to wrap them.
|
|
93
98
|
throw ErrorHandler.handleError(error, {
|
|
94
99
|
operation: "OauthStrategy.verify",
|
|
95
100
|
context,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauthStrategy.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/oauthStrategy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAmB,MAAM,MAAM,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,MAAM,EACN,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAIpC,MAAM,OAAO,aAAa;IACP,IAAI,CAAwC;IAE7D;QACE,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,SAAS,EAAE,2BAA2B;SACvC,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,OAAO,CAAC,CAAC;QAEvD,IAAI,MAAM,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YACnC,kFAAkF;YAClF,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YACpD,MAAM,CAAC,KAAK,CACV,2EAA2E,EAC3E,OAAO,CACR,CAAC;YACF,yEAAyE;YACzE,MAAM,IAAI,QAAQ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;YACH,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GACX,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;gBACnD,CAAC,CAAC,oBAAoB;gBACtB,CAAC,CAAC,kCAAkC,CAAC;YAEzC,MAAM,CAAC,OAAO,CAAC,oCAAoC,OAAO,EAAE,EAAE;gBAC5D,GAAG,OAAO;gBACV,SAAS,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;aAC3D,CAAC,CAAC;YAEH,MAAM,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE;gBACpC,SAAS,EAAE,sBAAsB;gBACjC,OAAO;gBACP,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,aAAa,CAAC,YAAY;gBACrC,WAAW,EAAE,GAAG,EAAE,CAChB,IAAI,QAAQ,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC;aAC7D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"oauthStrategy.js","sourceRoot":"","sources":["../../../../../src/mcp-server/transports/auth/strategies/oauthStrategy.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAmB,MAAM,MAAM,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,YAAY,EACZ,MAAM,EACN,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAIpC,MAAM,OAAO,aAAa;IACP,IAAI,CAAwC;IAE7D;QACE,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,SAAS,EAAE,2BAA2B;SACvC,CAAC,CAAC;QACH,MAA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Provides a utility for converting HTTP headers between Node.js
|
|
3
|
+
* and Web Standards formats, ensuring compliance and correctness.
|
|
4
|
+
* @module src/mcp-server/transports/core/headerUtils
|
|
5
|
+
*/
|
|
6
|
+
import type { OutgoingHttpHeaders } from "http";
|
|
7
|
+
/**
|
|
8
|
+
* Converts Node.js-style OutgoingHttpHeaders to a Web-standard Headers object.
|
|
9
|
+
*
|
|
10
|
+
* This function is critical for interoperability between Node.js's `http` module
|
|
11
|
+
* and Web APIs like Fetch and Hono. It correctly handles multi-value headers
|
|
12
|
+
* (e.g., `Set-Cookie`), which Node.js represents as an array of strings, by
|
|
13
|
+
* using the `Headers.append()` method. Standard single-value headers are set
|
|
14
|
+
* using `Headers.set()`.
|
|
15
|
+
*
|
|
16
|
+
* @param nodeHeaders - The Node.js-style headers object to convert.
|
|
17
|
+
* @returns A Web-standard Headers object.
|
|
18
|
+
*/
|
|
19
|
+
export declare function convertNodeHeadersToWebHeaders(nodeHeaders: OutgoingHttpHeaders): Headers;
|
|
20
|
+
//# sourceMappingURL=headerUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerUtils.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/headerUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAEhD;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,mBAAmB,GAC/B,OAAO,CAmBT"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Provides a utility for converting HTTP headers between Node.js
|
|
3
|
+
* and Web Standards formats, ensuring compliance and correctness.
|
|
4
|
+
* @module src/mcp-server/transports/core/headerUtils
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Converts Node.js-style OutgoingHttpHeaders to a Web-standard Headers object.
|
|
8
|
+
*
|
|
9
|
+
* This function is critical for interoperability between Node.js's `http` module
|
|
10
|
+
* and Web APIs like Fetch and Hono. It correctly handles multi-value headers
|
|
11
|
+
* (e.g., `Set-Cookie`), which Node.js represents as an array of strings, by
|
|
12
|
+
* using the `Headers.append()` method. Standard single-value headers are set
|
|
13
|
+
* using `Headers.set()`.
|
|
14
|
+
*
|
|
15
|
+
* @param nodeHeaders - The Node.js-style headers object to convert.
|
|
16
|
+
* @returns A Web-standard Headers object.
|
|
17
|
+
*/
|
|
18
|
+
export function convertNodeHeadersToWebHeaders(nodeHeaders) {
|
|
19
|
+
const webHeaders = new Headers();
|
|
20
|
+
for (const [key, value] of Object.entries(nodeHeaders)) {
|
|
21
|
+
// Skip undefined headers, which are valid in Node.js but not in Web Headers.
|
|
22
|
+
if (value === undefined) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
// For arrays, append each value to support multi-value headers.
|
|
27
|
+
for (const v of value) {
|
|
28
|
+
webHeaders.append(key, String(v));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// For single values, set the header, overwriting any existing value.
|
|
33
|
+
webHeaders.set(key, String(value));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return webHeaders;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=headerUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headerUtils.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/headerUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,8BAA8B,CAC5C,WAAgC;IAEhC,MAAM,UAAU,GAAG,IAAI,OAAO,EAAE,CAAC;IACjC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACvD,6EAA6E;QAC7E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,gEAAgE;YAChE,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;gBACtB,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;aAAM,CAAC;YACN,qEAAqE;YACrE,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1,24 +1,77 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Provides a bridge between the MCP SDK's Node.js-style
|
|
2
|
+
* @fileoverview Provides a high-fidelity bridge between the MCP SDK's Node.js-style
|
|
3
3
|
* streamable HTTP transport and Hono's Web Standards-based streaming response.
|
|
4
|
+
* This class is essential for adapting the Node.js `http.ServerResponse` API
|
|
5
|
+
* to a format consumable by modern web frameworks.
|
|
4
6
|
* @module src/mcp-server/transports/core/honoNodeBridge
|
|
5
7
|
*/
|
|
6
8
|
import { PassThrough } from "stream";
|
|
9
|
+
import type { OutgoingHttpHeaders } from "http";
|
|
7
10
|
/**
|
|
8
|
-
* A mock ServerResponse that pipes
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
+
* A mock `http.ServerResponse` that pipes all written data to a `PassThrough` stream.
|
|
12
|
+
*
|
|
13
|
+
* This class serves as a critical compatibility layer, emulating the behavior of a
|
|
14
|
+
* Node.js `ServerResponse` to capture status codes, headers, and the response body.
|
|
15
|
+
* The captured data can then be used to construct a Web-standard `Response` object,
|
|
16
|
+
* for instance in a Hono application. It pays close attention to the timing of when
|
|
17
|
+
* headers are considered "sent" to mimic Node.js behavior accurately.
|
|
11
18
|
*/
|
|
12
19
|
export declare class HonoStreamResponse extends PassThrough {
|
|
13
20
|
statusCode: number;
|
|
14
|
-
headers:
|
|
21
|
+
headers: OutgoingHttpHeaders;
|
|
22
|
+
private _headersSent;
|
|
15
23
|
constructor();
|
|
16
|
-
|
|
24
|
+
/**
|
|
25
|
+
* A getter that reports whether the headers have been sent.
|
|
26
|
+
* In this emulation, headers are considered sent the first time `write()` or `end()` is called.
|
|
27
|
+
*/
|
|
28
|
+
get headersSent(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the status code and headers for the response, mimicking `http.ServerResponse.writeHead`.
|
|
31
|
+
*
|
|
32
|
+
* @param statusCode - The HTTP status code.
|
|
33
|
+
* @param statusMessageOrHeaders - An optional status message (string) or headers object.
|
|
34
|
+
* @param headers - An optional headers object, used if the second argument is a status message.
|
|
35
|
+
* @returns The instance of the class for chaining.
|
|
36
|
+
*/
|
|
37
|
+
writeHead(statusCode: number, statusMessageOrHeaders?: string | OutgoingHttpHeaders, headers?: OutgoingHttpHeaders): this;
|
|
38
|
+
/**
|
|
39
|
+
* Sets a single header value.
|
|
40
|
+
*
|
|
41
|
+
* @param name - The name of the header.
|
|
42
|
+
* @param value - The value of the header.
|
|
43
|
+
* @returns The instance of the class for chaining.
|
|
44
|
+
*/
|
|
17
45
|
setHeader(name: string, value: string | number | string[]): this;
|
|
46
|
+
/**
|
|
47
|
+
* Gets a header that has been queued for the response.
|
|
48
|
+
* @param name - The name of the header.
|
|
49
|
+
* @returns The value of the header, or undefined if not set.
|
|
50
|
+
*/
|
|
18
51
|
getHeader(name: string): string | number | string[] | undefined;
|
|
19
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Returns a copy of the current outgoing headers.
|
|
54
|
+
*/
|
|
55
|
+
getHeaders(): OutgoingHttpHeaders;
|
|
56
|
+
/**
|
|
57
|
+
* Removes a header that has been queued for the response.
|
|
58
|
+
* @param name - The name of the header to remove.
|
|
59
|
+
*/
|
|
20
60
|
removeHeader(name: string): void;
|
|
61
|
+
/**
|
|
62
|
+
* A private helper to mark headers as sent. This is called implicitly
|
|
63
|
+
* before any part of the body is written.
|
|
64
|
+
*/
|
|
65
|
+
private ensureHeadersSent;
|
|
66
|
+
/**
|
|
67
|
+
* Writes a chunk of the response body, mimicking `http.ServerResponse.write`.
|
|
68
|
+
* This is the first point where headers are implicitly flushed.
|
|
69
|
+
*/
|
|
21
70
|
write(chunk: unknown, encodingOrCallback?: BufferEncoding | ((error: Error | null | undefined) => void), callback?: (error: Error | null | undefined) => void): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Finishes sending the response, mimicking `http.ServerResponse.end`.
|
|
73
|
+
* This also implicitly flushes headers if they haven't been sent yet.
|
|
74
|
+
*/
|
|
22
75
|
end(chunk?: unknown, encodingOrCallback?: BufferEncoding | (() => void), callback?: () => void): this;
|
|
23
76
|
}
|
|
24
77
|
//# sourceMappingURL=honoNodeBridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honoNodeBridge.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/honoNodeBridge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"honoNodeBridge.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/honoNodeBridge.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAEhD;;;;;;;;GAQG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;IAC1C,UAAU,SAAO;IACjB,OAAO,EAAE,mBAAmB,CAAM;IACzC,OAAO,CAAC,YAAY,CAAS;;IAM7B;;;OAGG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;;;;;;OAOG;IACH,SAAS,CACP,UAAU,EAAE,MAAM,EAClB,sBAAsB,CAAC,EAAE,MAAM,GAAG,mBAAmB,EACrD,OAAO,CAAC,EAAE,mBAAmB,GAC5B,IAAI;IAsBP;;;;;;OAMG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAahE;;;;OAIG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;IAI/D;;OAEG;IACH,UAAU,IAAI,mBAAmB;IAIjC;;;OAGG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAUhC;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAMzB;;;OAGG;IACH,KAAK,CACH,KAAK,EAAE,OAAO,EACd,kBAAkB,CAAC,EACf,cAAc,GACd,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC,EAC/C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,GACnD,OAAO;IAcV;;;OAGG;IACH,GAAG,CACD,KAAK,CAAC,EAAE,OAAO,EACf,kBAAkB,CAAC,EAAE,cAAc,GAAG,CAAC,MAAM,IAAI,CAAC,EAClD,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,IAAI;CAeR"}
|
|
@@ -1,51 +1,138 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Provides a bridge between the MCP SDK's Node.js-style
|
|
2
|
+
* @fileoverview Provides a high-fidelity bridge between the MCP SDK's Node.js-style
|
|
3
3
|
* streamable HTTP transport and Hono's Web Standards-based streaming response.
|
|
4
|
+
* This class is essential for adapting the Node.js `http.ServerResponse` API
|
|
5
|
+
* to a format consumable by modern web frameworks.
|
|
4
6
|
* @module src/mcp-server/transports/core/honoNodeBridge
|
|
5
7
|
*/
|
|
6
8
|
import { PassThrough } from "stream";
|
|
7
9
|
/**
|
|
8
|
-
* A mock ServerResponse that pipes
|
|
9
|
-
*
|
|
10
|
-
*
|
|
10
|
+
* A mock `http.ServerResponse` that pipes all written data to a `PassThrough` stream.
|
|
11
|
+
*
|
|
12
|
+
* This class serves as a critical compatibility layer, emulating the behavior of a
|
|
13
|
+
* Node.js `ServerResponse` to capture status codes, headers, and the response body.
|
|
14
|
+
* The captured data can then be used to construct a Web-standard `Response` object,
|
|
15
|
+
* for instance in a Hono application. It pays close attention to the timing of when
|
|
16
|
+
* headers are considered "sent" to mimic Node.js behavior accurately.
|
|
11
17
|
*/
|
|
12
18
|
export class HonoStreamResponse extends PassThrough {
|
|
13
19
|
statusCode = 200;
|
|
14
20
|
headers = {};
|
|
21
|
+
_headersSent = false;
|
|
15
22
|
constructor() {
|
|
16
23
|
super();
|
|
17
24
|
}
|
|
18
|
-
|
|
25
|
+
/**
|
|
26
|
+
* A getter that reports whether the headers have been sent.
|
|
27
|
+
* In this emulation, headers are considered sent the first time `write()` or `end()` is called.
|
|
28
|
+
*/
|
|
29
|
+
get headersSent() {
|
|
30
|
+
return this._headersSent;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Sets the status code and headers for the response, mimicking `http.ServerResponse.writeHead`.
|
|
34
|
+
*
|
|
35
|
+
* @param statusCode - The HTTP status code.
|
|
36
|
+
* @param statusMessageOrHeaders - An optional status message (string) or headers object.
|
|
37
|
+
* @param headers - An optional headers object, used if the second argument is a status message.
|
|
38
|
+
* @returns The instance of the class for chaining.
|
|
39
|
+
*/
|
|
40
|
+
writeHead(statusCode, statusMessageOrHeaders, headers) {
|
|
41
|
+
if (this._headersSent) {
|
|
42
|
+
// Per Node.js spec, do nothing if headers are already sent.
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
19
45
|
this.statusCode = statusCode;
|
|
20
|
-
|
|
21
|
-
|
|
46
|
+
const headersArg = typeof statusMessageOrHeaders === "string"
|
|
47
|
+
? headers
|
|
48
|
+
: statusMessageOrHeaders;
|
|
49
|
+
if (headersArg) {
|
|
50
|
+
for (const [key, value] of Object.entries(headersArg)) {
|
|
51
|
+
if (value !== undefined) {
|
|
52
|
+
this.setHeader(key, value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
22
55
|
}
|
|
23
56
|
return this;
|
|
24
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Sets a single header value.
|
|
60
|
+
*
|
|
61
|
+
* @param name - The name of the header.
|
|
62
|
+
* @param value - The value of the header.
|
|
63
|
+
* @returns The instance of the class for chaining.
|
|
64
|
+
*/
|
|
25
65
|
setHeader(name, value) {
|
|
66
|
+
if (this._headersSent) {
|
|
67
|
+
// This is a deviation from Node.js (which would throw), but provides a
|
|
68
|
+
// more graceful warning for this emulation layer.
|
|
69
|
+
console.warn(`[HonoBridge] Warning: Cannot set header "${name}" after headers are sent.`);
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
26
72
|
this.headers[name.toLowerCase()] = value;
|
|
27
73
|
return this;
|
|
28
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Gets a header that has been queued for the response.
|
|
77
|
+
* @param name - The name of the header.
|
|
78
|
+
* @returns The value of the header, or undefined if not set.
|
|
79
|
+
*/
|
|
29
80
|
getHeader(name) {
|
|
30
81
|
return this.headers[name.toLowerCase()];
|
|
31
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns a copy of the current outgoing headers.
|
|
85
|
+
*/
|
|
32
86
|
getHeaders() {
|
|
33
|
-
return this.headers;
|
|
87
|
+
return { ...this.headers };
|
|
34
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Removes a header that has been queued for the response.
|
|
91
|
+
* @param name - The name of the header to remove.
|
|
92
|
+
*/
|
|
35
93
|
removeHeader(name) {
|
|
94
|
+
if (this._headersSent) {
|
|
95
|
+
console.warn(`[HonoBridge] Warning: Cannot remove header "${name}" after headers are sent.`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
36
98
|
delete this.headers[name.toLowerCase()];
|
|
37
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* A private helper to mark headers as sent. This is called implicitly
|
|
102
|
+
* before any part of the body is written.
|
|
103
|
+
*/
|
|
104
|
+
ensureHeadersSent() {
|
|
105
|
+
if (!this._headersSent) {
|
|
106
|
+
this._headersSent = true;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Writes a chunk of the response body, mimicking `http.ServerResponse.write`.
|
|
111
|
+
* This is the first point where headers are implicitly flushed.
|
|
112
|
+
*/
|
|
38
113
|
write(chunk, encodingOrCallback, callback) {
|
|
114
|
+
this.ensureHeadersSent();
|
|
39
115
|
const encoding = typeof encodingOrCallback === "string" ? encodingOrCallback : undefined;
|
|
40
116
|
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
41
|
-
|
|
42
|
-
|
|
117
|
+
if (encoding) {
|
|
118
|
+
return super.write(chunk, encoding, cb);
|
|
119
|
+
}
|
|
120
|
+
return super.write(chunk, cb);
|
|
43
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Finishes sending the response, mimicking `http.ServerResponse.end`.
|
|
124
|
+
* This also implicitly flushes headers if they haven't been sent yet.
|
|
125
|
+
*/
|
|
44
126
|
end(chunk, encodingOrCallback, callback) {
|
|
127
|
+
this.ensureHeadersSent();
|
|
45
128
|
const encoding = typeof encodingOrCallback === "string" ? encodingOrCallback : undefined;
|
|
46
129
|
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
47
|
-
|
|
48
|
-
|
|
130
|
+
if (encoding) {
|
|
131
|
+
super.end(chunk, encoding, cb);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
super.end(chunk, cb);
|
|
135
|
+
}
|
|
49
136
|
return this;
|
|
50
137
|
}
|
|
51
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"honoNodeBridge.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/honoNodeBridge.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"honoNodeBridge.js","sourceRoot":"","sources":["../../../../src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;OAGG;IACH,GAAG,CACD,KAAe,EACf,kBAAkD,EAClD,QAAqB;QAErB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAEzB,MAAM,QAAQ,GACZ,OAAO,kBAAkB,KAAK,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1E,MAAM,EAAE,GACN,OAAO,kBAAkB,KAAK,UAAU,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC;QAE3E,IAAI,QAAQ,EAAE,CAAC;YACb,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* @fileoverview Implements a stateful transport manager for the MCP SDK.
|
|
3
|
+
*
|
|
4
|
+
* This manager handles multiple, persistent MCP sessions. It creates and maintains
|
|
5
|
+
* a dedicated McpServer and StreamableHTTPServerTransport instance for each session,
|
|
6
|
+
* allowing for stateful, multi-turn interactions. It includes robust mechanisms for
|
|
7
|
+
* session lifecycle management, including garbage collection of stale sessions and
|
|
8
|
+
* concurrency controls to prevent race conditions.
|
|
9
|
+
*
|
|
10
|
+
* SCALABILITY NOTE: This manager maintains all session state in local process memory.
|
|
11
|
+
* For horizontal scaling across multiple server instances, a load balancer with
|
|
12
|
+
* sticky sessions (session affinity) is required to ensure that all requests for a
|
|
13
|
+
* given session are routed to the same process instance that holds that session's state.
|
|
14
|
+
*
|
|
7
15
|
* @module src/mcp-server/transports/core/statefulTransportManager
|
|
8
16
|
*/
|
|
9
17
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -12,21 +20,58 @@ import { RequestContext } from "../../../utils/index.js";
|
|
|
12
20
|
import { BaseTransportManager } from "./baseTransportManager.js";
|
|
13
21
|
import { StatefulTransportManager as IStatefulTransportManager, TransportResponse, TransportSession } from "./transportTypes.js";
|
|
14
22
|
/**
|
|
15
|
-
*
|
|
16
|
-
|
|
23
|
+
* Defines the configuration options for the StatefulTransportManager.
|
|
24
|
+
*/
|
|
25
|
+
export interface StatefulTransportOptions {
|
|
26
|
+
staleSessionTimeoutMs: number;
|
|
27
|
+
mcpHttpEndpointPath: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Manages persistent, stateful MCP sessions.
|
|
17
31
|
*/
|
|
18
32
|
export declare class StatefulTransportManager extends BaseTransportManager implements IStatefulTransportManager {
|
|
19
33
|
private readonly transports;
|
|
20
34
|
private readonly servers;
|
|
21
35
|
private readonly sessions;
|
|
22
36
|
private readonly garbageCollector;
|
|
23
|
-
|
|
37
|
+
private readonly options;
|
|
38
|
+
/**
|
|
39
|
+
* @param createServerInstanceFn - A factory function to create new McpServer instances.
|
|
40
|
+
* @param options - Configuration options for the manager.
|
|
41
|
+
*/
|
|
42
|
+
constructor(createServerInstanceFn: () => Promise<McpServer>, options: StatefulTransportOptions);
|
|
43
|
+
/**
|
|
44
|
+
* Initializes a new stateful session and handles the first request.
|
|
45
|
+
*
|
|
46
|
+
* @param headers - The incoming request headers.
|
|
47
|
+
* @param body - The parsed body of the request.
|
|
48
|
+
* @param context - The request context.
|
|
49
|
+
* @returns A promise resolving to a streaming TransportResponse with a session ID.
|
|
50
|
+
*/
|
|
24
51
|
initializeAndHandle(headers: IncomingHttpHeaders, body: unknown, context: RequestContext): Promise<TransportResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Handles a subsequent request for an existing stateful session.
|
|
54
|
+
*/
|
|
25
55
|
handleRequest(headers: IncomingHttpHeaders, body: unknown, context: RequestContext, sessionId?: string): Promise<TransportResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* Handles a request to explicitly delete a session.
|
|
58
|
+
*/
|
|
26
59
|
handleDeleteRequest(sessionId: string, context: RequestContext): Promise<TransportResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves information about a specific session.
|
|
62
|
+
*/
|
|
27
63
|
getSession(sessionId: string): TransportSession | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Gracefully shuts down the manager, closing all active sessions.
|
|
66
|
+
*/
|
|
28
67
|
shutdown(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Closes a single session and releases its associated resources.
|
|
70
|
+
*/
|
|
29
71
|
private closeSession;
|
|
72
|
+
/**
|
|
73
|
+
* Periodically runs to find and clean up stale, inactive sessions.
|
|
74
|
+
*/
|
|
30
75
|
private cleanupStaleSessions;
|
|
31
76
|
}
|
|
32
77
|
//# sourceMappingURL=statefulTransportManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statefulTransportManager.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/statefulTransportManager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"statefulTransportManager.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/statefulTransportManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,MAAM,CAAC;AAIhE,OAAO,EAGL,cAAc,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,OAAO,EAEL,wBAAwB,IAAI,yBAAyB,EACrD,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mB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