@app-connect/core 1.7.17 → 1.7.19

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.
Files changed (57) hide show
  1. package/connector/proxy/index.js +2 -1
  2. package/handlers/log.js +181 -10
  3. package/handlers/plugin.js +27 -0
  4. package/handlers/user.js +31 -2
  5. package/index.js +99 -22
  6. package/lib/authSession.js +21 -12
  7. package/lib/callLogComposer.js +1 -1
  8. package/lib/debugTracer.js +20 -2
  9. package/lib/util.js +21 -4
  10. package/mcp/README.md +392 -0
  11. package/mcp/mcpHandler.js +293 -82
  12. package/mcp/tools/checkAuthStatus.js +27 -34
  13. package/mcp/tools/createCallLog.js +13 -9
  14. package/mcp/tools/createContact.js +2 -6
  15. package/mcp/tools/doAuth.js +27 -157
  16. package/mcp/tools/findContactByName.js +6 -9
  17. package/mcp/tools/findContactByPhone.js +2 -6
  18. package/mcp/tools/getGoogleFilePicker.js +5 -9
  19. package/mcp/tools/getHelp.js +2 -3
  20. package/mcp/tools/getPublicConnectors.js +41 -28
  21. package/mcp/tools/index.js +11 -36
  22. package/mcp/tools/logout.js +5 -10
  23. package/mcp/tools/rcGetCallLogs.js +3 -20
  24. package/mcp/ui/App/App.tsx +361 -0
  25. package/mcp/ui/App/components/AuthInfoForm.tsx +113 -0
  26. package/mcp/ui/App/components/AuthSuccess.tsx +22 -0
  27. package/mcp/ui/App/components/ConnectorList.tsx +82 -0
  28. package/mcp/ui/App/components/DebugPanel.tsx +43 -0
  29. package/mcp/ui/App/components/OAuthConnect.tsx +270 -0
  30. package/mcp/ui/App/lib/callTool.ts +130 -0
  31. package/mcp/ui/App/lib/debugLog.ts +41 -0
  32. package/mcp/ui/App/lib/developerPortal.ts +111 -0
  33. package/mcp/ui/App/main.css +6 -0
  34. package/mcp/ui/App/root.tsx +13 -0
  35. package/mcp/ui/dist/index.html +53 -0
  36. package/mcp/ui/index.html +13 -0
  37. package/mcp/ui/package-lock.json +6356 -0
  38. package/mcp/ui/package.json +25 -0
  39. package/mcp/ui/tsconfig.json +26 -0
  40. package/mcp/ui/vite.config.ts +16 -0
  41. package/models/llmSessionModel.js +14 -0
  42. package/package.json +2 -2
  43. package/releaseNotes.json +13 -1
  44. package/test/handlers/plugin.test.js +287 -0
  45. package/test/lib/util.test.js +379 -1
  46. package/test/mcp/tools/createCallLog.test.js +3 -3
  47. package/test/mcp/tools/doAuth.test.js +40 -303
  48. package/test/mcp/tools/findContactByName.test.js +3 -3
  49. package/test/mcp/tools/findContactByPhone.test.js +3 -3
  50. package/test/mcp/tools/getGoogleFilePicker.test.js +7 -7
  51. package/test/mcp/tools/getPublicConnectors.test.js +49 -70
  52. package/test/mcp/tools/logout.test.js +2 -2
  53. package/mcp/SupportedPlatforms.md +0 -12
  54. package/mcp/tools/collectAuthInfo.js +0 -91
  55. package/mcp/tools/setConnector.js +0 -69
  56. package/test/mcp/tools/collectAuthInfo.test.js +0 -234
  57. package/test/mcp/tools/setConnector.test.js +0 -177
package/mcp/mcpHandler.js CHANGED
@@ -1,21 +1,164 @@
1
1
  /**
2
2
  * MCP Server for RC Unified CRM Extension
3
- *
4
- * This module provides MCP (Model Context Protocol) interface for the CRM extension.
5
- * It exposes tools that can be called by AI assistants or other MCP clients.
3
+ *
4
+ * Stateless hand-rolled JSON-RPC handler no SDK, no SSE, no sessions Map.
5
+ * Fully compatible with stateless deployments (AWS Lambda, etc.).
6
+ * All auth context is resolved per-request; rcExtensionId is cached in CacheModel.
6
7
  */
