modality-kit 0.0.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 ADDED
@@ -0,0 +1,16 @@
1
+ # `modality-kit`
2
+
3
+ > TODO: description
4
+
5
+ ## Repository
6
+
7
+ - `GIT`
8
+ - https://github.com/react-atomic/modality
9
+ - `NPM`
10
+ - https://www.npmjs.com/package/modality-kit
11
+
12
+ ## Usage
13
+
14
+ ```
15
+
16
+ ```
package/dist/index.js ADDED
@@ -0,0 +1,61 @@
1
+ // src/util_mcp_tools_converter.ts
2
+ var setupAITools = (aiTools, mcpServer) => {
3
+ if (mcpServer) {
4
+ Object.entries(aiTools).forEach(([toolName, aiTool]) => {
5
+ let name = aiTool.name != null ? aiTool.name : toolName;
6
+ mcpServer.addTool({
7
+ ...aiTool,
8
+ name
9
+ });
10
+ });
11
+ }
12
+ return aiTools;
13
+ };
14
+ // src/util_response.ts
15
+ function formatSuccessResponse(content, meta) {
16
+ return JSON.stringify({
17
+ success: true,
18
+ content,
19
+ meta
20
+ });
21
+ }
22
+ function formatErrorResponse(errorData, operation, meta) {
23
+ let errorResponse;
24
+ if (typeof errorData === "string") {
25
+ errorResponse = {
26
+ success: false,
27
+ error: errorData,
28
+ operation,
29
+ meta
30
+ };
31
+ } else if (errorData instanceof Error) {
32
+ errorResponse = {
33
+ success: false,
34
+ error: errorData.message,
35
+ operation,
36
+ meta
37
+ };
38
+ } else if (typeof errorData === "object" && errorData !== null && typeof errorData.message === "string") {
39
+ const errObj = errorData;
40
+ errorResponse = {
41
+ success: errObj.success || false,
42
+ error: errObj.message,
43
+ code: errObj.code,
44
+ operation: errObj.operation || operation,
45
+ meta
46
+ };
47
+ } else {
48
+ errorResponse = {
49
+ success: false,
50
+ error: "Unknown error",
51
+ operation,
52
+ meta
53
+ };
54
+ }
55
+ return JSON.stringify(errorResponse);
56
+ }
57
+ export {
58
+ setupAITools,
59
+ formatSuccessResponse,
60
+ formatErrorResponse
61
+ };
@@ -0,0 +1,3 @@
1
+ export { setupAITools } from "./util_mcp_tools_converter";
2
+ export type { AITools, AITool } from "./schemas/schemas_tool_config";
3
+ export { formatErrorResponse, formatSuccessResponse } from "./util_response";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * TypeScript interfaces for tool configuration objects
3
+ */
4
+ /**
5
+ * Tool interface for AI SDK compatibility
6
+ */
7
+ export interface AITool {
8
+ name?: string;
9
+ annotations?: any;
10
+ description: string;
11
+ parameters: any;
12
+ execute: (parameters: any, options?: any) => Promise<any>;
13
+ }
14
+ /**
15
+ * Type for a collection of AI tools
16
+ */
17
+ export type AITools = Record<string, AITool>;
@@ -0,0 +1,9 @@
1
+ import { FastMCP } from "fastmcp";
2
+ import type { AITools } from "./schemas/schemas_tool_config.ts";
3
+ /**
4
+ * Setup function that optionally registers AITools with MCP server
5
+ * @param aiTools - The AITools object to optionally register
6
+ * @param mcpServer - Optional MCP server to register tools with
7
+ * @returns The AITools object
8
+ */
9
+ export declare const setupAITools: (aiTools: AITools, mcpServer?: FastMCP) => AITools;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Utility functions for formatting MCP responses
3
+ *
4
+ * This is a global utility module that should not import domain-specific classes.
5
+ * It provides generic response formatting for any MCP tool.
6
+ */
7
+ export interface McpSuccessResponse {
8
+ success: true;
9
+ content: any;
10
+ meta?: any;
11
+ }
12
+ export interface McpErrorResponse {
13
+ success: boolean;
14
+ error: string;
15
+ code?: string;
16
+ operation?: string;
17
+ meta?: Record<string, any>;
18
+ }
19
+ interface SuccessData {
20
+ message: string;
21
+ [key: string]: any;
22
+ }
23
+ /**
24
+ * Generic error data interface for MCP error responses
25
+ */
26
+ interface ErrorData {
27
+ success?: boolean;
28
+ message: string;
29
+ code?: string;
30
+ operation?: string;
31
+ [key: string]: any;
32
+ }
33
+ /**
34
+ * Format a successful response for MCP tools
35
+ */
36
+ export declare function formatSuccessResponse(content: SuccessData, meta?: any): string;
37
+ /**
38
+ * Format an error response for MCP tools using generic error data
39
+ */
40
+ export declare function formatErrorResponse(errorData: ErrorData | Error | string | unknown, operation?: string, meta?: Record<string, any>): string;
41
+ export {};
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "version": "0.0.0",
3
+ "name": "modality-kit",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/react-atomic/modality"
7
+ },
8
+ "homepage": "https://github.com/react-atomic/modality/modality-kit",
9
+ "description": "TODO: description",
10
+ "keywords": [
11
+ "modality-kit"
12
+ ],
13
+ "author": "Hill <hill@kimo.com>",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ },
17
+ "devDependencies": {
18
+ "fastmcp": "^3.6.2"
19
+ },
20
+ "exports": {
21
+ "require": "./dist/index.js",
22
+ "types": "./dist/types/index.d.ts"
23
+ },
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "scripts": {
27
+ "update-compile-sh": "yo reshow:compile-sh",
28
+ "build:types": "bunx tsc -p ./",
29
+ "build:src": "bun build src/index.ts --outdir dist",
30
+ "build": "bun run build:src && bun run build:types",
31
+ "test": "npm run build",
32
+ "prepublishOnly": "npm run test"
33
+ },
34
+ "types": "./dist/types/index.d.ts",
35
+ "files": [
36
+ "package.json",
37
+ "README.md",
38
+ "dist"
39
+ ]
40
+ }