modality-kit 0.12.4 → 0.12.6
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 +11 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/util_mcp_tools_converter.d.ts +78 -2
- package/package.json +9 -10
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]) => {
|
|
@@ -123,7 +132,7 @@ class ModalityLogger {
|
|
|
123
132
|
}
|
|
124
133
|
case "warn": {
|
|
125
134
|
const { message, ...restPayload } = payload;
|
|
126
|
-
console.warn(
|
|
135
|
+
console.warn(message);
|
|
127
136
|
console.dir(restPayload, {
|
|
128
137
|
depth: null,
|
|
129
138
|
colors: true,
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
export { setupAITools } from "./util_mcp_tools_converter";
|
|
1
|
+
export { setupAITools, ModalityFastMCP } from "./util_mcp_tools_converter";
|
|
2
2
|
export type { AITools, AITool } from "./schemas/schemas_tool_config";
|
|
3
3
|
export { formatErrorResponse, formatSuccessResponse } from "./util_response";
|
|
4
4
|
export { getLoggerInstance, type ModalityLogger } from "./util_logger";
|
|
@@ -1,6 +1,82 @@
|
|
|
1
|
-
import type { FastMCP } from "fastmcp";
|
|
2
1
|
import type { AITools } from "./schemas/schemas_tool_config.ts";
|
|
3
2
|
import type { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Copy of StandardSchemaV1 interface for compatibility
|
|
5
|
+
*/
|
|
6
|
+
export interface ToolParameters<Input = unknown, Output = Input> {
|
|
7
|
+
readonly "~standard": ToolParameters.Props<Input, Output>;
|
|
8
|
+
}
|
|
9
|
+
export declare namespace ToolParameters {
|
|
10
|
+
interface Props<Input = unknown, Output = Input> {
|
|
11
|
+
readonly version: 1;
|
|
12
|
+
readonly vendor: string;
|
|
13
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
14
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
15
|
+
}
|
|
16
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
17
|
+
interface SuccessResult<Output> {
|
|
18
|
+
readonly value: Output;
|
|
19
|
+
readonly issues?: undefined;
|
|
20
|
+
}
|
|
21
|
+
interface FailureResult {
|
|
22
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
23
|
+
}
|
|
24
|
+
interface Issue {
|
|
25
|
+
readonly message: string;
|
|
26
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
27
|
+
}
|
|
28
|
+
interface PathSegment {
|
|
29
|
+
readonly key: PropertyKey;
|
|
30
|
+
}
|
|
31
|
+
interface Types<Input = unknown, Output = Input> {
|
|
32
|
+
readonly input: Input;
|
|
33
|
+
readonly output: Output;
|
|
34
|
+
}
|
|
35
|
+
type InferInput<Schema extends ToolParameters> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
36
|
+
type InferOutput<Schema extends ToolParameters> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Copy of FastMCP's Tool type for compatibility
|
|
40
|
+
*/
|
|
41
|
+
export type Tool<T extends Record<string, unknown> | undefined = any, Params extends ToolParameters = ToolParameters> = {
|
|
42
|
+
annotations?: {
|
|
43
|
+
streamingHint?: boolean;
|
|
44
|
+
} & {
|
|
45
|
+
destructiveHint?: boolean;
|
|
46
|
+
idempotentHint?: boolean;
|
|
47
|
+
openWorldHint?: boolean;
|
|
48
|
+
readOnlyHint?: boolean;
|
|
49
|
+
title?: string;
|
|
50
|
+
};
|
|
51
|
+
canAccess?: (auth: T) => boolean;
|
|
52
|
+
description?: string;
|
|
53
|
+
execute: (args: ToolParameters.InferOutput<Params>, context: any) => Promise<any>;
|
|
54
|
+
name: string;
|
|
55
|
+
parameters?: Params;
|
|
56
|
+
timeoutMs?: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* FastMCP-compatible interface for MCP server functionality
|
|
60
|
+
* Provides exact API compatibility with FastMCP.addTool method
|
|
61
|
+
*/
|
|
62
|
+
export interface FastMCPCompatible {
|
|
63
|
+
addTool<Params extends ToolParameters>(tool: Tool<any, Params>): void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* ModalityFastMCP - A FastMCP-compatible implementation
|
|
67
|
+
* Provides addTool and getTools functionality for managing MCP tools
|
|
68
|
+
*/
|
|
69
|
+
export declare class ModalityFastMCP implements FastMCPCompatible {
|
|
70
|
+
private tools;
|
|
71
|
+
/**
|
|
72
|
+
* Add a tool to the server
|
|
73
|
+
*/
|
|
74
|
+
addTool<Params extends ToolParameters>(tool: Tool<any, Params>): void;
|
|
75
|
+
/**
|
|
76
|
+
* Get all registered tools
|
|
77
|
+
*/
|
|
78
|
+
getTools(): Tool<any, any>[];
|
|
79
|
+
}
|
|
4
80
|
/**
|
|
5
81
|
* Setup function that optionally registers AITools with MCP server
|
|
6
82
|
* Automatically infers and preserves schema types from the input
|
|
@@ -8,4 +84,4 @@ import type { z } from "zod";
|
|
|
8
84
|
* @param mcpServer - Optional MCP server to register tools with
|
|
9
85
|
* @returns The same AITools object with preserved types
|
|
10
86
|
*/
|
|
11
|
-
export declare const setupAITools: <T extends Record<string, z.ZodSchema>>(aiTools: AITools<T>, mcpServer?:
|
|
87
|
+
export declare const setupAITools: <T extends Record<string, z.ZodSchema>>(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.6",
|
|
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
|
}
|