7
8
 
9
+ const axios = require('axios');
8
10
  const tools = require('./tools');
11
+ const { LlmSessionModel } = require('../models/llmSessionModel');
12
+ const { CacheModel } = require('../models/cacheModel');
9
13
  const logger = require('../lib/logger');
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+
17
+ /**
18
+ * Increment this to bust ChatGPT's widget resource cache after every UI build.
19
+ * This is the single source of truth — injected into getPublicConnectors _meta at response time.
20
+ */
21
+ const WIDGET_VERSION = 6;
22
+ const WIDGET_URI = `ui://widget/ConnectorList-v${WIDGET_VERSION}.html`;
10
23
 
11
24
  const JSON_RPC_INTERNAL_ERROR = -32603;
12
25
  const JSON_RPC_METHOD_NOT_FOUND = -32601;
26
+ const JSON_RPC_INVALID_PARAMS = -32602;
27
+
28
+ /**
29
+ * JSON Schema definitions for tools that accept parameters.
30
+ * Without inputSchema, ChatGPT silently drops all arguments when calling the tool.
31
+ */
32
+ const inputSchemas = {
33
+ findContactByName: {
34
+ type: 'object',
35
+ properties: {
36
+ name: { type: 'string', description: 'Name to search for' },
37
+ },
38
+ required: ['name'],
39
+ },
40
+ findContactByPhone: {
41
+ type: 'object',
42
+ properties: {
43
+ phoneNumber: { type: 'string', description: 'Phone number in E.164 format (e.g. +14155551234)' },
44
+ overridingFormat: { type: 'string', description: 'Overriding format to search for' },
45
+ isExtension: { type: 'boolean', description: 'Whether the request is from an extension' },
46
+ },
47
+ required: ['phoneNumber'],
48
+ },
49
+ createContact: {
50
+ type: 'object',
51
+ properties: {
52
+ phoneNumber: { type: 'string', description: 'Phone number in E.164 format (e.g. +14155551234)' },
53
+ newContactName: { type: 'string', description: 'Full name of the new contact' },
54
+ },
55
+ required: ['phoneNumber'],
56
+ },
57
+ createCallLog: {
58
+ type: 'object',
59
+ properties: {
60
+ incomingData: { description: 'Call log data to create' },
61
+ contactId: { type: 'string', description: 'CRM contact ID to attach the log to' },
62
+ contactType: { type: 'string', description: 'Type of the CRM contact' },
63
+ note: { type: 'string', description: 'Note to include in the call log' },
64
+ },
65
+ required: [],
66
+ },
67
+ rcGetCallLogs: {
68
+ type: 'object',
69
+ properties: {
70
+ timeFrom: { type: 'string', description: 'Start of time range in ISO 8601 format' },
71
+ timeTo: { type: 'string', description: 'End of time range in ISO 8601 format' },
72
+ },
73
+ required: ['timeFrom', 'timeTo'],
74
+ },
75
+ logout: {
76
+ type: 'object',
77
+ properties: {},
78
+ required: [],
79
+ },
80
+ };
81
+
82
+ /**
83
+ * Verify an RC access token and return the caller's extension ID.
84
+ * Throws if the token is invalid.
85
+ */
86
+ async function resolveRcExtensionId(rcAccessToken) {
87
+ const resp = await axios.get(
88
+ 'https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~',
89
+ { headers: { Authorization: `Bearer ${rcAccessToken}` } }
90
+ );
91
+ return resp.data?.id?.toString() ?? null;
92
+ }
93
+
94
+ /**
95
+ * Resolve rcExtensionId for the current request.
96
+ * Checks CacheModel first (avoids RC API call on Lambda cold starts),
97
+ * falls back to a live RC API verification and persists the result.
98
+ */
99
+ async function resolveSessionContext(rcAccessToken, openaiSessionId) {
100
+ if (!rcAccessToken) return { rcExtensionId: null };
101
+
102
+ if (openaiSessionId) {
103
+ try {
104
+ const cached = await CacheModel.findByPk(`${openaiSessionId}-rcExtensionId`);
105
+ if (cached?.data?.rcExtensionId && (!cached.expiry || cached.expiry > new Date())) {
106
+ return { rcExtensionId: cached.data.rcExtensionId };
107
+ }
108
+ } catch (err) {
109
+ logger.warn('CacheModel lookup failed:', { message: err.message });
110
+ }
111
+ }
112
+
113
+ let rcExtensionId = null;
114
+ try {
115
+ rcExtensionId = await resolveRcExtensionId(rcAccessToken);
116
+ if (openaiSessionId && rcExtensionId) {
117
+ await CacheModel.upsert({
118
+ id: `${openaiSessionId}-rcExtensionId`,
119
+ userId: openaiSessionId,
120
+ cacheKey: 'rcExtensionId',
121
+ data: { rcExtensionId },
122
+ status: 'active',
123
+ expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24h TTL
124
+ });
125
+ }
126
+ } catch (err) {
127
+ logger.warn('Failed to resolve RC extension ID:', { message: err.message });
128
+ }
129
+
130
+ return { rcExtensionId };
131
+ }
132
+
133
+ /**
134
+ * Build the tools list to return in tools/list responses.
135
+ * Injects inputSchema and stamps WIDGET_URI into getPublicConnectors _meta.
136
+ */
137
+ function getToolsList() {
138
+ return tools.tools.map(tool => {
139
+ const def = { ...tool.definition };
140
+ if (def.name === 'getPublicConnectors') {
141
+ def._meta = { ...(def._meta || {}), 'openai/outputTemplate': WIDGET_URI };
142
+ }
143
+ if (inputSchemas[def.name]) {
144
+ def.inputSchema = inputSchemas[def.name];
145
+ }
146
+ return def;
147
+ });
148
+ }
13
149
 
