@progress/kendo-react-mcp 1.0.2 → 1.0.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/dist/index.js CHANGED
@@ -48,11 +48,12 @@ specify its name in the 'component' parameter. This tool can be automatically tr
48
48
  code_matches_count: 0,
49
49
  allowed_types: ['documentation'],
50
50
  });
51
+ log('Response from context API: ', JSON.stringify(response));
51
52
  const content = [
52
- ...response.values.map((item) => ({
53
+ {
53
54
  type: 'text',
54
- text: item,
55
- })),
55
+ text: response.values.join('\n\n'),
56
+ },
56
57
  ];
57
58
  log('Response from tool: ', JSON.stringify(content));
58
59
  return {
@@ -3,6 +3,7 @@ import grpc from '@grpc/grpc-js';
3
3
  import { dirname, join } from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { readLicense } from './read-license.js';
6
+ import { log } from './logger.js';
6
7
  const protoPath = join(dirname(fileURLToPath(import.meta.url)), '../../proto/service.proto');
7
8
  const proto = protoLoader.loadSync(protoPath, {
8
9
  keepCase: true,
@@ -15,8 +16,19 @@ const protoDescriptor = grpc.loadPackageDefinition(proto);
15
16
  const service = protoDescriptor.ContextQueryService;
16
17
  const client = new service('contextapi.telerik.com:443', grpc.credentials.createSsl());
17
18
  export async function query(queryParams) {
18
- const license = readLicense();
19
+ let license = readLicense();
19
20
  const metadata = new grpc.Metadata();
21
+ if (license && typeof license === 'string') {
22
+ // Check for BOM character and trim it
23
+ license = license.replace(/^\uFEFF/, '');
24
+ try {
25
+ metadata.add('x-license-key', license);
26
+ }
27
+ catch (error) {
28
+ log('Error adding license key to metadata:', error);
29
+ return Promise.reject(new Error(`Failed to use license key: ${error.message}`));
30
+ }
31
+ }
20
32
  if (license && typeof license === 'string') {
21
33
  metadata.add('x-license-key', license);
22
34
  }
@@ -1,23 +1,40 @@
1
1
  import fs from 'node:fs';
2
+ import path from 'node:path';
2
3
  let LOG_ENABLED = false;
3
4
  const LOG_FILE = process.env.DEBUG_LOG_FILE;
4
5
  const LOG_FILE_DEFINED = !!(LOG_FILE && typeof LOG_FILE === 'string');
5
6
  // check if the log file is a valid path
6
7
  if (LOG_FILE_DEFINED) {
7
- const logDir = LOG_FILE.substring(0, LOG_FILE.lastIndexOf('/'));
8
- if (!fs.existsSync(logDir)) {
9
- fs.mkdirSync(logDir, { recursive: true });
10
- fs.writeFileSync(LOG_FILE, '');
8
+ const resolvedLogFile = path.resolve(LOG_FILE);
9
+ const logDir = path.dirname(resolvedLogFile);
10
+ // Only create directory if it's not the current directory and doesn't exist
11
+ if (logDir !== '.' && logDir !== process.cwd() && !fs.existsSync(logDir)) {
12
+ try {
13
+ fs.mkdirSync(logDir, { recursive: true });
14
+ }
15
+ catch (err) {
16
+ console.error('Error creating log directory:', err);
17
+ }
18
+ }
19
+ // Create the log file if it doesn't exist
20
+ if (!fs.existsSync(resolvedLogFile)) {
21
+ try {
22
+ fs.writeFileSync(resolvedLogFile, '');
23
+ }
24
+ catch (err) {
25
+ console.error('Error creating log file:', err);
26
+ }
11
27
  }
12
28
  }
13
- LOG_ENABLED = LOG_FILE_DEFINED && fs.existsSync(LOG_FILE);
29
+ LOG_ENABLED = LOG_FILE_DEFINED && !!LOG_FILE && fs.existsSync(path.resolve(LOG_FILE));
14
30
  export function log(...args) {
15
- if (LOG_ENABLED) {
31
+ if (LOG_ENABLED && LOG_FILE) {
16
32
  // write a new line to the file with the date and time
17
33
  const date = new Date();
18
34
  const dateString = date.toISOString();
19
35
  const logString = `${dateString}: ${args.join(' ')}\n`;
20
- fs.appendFile(LOG_FILE, logString, (err) => {
36
+ const resolvedLogFile = path.resolve(LOG_FILE);
37
+ fs.appendFile(resolvedLogFile, logString, (err) => {
21
38
  if (err) {
22
39
  console.error('Error writing to log file:', err);
23
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-react-mcp",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "bin": "./dist/index.js",
6
6
  "license": "See LICENSE.md",