@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,9 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* request
|
|
2
|
+
* @fileoverview Implements a stateless transport manager for the MCP SDK.
|
|
3
|
+
*
|
|
4
|
+
* This manager handles single, ephemeral MCP operations. For each incoming request,
|
|
5
|
+
* it dynamically creates a temporary McpServer and transport instance, processes the
|
|
6
|
+
* request, and then immediately schedules the resources for cleanup. This approach
|
|
7
|
+
* is ideal for simple, one-off tool calls that do not require persistent session state.
|
|
8
|
+
*
|
|
9
|
+
* The key challenge addressed here is bridging the Node.js-centric MCP SDK with
|
|
10
|
+
* modern, Web Standards-based frameworks like Hono. This is achieved by deferring
|
|
11
|
+
* resource cleanup until the response stream has been fully consumed by the web
|
|
12
|
+
* framework, preventing premature closure and truncated responses.
|
|
13
|
+
*
|
|
7
14
|
* @module src/mcp-server/transports/core/statelessTransportManager
|
|
8
15
|
*/
|
|
9
16
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
@@ -11,10 +18,23 @@ import { Readable } from "stream";
|
|
|
11
18
|
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
12
19
|
import { BaseTransportManager } from "./baseTransportManager.js";
|
|
13
20
|
import { HonoStreamResponse } from "./honoNodeBridge.js";
|
|
21
|
+
import { convertNodeHeadersToWebHeaders } from "./headerUtils.js";
|
|
14
22
|
/**
|
|
15
|
-
*
|
|
23
|
+
* Manages ephemeral, single-request MCP operations.
|
|
16
24
|
*/
|
|
17
25
|
export class StatelessTransportManager extends BaseTransportManager {
|
|
26
|
+
/**
|
|
27
|
+
* Handles a single, stateless MCP request.
|
|
28
|
+
*
|
|
29
|
+
* This method orchestrates the creation of temporary server and transport instances,
|
|
30
|
+
* handles the request, and ensures resources are cleaned up only after the
|
|
31
|
+
* response stream is closed.
|
|
32
|
+
*
|
|
33
|
+
* @param headers - The incoming request headers.
|
|
34
|
+
* @param body - The parsed body of the request.
|
|
35
|
+
* @param context - The request context for logging and tracing.
|
|
36
|
+
* @returns A promise resolving to a streaming TransportResponse.
|
|
37
|
+
*/
|
|
18
38
|
async handleRequest(headers, body, context) {
|
|
19
39
|
const opContext = {
|
|
20
40
|
...context,
|
|
@@ -24,6 +44,7 @@ export class StatelessTransportManager extends BaseTransportManager {
|
|
|
24
44
|
let server;
|
|
25
45
|
let transport;
|
|
26
46
|
try {
|
|
47
|
+
// 1. Create ephemeral instances for this request.
|
|
27
48
|
server = await this.createServerInstanceFn();
|
|
28
49
|
transport = new StreamableHTTPServerTransport({
|
|
29
50
|
sessionIdGenerator: undefined,
|
|
@@ -31,45 +52,73 @@ export class StatelessTransportManager extends BaseTransportManager {
|
|
|
31
52
|
});
|
|
32
53
|
await server.connect(transport);
|
|
33
54
|
logger.debug("Ephemeral server connected to transport.", opContext);
|
|
55
|
+
// 2. Set up the Node.js-to-Web stream bridge.
|
|
34
56
|
const mockReq = {
|
|
35
57
|
headers,
|
|
36
58
|
method: "POST",
|
|
37
59
|
};
|
|
38
|
-
const
|
|
60
|
+
const mockResBridge = new HonoStreamResponse();
|
|
61
|
+
// 3. Defer cleanup until the stream is fully processed.
|
|
62
|
+
// This is the critical fix to prevent premature resource release.
|
|
63
|
+
this.setupDeferredCleanup(mockResBridge, server, transport, opContext);
|
|
64
|
+
// 4. Process the request using the MCP transport.
|
|
65
|
+
const mockRes = mockResBridge;
|
|
39
66
|
await transport.handleRequest(mockReq, mockRes, body);
|
|
40
67
|
logger.info("Stateless request handled successfully.", opContext);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
// Bridge the Node.js stream (PassThrough) to a Web Stream (ReadableStream)
|
|
46
|
-
const webStream = Readable.toWeb(mockRes);
|
|
68
|
+
// 5. Convert headers and create the final streaming response.
|
|
69
|
+
const responseHeaders = convertNodeHeadersToWebHeaders(mockRes.getHeaders());
|
|
70
|
+
const webStream = Readable.toWeb(mockResBridge);
|
|
47
71
|
return {
|
|
72
|
+
type: "stream",
|
|
48
73
|
headers: responseHeaders,
|
|
49
74
|
statusCode: mockRes.statusCode,
|
|
50
75
|
stream: webStream,
|
|
51
76
|
};
|
|
52
77
|
}
|
|
53
78
|
catch (error) {
|
|
79
|
+
// If an error occurs before the stream is returned, we must clean up immediately.
|
|
80
|
+
if (server || transport) {
|
|
81
|
+
this.cleanup(server, transport, opContext);
|
|
82
|
+
}
|
|
54
83
|
throw ErrorHandler.handleError(error, {
|
|
55
84
|
operation: "StatelessTransportManager.handleRequest",
|
|
56
85
|
context: opContext,
|
|
57
86
|
rethrow: true,
|
|
58
87
|
});
|
|
59
88
|
}
|
|
60
|
-
finally {
|
|
61
|
-
if (server || transport) {
|
|
62
|
-
this.cleanup(server, transport, opContext);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
89
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Attaches listeners to the response stream to trigger resource cleanup
|
|
92
|
+
* only after the stream has been fully consumed or has errored.
|
|
93
|
+
*
|
|
94
|
+
* @param stream - The response stream bridge.
|
|
95
|
+
* @param server - The ephemeral McpServer instance.
|
|
96
|
+
* @param transport - The ephemeral transport instance.
|
|
97
|
+
* @param context - The request context for logging.
|
|
98
|
+
*/
|
|
99
|
+
setupDeferredCleanup(stream, server, transport, context) {
|
|
100
|
+
let cleanedUp = false;
|
|
101
|
+
const cleanupFn = (error) => {
|
|
102
|
+
if (cleanedUp)
|
|
103
|
+
return;
|
|
104
|
+
cleanedUp = true;
|
|
105
|
+
if (error) {
|
|
106
|
+
logger.warning("Stream ended with an error, proceeding to cleanup.", {
|
|
107
|
+
...context,
|
|
108
|
+
error: error.message,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
// Cleanup is fire-and-forget.
|
|
112
|
+
this.cleanup(server, transport, context);
|
|
113
|
+
};
|
|
114
|
+
// 'close' is the most reliable event, firing on both normal completion and abrupt termination.
|
|
115
|
+
stream.on("close", () => cleanupFn());
|
|
116
|
+
stream.on("error", (err) => cleanupFn(err));
|
|
72
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Performs the actual cleanup of ephemeral resources.
|
|
120
|
+
* This method is designed to be "fire-and-forget".
|
|
121
|
+
*/
|
|
73
122
|
cleanup(server, transport, context) {
|
|
74
123
|
const opContext = {
|
|
75
124
|
...context,
|
|
@@ -89,5 +138,16 @@ export class StatelessTransportManager extends BaseTransportManager {
|
|
|
89
138
|
});
|
|
90
139
|
});
|
|
91
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Shuts down the manager. For the stateless manager, this is a no-op
|
|
143
|
+
* as there are no persistent resources to manage.
|
|
144
|
+
*/
|
|
145
|
+
async shutdown() {
|
|
146
|
+
const context = requestContextService.createRequestContext({
|
|
147
|
+
operation: "StatelessTransportManager.shutdown",
|
|
148
|
+
});
|
|
149
|
+
logger.info("Stateless transport manager shutdown - no persistent resources to clean up.", context);
|
|
150
|
+
return Promise.resolve();
|
|
151
|
+
}
|
|
92
152
|
}
|
|
93
153
|
//# sourceMappingURL=statelessTransportManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statelessTransportManager.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/statelessTransportManager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"statelessTransportManager.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/statelessTransportManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EACL,YAAY,EACZ,MAAM,EAEN,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAGlE;;GAEG;AACH,MAAM,OAAO,yBAA0B,SAAQ,oBAAoB;IACjE;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pD,OAAuB;QAEvB,MAAM,SAAS,GAAG;YAChB,GAAG,OAAO;YACV,SAAS,EAAE,mCAAmC;SAC/C,CAAC;QACF,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE,SAAS,CAAC,CAAC;QAEvE,OAAO,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;aAC/C,IAAI,CAAC,GAAG,EAAE;YACT,MAAM,CAAC,KAAK,CAAC,8CAA8C,EAAE,SAAS,CAAC,CAAC;QAC1E,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,YAAY,EAAE,EAAE;YACtB,MAAM,CAAC,OAAO,CAAC,0CAA0C,EAAE;gBACzD,GAAG,SAAS;gBACZ,KAAK,EACH,YAAY,YAAY,KAAK;oBAC3B,CAAC,CAAC,YAAY,CAAC,OAAO;oBACtB,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;aAC3B,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ;QACZ,MAAM,OAAO,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,SAAS,EAAE,oCAAoC;SAChD,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CACT,6EAA6E,EAC7E,OAAO,CACR,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -1,69 +1,106 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
2
|
+
* @fileoverview Defines the core types and interfaces for the transport layer abstraction.
|
|
3
|
+
* This module establishes the data contracts and abstract interfaces that decouple
|
|
4
|
+
* the MCP server's core logic from specific transport implementations like HTTP or stdio.
|
|
3
5
|
* @module src/mcp-server/transports/core/transportTypes
|
|
4
6
|
*/
|
|
5
7
|
import type { IncomingHttpHeaders } from "http";
|
|
6
8
|
import { RequestContext } from "../../../utils/index.js";
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
10
|
+
* Defines the set of valid HTTP status codes that the transport layer can return.
|
|
11
|
+
* This ensures type safety and consistency in response handling.
|
|
9
12
|
*/
|
|
10
13
|
export type HttpStatusCode = 200 | 201 | 400 | 401 | 403 | 404 | 409 | 429 | 500 | 502 | 503;
|
|
11
14
|
/**
|
|
12
|
-
*
|
|
15
|
+
* A base interface for all transport responses, containing common properties.
|
|
13
16
|
*/
|
|
14
|
-
|
|
17
|
+
interface BaseTransportResponse {
|
|
15
18
|
sessionId?: string;
|
|
16
19
|
headers: Headers;
|
|
17
20
|
statusCode: HttpStatusCode;
|
|
18
|
-
body?: unknown;
|
|
19
|
-
stream?: ReadableStream<Uint8Array>;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
|
-
* Represents
|
|
23
|
+
* Represents a transport response where the entire body is buffered in memory.
|
|
24
|
+
* Suitable for small, non-streamed responses.
|
|
25
|
+
*/
|
|
26
|
+
export interface BufferedTransportResponse extends BaseTransportResponse {
|
|
27
|
+
type: "buffered";
|
|
28
|
+
body: unknown;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Represents a transport response that streams its body.
|
|
32
|
+
* Essential for handling large or chunked responses efficiently without high memory usage.
|
|
33
|
+
*/
|
|
34
|
+
export interface StreamingTransportResponse extends BaseTransportResponse {
|
|
35
|
+
type: "stream";
|
|
36
|
+
stream: ReadableStream<Uint8Array>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A discriminated union representing the possible types of a transport response.
|
|
40
|
+
* Using a discriminated union on the `type` property allows for type-safe handling
|
|
41
|
+
* of different response formats (buffered vs. streamed).
|
|
42
|
+
*/
|
|
43
|
+
export type TransportResponse = BufferedTransportResponse | StreamingTransportResponse;
|
|
44
|
+
/**
|
|
45
|
+
* Represents the state of an active, persistent transport session.
|
|
23
46
|
*/
|
|
24
47
|
export interface TransportSession {
|
|
25
48
|
id: string;
|
|
26
49
|
createdAt: Date;
|
|
27
50
|
lastAccessedAt: Date;
|
|
51
|
+
/**
|
|
52
|
+
* A counter for requests currently being processed for this session.
|
|
53
|
+
* This is a critical mechanism to prevent race conditions where a session
|
|
54
|
+
* might be garbage-collected while a long-running request is still in flight.
|
|
55
|
+
* It is incremented when a request begins and decremented when it finishes.
|
|
56
|
+
*/
|
|
57
|
+
activeRequests: number;
|
|
28
58
|
}
|
|
29
59
|
/**
|
|
30
|
-
*
|
|
31
|
-
* This
|
|
60
|
+
* Defines the abstract interface for a transport manager.
|
|
61
|
+
* This contract ensures that any transport manager, regardless of its statefulness,
|
|
62
|
+
* provides a consistent way to handle requests and manage its lifecycle.
|
|
32
63
|
*/
|
|
33
64
|
export interface TransportManager {
|
|
34
65
|
/**
|
|
35
66
|
* Handles an incoming request.
|
|
36
|
-
* @param headers The request headers.
|
|
67
|
+
* @param headers The incoming request headers.
|
|
37
68
|
* @param body The parsed body of the request.
|
|
38
|
-
* @param context
|
|
39
|
-
* @param sessionId
|
|
40
|
-
* @returns A promise
|
|
69
|
+
* @param context The request context for logging, tracing, and metadata.
|
|
70
|
+
* @param sessionId An optional session identifier for stateful operations.
|
|
71
|
+
* @returns A promise that resolves to a TransportResponse object.
|
|
41
72
|
*/
|
|
42
73
|
handleRequest(headers: IncomingHttpHeaders, body: unknown, context: RequestContext, sessionId?: string): Promise<TransportResponse>;
|
|
43
74
|
/**
|
|
44
|
-
*
|
|
75
|
+
* Gracefully shuts down the transport manager, cleaning up any resources.
|
|
45
76
|
*/
|
|
46
77
|
shutdown(): Promise<void>;
|
|
47
78
|
}
|
|
48
79
|
/**
|
|
49
|
-
* Extends the base TransportManager with
|
|
80
|
+
* Extends the base TransportManager with operations specific to stateful sessions.
|
|
50
81
|
*/
|
|
51
82
|
export interface StatefulTransportManager extends TransportManager {
|
|
52
83
|
/**
|
|
53
|
-
* Initializes a new session and handles the request.
|
|
54
|
-
* @param headers The request headers.
|
|
84
|
+
* Initializes a new stateful session and handles the first request.
|
|
85
|
+
* @param headers The incoming request headers.
|
|
55
86
|
* @param body The parsed body of the request.
|
|
56
|
-
* @param context
|
|
57
|
-
* @returns A promise resolving to a TransportResponse.
|
|
87
|
+
* @param context The request context.
|
|
88
|
+
* @returns A promise resolving to a TransportResponse, which will include a session ID.
|
|
58
89
|
*/
|
|
59
90
|
initializeAndHandle(headers: IncomingHttpHeaders, body: unknown, context: RequestContext): Promise<TransportResponse>;
|
|
60
91
|
/**
|
|
61
|
-
* Handles a
|
|
92
|
+
* Handles a request to explicitly delete a session.
|
|
93
|
+
* @param sessionId The ID of the session to delete.
|
|
94
|
+
* @param context The request context.
|
|
95
|
+
* @returns A promise resolving to a TransportResponse confirming closure.
|
|
62
96
|
*/
|
|
63
97
|
handleDeleteRequest(sessionId: string, context: RequestContext): Promise<TransportResponse>;
|
|
64
98
|
/**
|
|
65
|
-
* Retrieves session
|
|
99
|
+
* Retrieves information about a specific session.
|
|
100
|
+
* @param sessionId The ID of the session to retrieve.
|
|
101
|
+
* @returns A TransportSession object if the session exists, otherwise undefined.
|
|
66
102
|
*/
|
|
67
103
|
getSession(sessionId: string): TransportSession | undefined;
|
|
68
104
|
}
|
|
105
|
+
export {};
|
|
69
106
|
//# sourceMappingURL=transportTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transportTypes.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/transportTypes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"transportTypes.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/transportTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GA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,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE9B;;;;OAIG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;CAC7D"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview
|
|
2
|
+
* @fileoverview Defines the core types and interfaces for the transport layer abstraction.
|
|
3
|
+
* This module establishes the data contracts and abstract interfaces that decouple
|
|
4
|
+
* the MCP server's core logic from specific transport implementations like HTTP or stdio.
|
|
3
5
|
* @module src/mcp-server/transports/core/transportTypes
|
|
4
6
|
*/
|
|
5
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transportTypes.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/transportTypes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"transportTypes.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/transportTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
* @module src/mcp-server/transports/http/httpTransport
|
|
6
6
|
*/
|
|
7
7
|
import { ServerType } from "@hono/node-server";
|
|
8
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
8
|
import { Hono } from "hono";
|
|
10
9
|
import { RequestContext } from "../../../utils/index.js";
|
|
10
|
+
import { ServerInstanceInfo } from "../../server.js";
|
|
11
11
|
import { TransportManager } from "../core/transportTypes.js";
|
|
12
12
|
import { HonoNodeBindings } from "./httpTypes.js";
|
|
13
|
-
export declare function createHttpApp(transportManager: TransportManager, createServerInstanceFn: () => Promise<
|
|
13
|
+
export declare function createHttpApp(transportManager: TransportManager, createServerInstanceFn: () => Promise<ServerInstanceInfo>, parentContext: RequestContext): Hono<{
|
|
14
14
|
Bindings: HonoNodeBindings;
|
|
15
15
|
}>;
|
|
16
|
-
export declare function startHttpTransport(createServerInstanceFn: () => Promise<
|
|
16
|
+
export declare function startHttpTransport(createServerInstanceFn: () => Promise<ServerInstanceInfo>, parentContext: RequestContext): Promise<{
|
|
17
17
|
app: Hono<{
|
|
18
18
|
Bindings: HonoNodeBindings;
|
|
19
19
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpTransport.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/httpTransport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAS,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"httpTransport.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/httpTransport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAS,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAW,IAAI,EAAQ,MAAM,MAAM,CAAC;AAK3C,OAAO,EAGL,cAAc,EAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAkMlD,wBAAgB,aAAa,CAC3B,gBAAgB,EAAE,gBAAgB,EAClC,sBAAsB,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,EACzD,aAAa,EAAE,cAAc,GAC5B,IAAI,CAAC;IAAE,QAAQ,EAAE,gBAAgB,CAAA;CAAE,CAAC,CAiMtC;AAED,wBAAsB,kBAAkB,CACtC,sBAAsB,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,EACzD,aAAa,EAAE,cAAc,GAC5B,OAAO,CAAC;IACT,GAAG,EAAE,IAAI,CAAC;QAAE,QAAQ,EAAE,gBAAgB,CAAA;KAAE,CAAC,CAAC;IAC1C,MAAM,EAAE,UAAU,CAAC;IACnB,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,CAAC,CA4BD"}
|
|
@@ -12,13 +12,24 @@ import http from "http";
|
|
|
12
12
|
import { config } from "../../../config/index.js";
|
|
13
13
|
import { logger, rateLimiter, requestContextService, } from "../../../utils/index.js";
|
|
14
14
|
import { createAuthMiddleware, createAuthStrategy } from "../auth/index.js";
|
|
15
|
-
import { StatefulTransportManager } from "../core/statefulTransportManager.js";
|
|
16
15
|
import { StatelessTransportManager } from "../core/statelessTransportManager.js";
|
|
16
|
+
import { StatefulTransportManager } from "./../core/statefulTransportManager.js";
|
|
17
17
|
import { httpErrorHandler } from "./httpErrorHandler.js";
|
|
18
18
|
import { mcpTransportMiddleware } from "./mcpTransportMiddleware.js";
|
|
19
19
|
const HTTP_PORT = config.mcpHttpPort;
|
|
20
20
|
const HTTP_HOST = config.mcpHttpHost;
|
|
21
21
|
const MCP_ENDPOINT_PATH = config.mcpHttpEndpointPath;
|
|
22
|
+
/**
|
|
23
|
+
* Extracts the client IP address from the request, prioritizing common proxy headers.
|
|
24
|
+
* @param c - The Hono context object.
|
|
25
|
+
* @returns The client's IP address or a default string if not found.
|
|
26
|
+
*/
|
|
27
|
+
function getClientIp(c) {
|
|
28
|
+
const forwardedFor = c.req.header("x-forwarded-for");
|
|
29
|
+
return ((forwardedFor?.split(",")[0] ?? "").trim() ||
|
|
30
|
+
c.req.header("x-real-ip") ||
|
|
31
|
+
"unknown_ip");
|
|
32
|
+
}
|
|
22
33
|
/**
|
|
23
34
|
* Converts a Fetch API Headers object to Node.js IncomingHttpHeaders.
|
|
24
35
|
* Hono uses Fetch API Headers, but the underlying transport managers expect
|
|
@@ -94,7 +105,8 @@ function startHttpServerWithRetry(app, initialPort, host, maxRetries, parentCont
|
|
|
94
105
|
}
|
|
95
106
|
})
|
|
96
107
|
.catch((err) => {
|
|
97
|
-
|
|
108
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
109
|
+
logger.fatal("Failed to check if port is in use.", error, attemptContext);
|
|
98
110
|
reject(err);
|
|
99
111
|
});
|
|
100
112
|
};
|
|
@@ -108,15 +120,20 @@ function createTransportManager(createServerInstanceFn, sessionMode, context) {
|
|
|
108
120
|
sessionMode,
|
|
109
121
|
};
|
|
110
122
|
logger.info(`Creating transport manager for session mode: ${sessionMode}`, opContext);
|
|
123
|
+
const statefulOptions = {
|
|
124
|
+
staleSessionTimeoutMs: config.mcpStatefulSessionStaleTimeoutMs,
|
|
125
|
+
mcpHttpEndpointPath: config.mcpHttpEndpointPath,
|
|
126
|
+
};
|
|
127
|
+
const getMcpServer = async () => (await createServerInstanceFn()).server;
|
|
111
128
|
switch (sessionMode) {
|
|
112
129
|
case "stateless":
|
|
113
|
-
return new StatelessTransportManager(
|
|
130
|
+
return new StatelessTransportManager(getMcpServer);
|
|
114
131
|
case "stateful":
|
|
115
|
-
return new StatefulTransportManager(
|
|
132
|
+
return new StatefulTransportManager(getMcpServer, statefulOptions);
|
|
116
133
|
case "auto":
|
|
117
134
|
default:
|
|
118
135
|
logger.info("Defaulting to 'auto' mode (stateful with stateless fallback).", opContext);
|
|
119
|
-
return new StatefulTransportManager(
|
|
136
|
+
return new StatefulTransportManager(getMcpServer, statefulOptions);
|
|
120
137
|
}
|
|
121
138
|
}
|
|
122
139
|
export function createHttpApp(transportManager, createServerInstanceFn, parentContext) {
|
|
@@ -142,10 +159,7 @@ export function createHttpApp(transportManager, createServerInstanceFn, parentCo
|
|
|
142
159
|
await next();
|
|
143
160
|
});
|
|
144
161
|
app.use(MCP_ENDPOINT_PATH, async (c, next) => {
|
|
145
|
-
const
|
|
146
|
-
const clientIp = (forwardedFor?.split(",")[0] ?? "").trim() ||
|
|
147
|
-
c.req.header("x-real-ip") ||
|
|
148
|
-
"unknown_ip";
|
|
162
|
+
const clientIp = getClientIp(c);
|
|
149
163
|
const context = requestContextService.createRequestContext({
|
|
150
164
|
operation: "httpRateLimitCheck",
|
|
151
165
|
ipAddress: clientIp,
|
|
@@ -178,15 +192,33 @@ export function createHttpApp(transportManager, createServerInstanceFn, parentCo
|
|
|
178
192
|
timestamp: new Date().toISOString(),
|
|
179
193
|
});
|
|
180
194
|
});
|
|
181
|
-
app.get(MCP_ENDPOINT_PATH, (c) => {
|
|
195
|
+
app.get(MCP_ENDPOINT_PATH, async (c) => {
|
|
182
196
|
const sessionId = c.req.header("mcp-session-id");
|
|
183
197
|
if (sessionId) {
|
|
184
198
|
return c.text("GET requests to existing sessions are not supported.", 405);
|
|
185
199
|
}
|
|
200
|
+
// Since this is a stateless endpoint, we create a temporary instance
|
|
201
|
+
// to report on the server's configuration.
|
|
202
|
+
const { tools, identity, options } = await createServerInstanceFn();
|
|
203
|
+
const effectiveSessionMode = transportManager instanceof StatefulTransportManager
|
|
204
|
+
? "stateful"
|
|
205
|
+
: "stateless";
|
|
186
206
|
return c.json({
|
|
187
207
|
status: "ok",
|
|
188
|
-
|
|
189
|
-
|
|
208
|
+
server: {
|
|
209
|
+
name: identity.name,
|
|
210
|
+
version: identity.version,
|
|
211
|
+
description: identity.description || "No description provided.",
|
|
212
|
+
nodeVersion: process.version,
|
|
213
|
+
environment: config.environment,
|
|
214
|
+
capabilities: options.capabilities,
|
|
215
|
+
},
|
|
216
|
+
sessionMode: {
|
|
217
|
+
configured: config.mcpSessionMode,
|
|
218
|
+
effective: effectiveSessionMode,
|
|
219
|
+
},
|
|
220
|
+
tools: tools,
|
|
221
|
+
message: "Server is running. POST to this endpoint to execute a tool call.",
|
|
190
222
|
});
|
|
191
223
|
});
|
|
192
224
|
app.post(MCP_ENDPOINT_PATH, mcpTransportMiddleware(transportManager, createServerInstanceFn), (c) => {
|
|
@@ -198,16 +230,16 @@ export function createHttpApp(transportManager, createServerInstanceFn, parentCo
|
|
|
198
230
|
c.header(key, value);
|
|
199
231
|
});
|
|
200
232
|
c.status(response.statusCode);
|
|
201
|
-
if (response.stream) {
|
|
233
|
+
if (response.type === "stream") {
|
|
202
234
|
return stream(c, async (s) => {
|
|
203
|
-
|
|
204
|
-
await s.pipe(response.stream);
|
|
205
|
-
}
|
|
235
|
+
await s.pipe(response.stream);
|
|
206
236
|
});
|
|
207
237
|
}
|
|
208
238
|
else {
|
|
209
|
-
|
|
210
|
-
|
|
239
|
+
const body = typeof response.body === "object" && response.body !== null
|
|
240
|
+
? response.body
|
|
241
|
+
: { body: response.body };
|
|
242
|
+
return c.json(body);
|
|
211
243
|
}
|
|
212
244
|
});
|
|
213
245
|
app.delete(MCP_ENDPOINT_PATH, async (c) => {
|
|
@@ -220,8 +252,14 @@ export function createHttpApp(transportManager, createServerInstanceFn, parentCo
|
|
|
220
252
|
if (sessionId) {
|
|
221
253
|
if (transportManager instanceof StatefulTransportManager) {
|
|
222
254
|
const response = await transportManager.handleDeleteRequest(sessionId, context);
|
|
223
|
-
|
|
224
|
-
|
|
255
|
+
if (response.type === "buffered") {
|
|
256
|
+
const body = typeof response.body === "object" && response.body !== null
|
|
257
|
+
? response.body
|
|
258
|
+
: { body: response.body };
|
|
259
|
+
return c.json(body, response.statusCode);
|
|
260
|
+
}
|
|
261
|
+
// Fallback for unexpected stream response on DELETE
|
|
262
|
+
return c.body(null, response.statusCode);
|
|
225
263
|
}
|
|
226
264
|
else {
|
|
227
265
|
return c.json({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpTransport.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/httpTransport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAc,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAW,IAAI,EAAQ,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EACL,MAAM,EACN,WAAW,EAEX,qBAAqB,GACtB,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import {
|
|
8
|
+
import { MiddlewareHandler } from "hono";
|
|
9
|
+
import { ServerInstanceInfo } from "../../server.js";
|
|
9
10
|
import { TransportManager, TransportResponse } from "../core/transportTypes.js";
|
|
10
11
|
import { HonoNodeBindings } from "./httpTypes.js";
|
|
11
12
|
/**
|
|
@@ -19,8 +20,8 @@ type McpMiddlewareEnv = {
|
|
|
19
20
|
mcpResponse: TransportResponse;
|
|
20
21
|
};
|
|
21
22
|
};
|
|
22
|
-
export declare const mcpTransportMiddleware: (transportManager: TransportManager, createServerInstanceFn: () => Promise<
|
|
23
|
+
export declare const mcpTransportMiddleware: (transportManager: TransportManager, createServerInstanceFn: () => Promise<ServerInstanceInfo>) => MiddlewareHandler<McpMiddlewareEnv & {
|
|
23
24
|
Bindings: HonoNodeBindings;
|
|
24
|
-
}
|
|
25
|
+
}>;
|
|
25
26
|
export {};
|
|
26
27
|
//# sourceMappingURL=mcpTransportMiddleware.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpTransportMiddleware.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/mcpTransportMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"mcpTransportMiddleware.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/transports/http/mcpTransportMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAKzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAsClD;;;;;GAKG;AAEH,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE;QACT,WAAW,EAAE,iBAAiB,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,kBAAkB,gBAAgB,EAClC,wBAAwB,MAAM,OAAO,CAAC,kBAAkB,CAAC,KACxD,iBAAiB,CAAC,gBAAgB,GAAG;IAAE,QAAQ,EAAE,gBAAgB,CAAA;CAAE,CAmDrE,CAAC"}
|