150
+ /**
151
+ * Handle incoming MCP HTTP requests.
152
+ * Stateless: each POST is handled independently with no session state between requests.
153
+ */
14
154
  async function handleMcpRequest(req, res) {
15
155
  try {
16
156
  const { method, params, id } = req.body;
17
157
  logger.info('Received MCP request:', { method });
18
158
 
159
+ const rcAccessToken = req.headers['authorization']?.split('Bearer ')?.[1];
160
+ const openaiSessionId = params?._meta?.['openai/session'] ?? null;
161
+
19
162
  let response;
20
163
 
21
164
  switch (method) {
@@ -27,44 +170,73 @@ async function handleMcpRequest(req, res) {
27
170
  protocolVersion: '2024-11-05',
28
171
  capabilities: {
29
172
  tools: {},
30
- prompts: {}
173
+ resources: {},
31
174
  },
32
175
  serverInfo: {
33
176
  name: 'rc-unified-crm-extension',
34
- version: '1.0.0'
35
- }
36
- }
177
+ version: '1.0.0',
178
+ },
179
+ },
37
180
  };
38
181
  break;
182
+
39
183
  case 'tools/list':
40
184
  response = {
41
185
  jsonrpc: '2.0',
42
186
  id,
43
- result: {
44
- tools: getTools()
45
- }
187
+ result: { tools: getToolsList() },
46
188
  };
47
189
  break;
