@ibm/ibmi-mcp-server 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2178 -46
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +57 -24
- package/dist/config/index.js.map +1 -1
- package/dist/config/resolver.d.ts.map +1 -1
- package/dist/config/resolver.js.map +1 -1
- package/dist/ibmi-mcp-server/auth/httpAuthEndpoint.js +1 -1
- package/dist/ibmi-mcp-server/services/connectionPool.js +2 -2
- package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts +80 -0
- package/dist/ibmi-mcp-server/tools/executeSql.tool.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/tools/executeSql.tool.js +356 -0
- package/dist/ibmi-mcp-server/tools/executeSql.tool.js.map +1 -0
- package/dist/ibmi-mcp-server/tools/generateSql.tool.d.ts +36 -0
- package/dist/ibmi-mcp-server/tools/generateSql.tool.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/tools/generateSql.tool.js +281 -0
- package/dist/ibmi-mcp-server/tools/generateSql.tool.js.map +1 -0
- package/dist/ibmi-mcp-server/tools/index.d.ts +85 -0
- package/dist/ibmi-mcp-server/tools/index.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/tools/index.js +21 -0
- package/dist/ibmi-mcp-server/tools/index.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/config/configParser.d.ts +9 -0
- package/dist/ibmi-mcp-server/utils/config/configParser.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/configParser.js +58 -0
- package/dist/ibmi-mcp-server/utils/config/configParser.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolConfigBuilder.js +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolConfigBuilder.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolDefinitions.d.ts +4 -4
- package/dist/ibmi-mcp-server/utils/config/toolDefinitions.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolDefinitions.js +7 -8
- package/dist/ibmi-mcp-server/utils/config/toolDefinitions.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts +0 -8
- package/dist/ibmi-mcp-server/utils/config/toolFactory.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolFactory.js +0 -31
- package/dist/ibmi-mcp-server/utils/config/toolFactory.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolsetManager.d.ts +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolsetManager.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/config/toolsetManager.js +2 -2
- package/dist/ibmi-mcp-server/utils/config/toolsetManager.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/language/document.d.ts +26 -0
- package/dist/ibmi-mcp-server/utils/language/document.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/document.js +318 -0
- package/dist/ibmi-mcp-server/utils/language/document.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/statement.d.ts +43 -0
- package/dist/ibmi-mcp-server/utils/language/statement.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/statement.js +796 -0
- package/dist/ibmi-mcp-server/utils/language/statement.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/tokens.d.ts +32 -0
- package/dist/ibmi-mcp-server/utils/language/tokens.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/tokens.js +532 -0
- package/dist/ibmi-mcp-server/utils/language/tokens.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/types.d.ts +138 -0
- package/dist/ibmi-mcp-server/utils/language/types.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/language/types.js +93 -0
- package/dist/ibmi-mcp-server/utils/language/types.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.d.ts +48 -0
- package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.js +93 -0
- package/dist/ibmi-mcp-server/utils/security/ibmiSqlParser.js.map +1 -0
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.d.ts +35 -59
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.d.ts.map +1 -1
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.js +108 -288
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidator.js.map +1 -1
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.d.ts +54 -0
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.d.ts.map +1 -0
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.js +91 -0
- package/dist/ibmi-mcp-server/utils/security/sqlSecurityValidatorFallback.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/index.d.ts +13 -2
- package/dist/mcp-server/tools/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/index.js +29 -9
- package/dist/mcp-server/tools/index.js.map +1 -1
- package/dist/mcp-server/tools/utils/index.d.ts +7 -0
- package/dist/mcp-server/tools/utils/index.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/index.js +7 -0
- package/dist/mcp-server/tools/utils/index.js.map +1 -0
- package/dist/mcp-server/tools/utils/tool-factory.d.ts +129 -0
- package/dist/mcp-server/tools/utils/tool-factory.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/tool-factory.js +179 -0
- package/dist/mcp-server/tools/utils/tool-factory.js.map +1 -0
- package/dist/mcp-server/tools/utils/types.d.ts +117 -0
- package/dist/mcp-server/tools/utils/types.d.ts.map +1 -0
- package/dist/mcp-server/tools/utils/types.js +11 -0
- package/dist/mcp-server/tools/utils/types.js.map +1 -0
- package/dist/mcp-server/transports/core/cleanupTransformStream.d.ts +26 -0
- package/dist/mcp-server/transports/core/cleanupTransformStream.d.ts.map +1 -0
- package/dist/mcp-server/transports/core/cleanupTransformStream.js +60 -0
- package/dist/mcp-server/transports/core/cleanupTransformStream.js.map +1 -0
- package/dist/mcp-server/transports/core/statefulTransportManager.d.ts +1 -1
- package/dist/mcp-server/transports/core/statefulTransportManager.d.ts.map +1 -1
- package/dist/mcp-server/transports/core/statefulTransportManager.js +50 -40
- package/dist/mcp-server/transports/core/statefulTransportManager.js.map +1 -1
- package/dist/mcp-server/transports/core/statelessTransportManager.d.ts +2 -13
- package/dist/mcp-server/transports/core/statelessTransportManager.d.ts.map +1 -1
- package/dist/mcp-server/transports/core/statelessTransportManager.js +35 -62
- package/dist/mcp-server/transports/core/statelessTransportManager.js.map +1 -1
- package/dist/mcp-server/transports/core/transportRequest.d.ts +1 -2
- package/dist/mcp-server/transports/core/transportRequest.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.js +1 -3
- package/dist/mcp-server/transports/http/mcpTransportMiddleware.js.map +1 -1
- package/dist/utils/internal/logger.d.ts +5 -0
- package/dist/utils/internal/logger.d.ts.map +1 -1
- package/dist/utils/internal/logger.js +65 -36
- package/dist/utils/internal/logger.js.map +1 -1
- package/package.json +29 -23
- package/dist/ibmi-mcp-server/tools/executeSql/index.d.ts +0 -9
- package/dist/ibmi-mcp-server/tools/executeSql/index.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/index.js +0 -9
- package/dist/ibmi-mcp-server/tools/executeSql/index.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/logic.d.ts +0 -51
- package/dist/ibmi-mcp-server/tools/executeSql/logic.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/logic.js +0 -179
- package/dist/ibmi-mcp-server/tools/executeSql/logic.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/registration.d.ts +0 -52
- package/dist/ibmi-mcp-server/tools/executeSql/registration.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/executeSql/registration.js +0 -161
- package/dist/ibmi-mcp-server/tools/executeSql/registration.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/index.d.ts +0 -13
- package/dist/ibmi-mcp-server/tools/generateSql/index.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/index.js +0 -13
- package/dist/ibmi-mcp-server/tools/generateSql/index.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/logic.d.ts +0 -64
- package/dist/ibmi-mcp-server/tools/generateSql/logic.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/logic.js +0 -190
- package/dist/ibmi-mcp-server/tools/generateSql/logic.js.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/registration.d.ts +0 -18
- package/dist/ibmi-mcp-server/tools/generateSql/registration.d.ts.map +0 -1
- package/dist/ibmi-mcp-server/tools/generateSql/registration.js +0 -64
- package/dist/ibmi-mcp-server/tools/generateSql/registration.js.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/index.d.ts +0 -8
- package/dist/mcp-server/tools/catFactFetcher/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/index.js +0 -8
- package/dist/mcp-server/tools/catFactFetcher/index.js.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/logic.d.ts +0 -52
- package/dist/mcp-server/tools/catFactFetcher/logic.d.ts.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/logic.js +0 -95
- package/dist/mcp-server/tools/catFactFetcher/logic.js.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/registration.d.ts +0 -9
- package/dist/mcp-server/tools/catFactFetcher/registration.d.ts.map +0 -1
- package/dist/mcp-server/tools/catFactFetcher/registration.js +0 -43
- package/dist/mcp-server/tools/catFactFetcher/registration.js.map +0 -1
- package/dist/mcp-server/tools/echoTool/index.d.ts +0 -13
- package/dist/mcp-server/tools/echoTool/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/echoTool/index.js +0 -13
- package/dist/mcp-server/tools/echoTool/index.js.map +0 -1
- package/dist/mcp-server/tools/echoTool/logic.d.ts +0 -69
- package/dist/mcp-server/tools/echoTool/logic.d.ts.map +0 -1
- package/dist/mcp-server/tools/echoTool/logic.js +0 -119
- package/dist/mcp-server/tools/echoTool/logic.js.map +0 -1
- package/dist/mcp-server/tools/echoTool/registration.d.ts +0 -9
- package/dist/mcp-server/tools/echoTool/registration.d.ts.map +0 -1
- package/dist/mcp-server/tools/echoTool/registration.js +0 -45
- package/dist/mcp-server/tools/echoTool/registration.js.map +0 -1
- package/dist/mcp-server/tools/imageTest/index.d.ts +0 -7
- package/dist/mcp-server/tools/imageTest/index.d.ts.map +0 -1
- package/dist/mcp-server/tools/imageTest/index.js +0 -7
- package/dist/mcp-server/tools/imageTest/index.js.map +0 -1
- package/dist/mcp-server/tools/imageTest/logic.d.ts +0 -27
- package/dist/mcp-server/tools/imageTest/logic.d.ts.map +0 -1
- package/dist/mcp-server/tools/imageTest/logic.js +0 -44
- package/dist/mcp-server/tools/imageTest/logic.js.map +0 -1
- package/dist/mcp-server/tools/imageTest/registration.d.ts +0 -9
- package/dist/mcp-server/tools/imageTest/registration.d.ts.map +0 -1
- package/dist/mcp-server/tools/imageTest/registration.js +0 -49
- package/dist/mcp-server/tools/imageTest/registration.js.map +0 -1
- package/dist/mcp-server/tools/utils/tool-utils.d.ts +0 -43
- package/dist/mcp-server/tools/utils/tool-utils.d.ts.map +0 -1
- package/dist/mcp-server/tools/utils/tool-utils.js +0 -44
- package/dist/mcp-server/tools/utils/tool-utils.js.map +0 -1
- package/dist/mcp-server/transports/core/headerUtils.d.ts +0 -27
- package/dist/mcp-server/transports/core/headerUtils.d.ts.map +0 -1
- package/dist/mcp-server/transports/core/headerUtils.js +0 -53
- package/dist/mcp-server/transports/core/headerUtils.js.map +0 -1
- package/dist/mcp-server/transports/core/honoNodeBridge.d.ts +0 -77
- package/dist/mcp-server/transports/core/honoNodeBridge.d.ts.map +0 -1
- package/dist/mcp-server/transports/core/honoNodeBridge.js +0 -150
- package/dist/mcp-server/transports/core/honoNodeBridge.js.map +0 -1
- package/dist/services/duck-db/duckDBConnectionManager.d.ts +0 -55
- package/dist/services/duck-db/duckDBConnectionManager.d.ts.map +0 -1
- package/dist/services/duck-db/duckDBConnectionManager.js +0 -184
- package/dist/services/duck-db/duckDBConnectionManager.js.map +0 -1
- package/dist/services/duck-db/duckDBQueryExecutor.d.ts +0 -18
- package/dist/services/duck-db/duckDBQueryExecutor.d.ts.map +0 -1
- package/dist/services/duck-db/duckDBQueryExecutor.js +0 -115
- package/dist/services/duck-db/duckDBQueryExecutor.js.map +0 -1
- package/dist/services/duck-db/duckDBService.d.ts +0 -27
- package/dist/services/duck-db/duckDBService.d.ts.map +0 -1
- package/dist/services/duck-db/duckDBService.js +0 -151
- package/dist/services/duck-db/duckDBService.js.map +0 -1
- package/dist/services/duck-db/types.d.ts +0 -135
- package/dist/services/duck-db/types.d.ts.map +0 -1
- package/dist/services/duck-db/types.js +0 -6
- package/dist/services/duck-db/types.js.map +0 -1
- package/dist/services/llm-providers/openRouterProvider.d.ts +0 -36
- package/dist/services/llm-providers/openRouterProvider.d.ts.map +0 -1
- package/dist/services/llm-providers/openRouterProvider.js +0 -235
- package/dist/services/llm-providers/openRouterProvider.js.map +0 -1
- package/dist/services/supabase/supabaseClient.d.ts +0 -25
- package/dist/services/supabase/supabaseClient.d.ts.map +0 -1
- package/dist/services/supabase/supabaseClient.js +0 -68
- package/dist/services/supabase/supabaseClient.js.map +0 -1
- package/dist/storage/duckdbExample.d.ts +0 -8
- package/dist/storage/duckdbExample.d.ts.map +0 -1
- package/dist/storage/duckdbExample.js +0 -197
- package/dist/storage/duckdbExample.js.map +0 -1
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Handles registration of the `fetch_image_test` tool.
|
|
3
|
-
* This module acts as the "handler" layer, connecting the pure business logic to the
|
|
4
|
-
* MCP server and ensuring all outcomes (success or failure) are handled gracefully.
|
|
5
|
-
* @module src/mcp-server/tools/imageTest/registration
|
|
6
|
-
**/
|
|
7
|
-
import { JsonRpcErrorCode } from "../../../types-global/errors.js";
|
|
8
|
-
import { ErrorHandler, requestContextService } from "../../../utils/index.js";
|
|
9
|
-
import { logOperationStart, logOperationSuccess, } from "../../../utils/internal/logging-helpers.js";
|
|
10
|
-
import { createToolHandler, } from "../../tools/utils/tool-utils.js";
|
|
11
|
-
import { FetchImageTestInputSchema, fetchImageTestLogic, FetchImageTestResponseSchema, } from "./logic.js";
|
|
12
|
-
const TOOL_NAME = "fetch_image_test";
|
|
13
|
-
const TOOL_DESCRIPTION = "Fetches a random cat image from an external API (cataas.com) and returns it as a blob. Useful for testing image handling capabilities.";
|
|
14
|
-
const responseFormatter = (result) => ({
|
|
15
|
-
structuredContent: result,
|
|
16
|
-
content: [
|
|
17
|
-
{
|
|
18
|
-
type: "image",
|
|
19
|
-
data: result.data,
|
|
20
|
-
mimeType: result.mimeType,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
});
|
|
24
|
-
export const registerFetchImageTestTool = async (server) => {
|
|
25
|
-
const registrationContext = requestContextService.createRequestContext({
|
|
26
|
-
operation: "RegisterTool",
|
|
27
|
-
toolName: TOOL_NAME,
|
|
28
|
-
});
|
|
29
|
-
logOperationStart(registrationContext, `Registering tool: '${TOOL_NAME}'`);
|
|
30
|
-
await ErrorHandler.tryCatch(async () => {
|
|
31
|
-
server.registerTool(TOOL_NAME, {
|
|
32
|
-
title: "Fetch Cat Image",
|
|
33
|
-
description: TOOL_DESCRIPTION,
|
|
34
|
-
inputSchema: FetchImageTestInputSchema.shape,
|
|
35
|
-
outputSchema: FetchImageTestResponseSchema.shape,
|
|
36
|
-
annotations: {
|
|
37
|
-
readOnlyHint: true,
|
|
38
|
-
openWorldHint: true,
|
|
39
|
-
},
|
|
40
|
-
}, createToolHandler(TOOL_NAME, fetchImageTestLogic, responseFormatter));
|
|
41
|
-
logOperationSuccess(registrationContext, `Tool '${TOOL_NAME}' registered successfully.`);
|
|
42
|
-
}, {
|
|
43
|
-
operation: `RegisteringTool_${TOOL_NAME}`,
|
|
44
|
-
context: registrationContext,
|
|
45
|
-
errorCode: JsonRpcErrorCode.InitializationFailed,
|
|
46
|
-
critical: true,
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=registration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/imageTest/registration.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAGJ,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,iBAAiB,GAElB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EAEnB,4BAA4B,GAC7B,MAAM,YAAY,CAAC;AAEpB,MAAM,SAAS,GAAG,kBAAkB,CAAC;AACrC,MAAM,gBAAgB,GACpB,wIAAwI,CAAC;AAE3I,MAAM,iBAAiB,GAA8C,CACnE,MAAM,EACN,EAAE,CAAC,CAAC;IACJ,iBAAiB,EAAE,MAAM;IACzB,OAAO,EAAE;QACP;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,EAC7C,MAAiB,EACF,EAAE;IACjB,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,oBAAoB,CAAC;QACrE,SAAS,EAAE,cAAc;QACzB,QAAQ,EAAE,SAAS;KACpB,CAAC,CAAC;IAEH,iBAAiB,CAAC,mBAAmB,EAAE,sBAAsB,SAAS,GAAG,CAAC,CAAC;IAE3E,MAAM,YAAY,CAAC,QAAQ,CACzB,KAAK,IAAI,EAAE;QACT,MAAM,CAAC,YAAY,CACjB,SAAS,EACT;YACE,KAAK,EAAE,iBAAiB;YACxB,WAAW,EAAE,gBAAgB;YAC7B,WAAW,EAAE,yBAAyB,CAAC,KAAK;YAC5C,YAAY,EAAE,4BAA4B,CAAC,KAAK;YAChD,WAAW,EAAE;gBACX,YAAY,EAAE,IAAI;gBAClB,aAAa,EAAE,IAAI;aACpB;SACF,EACD,iBAAiB,CAAC,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,CACrE,CAAC;QACF,mBAAmB,CACjB,mBAAmB,EACnB,SAAS,SAAS,4BAA4B,CAC/C,CAAC;IACJ,CAAC,EACD;QACE,SAAS,EAAE,mBAAmB,SAAS,EAAE;QACzC,OAAO,EAAE,mBAAmB;QAC5B,SAAS,EAAE,gBAAgB,CAAC,oBAAoB;QAChD,QAAQ,EAAE,IAAI;KACf,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Provides a generic factory for creating MCP tool handlers.
|
|
3
|
-
* This utility centralizes common logic for performance measurement, error handling,
|
|
4
|
-
* and response formatting, reducing boilerplate in individual tool registration files.
|
|
5
|
-
* @module src/mcp-server/tools/utils/tool-utils
|
|
6
|
-
*/
|
|
7
|
-
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
-
/**
|
|
9
|
-
* Defines the function signature for a core tool logic implementation.
|
|
10
|
-
* @template TInput The type of the validated input parameters.
|
|
11
|
-
* @template TOutput The type of the successful output from the logic.
|
|
12
|
-
* @param params The validated input parameters for the tool.
|
|
13
|
-
* @returns A promise that resolves with the tool's output.
|
|
14
|
-
*/
|
|
15
|
-
type ToolLogicFn<TInput, TOutput> = (params: TInput) => Promise<TOutput>;
|
|
16
|
-
/**
|
|
17
|
-
* Defines the function signature for formatting a successful tool logic result
|
|
18
|
-
* into the final structure expected by the MCP server.
|
|
19
|
-
* @template TOutput The type of the successful output from the logic.
|
|
20
|
-
* @param result The successful output from the tool's logic function.
|
|
21
|
-
* @returns The formatted tool response.
|
|
22
|
-
*/
|
|
23
|
-
export type ResponseFormatter<TOutput> = (result: TOutput) => CallToolResult;
|
|
24
|
-
/**
|
|
25
|
-
* A generic handler function for an MCP tool.
|
|
26
|
-
* @template TInput The type of the validated input parameters.
|
|
27
|
-
*/
|
|
28
|
-
export type McpToolHandler<TInput> = (params: TInput) => Promise<CallToolResult>;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a standardized MCP tool handler.
|
|
31
|
-
* This factory wraps the core business logic with cross-cutting concerns like
|
|
32
|
-
* performance monitoring and centralized error handling.
|
|
33
|
-
*
|
|
34
|
-
* @template TInput The type of the validated input parameters.
|
|
35
|
-
* @template TOutput The type of the successful output from the logic.
|
|
36
|
-
* @param toolName The name of the tool, used for logging and metrics.
|
|
37
|
-
* @param logicFn The core business logic function for the tool.
|
|
38
|
-
* @param responseFormatter A function to format the successful output.
|
|
39
|
-
* @returns A complete MCP tool handler function.
|
|
40
|
-
*/
|
|
41
|
-
export declare function createToolHandler<TInput, TOutput>(toolName: string, logicFn: ToolLogicFn<TInput, TOutput>, responseFormatter: ResponseFormatter<TOutput>): McpToolHandler<TInput>;
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=tool-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-utils.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/tool-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE;;;;;;GAMG;AACH,KAAK,WAAW,CAAC,MAAM,EAAE,OAAO,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,cAAc,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,MAAM,IAAI,CACnC,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,cAAc,CAAC,CAAC;AAE7B;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAC/C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAC5C,cAAc,CAAC,MAAM,CAAC,CA2BxB"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Provides a generic factory for creating MCP tool handlers.
|
|
3
|
-
* This utility centralizes common logic for performance measurement, error handling,
|
|
4
|
-
* and response formatting, reducing boilerplate in individual tool registration files.
|
|
5
|
-
* @module src/mcp-server/tools/utils/tool-utils
|
|
6
|
-
*/
|
|
7
|
-
import { ErrorHandler, getRequestContext, measureToolExecution, } from "../../../utils/index.js";
|
|
8
|
-
/**
|
|
9
|
-
* Creates a standardized MCP tool handler.
|
|
10
|
-
* This factory wraps the core business logic with cross-cutting concerns like
|
|
11
|
-
* performance monitoring and centralized error handling.
|
|
12
|
-
*
|
|
13
|
-
* @template TInput The type of the validated input parameters.
|
|
14
|
-
* @template TOutput The type of the successful output from the logic.
|
|
15
|
-
* @param toolName The name of the tool, used for logging and metrics.
|
|
16
|
-
* @param logicFn The core business logic function for the tool.
|
|
17
|
-
* @param responseFormatter A function to format the successful output.
|
|
18
|
-
* @returns A complete MCP tool handler function.
|
|
19
|
-
*/
|
|
20
|
-
export function createToolHandler(toolName, logicFn, responseFormatter) {
|
|
21
|
-
return async (params) => {
|
|
22
|
-
try {
|
|
23
|
-
const result = await measureToolExecution(toolName, () => logicFn(params), params);
|
|
24
|
-
return responseFormatter(result);
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
const mcpError = ErrorHandler.handleError(error, {
|
|
28
|
-
operation: `tool:${toolName}`,
|
|
29
|
-
context: getRequestContext(),
|
|
30
|
-
input: params,
|
|
31
|
-
});
|
|
32
|
-
return {
|
|
33
|
-
isError: true,
|
|
34
|
-
content: [{ type: "text", text: `Error: ${mcpError.message}` }],
|
|
35
|
-
structuredContent: {
|
|
36
|
-
code: mcpError.code,
|
|
37
|
-
message: mcpError.message,
|
|
38
|
-
details: mcpError.details,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=tool-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-utils.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/utils/tool-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AA6BjC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,OAAqC,EACrC,iBAA6C;IAE7C,OAAO,KAAK,EAAE,MAAc,EAAE,EAAE;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,oBAAoB,CACvC,QAAQ,EACR,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EACrB,MAAM,CACP,CAAC;YACF,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,CAAC,KAAK,EAAE;gBAC/C,SAAS,EAAE,QAAQ,QAAQ,EAAE;gBAC7B,OAAO,EAAE,iBAAiB,EAAE;gBAC5B,KAAK,EAAE,MAAM;aACd,CAAa,CAAC;YAEf,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC/D,iBAAiB,EAAE;oBACjB,IAAI,EAAE,QAAQ,CAAC,IAAI;oBACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;oBACzB,OAAO,EAAE,QAAQ,CAAC,OAAO;iBAC1B;aACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
import type { OutgoingHttpHeaders, IncomingHttpHeaders } 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
|
-
/**
|
|
21
|
-
* Converts a Web-standard Headers object (used by Hono) to Node.js-style IncomingHttpHeaders.
|
|
22
|
-
*
|
|
23
|
-
* @param webHeaders - The Web-standard Headers object to convert.
|
|
24
|
-
* @returns A Node.js-style IncomingHttpHeaders object.
|
|
25
|
-
*/
|
|
26
|
-
export declare function convertWebHeadersToNodeHeaders(webHeaders: Headers): IncomingHttpHeaders;
|
|
27
|
-
//# sourceMappingURL=headerUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAErE;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,mBAAmB,GAC/B,OAAO,CAmBT;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,OAAO,GAClB,mBAAmB,CAQrB"}
|
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
/**
|
|
39
|
-
* Converts a Web-standard Headers object (used by Hono) to Node.js-style IncomingHttpHeaders.
|
|
40
|
-
*
|
|
41
|
-
* @param webHeaders - The Web-standard Headers object to convert.
|
|
42
|
-
* @returns A Node.js-style IncomingHttpHeaders object.
|
|
43
|
-
*/
|
|
44
|
-
export function convertWebHeadersToNodeHeaders(webHeaders) {
|
|
45
|
-
const nodeHeaders = {};
|
|
46
|
-
// The Headers.forEach provides the comma-separated string if multiple headers existed.
|
|
47
|
-
webHeaders.forEach((value, key) => {
|
|
48
|
-
// Node.js lowercases incoming header keys.
|
|
49
|
-
nodeHeaders[key.toLowerCase()] = value;
|
|
50
|
-
});
|
|
51
|
-
return nodeHeaders;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=headerUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAED;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAC5C,UAAmB;IAEnB,MAAM,WAAW,GAAwB,EAAE,CAAC;IAC5C,uFAAuF;IACvF,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAChC,2CAA2C;QAC3C,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Provides a high-fidelity bridge between the MCP SDK's Node.js-style
|
|
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.
|
|
6
|
-
* @module src/mcp-server/transports/core/honoNodeBridge
|
|
7
|
-
*/
|
|
8
|
-
import { PassThrough } from "stream";
|
|
9
|
-
import type { OutgoingHttpHeaders } from "http";
|
|
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.
|
|
18
|
-
*/
|
|
19
|
-
export declare class HonoStreamResponse extends PassThrough {
|
|
20
|
-
statusCode: number;
|
|
21
|
-
headers: OutgoingHttpHeaders;
|
|
22
|
-
private _headersSent;
|
|
23
|
-
constructor();
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
51
|
-
getHeader(name: string): string | number | string[] | undefined;
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
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
|
-
*/
|
|
75
|
-
end(chunk?: unknown, encodingOrCallback?: BufferEncoding | (() => void), callback?: () => void): this;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=honoNodeBridge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAGhD;;;;;;;;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;IAmBhE;;;;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;IAkBhC;;;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,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Provides a high-fidelity bridge between the MCP SDK's Node.js-style
|
|
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.
|
|
6
|
-
* @module src/mcp-server/transports/core/honoNodeBridge
|
|
7
|
-
*/
|
|
8
|
-
import { PassThrough } from "stream";
|
|
9
|
-
import { logger, requestContextService } from "../../../utils/index.js";
|
|
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.
|
|
18
|
-
*/
|
|
19
|
-
export class HonoStreamResponse extends PassThrough {
|
|
20
|
-
statusCode = 200;
|
|
21
|
-
headers = {};
|
|
22
|
-
_headersSent = false;
|
|
23
|
-
constructor() {
|
|
24
|
-
super();
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* A getter that reports whether the headers have been sent.
|
|
28
|
-
* In this emulation, headers are considered sent the first time `write()` or `end()` is called.
|
|
29
|
-
*/
|
|
30
|
-
get headersSent() {
|
|
31
|
-
return this._headersSent;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Sets the status code and headers for the response, mimicking `http.ServerResponse.writeHead`.
|
|
35
|
-
*
|
|
36
|
-
* @param statusCode - The HTTP status code.
|
|
37
|
-
* @param statusMessageOrHeaders - An optional status message (string) or headers object.
|
|
38
|
-
* @param headers - An optional headers object, used if the second argument is a status message.
|
|
39
|
-
* @returns The instance of the class for chaining.
|
|
40
|
-
*/
|
|
41
|
-
writeHead(statusCode, statusMessageOrHeaders, headers) {
|
|
42
|
-
if (this._headersSent) {
|
|
43
|
-
// Per Node.js spec, do nothing if headers are already sent.
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
this.statusCode = statusCode;
|
|
47
|
-
const headersArg = typeof statusMessageOrHeaders === "string"
|
|
48
|
-
? headers
|
|
49
|
-
: statusMessageOrHeaders;
|
|
50
|
-
if (headersArg) {
|
|
51
|
-
for (const [key, value] of Object.entries(headersArg)) {
|
|
52
|
-
if (value !== undefined) {
|
|
53
|
-
this.setHeader(key, value);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Sets a single header value.
|
|
61
|
-
*
|
|
62
|
-
* @param name - The name of the header.
|
|
63
|
-
* @param value - The value of the header.
|
|
64
|
-
* @returns The instance of the class for chaining.
|
|
65
|
-
*/
|
|
66
|
-
setHeader(name, value) {
|
|
67
|
-
if (this._headersSent) {
|
|
68
|
-
// Retrieve context if available, otherwise create a basic one
|
|
69
|
-
const context = requestContextService.createRequestContext({
|
|
70
|
-
operation: "HonoStreamResponse.setHeader",
|
|
71
|
-
component: "HonoNodeBridge",
|
|
72
|
-
});
|
|
73
|
-
// Replace console.warn with logger.warning
|
|
74
|
-
logger.warning({ ...context, headerName: name }, `[HonoBridge] Warning: Cannot set header "${name}" after headers are sent.`);
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
this.headers[name.toLowerCase()] = value;
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Gets a header that has been queued for the response.
|
|
82
|
-
* @param name - The name of the header.
|
|
83
|
-
* @returns The value of the header, or undefined if not set.
|
|
84
|
-
*/
|
|
85
|
-
getHeader(name) {
|
|
86
|
-
return this.headers[name.toLowerCase()];
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Returns a copy of the current outgoing headers.
|
|
90
|
-
*/
|
|
91
|
-
getHeaders() {
|
|
92
|
-
return { ...this.headers };
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Removes a header that has been queued for the response.
|
|
96
|
-
* @param name - The name of the header to remove.
|
|
97
|
-
*/
|
|
98
|
-
removeHeader(name) {
|
|
99
|
-
if (this._headersSent) {
|
|
100
|
-
// Retrieve context if available
|
|
101
|
-
const context = requestContextService.createRequestContext({
|
|
102
|
-
operation: "HonoStreamResponse.removeHeader",
|
|
103
|
-
component: "HonoNodeBridge",
|
|
104
|
-
});
|
|
105
|
-
// Replace console.warn with logger.warning
|
|
106
|
-
logger.warning({ ...context, headerName: name }, `[HonoBridge] Warning: Cannot remove header "${name}" after headers are sent.`);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
delete this.headers[name.toLowerCase()];
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* A private helper to mark headers as sent. This is called implicitly
|
|
113
|
-
* before any part of the body is written.
|
|
114
|
-
*/
|
|
115
|
-
ensureHeadersSent() {
|
|
116
|
-
if (!this._headersSent) {
|
|
117
|
-
this._headersSent = true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Writes a chunk of the response body, mimicking `http.ServerResponse.write`.
|
|
122
|
-
* This is the first point where headers are implicitly flushed.
|
|
123
|
-
*/
|
|
124
|
-
write(chunk, encodingOrCallback, callback) {
|
|
125
|
-
this.ensureHeadersSent();
|
|
126
|
-
const encoding = typeof encodingOrCallback === "string" ? encodingOrCallback : undefined;
|
|
127
|
-
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
128
|
-
if (encoding) {
|
|
129
|
-
return super.write(chunk, encoding, cb);
|
|
130
|
-
}
|
|
131
|
-
return super.write(chunk, cb);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Finishes sending the response, mimicking `http.ServerResponse.end`.
|
|
135
|
-
* This also implicitly flushes headers if they haven't been sent yet.
|
|
136
|
-
*/
|
|
137
|
-
end(chunk, encodingOrCallback, callback) {
|
|
138
|
-
this.ensureHeadersSent();
|
|
139
|
-
const encoding = typeof encodingOrCallback === "string" ? encodingOrCallback : undefined;
|
|
140
|
-
const cb = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
|
|
141
|
-
if (encoding) {
|
|
142
|
-
super.end(chunk, encoding, cb);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
super.end(chunk, cb);
|
|
146
|
-
}
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=honoNodeBridge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"honoNodeBridge.js","sourceRoot":"","sources":["../../../../src/mcp-server/transports/core/honoNodeBridge.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Manages DuckDB instance and connection lifecycle.
|
|
3
|
-
* @module services/duck-db/duckDBConnectionManager
|
|
4
|
-
*/
|
|
5
|
-
import * as duckdb from "@duckdb/node-api";
|
|
6
|
-
import { RequestContext } from "../../utils/index.js";
|
|
7
|
-
import { DuckDBServiceConfig } from "./types.js";
|
|
8
|
-
export declare class DuckDBConnectionManager {
|
|
9
|
-
private dbInstance;
|
|
10
|
-
private dbConnection;
|
|
11
|
-
private isInitialized;
|
|
12
|
-
private currentConfig;
|
|
13
|
-
/**
|
|
14
|
-
* Initializes the DuckDB instance and connection.
|
|
15
|
-
* @param {DuckDBServiceConfig} [config] - Configuration for the service.
|
|
16
|
-
* @returns {Promise<void>}
|
|
17
|
-
*/
|
|
18
|
-
initialize(config?: DuckDBServiceConfig): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Installs and loads a DuckDB extension.
|
|
21
|
-
* @param {string} extensionName - The name of the extension.
|
|
22
|
-
* @param {RequestContext} parentContext - The parent request context.
|
|
23
|
-
* @returns {Promise<void>}
|
|
24
|
-
*/
|
|
25
|
-
loadExtension(extensionName: string, parentContext: RequestContext): Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Closes the DuckDB connection and instance.
|
|
28
|
-
* @returns {Promise<void>}
|
|
29
|
-
*/
|
|
30
|
-
close(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Ensures that the service is initialized.
|
|
33
|
-
* @param {RequestContext} context - The request context for error reporting.
|
|
34
|
-
* @throws {McpError} If the service is not initialized.
|
|
35
|
-
*/
|
|
36
|
-
ensureInitialized(context: RequestContext): void;
|
|
37
|
-
/**
|
|
38
|
-
* Gets the underlying DuckDB connection object.
|
|
39
|
-
* @returns {duckdb.DuckDBConnection}
|
|
40
|
-
* @throws {McpError} If the service is not initialized.
|
|
41
|
-
*/
|
|
42
|
-
getConnection(): duckdb.DuckDBConnection;
|
|
43
|
-
/**
|
|
44
|
-
* Gets the underlying DuckDB instance object.
|
|
45
|
-
* @returns {duckdb.DuckDBInstance}
|
|
46
|
-
* @throws {McpError} If the service is not initialized.
|
|
47
|
-
*/
|
|
48
|
-
getInstance(): duckdb.DuckDBInstance;
|
|
49
|
-
/**
|
|
50
|
-
* Checks if the service is currently initialized.
|
|
51
|
-
* @returns {boolean} True if initialized, false otherwise.
|
|
52
|
-
*/
|
|
53
|
-
get isServiceInitialized(): boolean;
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=duckDBConnectionManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duckDBConnectionManager.d.ts","sourceRoot":"","sources":["../../../src/services/duck-db/duckDBConnectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAGL,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAIjD,qBAAa,uBAAuB;IAClC,OAAO,CAAC,UAAU,CAAsC;IACxD,OAAO,CAAC,YAAY,CAAwC;IAC5D,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,aAAa,CAAoC;IAEzD;;;;OAIG;IACU,UAAU,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8FpE;;;;;OAKG;IACU,aAAa,CACxB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,cAAc,GAC5B,OAAO,CAAC,IAAI,CAAC;IAgChB;;;OAGG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqCnC;;;;OAIG;IACI,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAUvD;;;;OAIG;IACI,aAAa,IAAI,MAAM,CAAC,gBAAgB;IAQ/C;;;;OAIG;IACI,WAAW,IAAI,MAAM,CAAC,cAAc;IAQ3C;;;OAGG;IACH,IAAW,oBAAoB,IAAI,OAAO,CAEzC;CACF"}
|