@forklaunch/core 0.11.4 → 0.11.5
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/lib/http/index.d.mts +2 -2
- package/lib/http/index.d.ts +2 -2
- package/lib/http/index.js +13 -12
- package/lib/http/index.js.map +1 -1
- package/lib/http/index.mjs +13 -12
- package/lib/http/index.mjs.map +1 -1
- package/package.json +4 -4
package/lib/http/index.d.mts
CHANGED
@@ -9,7 +9,7 @@ export { LevelWithSilent, LevelWithSilentOrString, Logger } from 'pino';
|
|
9
9
|
import { JWTPayload } from 'jose';
|
10
10
|
import { Readable } from 'stream';
|
11
11
|
import { ZodSchemaValidator } from '@forklaunch/validator/zod';
|
12
|
-
import {
|
12
|
+
import { FastMCP } from 'fastmcp';
|
13
13
|
import { OpenAPIObject } from 'openapi3-ts/oas31';
|
14
14
|
import { AnyValueMap } from '@opentelemetry/api-logs';
|
15
15
|
import { ApiReferenceConfiguration } from '@scalar/express-api-reference';
|
@@ -1499,7 +1499,7 @@ declare const getCodeForStatus: (status: string) => null | StatusCode;
|
|
1499
1499
|
* @param {ForklaunchRouter<SV>[]} routers - The routers to include in the server.
|
1500
1500
|
* @returns {McpServer} - The generated ModelContextProtocol server.
|
1501
1501
|
*/
|
1502
|
-
declare function generateMcpServer(schemaValidator: ZodSchemaValidator, protocol: 'http' | 'https', host: string, port: number, version:
|
1502
|
+
declare function generateMcpServer<T extends Record<string, unknown> | undefined = Record<string, unknown> | undefined>(schemaValidator: ZodSchemaValidator, protocol: 'http' | 'https', host: string, port: number, version: `${number}.${number}.${number}`, routers: ForklaunchRouter<ZodSchemaValidator>[], options?: ConstructorParameters<typeof FastMCP<T>>[0], contentTypeMap?: Record<string, string>): FastMCP<T>;
|
1503
1503
|
|
1504
1504
|
/**
|
1505
1505
|
* Enhances the Express-like `send` method with additional logic for response handling and validation.
|
package/lib/http/index.d.ts
CHANGED
@@ -9,7 +9,7 @@ export { LevelWithSilent, LevelWithSilentOrString, Logger } from 'pino';
|
|
9
9
|
import { JWTPayload } from 'jose';
|
10
10
|
import { Readable } from 'stream';
|
11
11
|
import { ZodSchemaValidator } from '@forklaunch/validator/zod';
|
12
|
-
import {
|
12
|
+
import { FastMCP } from 'fastmcp';
|
13
13
|
import { OpenAPIObject } from 'openapi3-ts/oas31';
|
14
14
|
import { AnyValueMap } from '@opentelemetry/api-logs';
|
15
15
|
import { ApiReferenceConfiguration } from '@scalar/express-api-reference';
|
@@ -1499,7 +1499,7 @@ declare const getCodeForStatus: (status: string) => null | StatusCode;
|
|
1499
1499
|
* @param {ForklaunchRouter<SV>[]} routers - The routers to include in the server.
|
1500
1500
|
* @returns {McpServer} - The generated ModelContextProtocol server.
|
1501
1501
|
*/
|
1502
|
-
declare function generateMcpServer(schemaValidator: ZodSchemaValidator, protocol: 'http' | 'https', host: string, port: number, version:
|
1502
|
+
declare function generateMcpServer<T extends Record<string, unknown> | undefined = Record<string, unknown> | undefined>(schemaValidator: ZodSchemaValidator, protocol: 'http' | 'https', host: string, port: number, version: `${number}.${number}.${number}`, routers: ForklaunchRouter<ZodSchemaValidator>[], options?: ConstructorParameters<typeof FastMCP<T>>[0], contentTypeMap?: Record<string, string>): FastMCP<T>;
|
1503
1503
|
|
1504
1504
|
/**
|
1505
1505
|
* Enhances the Express-like `send` method with additional logic for response handling and validation.
|
package/lib/http/index.js
CHANGED
@@ -2562,7 +2562,7 @@ var httpStatusCodes_default = HTTPStatuses;
|
|
2562
2562
|
// src/http/mcpGenerator/mcpGenerator.ts
|
2563
2563
|
var import_common8 = require("@forklaunch/common");
|
2564
2564
|
var import_zod = require("@forklaunch/validator/zod");
|
2565
|
-
var
|
2565
|
+
var import_fastmcp = require("fastmcp");
|
2566
2566
|
|
2567
2567
|
// src/http/router/unpackRouters.ts
|
2568
2568
|
var import_common7 = require("@forklaunch/common");
|
@@ -2591,14 +2591,15 @@ function unpackRouters(routers, recursiveBasePath = [], recursiveSdkPath = []) {
|
|
2591
2591
|
}
|
2592
2592
|
|
2593
2593
|
// src/http/mcpGenerator/mcpGenerator.ts
|
2594
|
-
function generateMcpServer(schemaValidator, protocol, host, port, version, routers, contentTypeMap) {
|
2594
|
+
function generateMcpServer(schemaValidator, protocol, host, port, version, routers, options2, contentTypeMap) {
|
2595
2595
|
if (!(schemaValidator instanceof import_zod.ZodSchemaValidator)) {
|
2596
2596
|
throw new Error(
|
2597
2597
|
"Schema validator must be an instance of ZodSchemaValidator"
|
2598
2598
|
);
|
2599
2599
|
}
|
2600
|
-
const mcpServer = new
|
2601
|
-
|
2600
|
+
const mcpServer = new import_fastmcp.FastMCP({
|
2601
|
+
...options2,
|
2602
|
+
name: options2?.name ?? "mcp-server",
|
2602
2603
|
version
|
2603
2604
|
});
|
2604
2605
|
unpackRouters(routers).forEach(({ fullPath, router }) => {
|
@@ -2610,7 +2611,7 @@ function generateMcpServer(schemaValidator, protocol, host, port, version, route
|
|
2610
2611
|
route.contractDetails.body
|
2611
2612
|
);
|
2612
2613
|
}
|
2613
|
-
const inputSchema = {
|
2614
|
+
const inputSchema = schemaValidator.schemify({
|
2614
2615
|
...discriminatedBody && "body" in route.contractDetails ? {
|
2615
2616
|
..."contentType" in route.contractDetails.body ? { contentType: route.contractDetails.body.contentType } : {},
|
2616
2617
|
body: schemaValidator.schemify(discriminatedBody.schema)
|
@@ -2627,12 +2628,12 @@ function generateMcpServer(schemaValidator, protocol, host, port, version, route
|
|
2627
2628
|
} : {}
|
2628
2629
|
})
|
2629
2630
|
} : {}
|
2630
|
-
};
|
2631
|
-
mcpServer.
|
2632
|
-
route.contractDetails.name,
|
2633
|
-
route.contractDetails.summary,
|
2634
|
-
inputSchema,
|
2635
|
-
async (args) => {
|
2631
|
+
});
|
2632
|
+
mcpServer.addTool({
|
2633
|
+
name: route.contractDetails.name,
|
2634
|
+
description: route.contractDetails.summary,
|
2635
|
+
parameters: inputSchema,
|
2636
|
+
execute: async (args) => {
|
2636
2637
|
const { contentType, body, params, query, headers } = args;
|
2637
2638
|
let url = `${protocol}://${host}:${port}${fullPath}${route.path}`;
|
2638
2639
|
if (params) {
|
@@ -2766,7 +2767,7 @@ function generateMcpServer(schemaValidator, protocol, host, port, version, route
|
|
2766
2767
|
};
|
2767
2768
|
}
|
2768
2769
|
}
|
2769
|
-
);
|
2770
|
+
});
|
2770
2771
|
});
|
2771
2772
|
});
|
2772
2773
|
return mcpServer;
|