48
- case 'tools/call':
190
+
191
+ case 'tools/call': {
49
192
  const { name: toolName, arguments: args } = params;
50
- const rcAccessToken = req.headers['authorization']?.split('Bearer ')?.[1];
51
- if (args && rcAccessToken) {
52
- args.rcAccessToken = rcAccessToken;
193
+ const toolArgs = { ...(args || {}) };
194
+
195
+ if (rcAccessToken) toolArgs.rcAccessToken = rcAccessToken;
196
+ if (openaiSessionId) toolArgs.openaiSessionId = openaiSessionId;
197
+
198
+ const { rcExtensionId } = await resolveSessionContext(rcAccessToken, openaiSessionId);
199
+ if (rcExtensionId) {
200
+ toolArgs.rcExtensionId = rcExtensionId;
201
+ if (!toolArgs.jwtToken) {
202
+ let llmSession = await LlmSessionModel.findByPk(rcExtensionId);
203
+ if (!llmSession?.jwtToken && openaiSessionId) {
204
+ const fallback = await LlmSessionModel.findByPk(openaiSessionId);
205
+ if (fallback?.jwtToken) {
206
+ await LlmSessionModel.upsert({ id: rcExtensionId, jwtToken: fallback.jwtToken });
207
+ llmSession = fallback;
208
+ }
209
+ }
210
+ if (llmSession?.jwtToken) toolArgs.jwtToken = llmSession.jwtToken;
211
+ }
53
212
  }
213
+
54
214
  try {
55
- const result = await executeTool(toolName, args || {});
56
- response = {
57
- jsonrpc: '2.0',
58
- id,
59
- result: {
60
- content: [
61
- {
62
- type: 'text',
63
- text: JSON.stringify(result, null, 2)
64
- }
65
- ]
66
- }
67
- };
215
+ const tool = tools.tools.find(t => t.definition.name === toolName);
216
+ if (!tool) throw new Error(`Tool not found: ${toolName}`);
217
+
218
+ const result = await tool.execute(toolArgs);
219
+
220
+ if (result?.structuredContent) {
221
+ response = {
222
+ jsonrpc: '2.0',
223
+ id,
224
+ result: {
225
+ structuredContent: result.structuredContent,
226
+ content: Array.isArray(result.content)
227
+ ? result.content
228
+ : [{ type: 'text', text: '[Interactive widget displayed above - no additional response needed]' }],
229
+ },
230
+ };
231
+ } else {
232
+ response = {
233
+ jsonrpc: '2.0',
234
+ id,
235
+ result: {
236
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
237
+ },
238
+ };
239
+ }
68
240
  } catch (toolError) {
69
241
  response = {
70
242
  jsonrpc: '2.0',
@@ -72,95 +244,134 @@ async function handleMcpRequest(req, res) {
72
244
  error: {
73
245
  code: JSON_RPC_INTERNAL_ERROR,
74
246
  message: `Tool execution failed: ${toolError.message}`,
75
- data: {
76
- error: toolError.message,
77
- stack: process.env.NODE_ENV !== 'production' ? toolError.stack : undefined
78
- }
79
- }
247
+ },
80
248
  };
81
249
  }
82
250
  break;
83
- case 'ping':
251
+ }
252
+
253
+ case 'resources/list':
254
+ response = {
255
+ jsonrpc: '2.0',
256
+ id,
257
+ result: {
258
+ resources: [{
259
+ uri: WIDGET_URI,
260
+ name: 'connector-list-widget',
261
+ title: 'ConnectorList',
262
+ description: 'ChatGPT widget for connector selection',
263
+ mimeType: 'text/html+skybridge',
264
+ }],
265
+ },
266
+ };
267
+ break;
268
+
269
+ case 'resources/read': {
270
+ const uri = params?.uri;
271
+ if (!uri?.startsWith('ui://widget/')) {
272
+ response = {
273
+ jsonrpc: '2.0',
274
+ id,
275
+ error: { code: JSON_RPC_INVALID_PARAMS, message: `Unknown resource: ${uri}` },
276
+ };
277
+ break;
278
+ }
279
+
280
+ const appUrl = process.env.APP_SERVER || 'http://localhost:6066';
281
+ const distPath = path.join(__dirname, 'ui', 'dist', 'index.html');
282
+ const devPath = path.join(__dirname, 'ui', 'index.html');
283
+ let htmlContent;
284
+ try { htmlContent = fs.readFileSync(distPath, 'utf8'); }
285
+ catch { htmlContent = fs.readFileSync(devPath, 'utf8'); }
286
+
84
287
  response = {
85
288
  jsonrpc: '2.0',
86
289
  id,
87
- result: {}
290
+ result: {
291
+ contents: [{
292
+ uri: WIDGET_URI,
293
+ mimeType: 'text/html+skybridge',
294
+ text: htmlContent,
295
+ _meta: {
296
+ 'openai/widgetPrefersBorder': true,
297
+ 'openai/widgetDomain': appUrl,
298
+ 'openai/widgetCSP': {
299
+ connect_domains: [appUrl, 'https://appconnect.labs.ringcentral.com'],
300
+ resource_domains: [appUrl],
301
+ },
302
+ },
303
+ }],
304
+ },
88
305
  };
89
306
  break;
307
+ }
308
+
309
+ case 'ping':
310
+ response = { jsonrpc: '2.0', id, result: {} };
311
+ break;
312
+
313
+ case 'notifications/initialized':
314
+ case 'notifications/cancelled':
315
+ // JSON-RPC notifications — no id, no response expected
316
+ return res.status(200).end();
317
+
90
318
  default:
91
319
  response = {
92
320
  jsonrpc: '2.0',
93
321
  id,
94
- error: {
95
- code: JSON_RPC_METHOD_NOT_FOUND,
96
- message: `Method not found: ${method}`
97
- }
322
+ error: { code: JSON_RPC_METHOD_NOT_FOUND, message: `Method not found: ${method}` },
98
323
  };
99
324
  }
