bc-telemetry-buddy-mcp 2.3.1 → 2.3.2

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/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.3.2] - 2026-01-14
11
+
12
+ ### Changed
13
+ - **Agent Documentation**: Terminology change from "chatmodes" to "agents" for clearer communication (GitHub Copilot agent definitions)
14
+ - **Mandatory Field Sampling**: Documentation now emphasizes calling `get_event_field_samples` before creating queries to prevent incorrect datatype assumptions
15
+
10
16
  ## [2.3.1] - 2026-01-14
11
17
 
12
18
  ### Fixed
package/dist/cli.js CHANGED
@@ -82,7 +82,7 @@ Headers: ${JSON.stringify(r)}`}}return o},this.logUrlWithPiiAwareness=(a,c)=>{if
82
82
  `),new Error("BCTB_WORKSPACE_PATH environment variable is required");return{connectionName:process.env.BCTB_CONNECTION_NAME||"Default",tenantId:process.env.BCTB_TENANT_ID||"",clientId:process.env.BCTB_CLIENT_ID,clientSecret:process.env.BCTB_CLIENT_SECRET,authFlow:process.env.BCTB_AUTH_FLOW||"azure_cli",applicationInsightsAppId:process.env.BCTB_APP_INSIGHTS_ID||"",kustoClusterUrl:process.env.BCTB_KUSTO_URL||"",cacheEnabled:process.env.BCTB_CACHE_ENABLED!=="false",cacheTTLSeconds:parseInt(process.env.BCTB_CACHE_TTL||"3600",10),removePII:process.env.BCTB_REMOVE_PII==="true",port:parseInt(process.env.BCTB_PORT||"52345",10),workspacePath:n,queriesFolder:process.env.BCTB_QUERIES_FOLDER||"queries",references:wFt(process.env.BCTB_REFERENCES||"[]")}}function wFt(n){try{let t=JSON.parse(n);return Array.isArray(t)?t:[]}catch(t){return console.error("Failed to parse references:",t),[]}}function W1e(n,t,i=new Set){if(i.has(t))throw new Error(`Circular profile inheritance detected: ${t}`);i.add(t);let s=n[t];if(!s)throw new Error(`Profile '${t}' not found`);if(!s.extends)return lD(s);let a=W1e(n,s.extends,i),c=J1e(a,s);return delete c.extends,lD(c)}function J1e(n,t){let i={...n};for(let s in t)s!=="extends"&&(typeof t[s]=="object"&&!Array.isArray(t[s])&&t[s]!==null?i[s]=J1e(n[s]||{},t[s]):i[s]=t[s]);return i}function lD(n){let t=Array.isArray(n)?[]:{};for(let i in n){let s=n[i];typeof s=="string"?t[i]=s.replace(/\$\{([^}]+)\}/g,(a,c)=>process.env[c]||""):typeof s=="object"&&s!==null?t[i]=lD(s):t[i]=s}return t}function MFt(n){let t=[];return n.authFlow!=="azure_cli"&&n.authFlow!=="vscode_auth"&&!n.tenantId&&t.push("BCTB_TENANT_ID is required (unless using azure_cli or vscode_auth auth flow)"),n.applicationInsightsAppId||t.push("BCTB_APP_INSIGHTS_ID is required"),n.kustoClusterUrl||t.push("BCTB_KUSTO_URL is required"),n.authFlow==="client_credentials"&&!n.clientId&&t.push("BCTB_CLIENT_ID is required for client_credentials auth flow"),n.authFlow==="client_credentials"&&!n.clientSecret&&t.push("BCTB_CLIENT_SECRET is required for client_credentials auth flow"),t.length>0&&(console.error(`
83
83
  \u26A0\uFE0F Configuration Incomplete:`),t.forEach(i=>console.error(` - ${i}`)),console.error(`
84
84
  Server will start but queries will fail until configuration is complete.`),console.error(`Run "BC Telemetry Buddy: Setup Wizard" from Command Palette to configure.
85
- `)),t}});var OQ=f(Ur=>{"use strict";var LFt=Ur&&Ur.__createBinding||(Object.create?(function(n,t,i,s){s===void 0&&(s=i);var a=Object.getOwnPropertyDescriptor(t,i);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(n,s,a)}):(function(n,t,i,s){s===void 0&&(s=i),n[s]=t[i]})),gl=Ur&&Ur.__exportStar||function(n,t){for(var i in n)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&LFt(t,n,i)};Object.defineProperty(Ur,"__esModule",{value:!0});Ur.expandEnvironmentVariables=Ur.resolveProfileInheritance=Ur.validateConfig=Ur.loadConfig=Ur.TELEMETRY_CONNECTION_STRING=void 0;gl(a0e(),Ur);gl(T1e(),Ur);gl(E1e(),Ur);gl(O1e(),Ur);gl(I1e(),Ur);gl(U1e(),Ur);gl(q1e(),Ur);gl(hQ(),Ur);gl(z1e(),Ur);gl($1e(),Ur);var DFt=Y1e();Object.defineProperty(Ur,"TELEMETRY_CONNECTION_STRING",{enumerable:!0,get:function(){return DFt.TELEMETRY_CONNECTION_STRING}});var pD=X1e();Object.defineProperty(Ur,"loadConfig",{enumerable:!0,get:function(){return pD.loadConfig}});Object.defineProperty(Ur,"validateConfig",{enumerable:!0,get:function(){return pD.validateConfig}});Object.defineProperty(Ur,"resolveProfileInheritance",{enumerable:!0,get:function(){return pD.resolveProfileInheritance}});Object.defineProperty(Ur,"expandEnvironmentVariables",{enumerable:!0,get:function(){return pD.expandEnvironmentVariables}})});var gu,AQ=B(()=>{"use strict";gu="2.3.1"});var vl=f((acn,twe)=>{var UFt=require("path").relative;twe.exports=FFt;var kFt=process.cwd();function Z1e(n,t){for(var i=n.split(/[ ,]+/),s=String(t).toLowerCase(),a=0;a<i.length;a++){var c=i[a];if(c&&(c==="*"||c.toLowerCase()===s))return!0}return!1}function qFt(n,t,i){var s=Object.getOwnPropertyDescriptor(n,t),a=s.value;return s.get=function(){return a},s.writable&&(s.set=function(r){return a=r}),delete s.value,delete s.writable,Object.defineProperty(n,t,s),s}function BFt(n){for(var t="",i=0;i<n;i++)t+=", arg"+i;return t.substr(2)}function VFt(n){var t=this.name+": "+this.namespace;this.message&&(t+=" deprecated "+this.message);for(var i=0;i<n.length;i++)t+=`
85
+ `)),t}});var OQ=f(Ur=>{"use strict";var LFt=Ur&&Ur.__createBinding||(Object.create?(function(n,t,i,s){s===void 0&&(s=i);var a=Object.getOwnPropertyDescriptor(t,i);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(n,s,a)}):(function(n,t,i,s){s===void 0&&(s=i),n[s]=t[i]})),gl=Ur&&Ur.__exportStar||function(n,t){for(var i in n)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&LFt(t,n,i)};Object.defineProperty(Ur,"__esModule",{value:!0});Ur.expandEnvironmentVariables=Ur.resolveProfileInheritance=Ur.validateConfig=Ur.loadConfig=Ur.TELEMETRY_CONNECTION_STRING=void 0;gl(a0e(),Ur);gl(T1e(),Ur);gl(E1e(),Ur);gl(O1e(),Ur);gl(I1e(),Ur);gl(U1e(),Ur);gl(q1e(),Ur);gl(hQ(),Ur);gl(z1e(),Ur);gl($1e(),Ur);var DFt=Y1e();Object.defineProperty(Ur,"TELEMETRY_CONNECTION_STRING",{enumerable:!0,get:function(){return DFt.TELEMETRY_CONNECTION_STRING}});var pD=X1e();Object.defineProperty(Ur,"loadConfig",{enumerable:!0,get:function(){return pD.loadConfig}});Object.defineProperty(Ur,"validateConfig",{enumerable:!0,get:function(){return pD.validateConfig}});Object.defineProperty(Ur,"resolveProfileInheritance",{enumerable:!0,get:function(){return pD.resolveProfileInheritance}});Object.defineProperty(Ur,"expandEnvironmentVariables",{enumerable:!0,get:function(){return pD.expandEnvironmentVariables}})});var gu,AQ=B(()=>{"use strict";gu="2.3.2"});var vl=f((acn,twe)=>{var UFt=require("path").relative;twe.exports=FFt;var kFt=process.cwd();function Z1e(n,t){for(var i=n.split(/[ ,]+/),s=String(t).toLowerCase(),a=0;a<i.length;a++){var c=i[a];if(c&&(c==="*"||c.toLowerCase()===s))return!0}return!1}function qFt(n,t,i){var s=Object.getOwnPropertyDescriptor(n,t),a=s.value;return s.get=function(){return a},s.writable&&(s.set=function(r){return a=r}),delete s.value,delete s.writable,Object.defineProperty(n,t,s),s}function BFt(n){for(var t="",i=0;i<n;i++)t+=", arg"+i;return t.substr(2)}function VFt(n){var t=this.name+": "+this.namespace;this.message&&(t+=" deprecated "+this.message);for(var i=0;i<n.length;i++)t+=`
86
86
  at `+n[i].toString();return t}function FFt(n){if(!n)throw new TypeError("argument namespace is required");var t=fD(),i=nb(t[1]),s=i[0];function a(c){dD.call(a,c)}return a._file=s,a._ignored=HFt(n),a._namespace=n,a._traced=GFt(n),a._warned=Object.create(null),a.function=YFt,a.property=WFt,a}function jFt(n,t){var i=typeof n.listenerCount!="function"?n.listeners(t).length:n.listenerCount(t);return i>0}function HFt(n){if(process.noDeprecation)return!0;var t=process.env.NO_DEPRECATION||"";return Z1e(t,n)}function GFt(n){if(process.traceDeprecation)return!0;var t=process.env.TRACE_DEPRECATION||"";return Z1e(t,n)}function dD(n,t){var i=jFt(process,"deprecation");if(!(!i&&this._ignored)){var s,a,c,r,e=0,o=!1,u=fD(),l=this._file;for(t?(r=t,c=nb(u[1]),c.name=r.name,l=c[0]):(e=2,r=nb(u[e]),c=r);e<u.length;e++)if(s=nb(u[e]),a=s[0],a===l)o=!0;else if(a===this._file)l=this._file;else if(o)break;var p=s?r.join(":")+"__"+s.join(":"):void 0;if(!(p!==void 0&&p in this._warned)){this._warned[p]=!0;var d=n;if(d||(d=c===r||!c.name?Q1e(r):Q1e(c)),i){var h=ewe(this._namespace,d,u.slice(e));process.emit("deprecation",h);return}var m=process.stderr.isTTY?KFt:zFt,y=m.call(this,d,s,u.slice(e));process.stderr.write(y+`
87
87
  `,"utf8")}}}function nb(n){var t=n.getFileName()||"<anonymous>",i=n.getLineNumber(),s=n.getColumnNumber();n.isEval()&&(t=n.getEvalOrigin()+", "+t);var a=[t,i,s];return a.callSite=n,a.name=n.getFunctionName(),a}function Q1e(n){var t=n.callSite,i=n.name;i||(i="<anonymous@"+xQ(n)+">");var s=t.getThis(),a=s&&t.getTypeName();return a==="Object"&&(a=void 0),a==="Function"&&(a=s.name||a),a&&t.getMethodName()?a+"."+i:i}function zFt(n,t,i){var s=new Date().toUTCString(),a=s+" "+this._namespace+" deprecated "+n;if(this._traced){for(var c=0;c<i.length;c++)a+=`
88
88
  at `+i[c].toString();return a}return t&&(a+=" at "+xQ(t)),a}function KFt(n,t,i){var s="\x1B[36;1m"+this._namespace+"\x1B[22;39m \x1B[33;1mdeprecated\x1B[22;39m \x1B[0m"+n+"\x1B[39m";if(this._traced){for(var a=0;a<i.length;a++)s+=`
package/dist/server.js CHANGED
@@ -244,7 +244,7 @@ Server will start but queries will fail until configuration is complete.`),conso
244
244
  Searched locations:`),process.env.BCTB_WORKSPACE_PATH&&console.error(` - ${ul.join(process.env.BCTB_WORKSPACE_PATH,".bctb-config.json")} (workspace)`),console.error(` - ${ul.join(yx.homedir(),".bctb","config.json")} (home directory)`),console.error(` - ${ul.join(yx.homedir(),".bctb-config.json")} (home directory)`),console.error(`
245
245
  To create a config file, run:
246
246
  node path/to/mcp/dist/cli.js init
247
- `),null;i||(console.error(`\u{1F4C4} Loading config from: ${s}`),console.error(`[Config] BCTB_WORKSPACE_PATH env var = ${process.env.BCTB_WORKSPACE_PATH||"(not set)"}`));let a=bf.readFileSync(s,"utf-8"),c=JSON.parse(a);if(c.profiles){let e=r||process.env.BCTB_PROFILE||c.defaultProfile;if(!e)throw new Error("No profile specified. Use --profile <name> or set BCTB_PROFILE env var");if(!c.profiles[e])throw new Error(`Profile '${e}' not found in config`);console.error(`\u{1F4CB} Using profile: "${e}"`);let o=z0e(c.profiles,e),u={...o,cacheEnabled:o.cacheEnabled??c.cache?.enabled??!0,cacheTTLSeconds:o.cacheTTLSeconds??c.cache?.ttlSeconds??3600,removePII:o.removePII??c.sanitize?.removePII??!1,references:o.references??c.references??[],port:o.port??52345,workspacePath:o.workspacePath??process.env.BCTB_WORKSPACE_PATH??process.cwd(),queriesFolder:o.queriesFolder??"queries",connectionName:o.connectionName??"Default",tenantId:o.tenantId??"",authFlow:o.authFlow??"azure_cli",applicationInsightsAppId:o.applicationInsightsAppId??"",kustoClusterUrl:o.kustoClusterUrl??""};return pM(u)}let t={connectionName:c.connectionName??"Default",tenantId:c.tenantId??"",clientId:c.clientId,clientSecret:c.clientSecret,authFlow:c.authFlow??"azure_cli",applicationInsightsAppId:c.applicationInsightsAppId??"",kustoClusterUrl:c.kustoClusterUrl??"",cacheEnabled:c.cacheEnabled??!0,cacheTTLSeconds:c.cacheTTLSeconds??3600,removePII:c.removePII??!1,port:c.port??52345,workspacePath:c.workspacePath??process.env.BCTB_WORKSPACE_PATH??process.cwd(),queriesFolder:c.queriesFolder??"queries",references:c.references??[]};return pM(t)}function z0e(n,r,i=new Set){if(i.has(r))throw new Error(`Circular profile inheritance detected: ${r}`);i.add(r);let s=n[r];if(!s)throw new Error(`Profile '${r}' not found`);if(!s.extends)return s;let a=z0e(n,s.extends,i),c=K0e(a,s);return delete c.extends,c}function K0e(n,r){let i={...n};for(let s in r)s!=="extends"&&(typeof r[s]=="object"&&!Array.isArray(r[s])&&r[s]!==null?i[s]=K0e(n[s]||{},r[s]):i[s]=r[s]);return i}function pM(n){if(typeof n=="string")return n.replace(/\$\{([^}]+)\}/g,(r,i)=>{if(i==="workspaceFolder"){let s=process.env.BCTB_WORKSPACE_PATH||process.cwd();return console.error(`[Config] Expanding \${workspaceFolder} to: ${s}`),s}return process.env[i]||""});if(Array.isArray(n))return n.map(r=>pM(r));if(typeof n=="object"&&n!==null){let r={};for(let i in n)r[i]=pM(n[i]);return r}return n}var At=ve(r2e());var vd="2.3.1";var yPt=ve(require("https"));var fA=ve(lPt()),zo=ve(require("fs")),F1=ve(require("path")),dPt=ve(require("crypto")),fPt=ve(require("os")),EEe=class{client;constructor(r,i,s){fA.setup(r).setAutoCollectRequests(!1).setAutoCollectPerformance(!1,!1).setAutoCollectExceptions(!1).setAutoCollectDependencies(!1).setAutoCollectConsole(!1).setUseDiskRetryCaching(!0),fA.start(),this.client=fA.defaultClient,this.client.commonProperties={installationId:i,version:s,component:"MCP"}}trackEvent(r,i,s){let a={};if(i)for(let[c,t]of Object.entries(i))a[c]=String(t);this.client.trackEvent({name:r,properties:a,measurements:s})}trackException(r,i){this.client.trackException({exception:r,properties:{errorName:r.name,errorMessage:r.message,...i}})}trackDependency(r,i,s,a,c,t){this.client.trackDependency({name:r,data:i,duration:s,success:a,resultCode:c||(a?"200":"500"),dependencyTypeName:"External",properties:t})}trackTrace(r,i){this.client.trackTrace({message:r,properties:i})}async flush(){return new Promise(r=>{this.client.flush(),setTimeout(r,2e3)})}},hPt=".bctb-installation-id",tnn=".bctb",rnn="installation-id";function nnn(){let n=fPt.homedir();return F1.join(n,tnn)}function SEe(n){let r=nnn(),i=F1.join(r,rnn);try{if(zo.existsSync(i)){let c=zo.readFileSync(i,"utf8").trim();if(c)return inn(n),c}}catch{}let s=F1.join(n,hPt);try{if(zo.existsSync(s)){let c=zo.readFileSync(s,"utf8").trim();if(c)return pPt(r),zo.writeFileSync(i,c,"utf8"),zo.unlinkSync(s),c}}catch(c){console.error(`Failed to migrate workspace installation ID: ${c}`)}let a=dPt.randomUUID();try{pPt(r),zo.writeFileSync(i,a,"utf8")}catch(c){console.error(`Failed to write installation ID file: ${c}`)}return a}function pPt(n){zo.existsSync(n)||zo.mkdirSync(n,{recursive:!0})}function inn(n){let r=F1.join(n,hPt);try{zo.existsSync(r)&&zo.unlinkSync(r)}catch{}}function mPt(n,r,i){if(!n||n.trim()==="")return null;try{let s=SEe(r);return new EEe(n,s,i)}catch(s){return console.error(`Failed to initialize MCP usage telemetry: ${s}`),null}}var AEe=ve(require("crypto")),QY=class{app;config;auth;kusto;cache;queries;references;configErrors;usageTelemetry;sessionId;installationId;isStdioMode;constructor(r,i){if(this.app=(0,OEe.default)(),this.isStdioMode=i==="stdio",r)this.config=r;else{let c=G0e(void 0,void 0,this.isStdioMode);c?(this.isStdioMode||console.error("[Config] Using config file (.bctb-config.json)"),this.config=c):(this.isStdioMode||console.error("[Config] No config file found, using environment variables"),this.config=j0e())}this.configErrors=H0e(this.config),this.isStdioMode||(console.error("=== BC Telemetry Buddy MCP Server ==="),console.error(`Connection: ${this.config.connectionName}`),console.error(`Workspace: ${this.config.workspacePath}`),console.error(`App Insights ID: ${this.config.applicationInsightsAppId||"(not set)"}`),console.error(`Kusto URL: ${this.config.kustoClusterUrl||"(not set)"}`),console.error(`Auth flow: ${this.config.authFlow}`),console.error(`Cache: ${this.config.cacheEnabled?`enabled (TTL: ${this.config.cacheTTLSeconds}s)`:"disabled"}`),console.error(`PII sanitization: ${this.config.removePII?"enabled":"disabled"}`),console.error(`External references: ${this.config.references.length}`),this.configErrors.length>0?console.error(`\u26A0\uFE0F Configuration incomplete (${this.configErrors.length} issues)`):console.error("\u2705 Configuration valid"),console.error(`=====================================
247
+ `),null;i||(console.error(`\u{1F4C4} Loading config from: ${s}`),console.error(`[Config] BCTB_WORKSPACE_PATH env var = ${process.env.BCTB_WORKSPACE_PATH||"(not set)"}`));let a=bf.readFileSync(s,"utf-8"),c=JSON.parse(a);if(c.profiles){let e=r||process.env.BCTB_PROFILE||c.defaultProfile;if(!e)throw new Error("No profile specified. Use --profile <name> or set BCTB_PROFILE env var");if(!c.profiles[e])throw new Error(`Profile '${e}' not found in config`);console.error(`\u{1F4CB} Using profile: "${e}"`);let o=z0e(c.profiles,e),u={...o,cacheEnabled:o.cacheEnabled??c.cache?.enabled??!0,cacheTTLSeconds:o.cacheTTLSeconds??c.cache?.ttlSeconds??3600,removePII:o.removePII??c.sanitize?.removePII??!1,references:o.references??c.references??[],port:o.port??52345,workspacePath:o.workspacePath??process.env.BCTB_WORKSPACE_PATH??process.cwd(),queriesFolder:o.queriesFolder??"queries",connectionName:o.connectionName??"Default",tenantId:o.tenantId??"",authFlow:o.authFlow??"azure_cli",applicationInsightsAppId:o.applicationInsightsAppId??"",kustoClusterUrl:o.kustoClusterUrl??""};return pM(u)}let t={connectionName:c.connectionName??"Default",tenantId:c.tenantId??"",clientId:c.clientId,clientSecret:c.clientSecret,authFlow:c.authFlow??"azure_cli",applicationInsightsAppId:c.applicationInsightsAppId??"",kustoClusterUrl:c.kustoClusterUrl??"",cacheEnabled:c.cacheEnabled??!0,cacheTTLSeconds:c.cacheTTLSeconds??3600,removePII:c.removePII??!1,port:c.port??52345,workspacePath:c.workspacePath??process.env.BCTB_WORKSPACE_PATH??process.cwd(),queriesFolder:c.queriesFolder??"queries",references:c.references??[]};return pM(t)}function z0e(n,r,i=new Set){if(i.has(r))throw new Error(`Circular profile inheritance detected: ${r}`);i.add(r);let s=n[r];if(!s)throw new Error(`Profile '${r}' not found`);if(!s.extends)return s;let a=z0e(n,s.extends,i),c=K0e(a,s);return delete c.extends,c}function K0e(n,r){let i={...n};for(let s in r)s!=="extends"&&(typeof r[s]=="object"&&!Array.isArray(r[s])&&r[s]!==null?i[s]=K0e(n[s]||{},r[s]):i[s]=r[s]);return i}function pM(n){if(typeof n=="string")return n.replace(/\$\{([^}]+)\}/g,(r,i)=>{if(i==="workspaceFolder"){let s=process.env.BCTB_WORKSPACE_PATH||process.cwd();return console.error(`[Config] Expanding \${workspaceFolder} to: ${s}`),s}return process.env[i]||""});if(Array.isArray(n))return n.map(r=>pM(r));if(typeof n=="object"&&n!==null){let r={};for(let i in n)r[i]=pM(n[i]);return r}return n}var At=ve(r2e());var vd="2.3.2";var yPt=ve(require("https"));var fA=ve(lPt()),zo=ve(require("fs")),F1=ve(require("path")),dPt=ve(require("crypto")),fPt=ve(require("os")),EEe=class{client;constructor(r,i,s){fA.setup(r).setAutoCollectRequests(!1).setAutoCollectPerformance(!1,!1).setAutoCollectExceptions(!1).setAutoCollectDependencies(!1).setAutoCollectConsole(!1).setUseDiskRetryCaching(!0),fA.start(),this.client=fA.defaultClient,this.client.commonProperties={installationId:i,version:s,component:"MCP"}}trackEvent(r,i,s){let a={};if(i)for(let[c,t]of Object.entries(i))a[c]=String(t);this.client.trackEvent({name:r,properties:a,measurements:s})}trackException(r,i){this.client.trackException({exception:r,properties:{errorName:r.name,errorMessage:r.message,...i}})}trackDependency(r,i,s,a,c,t){this.client.trackDependency({name:r,data:i,duration:s,success:a,resultCode:c||(a?"200":"500"),dependencyTypeName:"External",properties:t})}trackTrace(r,i){this.client.trackTrace({message:r,properties:i})}async flush(){return new Promise(r=>{this.client.flush(),setTimeout(r,2e3)})}},hPt=".bctb-installation-id",tnn=".bctb",rnn="installation-id";function nnn(){let n=fPt.homedir();return F1.join(n,tnn)}function SEe(n){let r=nnn(),i=F1.join(r,rnn);try{if(zo.existsSync(i)){let c=zo.readFileSync(i,"utf8").trim();if(c)return inn(n),c}}catch{}let s=F1.join(n,hPt);try{if(zo.existsSync(s)){let c=zo.readFileSync(s,"utf8").trim();if(c)return pPt(r),zo.writeFileSync(i,c,"utf8"),zo.unlinkSync(s),c}}catch(c){console.error(`Failed to migrate workspace installation ID: ${c}`)}let a=dPt.randomUUID();try{pPt(r),zo.writeFileSync(i,a,"utf8")}catch(c){console.error(`Failed to write installation ID file: ${c}`)}return a}function pPt(n){zo.existsSync(n)||zo.mkdirSync(n,{recursive:!0})}function inn(n){let r=F1.join(n,hPt);try{zo.existsSync(r)&&zo.unlinkSync(r)}catch{}}function mPt(n,r,i){if(!n||n.trim()==="")return null;try{let s=SEe(r);return new EEe(n,s,i)}catch(s){return console.error(`Failed to initialize MCP usage telemetry: ${s}`),null}}var AEe=ve(require("crypto")),QY=class{app;config;auth;kusto;cache;queries;references;configErrors;usageTelemetry;sessionId;installationId;isStdioMode;constructor(r,i){if(this.app=(0,OEe.default)(),this.isStdioMode=i==="stdio",r)this.config=r;else{let c=G0e(void 0,void 0,this.isStdioMode);c?(this.isStdioMode||console.error("[Config] Using config file (.bctb-config.json)"),this.config=c):(this.isStdioMode||console.error("[Config] No config file found, using environment variables"),this.config=j0e())}this.configErrors=H0e(this.config),this.isStdioMode||(console.error("=== BC Telemetry Buddy MCP Server ==="),console.error(`Connection: ${this.config.connectionName}`),console.error(`Workspace: ${this.config.workspacePath}`),console.error(`App Insights ID: ${this.config.applicationInsightsAppId||"(not set)"}`),console.error(`Kusto URL: ${this.config.kustoClusterUrl||"(not set)"}`),console.error(`Auth flow: ${this.config.authFlow}`),console.error(`Cache: ${this.config.cacheEnabled?`enabled (TTL: ${this.config.cacheTTLSeconds}s)`:"disabled"}`),console.error(`PII sanitization: ${this.config.removePII?"enabled":"disabled"}`),console.error(`External references: ${this.config.references.length}`),this.configErrors.length>0?console.error(`\u26A0\uFE0F Configuration incomplete (${this.configErrors.length} issues)`):console.error("\u2705 Configuration valid"),console.error(`=====================================
248
248
  `)),this.sessionId=AEe.randomUUID();let s=At.TELEMETRY_CONNECTION_STRING;if(s&&!0){let c=mPt(s,this.config.workspacePath,vd);if(c){this.installationId=SEe(this.config.workspacePath),this.usageTelemetry=new At.RateLimitedUsageTelemetry(c,{maxIdenticalErrors:10,maxEventsPerSession:2e3,maxEventsPerMinute:200}),this.isStdioMode||console.error(`\u2713 Usage Telemetry initialized
249
249
  `);let t=this.config.connectionName?(0,At.hashValue)(this.config.connectionName).substring(0,16):void 0,e=(0,At.createCommonProperties)(At.TELEMETRY_EVENTS.MCP.SERVER_STARTED,"mcp",this.sessionId,this.installationId,vd,{profileHash:t,authFlow:this.config.authFlow,cacheEnabled:String(this.config.cacheEnabled)});this.usageTelemetry.trackEvent("Mcp.ServerStarted",(0,At.cleanTelemetryProperties)(e))}else this.usageTelemetry=new At.NoOpUsageTelemetry,this.installationId="unknown",this.isStdioMode||console.error(`\u26A0\uFE0F Usage Telemetry initialization failed
250
250
  `)}else this.usageTelemetry=new At.NoOpUsageTelemetry,this.installationId="unknown",this.isStdioMode||console.error(`\u2139\uFE0F Usage Telemetry disabled
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bc-telemetry-buddy-mcp",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Model Context Protocol server for Business Central telemetry",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/server.js",