@realtimex/sdk 1.3.2 → 1.3.4
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 +13 -0
- package/dist/index.d.mts +98 -2
- package/dist/index.d.ts +98 -2
- package/dist/index.js +51 -0
- package/dist/index.mjs +50 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -167,6 +167,19 @@ const response = await sdk.llm.chat(
|
|
|
167
167
|
);
|
|
168
168
|
console.log(response.response?.content);
|
|
169
169
|
|
|
170
|
+
// Multimodal Chat (text + file/image blocks)
|
|
171
|
+
const multimodal = await sdk.llm.chat([
|
|
172
|
+
{
|
|
173
|
+
role: 'user',
|
|
174
|
+
content: [
|
|
175
|
+
{ type: 'text', text: 'Summarize the attached document' },
|
|
176
|
+
{ type: 'input_file', file_url: 'https://example.com/report.pdf' },
|
|
177
|
+
{ type: 'input_image', image_url: 'https://example.com/chart.png' }
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
]);
|
|
181
|
+
console.log(multimodal.response?.content);
|
|
182
|
+
|
|
170
183
|
// Streaming Chat
|
|
171
184
|
for await (const chunk of sdk.llm.chatStream(messages, options)) {
|
|
172
185
|
process.stdout.write(chunk.textResponse || '');
|
package/dist/index.d.mts
CHANGED
|
@@ -380,9 +380,36 @@ declare class PortModule {
|
|
|
380
380
|
* - Vector storage (upsert, query, delete)
|
|
381
381
|
*/
|
|
382
382
|
|
|
383
|
+
interface ChatTextBlock {
|
|
384
|
+
type: 'text' | 'input_text';
|
|
385
|
+
text: string;
|
|
386
|
+
[key: string]: unknown;
|
|
387
|
+
}
|
|
388
|
+
interface ChatImageUrlBlock {
|
|
389
|
+
type: 'image_url' | 'input_image';
|
|
390
|
+
image_url: string | {
|
|
391
|
+
url: string;
|
|
392
|
+
detail?: 'auto' | 'low' | 'high';
|
|
393
|
+
[key: string]: unknown;
|
|
394
|
+
};
|
|
395
|
+
[key: string]: unknown;
|
|
396
|
+
}
|
|
397
|
+
interface ChatFileBlock {
|
|
398
|
+
type: 'input_file' | 'file';
|
|
399
|
+
file_url?: string;
|
|
400
|
+
file_id?: string;
|
|
401
|
+
filename?: string;
|
|
402
|
+
[key: string]: unknown;
|
|
403
|
+
}
|
|
404
|
+
interface ChatCustomBlock {
|
|
405
|
+
type: string;
|
|
406
|
+
[key: string]: unknown;
|
|
407
|
+
}
|
|
408
|
+
type ChatContentBlock = ChatTextBlock | ChatImageUrlBlock | ChatFileBlock | ChatCustomBlock;
|
|
409
|
+
type ChatMessageContent = string | ChatContentBlock[];
|
|
383
410
|
interface ChatMessage {
|
|
384
411
|
role: 'system' | 'user' | 'assistant';
|
|
385
|
-
content:
|
|
412
|
+
content: ChatMessageContent;
|
|
386
413
|
}
|
|
387
414
|
interface ChatOptions {
|
|
388
415
|
model?: string;
|
|
@@ -955,6 +982,74 @@ declare class AgentModule {
|
|
|
955
982
|
}>;
|
|
956
983
|
}
|
|
957
984
|
|
|
985
|
+
/**
|
|
986
|
+
* MCP Module - Interact with MCP servers via RealtimeX SDK
|
|
987
|
+
*/
|
|
988
|
+
|
|
989
|
+
interface MCPServer {
|
|
990
|
+
/** Unique server name (slug) */
|
|
991
|
+
name: string;
|
|
992
|
+
/** User-friendly display name */
|
|
993
|
+
display_name: string;
|
|
994
|
+
/** Server description */
|
|
995
|
+
description: string | null;
|
|
996
|
+
/** Server type: 'stdio', 'http', 'sse', or 'remote' */
|
|
997
|
+
server_type: string;
|
|
998
|
+
/** Whether the server is enabled */
|
|
999
|
+
enabled: boolean;
|
|
1000
|
+
/** Provider: 'local' or 'remote' */
|
|
1001
|
+
provider: 'local' | 'remote';
|
|
1002
|
+
/** Tags / categories */
|
|
1003
|
+
tags: string[];
|
|
1004
|
+
}
|
|
1005
|
+
interface MCPTool {
|
|
1006
|
+
/** Tool name */
|
|
1007
|
+
name: string;
|
|
1008
|
+
/** Tool description */
|
|
1009
|
+
description: string | null;
|
|
1010
|
+
/** JSON Schema describing the tool's input parameters */
|
|
1011
|
+
input_schema: Record<string, any>;
|
|
1012
|
+
}
|
|
1013
|
+
interface MCPToolResult {
|
|
1014
|
+
/** Whether the execution was successful */
|
|
1015
|
+
success: boolean;
|
|
1016
|
+
/** Server that executed the tool */
|
|
1017
|
+
server: string;
|
|
1018
|
+
/** Tool that was executed */
|
|
1019
|
+
tool: string;
|
|
1020
|
+
/** Provider used */
|
|
1021
|
+
provider: string;
|
|
1022
|
+
/** Execution result data */
|
|
1023
|
+
result: any;
|
|
1024
|
+
/** Error message if failed */
|
|
1025
|
+
error?: string;
|
|
1026
|
+
}
|
|
1027
|
+
declare class MCPModule extends ApiModule {
|
|
1028
|
+
constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
|
|
1029
|
+
/**
|
|
1030
|
+
* List configured MCP servers.
|
|
1031
|
+
* @param provider - Filter by provider: 'local', 'remote', or 'all' (default: 'all')
|
|
1032
|
+
* @returns Array of MCP server objects
|
|
1033
|
+
*/
|
|
1034
|
+
getServers(provider?: 'local' | 'remote' | 'all'): Promise<MCPServer[]>;
|
|
1035
|
+
/**
|
|
1036
|
+
* List available tools for a specific MCP server.
|
|
1037
|
+
* @param serverName - The server name (slug)
|
|
1038
|
+
* @param provider - Provider: 'local' or 'remote' (default: 'local')
|
|
1039
|
+
* @returns Array of tool objects with name, description, and input schema
|
|
1040
|
+
*/
|
|
1041
|
+
getTools(serverName: string, provider?: 'local' | 'remote'): Promise<MCPTool[]>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Execute a tool on an MCP server.
|
|
1044
|
+
* @param serverName - The server name (slug)
|
|
1045
|
+
* @param toolName - The tool name to execute
|
|
1046
|
+
* @param args - Arguments to pass to the tool (matches tool's input_schema)
|
|
1047
|
+
* @param provider - Provider: 'local' or 'remote' (default: 'local')
|
|
1048
|
+
* @returns Tool execution result
|
|
1049
|
+
*/
|
|
1050
|
+
executeTool(serverName: string, toolName: string, args?: Record<string, any>, provider?: 'local' | 'remote'): Promise<any>;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
958
1053
|
/**
|
|
959
1054
|
* RealtimeX Local App SDK
|
|
960
1055
|
*
|
|
@@ -972,6 +1067,7 @@ declare class RealtimeXSDK {
|
|
|
972
1067
|
tts: TTSModule;
|
|
973
1068
|
stt: STTModule;
|
|
974
1069
|
agent: AgentModule;
|
|
1070
|
+
mcp: MCPModule;
|
|
975
1071
|
readonly appId: string;
|
|
976
1072
|
readonly appName: string | undefined;
|
|
977
1073
|
readonly apiKey: string | undefined;
|
|
@@ -1006,4 +1102,4 @@ declare class RealtimeXSDK {
|
|
|
1006
1102
|
getAppDataDir(): Promise<string>;
|
|
1007
1103
|
}
|
|
1008
1104
|
|
|
1009
|
-
export { ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, type ChatMessage, type ChatOptions, type ChatResponse, type EmbedOptions, type EmbedResponse, LLMModule, LLMPermissionError, LLMProviderError, PermissionDeniedError, PermissionRequiredError, PortModule, type Provider, type ProvidersResponse, RealtimeXSDK, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, type StreamChunk, type StreamChunkEvent, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace };
|
|
1105
|
+
export { ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, type ChatContentBlock, type ChatCustomBlock, type ChatFileBlock, type ChatImageUrlBlock, type ChatMessage, type ChatMessageContent, type ChatOptions, type ChatResponse, type ChatTextBlock, type EmbedOptions, type EmbedResponse, LLMModule, LLMPermissionError, LLMProviderError, MCPModule, type MCPServer, type MCPTool, type MCPToolResult, PermissionDeniedError, PermissionRequiredError, PortModule, type Provider, type ProvidersResponse, RealtimeXSDK, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, type StreamChunk, type StreamChunkEvent, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace };
|
package/dist/index.d.ts
CHANGED
|
@@ -380,9 +380,36 @@ declare class PortModule {
|
|
|
380
380
|
* - Vector storage (upsert, query, delete)
|
|
381
381
|
*/
|
|
382
382
|
|
|
383
|
+
interface ChatTextBlock {
|
|
384
|
+
type: 'text' | 'input_text';
|
|
385
|
+
text: string;
|
|
386
|
+
[key: string]: unknown;
|
|
387
|
+
}
|
|
388
|
+
interface ChatImageUrlBlock {
|
|
389
|
+
type: 'image_url' | 'input_image';
|
|
390
|
+
image_url: string | {
|
|
391
|
+
url: string;
|
|
392
|
+
detail?: 'auto' | 'low' | 'high';
|
|
393
|
+
[key: string]: unknown;
|
|
394
|
+
};
|
|
395
|
+
[key: string]: unknown;
|
|
396
|
+
}
|
|
397
|
+
interface ChatFileBlock {
|
|
398
|
+
type: 'input_file' | 'file';
|
|
399
|
+
file_url?: string;
|
|
400
|
+
file_id?: string;
|
|
401
|
+
filename?: string;
|
|
402
|
+
[key: string]: unknown;
|
|
403
|
+
}
|
|
404
|
+
interface ChatCustomBlock {
|
|
405
|
+
type: string;
|
|
406
|
+
[key: string]: unknown;
|
|
407
|
+
}
|
|
408
|
+
type ChatContentBlock = ChatTextBlock | ChatImageUrlBlock | ChatFileBlock | ChatCustomBlock;
|
|
409
|
+
type ChatMessageContent = string | ChatContentBlock[];
|
|
383
410
|
interface ChatMessage {
|
|
384
411
|
role: 'system' | 'user' | 'assistant';
|
|
385
|
-
content:
|
|
412
|
+
content: ChatMessageContent;
|
|
386
413
|
}
|
|
387
414
|
interface ChatOptions {
|
|
388
415
|
model?: string;
|
|
@@ -955,6 +982,74 @@ declare class AgentModule {
|
|
|
955
982
|
}>;
|
|
956
983
|
}
|
|
957
984
|
|
|
985
|
+
/**
|
|
986
|
+
* MCP Module - Interact with MCP servers via RealtimeX SDK
|
|
987
|
+
*/
|
|
988
|
+
|
|
989
|
+
interface MCPServer {
|
|
990
|
+
/** Unique server name (slug) */
|
|
991
|
+
name: string;
|
|
992
|
+
/** User-friendly display name */
|
|
993
|
+
display_name: string;
|
|
994
|
+
/** Server description */
|
|
995
|
+
description: string | null;
|
|
996
|
+
/** Server type: 'stdio', 'http', 'sse', or 'remote' */
|
|
997
|
+
server_type: string;
|
|
998
|
+
/** Whether the server is enabled */
|
|
999
|
+
enabled: boolean;
|
|
1000
|
+
/** Provider: 'local' or 'remote' */
|
|
1001
|
+
provider: 'local' | 'remote';
|
|
1002
|
+
/** Tags / categories */
|
|
1003
|
+
tags: string[];
|
|
1004
|
+
}
|
|
1005
|
+
interface MCPTool {
|
|
1006
|
+
/** Tool name */
|
|
1007
|
+
name: string;
|
|
1008
|
+
/** Tool description */
|
|
1009
|
+
description: string | null;
|
|
1010
|
+
/** JSON Schema describing the tool's input parameters */
|
|
1011
|
+
input_schema: Record<string, any>;
|
|
1012
|
+
}
|
|
1013
|
+
interface MCPToolResult {
|
|
1014
|
+
/** Whether the execution was successful */
|
|
1015
|
+
success: boolean;
|
|
1016
|
+
/** Server that executed the tool */
|
|
1017
|
+
server: string;
|
|
1018
|
+
/** Tool that was executed */
|
|
1019
|
+
tool: string;
|
|
1020
|
+
/** Provider used */
|
|
1021
|
+
provider: string;
|
|
1022
|
+
/** Execution result data */
|
|
1023
|
+
result: any;
|
|
1024
|
+
/** Error message if failed */
|
|
1025
|
+
error?: string;
|
|
1026
|
+
}
|
|
1027
|
+
declare class MCPModule extends ApiModule {
|
|
1028
|
+
constructor(realtimexUrl: string, appId: string, appName?: string, apiKey?: string);
|
|
1029
|
+
/**
|
|
1030
|
+
* List configured MCP servers.
|
|
1031
|
+
* @param provider - Filter by provider: 'local', 'remote', or 'all' (default: 'all')
|
|
1032
|
+
* @returns Array of MCP server objects
|
|
1033
|
+
*/
|
|
1034
|
+
getServers(provider?: 'local' | 'remote' | 'all'): Promise<MCPServer[]>;
|
|
1035
|
+
/**
|
|
1036
|
+
* List available tools for a specific MCP server.
|
|
1037
|
+
* @param serverName - The server name (slug)
|
|
1038
|
+
* @param provider - Provider: 'local' or 'remote' (default: 'local')
|
|
1039
|
+
* @returns Array of tool objects with name, description, and input schema
|
|
1040
|
+
*/
|
|
1041
|
+
getTools(serverName: string, provider?: 'local' | 'remote'): Promise<MCPTool[]>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Execute a tool on an MCP server.
|
|
1044
|
+
* @param serverName - The server name (slug)
|
|
1045
|
+
* @param toolName - The tool name to execute
|
|
1046
|
+
* @param args - Arguments to pass to the tool (matches tool's input_schema)
|
|
1047
|
+
* @param provider - Provider: 'local' or 'remote' (default: 'local')
|
|
1048
|
+
* @returns Tool execution result
|
|
1049
|
+
*/
|
|
1050
|
+
executeTool(serverName: string, toolName: string, args?: Record<string, any>, provider?: 'local' | 'remote'): Promise<any>;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
958
1053
|
/**
|
|
959
1054
|
* RealtimeX Local App SDK
|
|
960
1055
|
*
|
|
@@ -972,6 +1067,7 @@ declare class RealtimeXSDK {
|
|
|
972
1067
|
tts: TTSModule;
|
|
973
1068
|
stt: STTModule;
|
|
974
1069
|
agent: AgentModule;
|
|
1070
|
+
mcp: MCPModule;
|
|
975
1071
|
readonly appId: string;
|
|
976
1072
|
readonly appName: string | undefined;
|
|
977
1073
|
readonly apiKey: string | undefined;
|
|
@@ -1006,4 +1102,4 @@ declare class RealtimeXSDK {
|
|
|
1006
1102
|
getAppDataDir(): Promise<string>;
|
|
1007
1103
|
}
|
|
1008
1104
|
|
|
1009
|
-
export { ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, type ChatMessage, type ChatOptions, type ChatResponse, type EmbedOptions, type EmbedResponse, LLMModule, LLMPermissionError, LLMProviderError, PermissionDeniedError, PermissionRequiredError, PortModule, type Provider, type ProvidersResponse, RealtimeXSDK, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, type StreamChunk, type StreamChunkEvent, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace };
|
|
1105
|
+
export { ActivitiesModule, type Activity, type Agent, type AgentChatOptions, type AgentChatResponse, AgentModule, type AgentSession, type AgentSessionInfo, type AgentSessionOptions, ApiModule, type ChatContentBlock, type ChatCustomBlock, type ChatFileBlock, type ChatImageUrlBlock, type ChatMessage, type ChatMessageContent, type ChatOptions, type ChatResponse, type ChatTextBlock, type EmbedOptions, type EmbedResponse, LLMModule, LLMPermissionError, LLMProviderError, MCPModule, type MCPServer, type MCPTool, type MCPToolResult, PermissionDeniedError, PermissionRequiredError, PortModule, type Provider, type ProvidersResponse, RealtimeXSDK, type SDKConfig, type STTListenOptions, type STTModel, type STTModelsResponse, STTModule, type STTProvider, type STTProvidersResponse, type STTResponse, type StreamChunk, type StreamChunkEvent, type TTSChunk, type TTSChunkEvent, TTSModule, type TTSOptions, type TTSProvider, type TTSProviderConfig, type TTSProvidersResponse, type Task, TaskModule, type TaskRun, type Thread, type TriggerAgentPayload, type TriggerAgentResponse, type VectorDeleteOptions, type VectorDeleteResponse, type VectorQueryOptions, type VectorQueryResponse, type VectorQueryResult, type VectorRecord, VectorStore, type VectorUpsertOptions, type VectorUpsertResponse, WebhookModule, type Workspace };
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
LLMModule: () => LLMModule,
|
|
37
37
|
LLMPermissionError: () => LLMPermissionError,
|
|
38
38
|
LLMProviderError: () => LLMProviderError,
|
|
39
|
+
MCPModule: () => MCPModule,
|
|
39
40
|
PermissionDeniedError: () => PermissionDeniedError,
|
|
40
41
|
PermissionRequiredError: () => PermissionRequiredError,
|
|
41
42
|
PortModule: () => PortModule,
|
|
@@ -1358,6 +1359,54 @@ var AgentModule = class {
|
|
|
1358
1359
|
}
|
|
1359
1360
|
};
|
|
1360
1361
|
|
|
1362
|
+
// src/modules/mcp.ts
|
|
1363
|
+
var MCPModule = class extends ApiModule {
|
|
1364
|
+
constructor(realtimexUrl, appId, appName, apiKey) {
|
|
1365
|
+
super(realtimexUrl, appId, appName, apiKey);
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* List configured MCP servers.
|
|
1369
|
+
* @param provider - Filter by provider: 'local', 'remote', or 'all' (default: 'all')
|
|
1370
|
+
* @returns Array of MCP server objects
|
|
1371
|
+
*/
|
|
1372
|
+
async getServers(provider = "all") {
|
|
1373
|
+
const params = provider !== "all" ? `?provider=${provider}` : "";
|
|
1374
|
+
const data = await this.apiCall("GET", `/sdk/mcp/servers${params}`);
|
|
1375
|
+
return data.servers;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* List available tools for a specific MCP server.
|
|
1379
|
+
* @param serverName - The server name (slug)
|
|
1380
|
+
* @param provider - Provider: 'local' or 'remote' (default: 'local')
|
|
1381
|
+
* @returns Array of tool objects with name, description, and input schema
|
|
1382
|
+
*/
|
|
1383
|
+
async getTools(serverName, provider = "local") {
|
|
1384
|
+
const data = await this.apiCall(
|
|
1385
|
+
"GET",
|
|
1386
|
+
`/sdk/mcp/servers/${encodeURIComponent(serverName)}/tools?provider=${provider}`
|
|
1387
|
+
);
|
|
1388
|
+
return data.tools;
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Execute a tool on an MCP server.
|
|
1392
|
+
* @param serverName - The server name (slug)
|
|
1393
|
+
* @param toolName - The tool name to execute
|
|
1394
|
+
* @param args - Arguments to pass to the tool (matches tool's input_schema)
|
|
1395
|
+
* @param provider - Provider: 'local' or 'remote' (default: 'local')
|
|
1396
|
+
* @returns Tool execution result
|
|
1397
|
+
*/
|
|
1398
|
+
async executeTool(serverName, toolName, args = {}, provider = "local") {
|
|
1399
|
+
const data = await this.apiCall(
|
|
1400
|
+
"POST",
|
|
1401
|
+
`/sdk/mcp/servers/${encodeURIComponent(serverName)}/tools/${encodeURIComponent(toolName)}/execute?provider=${provider}`,
|
|
1402
|
+
{
|
|
1403
|
+
body: JSON.stringify({ arguments: args })
|
|
1404
|
+
}
|
|
1405
|
+
);
|
|
1406
|
+
return data.result;
|
|
1407
|
+
}
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1361
1410
|
// src/modules/http.ts
|
|
1362
1411
|
var HttpClient = class {
|
|
1363
1412
|
constructor(baseUrl, appId, apiKey) {
|
|
@@ -1436,6 +1485,7 @@ var _RealtimeXSDK = class _RealtimeXSDK {
|
|
|
1436
1485
|
this.tts = new TTSModule(this.realtimexUrl, this.appId, this.appName, this.apiKey);
|
|
1437
1486
|
this.stt = new STTModule(this.realtimexUrl, this.appId, this.appName, this.apiKey);
|
|
1438
1487
|
this.agent = new AgentModule(this.httpClient);
|
|
1488
|
+
this.mcp = new MCPModule(this.realtimexUrl, this.appId, this.appName, this.apiKey);
|
|
1439
1489
|
if (this.permissions.length > 0 && this.appId && !this.apiKey) {
|
|
1440
1490
|
this.register().catch((err) => {
|
|
1441
1491
|
console.error("[RealtimeX SDK] Auto-registration failed:", err.message);
|
|
@@ -1543,6 +1593,7 @@ var RealtimeXSDK = _RealtimeXSDK;
|
|
|
1543
1593
|
LLMModule,
|
|
1544
1594
|
LLMPermissionError,
|
|
1545
1595
|
LLMProviderError,
|
|
1596
|
+
MCPModule,
|
|
1546
1597
|
PermissionDeniedError,
|
|
1547
1598
|
PermissionRequiredError,
|
|
1548
1599
|
PortModule,
|
package/dist/index.mjs
CHANGED
|
@@ -1308,6 +1308,54 @@ var AgentModule = class {
|
|
|
1308
1308
|
}
|
|
1309
1309
|
};
|
|
1310
1310
|
|
|
1311
|
+
// src/modules/mcp.ts
|
|
1312
|
+
var MCPModule = class extends ApiModule {
|
|
1313
|
+
constructor(realtimexUrl, appId, appName, apiKey) {
|
|
1314
|
+
super(realtimexUrl, appId, appName, apiKey);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* List configured MCP servers.
|
|
1318
|
+
* @param provider - Filter by provider: 'local', 'remote', or 'all' (default: 'all')
|
|
1319
|
+
* @returns Array of MCP server objects
|
|
1320
|
+
*/
|
|
1321
|
+
async getServers(provider = "all") {
|
|
1322
|
+
const params = provider !== "all" ? `?provider=${provider}` : "";
|
|
1323
|
+
const data = await this.apiCall("GET", `/sdk/mcp/servers${params}`);
|
|
1324
|
+
return data.servers;
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* List available tools for a specific MCP server.
|
|
1328
|
+
* @param serverName - The server name (slug)
|
|
1329
|
+
* @param provider - Provider: 'local' or 'remote' (default: 'local')
|
|
1330
|
+
* @returns Array of tool objects with name, description, and input schema
|
|
1331
|
+
*/
|
|
1332
|
+
async getTools(serverName, provider = "local") {
|
|
1333
|
+
const data = await this.apiCall(
|
|
1334
|
+
"GET",
|
|
1335
|
+
`/sdk/mcp/servers/${encodeURIComponent(serverName)}/tools?provider=${provider}`
|
|
1336
|
+
);
|
|
1337
|
+
return data.tools;
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Execute a tool on an MCP server.
|
|
1341
|
+
* @param serverName - The server name (slug)
|
|
1342
|
+
* @param toolName - The tool name to execute
|
|
1343
|
+
* @param args - Arguments to pass to the tool (matches tool's input_schema)
|
|
1344
|
+
* @param provider - Provider: 'local' or 'remote' (default: 'local')
|
|
1345
|
+
* @returns Tool execution result
|
|
1346
|
+
*/
|
|
1347
|
+
async executeTool(serverName, toolName, args = {}, provider = "local") {
|
|
1348
|
+
const data = await this.apiCall(
|
|
1349
|
+
"POST",
|
|
1350
|
+
`/sdk/mcp/servers/${encodeURIComponent(serverName)}/tools/${encodeURIComponent(toolName)}/execute?provider=${provider}`,
|
|
1351
|
+
{
|
|
1352
|
+
body: JSON.stringify({ arguments: args })
|
|
1353
|
+
}
|
|
1354
|
+
);
|
|
1355
|
+
return data.result;
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
|
|
1311
1359
|
// src/modules/http.ts
|
|
1312
1360
|
var HttpClient = class {
|
|
1313
1361
|
constructor(baseUrl, appId, apiKey) {
|
|
@@ -1386,6 +1434,7 @@ var _RealtimeXSDK = class _RealtimeXSDK {
|
|
|
1386
1434
|
this.tts = new TTSModule(this.realtimexUrl, this.appId, this.appName, this.apiKey);
|
|
1387
1435
|
this.stt = new STTModule(this.realtimexUrl, this.appId, this.appName, this.apiKey);
|
|
1388
1436
|
this.agent = new AgentModule(this.httpClient);
|
|
1437
|
+
this.mcp = new MCPModule(this.realtimexUrl, this.appId, this.appName, this.apiKey);
|
|
1389
1438
|
if (this.permissions.length > 0 && this.appId && !this.apiKey) {
|
|
1390
1439
|
this.register().catch((err) => {
|
|
1391
1440
|
console.error("[RealtimeX SDK] Auto-registration failed:", err.message);
|
|
@@ -1492,6 +1541,7 @@ export {
|
|
|
1492
1541
|
LLMModule,
|
|
1493
1542
|
LLMPermissionError,
|
|
1494
1543
|
LLMProviderError,
|
|
1544
|
+
MCPModule,
|
|
1495
1545
|
PermissionDeniedError,
|
|
1496
1546
|
PermissionRequiredError,
|
|
1497
1547
|
PortModule,
|