100
325
 
101
326
  res.status(200).json(response);
102
327
  } catch (error) {
103
328
  logger.error('Error handling MCP request:', { stack: error.stack });
104
- const errorResponse = {
329
+ res.status(200).json({
105
330
  jsonrpc: '2.0',
106
331
  id: req.body?.id || null,
107
332
  error: {
108
333
  code: JSON_RPC_INTERNAL_ERROR,
109
334
  message: 'Internal server error',
110
- data: {
111
- error: error.message,
112
- stack: process.env.NODE_ENV !== 'production' ? error.stack : undefined
113
- }
114
- }
115
- };
116
- res.status(200).json(errorResponse);
335
+ data: { error: error.message },
336
+ },
337
+ });
117
338
  }
118
339
  }
119
340
 
120
-
121
341
  /**
122
- * Get all registered MCP tools
123
- * @returns {Array} Array of tool definitions
342
+ * Handle widget tool calls via direct HTTP (bypasses MCP protocol).
343
+ * The ChatGPT postMessage bridge does not forward tool arguments,
344
+ * so the widget uses fetch() to this endpoint instead.
124
345
  */
125
- function getTools() {
126
- return tools.tools.map(tool => tool.definition);
127
- }
346
+ async function handleWidgetToolCall(req, res) {
347
+ try {
348
+ logger.info('Widget tool call received. body:', JSON.stringify(req.body));
128
349
 
129
- /**
130
- * Execute a specific MCP tool
131
- * @param {string} toolName - Name of the tool to execute
132
- * @param {Object} args - Arguments to pass to the tool
133
- * @returns {Promise<Object>} Tool execution result
134
- */
135
- async function executeTool(toolName, args) {
136
- // Find the tool by name
137
- const tool = tools.tools.find(t => t.definition.name === toolName);
350
+ const { tool: toolName, toolArgs: args } = req.body || {};
138
351
 
139
- if (!tool) {
140
- throw new Error(`Tool not found: ${toolName}`);
141
- }
352
+ logger.info('Widget tool call parsed:', { toolName, args: JSON.stringify(args) });
142
353
 
143
- // Execute the tool
144
- return await tool.execute(args);
145
- }
354
+ if (!toolName) {
355
+ return res.status(400).json({ success: false, error: 'Missing tool name' });
356
+ }
146
357
 
147
- /**
148
- * Get a specific tool definition
149
- * @param {string} toolName - Name of the tool
150
- * @returns {Object} Tool definition
151
- */
152
- function getToolDefinition(toolName) {
153
- const tool = tools.tools.find(t => t.definition.name === toolName);
358
+ const allWidgetCallable = [...tools.tools, ...tools.widgetTools];
359
+ const tool = allWidgetCallable.find(t => t.definition.name === toolName);
360
+ if (!tool) {
361
+ return res.status(404).json({ success: false, error: `Unknown tool: ${toolName}` });
362
+ }
154
363
 
155
- if (!tool) {
156
- throw new Error(`Tool not found: ${toolName}`);
364
+ const result = await tool.execute(args || {});
365
+ logger.info('Widget tool call result:', { toolName, success: result?.success });
366
+ res.json(result);
367
+ } catch (error) {
368
+ logger.error('Widget tool call error:', { stack: error.stack });
369
+ res.status(500).json({
370
+ success: false,
371
+ error: error.message || 'Internal server error',
372
+ });
157
373
  }
158
-
159
- return tool.definition;
160
374
  }
161
375
 
162
376
  exports.handleMcpRequest = handleMcpRequest;
163
- exports.getTools = getTools;
164
- exports.executeTool = executeTool;
165
- exports.getToolDefinition = getToolDefinition;
166
- exports.tools = tools.tools;
377
+ exports.handleWidgetToolCall = handleWidgetToolCall;
@@ -1,4 +1,5 @@
1
1
  const { getAuthSession } = require('../../lib/authSession');
2
+ const { LlmSessionModel } = require('../../models/llmSessionModel');
2
3
 
3
4
  /**
4
5
  * MCP Tool: Check Auth Status
@@ -16,10 +17,6 @@ const toolDefinition = {
16
17
  type: 'string',
17
18
  description: 'The session ID returned from doAuth tool'
18
19
  },
19
- platform: {
20
- type: 'string',
21
- description: 'The platform to check the status of'
22
- }
23
20
  },
24
21
  required: ['sessionId']
25
22
  },
@@ -34,39 +31,39 @@ const toolDefinition = {
34
31
  * Execute the checkAuthStatus tool
35
32
  * @param {Object} args - The tool arguments
36
33
  * @param {string} args.sessionId - The session ID to check
34
+ * @param {string} args.rcExtensionId - The RC extension ID
37
35
  * @returns {Object} Result object with authentication status
38
36
  */
39
37
  async function execute(args) {
40
38
  try {
41
- const { sessionId, platform } = args;
42
-
39
+ // rcExtensionId is injected by mcpHandler after verifying the RC access
40
+ // token. Using it as the DB key binds the CRM credential to a verified
41
+ // RC identity.
42
+ const { sessionId, rcExtensionId } = args;
43
+ if (!rcExtensionId) {
44
+ throw new Error('rcExtensionId is required');
45
+ }
43
46
  const session = await getAuthSession(sessionId);
44
-
47
+
45
48
  if (!session) {
46
49
  return {
47
50
  success: false,
48
- error: 'Session not found or expired',
49
- data: {
50
- status: 'expired'
51
- }
51
+ error: 'CRM auth session not found or expired. Ask the user to start the auth flow again.'
52
52
  };
53
53
  }
54
-
54
+
55
55
  switch (session.status) {
56
- case 'completed':
57
- if(platform === 'googleSheets') {
58
- return {
59
- success: true,
60
- data: {
61
- status: 'completed',
62
- jwtToken: session.jwtToken,
63
- userInfo: session.userInfo,
64
- message: 'IMPORTANT: Authentication successful! Keep jwtToken in memory for future use. DO NOT directly show it to user. Next step is to call getGoogleFilePicker tool.'
65
- }
66
- };
56
+ case 'completed': {
57
+ // Guard against duplicate DB writes if polled concurrently
58
+ try {
59
+ await LlmSessionModel.create({
60
+ id: rcExtensionId,
61
+ jwtToken: session.jwtToken
62
+ });
63
+ } catch {
64
+ // Record already exists from a prior poll safe to ignore
67
65
  }
68
66
  return {
69
- success: true,
70
67
  data: {
71
68
  status: 'completed',
72
69
  jwtToken: session.jwtToken,
@@ -74,24 +71,21 @@ async function execute(args) {
74
71
  message: 'IMPORTANT: Authentication successful! Keep jwtToken in memory for future use. DO NOT directly show it to user.'
75
72
  }
76
73
  };
77
-
74
+ }
75
+
78
76
  case 'failed':
79
77
  return {
80
- success: false,
81
- error: 'Authentication failed',
82
78
  data: {
83
79
  status: 'failed',
84
- errorMessage: session.errorMessage
80
+ errorMessage: session.errorMessage || 'Unknown error'
85
81
  }
86
82
  };
87
-
83
+
88
84
  case 'pending':
89
85
  default:
90
86
  return {
91
- success: true,
92
87
  data: {
93
- status: 'pending',
94
- message: 'Waiting for user to complete authorization. Poll again in a few seconds.'
88
+ status: 'pending'
95
89
  }
96
90
  };
97
91
  }
@@ -99,8 +93,7 @@ async function execute(args) {
99
93
  catch (error) {
100
94
  return {
101
95
  success: false,
102
- error: error.message || 'Unknown error occurred',
103
- errorDetails: error.stack
96
+ error: `CRM auth status check error: ${error.message}`
104
97
  };
105
98
  }
106
99
  }
@@ -12,21 +12,17 @@ const { CallLogModel } = require('../../models/callLogModel');
12
12
 
13
13
  const toolDefinition = {
14
14
  name: 'createCallLog',
15
- description: '⚠️ REQUIRES AUTHENTICATION: User must first authenticate using the "auth" tool to obtain a JWT token before using this tool. | Create only one call log in the CRM platform. Returns the created log ID if successful.',
15
+ description: '⚠️ REQUIRES CRM CONNECTION. | Create only one call log in the CRM platform. Returns the created log ID if successful. To use with `rcGetCallLogs`: pass a single item from the `records[]` array directly as `incomingData.logInfo`.',
16
16
  inputSchema: {
17
17
  type: 'object',
18
18
  properties: {
19
- jwtToken: {
20
- type: 'string',
21
- description: 'JWT token containing userId and platform information. If user does not have this, direct them to use the "auth" tool first.'
22
- },
23
19
  incomingData: {
24
20
  type: 'object',
25
21
  description: 'Call log data to create',
26
22
  properties: {
27
23
  logInfo: {
28
24
  type: 'object',
29
- description: 'RingCentral call log information (follows RingCentral Call Log schema)',
25
+ description: 'A single record from `rcGetCallLogs` pass the object exactly as returned, with no changes.',
30
26
  properties: {
31
27
  id: {
32
28
  type: 'string',
@@ -153,16 +149,24 @@ const toolDefinition = {
153
149
  description: 'RingCentral extension ID of the assigned user'
154
150
  }
155
151
  }
152
+ },
153
+ contactName: {
154
+ type: 'string',
155
+ description: 'Contact name'
156
+ },
157
+ contactType: {
158
+ type: 'string',
159
+ description: 'Contact type'
156
160
  }
157
161
  },
158
- required: ['logInfo']
162
+ required: ['logInfo', 'contactName']
159
163
  },
160
164
  contactId: {
161
165
  type: 'string',
162
166
  description: 'OPTIONAL: CRM contact ID to associate with the call.'
163
167
  }
164
168
  },
165
- required: ['jwtToken', 'incomingData']
169
+ required: ['incomingData']
166
170
  },
167
171
  annotations: {
168
172
  readOnlyHint: false,
@@ -250,7 +254,7 @@ async function execute(args) {
250
254
  userId,
251
255
  phoneNumber: contactNumber,
252
256
  overridingFormat: '',
253
- isExtension: 'false'
257
+ isExtension: false
254
258
  });
255
259
  const filteredContact = contactInfo.contact?.filter(c => !c.isNewContact);
256
260
  if (contactInfo.successful && filteredContact?.length > 0) {
@@ -10,14 +10,10 @@ const contactCore = require('../../handlers/contact');
10
10
 
11
11
  const toolDefinition = {
12
12
  name: 'createContact',
13
- description: '⚠️ REQUIRES AUTHENTICATION: User must first authenticate using the "auth" tool to obtain a JWT token before using this tool. | Create a new contact in the CRM platform. Returns the created contact information if successful.',
13
+ description: '⚠️ REQUIRES CRM CONNECTION. | Create a new contact in the CRM platform. Returns the created contact information if successful.',
14
14
  inputSchema: {
15
15
  type: 'object',
16
16
  properties: {
17
- jwtToken: {
18
- type: 'string',
19
- description: 'JWT token containing userId and platform information. If user does not have this, direct them to use the "auth" tool first.'
20
- },
21
17
  phoneNumber: {
22
18
  type: 'string',
23
19
  description: 'Phone number of the new contact (MUST BE in E.164 format, e.g., +14155551234)'
@@ -27,7 +23,7 @@ const toolDefinition = {
27
23
  description: 'Full name of the new contact. If not provided, use phone number as the name'
28
24
  }
29
25
  },
30
- required: ['jwtToken', 'phoneNumber']
26
+ required: ['phoneNumber']
31
27
  },
32
28
  annotations: {
33
29
  readOnlyHint: false,