modality-kit 0.12.5 → 0.12.7
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/dist/index.js
CHANGED
|
@@ -17,6 +17,15 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
// src/util_mcp_tools_converter.ts
|
|
20
|
+
class ModalityFastMCP {
|
|
21
|
+
tools = new Map;
|
|
22
|
+
addTool(tool) {
|
|
23
|
+
this.tools.set(tool.name, tool);
|
|
24
|
+
}
|
|
25
|
+
getTools() {
|
|
26
|
+
return Array.from(this.tools.values());
|
|
27
|
+
}
|
|
28
|
+
}
|
|
20
29
|
var setupAITools = (aiTools, mcpServer) => {
|
|
21
30
|
if (mcpServer) {
|
|
22
31
|
Object.entries(aiTools).forEach(([toolName, aiTool]) => {
|
|
@@ -5957,6 +5966,7 @@ export {
|
|
|
5957
5966
|
compressWithLanguageDetection as compressText,
|
|
5958
5967
|
WebSocketClient,
|
|
5959
5968
|
exports_schemas_symbol as SymbolTypes,
|
|
5969
|
+
ModalityFastMCP,
|
|
5960
5970
|
LruCache,
|
|
5961
5971
|
JSONRPCUtils,
|
|
5962
5972
|
JSONRPCManager,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { setupAITools } from "./util_mcp_tools_converter";
|
|
2
|
-
export type { AITools, AITool } from "./schemas/schemas_tool_config";
|
|
1
|
+
export { setupAITools, ModalityFastMCP } from "./util_mcp_tools_converter";
|
|
2
|
+
export type { AITools, AITool, FastMCPTool, } from "./schemas/schemas_tool_config";
|
|
3
3
|
export { formatErrorResponse, formatSuccessResponse } from "./util_response";
|
|
4
4
|
export { getLoggerInstance, type ModalityLogger } from "./util_logger";
|
|
5
5
|
export { withErrorHandling, ErrorCode } from "./util_error";
|
|
@@ -1,22 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Copy of StandardSchemaV1 interface for compatibility
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
export interface ToolParameters<Input = unknown, Output = Input> {
|
|
5
|
+
readonly "~standard": ToolParameters.Props<Input, Output>;
|
|
6
|
+
}
|
|
7
|
+
export declare namespace ToolParameters {
|
|
8
|
+
interface Props<Input = unknown, Output = Input> {
|
|
9
|
+
readonly version: 1;
|
|
10
|
+
readonly vendor: string;
|
|
11
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
12
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
13
|
+
}
|
|
14
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
15
|
+
interface SuccessResult<Output> {
|
|
16
|
+
readonly value: Output;
|
|
17
|
+
readonly issues?: undefined;
|
|
18
|
+
}
|
|
19
|
+
interface FailureResult {
|
|
20
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
21
|
+
}
|
|
22
|
+
interface Issue {
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
25
|
+
}
|
|
26
|
+
interface PathSegment {
|
|
27
|
+
readonly key: PropertyKey;
|
|
28
|
+
}
|
|
29
|
+
interface Types<Input = unknown, Output = Input> {
|
|
30
|
+
readonly input: Input;
|
|
31
|
+
readonly output: Output;
|
|
32
|
+
}
|
|
33
|
+
type InferInput<Schema extends ToolParameters> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
34
|
+
type InferOutput<Schema extends ToolParameters> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
35
|
+
}
|
|
5
36
|
/**
|
|
6
37
|
* Tool interface for AI SDK compatibility
|
|
7
38
|
*/
|
|
8
|
-
export interface AITool<T extends
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
39
|
+
export interface AITool<T extends Record<string, unknown> | undefined = any, TParams extends ToolParameters = ToolParameters> {
|
|
40
|
+
annotations?: {
|
|
41
|
+
streamingHint?: boolean;
|
|
42
|
+
} & {
|
|
43
|
+
destructiveHint?: boolean;
|
|
44
|
+
idempotentHint?: boolean;
|
|
45
|
+
openWorldHint?: boolean;
|
|
46
|
+
readOnlyHint?: boolean;
|
|
47
|
+
title?: string;
|
|
48
|
+
};
|
|
49
|
+
canAccess?: (auth: T) => boolean;
|
|
50
|
+
description?: string;
|
|
51
|
+
execute: (args: ToolParameters.InferOutput<TParams>, context: any) => Promise<any>;
|
|
52
|
+
name: string;
|
|
53
|
+
inputSchema?: TParams;
|
|
54
|
+
timeoutMs?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface FastMCPTool<T extends Record<string, unknown> | undefined = any, TParams extends ToolParameters = ToolParameters> extends AITool<T, TParams> {
|
|
57
|
+
parameters?: TParams;
|
|
14
58
|
}
|
|
15
59
|
/**
|
|
16
60
|
* Type for a collection of AI tools with preserved schema types
|
|
17
61
|
* @template T - Record mapping tool names to their inputSchema types
|
|
18
62
|
* @example AITools<{getUserById: z.object({id: z.string()}), createUser: z.object({name: z.string()})}>
|
|
19
63
|
*/
|
|
20
|
-
export type AITools<T extends Record<string,
|
|
21
|
-
[K in keyof T]: AITool<T[K]>;
|
|
64
|
+
export type AITools<T extends Record<string, ToolParameters> = Record<string, ToolParameters>> = {
|
|
65
|
+
[K in keyof T]: AITool<any, T[K]>;
|
|
22
66
|
};
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { AITools, FastMCPTool, ToolParameters } from "./schemas/schemas_tool_config";
|
|
2
|
+
/**
|
|
3
|
+
* FastMCP-compatible interface for MCP server functionality
|
|
4
|
+
* Provides exact API compatibility with FastMCP.addTool method
|
|
5
|
+
*/
|
|
6
|
+
export interface FastMCPCompatible {
|
|
7
|
+
addTool<Params extends ToolParameters>(tool: FastMCPTool<any, Params>): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* ModalityFastMCP - A FastMCP-compatible implementation
|
|
11
|
+
* Provides addTool and getTools functionality for managing MCP tools
|
|
12
|
+
*/
|
|
13
|
+
export declare class ModalityFastMCP implements FastMCPCompatible {
|
|
14
|
+
private tools;
|
|
15
|
+
/**
|
|
16
|
+
* Add a tool to the server
|
|
17
|
+
*/
|
|
18
|
+
addTool<Params extends ToolParameters>(tool: FastMCPTool<any, Params>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get all registered tools
|
|
21
|
+
*/
|
|
22
|
+
getTools(): FastMCPTool<any, any>[];
|
|
23
|
+
}
|
|
4
24
|
/**
|
|
5
25
|
* Setup function that optionally registers AITools with MCP server
|
|
6
26
|
* Automatically infers and preserves schema types from the input
|
|
7
|
-
* @param aiTools - The AITools object with schema mapping
|
|
8
|
-
* @param mcpServer - Optional MCP server to register tools with
|
|
9
|
-
* @returns The same AITools object with preserved types
|
|
10
27
|
*/
|
|
11
|
-
export declare const setupAITools: <T extends Record<string,
|
|
28
|
+
export declare const setupAITools: <T extends Record<string, ToolParameters>>(aiTools: AITools<T>, mcpServer?: FastMCPCompatible) => AITools<T>;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.12.
|
|
2
|
+
"version": "0.12.7",
|
|
3
3
|
"name": "modality-kit",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -11,16 +11,18 @@
|
|
|
11
11
|
"author": "Hill <hill@kimo.com>",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@types/bun": "^1.2.
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"zod": "3.x"
|
|
14
|
+
"@types/bun": "^1.2.22",
|
|
15
|
+
"typescript": "^5.9.2",
|
|
16
|
+
"zod": "^3.25.76"
|
|
18
17
|
},
|
|
19
18
|
"exports": {
|
|
19
|
+
"types": "./dist/types/index.d.ts",
|
|
20
20
|
"require": "./dist/index.js",
|
|
21
|
-
"import": "./dist/index.js"
|
|
22
|
-
"types": "./dist/types/index.d.ts"
|
|
21
|
+
"import": "./dist/index.js"
|
|
23
22
|
},
|
|
23
|
+
"types": "./dist/types/index.d.ts",
|
|
24
|
+
"main": "./dist/index.js",
|
|
25
|
+
"module": "./dist/index.js",
|
|
24
26
|
"scripts": {
|
|
25
27
|
"update-compile-sh": "yo reshow:compile-sh",
|
|
26
28
|
"build:clean": "find ./dist -name '*.*' | xargs rm -rf",
|
|
@@ -31,8 +33,5 @@
|
|
|
31
33
|
"test": "bun test",
|
|
32
34
|
"prepublishOnly": "npm run build && npm run test"
|
|
33
35
|
},
|
|
34
|
-
"main": "./dist/index.js",
|
|
35
|
-
"module": "./dist/index.js",
|
|
36
|
-
"types": "./dist/types/index.d.ts",
|
|
37
36
|
"files": ["package.json", "README.md", "dist"]
|
|
38
37
|
}
|