@codebolt/codeboltjs 1.1.95 → 1.1.97
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/{src/modules → bkp}/toolBox.bkp.ts +0 -3
- package/modules/agent.js +1 -1
- package/modules/agentlib/agent.d.ts +63 -0
- package/modules/agentlib/agent.js +57 -7
- package/modules/agentlib/taskInstruction.d.ts +37 -0
- package/modules/agentlib/taskInstruction.js +20 -0
- package/modules/agentlib/usermessage.d.ts +68 -0
- package/modules/agentlib/usermessage.js +43 -0
- package/modules/chat.js +0 -6
- package/modules/codeparsers.js +0 -2
- package/modules/codeutils.js +0 -1
- package/modules/history.d.ts +22 -0
- package/modules/history.js +22 -0
- package/modules/rag.js +0 -1
- package/modules/search.js +0 -3
- package/modules/terminal.js +0 -1
- package/modules/toolBox.d.ts +202 -2
- package/modules/toolBox.js +53 -35
- package/modules/tools.d.ts +58 -0
- package/modules/tools.js +58 -0
- package/modules/websocket.js +0 -3
- package/package.json +1 -1
- package/src/modules/agent.ts +1 -1
- package/src/modules/agentlib/agent.ts +84 -9
- package/src/modules/agentlib/taskInstruction.ts +43 -4
- package/src/modules/agentlib/usermessage.ts +82 -8
- package/src/modules/chat.ts +0 -6
- package/src/modules/codeparsers.ts +0 -2
- package/src/modules/codeutils.ts +0 -1
- package/src/modules/history.ts +23 -2
- package/src/modules/rag.ts +0 -1
- package/src/modules/search.ts +0 -3
- package/src/modules/terminal.ts +0 -1
- package/src/modules/toolBox.ts +218 -40
- package/src/modules/tools.ts +67 -0
- package/src/modules/websocket.ts +0 -3
- package/modules/mcp.d.ts +0 -9
- package/modules/mcp.js +0 -148
- package/modules/toolBox.bkp.d.ts +0 -262
- package/modules/toolBox.bkp.js +0 -721
- package/src/modules/agentlib/package-lock.json +0 -282
- package/src/modules/agentlib/package.json +0 -6
package/src/modules/tools.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { UserMessage } from '../utils';
|
|
2
2
|
import cbws from './websocket';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Object containing methods for interacting with Codebolt MCP (Model Context Protocol) tools.
|
|
6
|
+
* Provides functionality to discover, list, and execute tools.
|
|
7
|
+
*/
|
|
3
8
|
const codeboltMCP = {
|
|
9
|
+
/**
|
|
10
|
+
* Gets the list of currently enabled toolboxes.
|
|
11
|
+
*
|
|
12
|
+
* @returns Promise with the enabled toolboxes data
|
|
13
|
+
*/
|
|
4
14
|
getEnabledToolBoxes: (): Promise<any> => {
|
|
5
15
|
return new Promise((resolve, reject) => {
|
|
6
16
|
cbws.getWebsocket.send(JSON.stringify({
|
|
@@ -22,6 +32,12 @@ const codeboltMCP = {
|
|
|
22
32
|
});
|
|
23
33
|
});
|
|
24
34
|
},
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Gets the list of locally available toolboxes.
|
|
38
|
+
*
|
|
39
|
+
* @returns Promise with the local toolboxes data
|
|
40
|
+
*/
|
|
25
41
|
getLocalToolBoxes: (): Promise<any> => {
|
|
26
42
|
return new Promise((resolve, reject) => {
|
|
27
43
|
cbws.getWebsocket.send(JSON.stringify({
|
|
@@ -43,11 +59,24 @@ const codeboltMCP = {
|
|
|
43
59
|
});
|
|
44
60
|
});
|
|
45
61
|
},
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Gets toolboxes mentioned in a user message.
|
|
65
|
+
*
|
|
66
|
+
* @param userMessage - The user message to extract mentions from
|
|
67
|
+
* @returns Promise with the mentioned toolboxes
|
|
68
|
+
*/
|
|
46
69
|
getMentionedToolBoxes: (userMessage: UserMessage): Promise<any> => {
|
|
47
70
|
return new Promise((resolve, reject) => {
|
|
48
71
|
resolve(userMessage.mentionedMCPs);
|
|
49
72
|
});
|
|
50
73
|
},
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Gets all available toolboxes.
|
|
77
|
+
*
|
|
78
|
+
* @returns Promise with all available toolboxes data
|
|
79
|
+
*/
|
|
51
80
|
getAvailableToolBoxes: (): Promise<any> => {
|
|
52
81
|
return new Promise((resolve, reject) => {
|
|
53
82
|
cbws.getWebsocket.send(JSON.stringify({
|
|
@@ -69,6 +98,13 @@ const codeboltMCP = {
|
|
|
69
98
|
});
|
|
70
99
|
});
|
|
71
100
|
},
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Searches for available toolboxes matching a query.
|
|
104
|
+
*
|
|
105
|
+
* @param query - The search query string
|
|
106
|
+
* @returns Promise with matching toolboxes data
|
|
107
|
+
*/
|
|
72
108
|
searchAvailableToolBoxes: (query: string): Promise<any> => {
|
|
73
109
|
return new Promise((resolve, reject) => {
|
|
74
110
|
cbws.getWebsocket.send(JSON.stringify({
|
|
@@ -91,6 +127,13 @@ const codeboltMCP = {
|
|
|
91
127
|
});
|
|
92
128
|
});
|
|
93
129
|
},
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Lists all tools from the specified toolboxes.
|
|
133
|
+
*
|
|
134
|
+
* @param toolBoxes - Array of toolbox names to list tools from
|
|
135
|
+
* @returns Promise with tools from the specified toolboxes
|
|
136
|
+
*/
|
|
94
137
|
listToolsFromToolBoxes: (toolBoxes: string[]): Promise<any> => {
|
|
95
138
|
return new Promise((resolve, reject) => {
|
|
96
139
|
cbws.getWebsocket.send(JSON.stringify({
|
|
@@ -114,6 +157,14 @@ const codeboltMCP = {
|
|
|
114
157
|
});
|
|
115
158
|
|
|
116
159
|
},
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Configures a specific toolbox with provided configuration.
|
|
163
|
+
*
|
|
164
|
+
* @param name - The name of the toolbox to configure
|
|
165
|
+
* @param config - Configuration object for the toolbox
|
|
166
|
+
* @returns Promise with the configuration result
|
|
167
|
+
*/
|
|
117
168
|
configureToolBox: (name: string, config: any): Promise<any> => {
|
|
118
169
|
return new Promise((resolve, reject) => {
|
|
119
170
|
cbws.getWebsocket.send(JSON.stringify({
|
|
@@ -137,6 +188,13 @@ const codeboltMCP = {
|
|
|
137
188
|
});
|
|
138
189
|
});
|
|
139
190
|
},
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Gets detailed information about specific tools.
|
|
194
|
+
*
|
|
195
|
+
* @param tools - Array of toolbox and tool name pairs
|
|
196
|
+
* @returns Promise with detailed information about the tools
|
|
197
|
+
*/
|
|
140
198
|
getTools: (tools: { toolbox: string, toolName: string }[]): Promise<any[]> => {
|
|
141
199
|
return new Promise((resolve, reject) => {
|
|
142
200
|
cbws.getWebsocket.send(JSON.stringify({
|
|
@@ -159,6 +217,15 @@ const codeboltMCP = {
|
|
|
159
217
|
});
|
|
160
218
|
});
|
|
161
219
|
},
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Executes a specific tool with provided parameters.
|
|
223
|
+
*
|
|
224
|
+
* @param toolbox - The name of the toolbox containing the tool
|
|
225
|
+
* @param toolName - The name of the tool to execute
|
|
226
|
+
* @param params - Parameters to pass to the tool
|
|
227
|
+
* @returns Promise with the execution result
|
|
228
|
+
*/
|
|
162
229
|
executeTool: (toolbox: string, toolName: string, params: any): Promise<any> => {
|
|
163
230
|
return new Promise((resolve, reject) => {
|
|
164
231
|
cbws.getWebsocket.send(JSON.stringify({
|
package/src/modules/websocket.ts
CHANGED
|
@@ -59,12 +59,10 @@ class cbws {
|
|
|
59
59
|
|
|
60
60
|
return new Promise((resolve, reject) => {
|
|
61
61
|
this.websocket.on('error', (error: Error) => {
|
|
62
|
-
console.log('WebSocket error:', error);
|
|
63
62
|
reject(error);
|
|
64
63
|
});
|
|
65
64
|
|
|
66
65
|
this.websocket.on('open', () => {
|
|
67
|
-
console.log('WebSocket connected');
|
|
68
66
|
// if (this.websocket) {
|
|
69
67
|
// this.websocket.send(JSON.stringify({
|
|
70
68
|
// "type": "sendMessage",
|
|
@@ -76,7 +74,6 @@ class cbws {
|
|
|
76
74
|
|
|
77
75
|
this.websocket.on('message', (data: WebSocket.Data) => {
|
|
78
76
|
// Handle incoming WebSocket messages here.
|
|
79
|
-
// console.log('WebSocket message received:', data);
|
|
80
77
|
});
|
|
81
78
|
});
|
|
82
79
|
}
|
package/modules/mcp.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare const codeboltMCP: {
|
|
2
|
-
executeTool: (toolName: string, params: any, mcpServer?: string) => Promise<any>;
|
|
3
|
-
getMcpTools: (tools: string[]) => Promise<any>;
|
|
4
|
-
getAllMCPTools: (mpcName: string) => Promise<any>;
|
|
5
|
-
getMCPTool: (name: string) => Promise<any>;
|
|
6
|
-
getEnabledMCPS: () => Promise<any>;
|
|
7
|
-
configureMCPTool: (name: string, config: any) => Promise<any>;
|
|
8
|
-
};
|
|
9
|
-
export default codeboltMCP;
|
package/modules/mcp.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const websocket_1 = __importDefault(require("./websocket"));
|
|
7
|
-
const codeboltMCP = {
|
|
8
|
-
executeTool: (toolName, params, mcpServer) => {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
11
|
-
"type": "mcpEvent",
|
|
12
|
-
"action": "executeTool",
|
|
13
|
-
"toolName": toolName,
|
|
14
|
-
"params": params
|
|
15
|
-
}));
|
|
16
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
17
|
-
try {
|
|
18
|
-
const response = JSON.parse(data);
|
|
19
|
-
if (response.type === "executeToolResponse") {
|
|
20
|
-
resolve(response.data);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
reject(new Error("Failed to parse response"));
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
28
|
-
reject(error);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
},
|
|
32
|
-
getMcpTools: (tools) => {
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
35
|
-
"type": "mcpEvent",
|
|
36
|
-
"action": "getMcpTools",
|
|
37
|
-
"tools": tools
|
|
38
|
-
}));
|
|
39
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
40
|
-
try {
|
|
41
|
-
const response = JSON.parse(data);
|
|
42
|
-
if (response.type === "getMcpToolsResponse") {
|
|
43
|
-
resolve(response.data);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
reject(new Error("Failed to parse response"));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
51
|
-
reject(error);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
getAllMCPTools: (mpcName) => {
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
58
|
-
"type": "mcpEvent",
|
|
59
|
-
"action": "getAllMCPTools",
|
|
60
|
-
"mpcName": mpcName
|
|
61
|
-
}));
|
|
62
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
63
|
-
try {
|
|
64
|
-
const response = JSON.parse(data);
|
|
65
|
-
if (response.type === "getAllMCPToolsResponse") {
|
|
66
|
-
resolve(response.data);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
reject(new Error("Failed to parse response"));
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
74
|
-
reject(error);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
},
|
|
78
|
-
getMCPTool: (name) => {
|
|
79
|
-
return new Promise((resolve, reject) => {
|
|
80
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
81
|
-
"type": "mcpEvent",
|
|
82
|
-
"action": "getMCPTool",
|
|
83
|
-
"mcpName": name
|
|
84
|
-
}));
|
|
85
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
86
|
-
try {
|
|
87
|
-
const response = JSON.parse(data);
|
|
88
|
-
if (response.type === "getMCPToolResponse") {
|
|
89
|
-
resolve(response.data);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
reject(new Error("Failed to parse response"));
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
97
|
-
reject(error);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
getEnabledMCPS: () => {
|
|
102
|
-
return new Promise((resolve, reject) => {
|
|
103
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
104
|
-
"type": "mcpEvent",
|
|
105
|
-
"action": "getEnabledMCPS"
|
|
106
|
-
}));
|
|
107
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
108
|
-
try {
|
|
109
|
-
const response = JSON.parse(data);
|
|
110
|
-
if (response.type === "getEnabledMCPSResponse") {
|
|
111
|
-
resolve(response.data);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
reject(new Error("Failed to parse response"));
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
119
|
-
reject(error);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
},
|
|
123
|
-
configureMCPTool: (name, config) => {
|
|
124
|
-
return new Promise((resolve, reject) => {
|
|
125
|
-
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
126
|
-
"type": "mcpEvent",
|
|
127
|
-
"action": "configureMCPTool",
|
|
128
|
-
"mcpName": name,
|
|
129
|
-
"config": config
|
|
130
|
-
}));
|
|
131
|
-
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
132
|
-
try {
|
|
133
|
-
const response = JSON.parse(data);
|
|
134
|
-
if (response.type === "configureMCPToolResponse") {
|
|
135
|
-
resolve(response.data);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
catch (error) {
|
|
139
|
-
reject(new Error("Failed to parse response"));
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
websocket_1.default.getWebsocket.on('error', (error) => {
|
|
143
|
-
reject(error);
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
};
|
|
148
|
-
exports.default = codeboltMCP;
|
package/modules/toolBox.bkp.d.ts
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
|
-
import { ClientCapabilities, CreateMessageRequestSchema, Root } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
-
import { z } from "zod";
|
|
7
|
-
import { StrictEventEmitter } from "strict-event-emitter-types";
|
|
8
|
-
import { EventEmitter } from "events";
|
|
9
|
-
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
10
|
-
export type SSEServer = {
|
|
11
|
-
close: () => Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
type FastMCPEvents = {
|
|
14
|
-
connect: (event: {
|
|
15
|
-
session: FastMCPSession;
|
|
16
|
-
}) => void;
|
|
17
|
-
disconnect: (event: {
|
|
18
|
-
session: FastMCPSession;
|
|
19
|
-
}) => void;
|
|
20
|
-
};
|
|
21
|
-
type FastMCPSessionEvents = {
|
|
22
|
-
rootsChanged: (event: {
|
|
23
|
-
roots: Root[];
|
|
24
|
-
}) => void;
|
|
25
|
-
error: (event: {
|
|
26
|
-
error: Error;
|
|
27
|
-
}) => void;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Generates an image content object from a URL, file path, or buffer.
|
|
31
|
-
*/
|
|
32
|
-
export declare const imageContent: (input: {
|
|
33
|
-
url: string;
|
|
34
|
-
} | {
|
|
35
|
-
path: string;
|
|
36
|
-
} | {
|
|
37
|
-
buffer: Buffer;
|
|
38
|
-
}) => Promise<ImageContent>;
|
|
39
|
-
declare abstract class FastMCPError extends Error {
|
|
40
|
-
constructor(message?: string);
|
|
41
|
-
}
|
|
42
|
-
type Extra = unknown;
|
|
43
|
-
type Extras = Record<string, Extra>;
|
|
44
|
-
export declare class UnexpectedStateError extends FastMCPError {
|
|
45
|
-
extras?: Extras;
|
|
46
|
-
constructor(message: string, extras?: Extras);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* An error that is meant to be surfaced to the user.
|
|
50
|
-
*/
|
|
51
|
-
export declare class UserError extends UnexpectedStateError {
|
|
52
|
-
}
|
|
53
|
-
type ToolParameters = z.ZodTypeAny;
|
|
54
|
-
type Literal = boolean | null | number | string | undefined;
|
|
55
|
-
type SerializableValue = Literal | SerializableValue[] | {
|
|
56
|
-
[key: string]: SerializableValue;
|
|
57
|
-
};
|
|
58
|
-
type Progress = {
|
|
59
|
-
/**
|
|
60
|
-
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
|
|
61
|
-
*/
|
|
62
|
-
progress: number;
|
|
63
|
-
/**
|
|
64
|
-
* Total number of items to process (or total progress required), if known.
|
|
65
|
-
*/
|
|
66
|
-
total?: number;
|
|
67
|
-
};
|
|
68
|
-
type Context = {
|
|
69
|
-
reportProgress: (progress: Progress) => Promise<void>;
|
|
70
|
-
log: {
|
|
71
|
-
debug: (message: string, data?: SerializableValue) => void;
|
|
72
|
-
error: (message: string, data?: SerializableValue) => void;
|
|
73
|
-
info: (message: string, data?: SerializableValue) => void;
|
|
74
|
-
warn: (message: string, data?: SerializableValue) => void;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
type TextContent = {
|
|
78
|
-
type: "text";
|
|
79
|
-
text: string;
|
|
80
|
-
};
|
|
81
|
-
type ImageContent = {
|
|
82
|
-
type: "image";
|
|
83
|
-
data: string;
|
|
84
|
-
mimeType: string;
|
|
85
|
-
};
|
|
86
|
-
type Content = TextContent | ImageContent;
|
|
87
|
-
type ContentResult = {
|
|
88
|
-
content: Content[];
|
|
89
|
-
isError?: boolean;
|
|
90
|
-
};
|
|
91
|
-
type Completion = {
|
|
92
|
-
values: string[];
|
|
93
|
-
total?: number;
|
|
94
|
-
hasMore?: boolean;
|
|
95
|
-
};
|
|
96
|
-
type Tool<Params extends ToolParameters = ToolParameters> = {
|
|
97
|
-
name: string;
|
|
98
|
-
description?: string;
|
|
99
|
-
parameters?: Params;
|
|
100
|
-
execute: (args: z.infer<Params>, context: Context) => Promise<string | ContentResult | TextContent | ImageContent>;
|
|
101
|
-
};
|
|
102
|
-
type ResourceResult = {
|
|
103
|
-
text: string;
|
|
104
|
-
} | {
|
|
105
|
-
blob: string;
|
|
106
|
-
};
|
|
107
|
-
type InputResourceTemplateArgument = Readonly<{
|
|
108
|
-
name: string;
|
|
109
|
-
description?: string;
|
|
110
|
-
complete?: ArgumentValueCompleter;
|
|
111
|
-
}>;
|
|
112
|
-
type ResourceTemplateArgument = Readonly<{
|
|
113
|
-
name: string;
|
|
114
|
-
description?: string;
|
|
115
|
-
complete?: ArgumentValueCompleter;
|
|
116
|
-
}>;
|
|
117
|
-
type ResourceTemplateArgumentsToObject<T extends {
|
|
118
|
-
name: string;
|
|
119
|
-
}[]> = {
|
|
120
|
-
[K in T[number]["name"]]: string;
|
|
121
|
-
};
|
|
122
|
-
type InputResourceTemplate<Arguments extends ResourceTemplateArgument[] = ResourceTemplateArgument[]> = {
|
|
123
|
-
uriTemplate: string;
|
|
124
|
-
name: string;
|
|
125
|
-
description?: string;
|
|
126
|
-
mimeType?: string;
|
|
127
|
-
arguments: Arguments;
|
|
128
|
-
load: (args: ResourceTemplateArgumentsToObject<Arguments>) => Promise<ResourceResult>;
|
|
129
|
-
};
|
|
130
|
-
type Resource = {
|
|
131
|
-
uri: string;
|
|
132
|
-
name: string;
|
|
133
|
-
description?: string;
|
|
134
|
-
mimeType?: string;
|
|
135
|
-
load: () => Promise<ResourceResult | ResourceResult[]>;
|
|
136
|
-
complete?: (name: string, value: string) => Promise<Completion>;
|
|
137
|
-
};
|
|
138
|
-
type ArgumentValueCompleter = (value: string) => Promise<Completion>;
|
|
139
|
-
type InputPromptArgument = Readonly<{
|
|
140
|
-
name: string;
|
|
141
|
-
description?: string;
|
|
142
|
-
required?: boolean;
|
|
143
|
-
complete?: ArgumentValueCompleter;
|
|
144
|
-
enum?: string[];
|
|
145
|
-
}>;
|
|
146
|
-
type PromptArgumentsToObject<T extends {
|
|
147
|
-
name: string;
|
|
148
|
-
required?: boolean;
|
|
149
|
-
}[]> = {
|
|
150
|
-
[K in T[number]["name"]]: Extract<T[number], {
|
|
151
|
-
name: K;
|
|
152
|
-
}>["required"] extends true ? string : string | undefined;
|
|
153
|
-
};
|
|
154
|
-
type InputPrompt<Arguments extends InputPromptArgument[] = InputPromptArgument[], Args = PromptArgumentsToObject<Arguments>> = {
|
|
155
|
-
name: string;
|
|
156
|
-
description?: string;
|
|
157
|
-
arguments?: InputPromptArgument[];
|
|
158
|
-
load: (args: Args) => Promise<string>;
|
|
159
|
-
};
|
|
160
|
-
type PromptArgument = Readonly<{
|
|
161
|
-
name: string;
|
|
162
|
-
description?: string;
|
|
163
|
-
required?: boolean;
|
|
164
|
-
complete?: ArgumentValueCompleter;
|
|
165
|
-
enum?: string[];
|
|
166
|
-
}>;
|
|
167
|
-
type Prompt<Arguments extends PromptArgument[] = PromptArgument[], Args = PromptArgumentsToObject<Arguments>> = {
|
|
168
|
-
arguments?: PromptArgument[];
|
|
169
|
-
complete?: (name: string, value: string) => Promise<Completion>;
|
|
170
|
-
description?: string;
|
|
171
|
-
load: (args: Args) => Promise<string>;
|
|
172
|
-
name: string;
|
|
173
|
-
};
|
|
174
|
-
type ServerOptions = {
|
|
175
|
-
name: string;
|
|
176
|
-
version: `${number}.${number}.${number}`;
|
|
177
|
-
};
|
|
178
|
-
type LoggingLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
|
|
179
|
-
declare const FastMCPSessionEventEmitterBase: {
|
|
180
|
-
new (): StrictEventEmitter<EventEmitter, FastMCPSessionEvents>;
|
|
181
|
-
};
|
|
182
|
-
declare class FastMCPSessionEventEmitter extends FastMCPSessionEventEmitterBase {
|
|
183
|
-
}
|
|
184
|
-
type SamplingResponse = {
|
|
185
|
-
model: string;
|
|
186
|
-
stopReason?: "endTurn" | "stopSequence" | "maxTokens" | string;
|
|
187
|
-
role: "user" | "assistant";
|
|
188
|
-
content: TextContent | ImageContent;
|
|
189
|
-
};
|
|
190
|
-
export declare class FastMCPSession extends FastMCPSessionEventEmitter {
|
|
191
|
-
#private;
|
|
192
|
-
constructor({ name, version, tools, resources, resourcesTemplates, prompts, }: {
|
|
193
|
-
name: string;
|
|
194
|
-
version: string;
|
|
195
|
-
tools: Tool[];
|
|
196
|
-
resources: Resource[];
|
|
197
|
-
resourcesTemplates: InputResourceTemplate[];
|
|
198
|
-
prompts: Prompt[];
|
|
199
|
-
});
|
|
200
|
-
private addResource;
|
|
201
|
-
private addResourceTemplate;
|
|
202
|
-
private addPrompt;
|
|
203
|
-
get clientCapabilities(): ClientCapabilities | null;
|
|
204
|
-
get server(): Server;
|
|
205
|
-
requestSampling(message: z.infer<typeof CreateMessageRequestSchema>["params"]): Promise<SamplingResponse>;
|
|
206
|
-
connect(transport: Transport): Promise<void>;
|
|
207
|
-
get roots(): Root[];
|
|
208
|
-
close(): Promise<void>;
|
|
209
|
-
private setupErrorHandling;
|
|
210
|
-
get loggingLevel(): LoggingLevel;
|
|
211
|
-
private setupCompleteHandlers;
|
|
212
|
-
private setupRootsHandlers;
|
|
213
|
-
private setupLoggingHandlers;
|
|
214
|
-
private setupToolHandlers;
|
|
215
|
-
private setupResourceHandlers;
|
|
216
|
-
private setupResourceTemplateHandlers;
|
|
217
|
-
private setupPromptHandlers;
|
|
218
|
-
}
|
|
219
|
-
declare const FastMCPEventEmitterBase: {
|
|
220
|
-
new (): StrictEventEmitter<EventEmitter, FastMCPEvents>;
|
|
221
|
-
};
|
|
222
|
-
declare class FastMCPEventEmitter extends FastMCPEventEmitterBase {
|
|
223
|
-
}
|
|
224
|
-
export declare class ToolBox extends FastMCPEventEmitter {
|
|
225
|
-
#private;
|
|
226
|
-
options: ServerOptions;
|
|
227
|
-
constructor(options: ServerOptions);
|
|
228
|
-
get sessions(): FastMCPSession[];
|
|
229
|
-
/**
|
|
230
|
-
* Adds a tool to the server.
|
|
231
|
-
*/
|
|
232
|
-
addTool<Params extends ToolParameters>(tool: Tool<Params>): void;
|
|
233
|
-
/**
|
|
234
|
-
* Adds a resource to the server.
|
|
235
|
-
*/
|
|
236
|
-
addResource(resource: Resource): void;
|
|
237
|
-
/**
|
|
238
|
-
* Adds a resource template to the server.
|
|
239
|
-
*/
|
|
240
|
-
addResourceTemplate<const Args extends InputResourceTemplateArgument[]>(resource: InputResourceTemplate<Args>): void;
|
|
241
|
-
/**
|
|
242
|
-
* Adds a prompt to the server.
|
|
243
|
-
*/
|
|
244
|
-
addPrompt<const Args extends InputPromptArgument[]>(prompt: InputPrompt<Args>): void;
|
|
245
|
-
/**
|
|
246
|
-
* Starts the server.
|
|
247
|
-
*/
|
|
248
|
-
activate(options?: {
|
|
249
|
-
transportType: "stdio";
|
|
250
|
-
} | {
|
|
251
|
-
transportType: "sse";
|
|
252
|
-
sse: {
|
|
253
|
-
endpoint: `/${string}`;
|
|
254
|
-
port: number;
|
|
255
|
-
};
|
|
256
|
-
}): Promise<void>;
|
|
257
|
-
/**
|
|
258
|
-
* Stops the server.
|
|
259
|
-
*/
|
|
260
|
-
stop(): Promise<void>;
|
|
261
|
-
}
|
|
262
|
-
export {};
|