xmcp 0.4.0 → 0.4.1-alpha.1

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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,()=>(()=>{var t={853:(t,e,n)=>{var r=n(6971);e.operation=function(t){var n=e.timeouts(t);return new r(n,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})},e.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in t)e[n]=t[n];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<e.retries;o++)r.push(this.createTimeout(o,e));return t&&t.forever&&!r.length&&r.push(this.createTimeout(o,e)),r.sort(function(t,e){return t-e}),r},e.createTimeout=function(t,e){var n=e.randomize?Math.random()+1:1,r=Math.round(n*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return Math.min(r,e.maxTimeout)},e.wrap=function(t,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var o in r=[],t)"function"==typeof t[o]&&r.push(o);for(var i=0;i<r.length;i++){var s=r[i],a=t[s];t[s]=function(r){var o=e.operation(n),i=Array.prototype.slice.call(arguments,1),s=i.pop();i.push(function(t){o.retry(t)||(t&&(arguments[0]=o.mainError()),s.apply(this,arguments))}),o.attempt(function(){r.apply(t,i)})}.bind(t,a),t[s].options=n}}},3389:(t,e,n)=>{"use strict";const r=n(9858),o=process.env;function i(t){return"string"==typeof t?!!o[t]:"env"in t?o[t.env]&&o[t.env].includes(t.includes):"any"in t?t.any.some(function(t){return!!o[t]}):Object.keys(t).every(function(e){return o[e]===t[e]})}Object.defineProperty(e,"_vendors",{value:r.map(function(t){return t.constant})}),e.name=null,e.isPR=null,e.id=null,"false"!==o.CI&&r.forEach(function(t){const n=(Array.isArray(t.env)?t.env:[t.env]).every(function(t){return i(t)});e[t.constant]=n,n&&(e.name=t.name,e.isPR=function(t){switch(typeof t.pr){case"string":return!!o[t.pr];case"object":return"env"in t.pr?"any"in t.pr?t.pr.any.some(function(e){return o[t.pr.env]===e}):t.pr.env in o&&o[t.pr.env]!==t.pr.ne:"any"in t.pr?t.pr.any.some(function(t){return!!o[t]}):i(t.pr);default:return null}}(t),e.id=t.constant)}),e.isCI=!("false"===o.CI||!(o.BUILD_ID||o.BUILD_NUMBER||o.CI||o.CI_APP_ID||o.CI_BUILD_ID||o.CI_BUILD_NUMBER||o.CI_NAME||o.CONTINUOUS_INTEGRATION||o.RUN_ID||e.name))},3985:(t,e,n)=>{var r=n(9627);t.exports=function(t,e){return new Promise(function(n,o){var i,s=e||{};function a(t){o(t||new Error("Aborted"))}function c(t,e){t.bail?a(t):i.retry(t)?s.onRetry&&s.onRetry(t,e):o(i.mainError())}"randomize"in s||(s.randomize=!0),(i=r.operation(s)).attempt(function(e){var r;try{r=t(a,e)}catch(t){return void c(t,e)}Promise.resolve(r).then(n).catch(function(t){c(t,e)})})})}},6971:t=>{function e(t,e){"boolean"==typeof e&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}t.exports=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},e.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=(new Date).getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0},e.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},e.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)},e.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var t={},e=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],i=o.message,s=(t[i]||0)+1;t[i]=s,s>=n&&(e=o,n=s)}return e}},9627:(t,e,n)=>{t.exports=n(853)},9858:t=>{"use strict";t.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE","pr":{"env":"AC_GIT_PR","ne":"false"}},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN","pr":{"env":"CODEBUILD_WEBHOOK_EVENT","any":["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{"name":"Azure Pipelines","constant":"AZURE_PIPELINES","env":"TF_BUILD","pr":{"BUILD_REASON":"PullRequest"}},{"name":"Bamboo","constant":"BAMBOO","env":"bamboo_planKey"},{"name":"Bitbucket Pipelines","constant":"BITBUCKET","env":"BITBUCKET_COMMIT","pr":"BITBUCKET_PR_ID"},{"name":"Bitrise","constant":"BITRISE","env":"BITRISE_IO","pr":"BITRISE_PULL_REQUEST"},{"name":"Buddy","constant":"BUDDY","env":"BUDDY_WORKSPACE_ID","pr":"BUDDY_EXECUTION_PULL_REQUEST_ID"},{"name":"Buildkite","constant":"BUILDKITE","env":"BUILDKITE","pr":{"env":"BUILDKITE_PULL_REQUEST","ne":"false"}},{"name":"CircleCI","constant":"CIRCLE","env":"CIRCLECI","pr":"CIRCLE_PULL_REQUEST"},{"name":"Cirrus CI","constant":"CIRRUS","env":"CIRRUS_CI","pr":"CIRRUS_PR"},{"name":"Cloudflare Pages","constant":"CLOUDFLARE_PAGES","env":"CF_PAGES"},{"name":"Cloudflare Workers","constant":"CLOUDFLARE_WORKERS","env":"WORKERS_CI"},{"name":"Codefresh","constant":"CODEFRESH","env":"CF_BUILD_ID","pr":{"any":["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{"name":"Codemagic","constant":"CODEMAGIC","env":"CM_BUILD_ID","pr":"CM_PULL_REQUEST"},{"name":"Codeship","constant":"CODESHIP","env":{"CI_NAME":"codeship"}},{"name":"Drone","constant":"DRONE","env":"DRONE","pr":{"DRONE_BUILD_EVENT":"pull_request"}},{"name":"dsari","constant":"DSARI","env":"DSARI"},{"name":"Earthly","constant":"EARTHLY","env":"EARTHLY_CI"},{"name":"Expo Application Services","constant":"EAS","env":"EAS_BUILD"},{"name":"Gerrit","constant":"GERRIT","env":"GERRIT_PROJECT"},{"name":"Gitea Actions","constant":"GITEA_ACTIONS","env":"GITEA_ACTIONS"},{"name":"GitHub Actions","constant":"GITHUB_ACTIONS","env":"GITHUB_ACTIONS","pr":{"GITHUB_EVENT_NAME":"pull_request"}},{"name":"GitLab CI","constant":"GITLAB","env":"GITLAB_CI","pr":"CI_MERGE_REQUEST_ID"},{"name":"GoCD","constant":"GOCD","env":"GO_PIPELINE_LABEL"},{"name":"Google Cloud Build","constant":"GOOGLE_CLOUD_BUILD","env":"BUILDER_OUTPUT"},{"name":"Harness CI","constant":"HARNESS","env":"HARNESS_BUILD_ID"},{"name":"Heroku","constant":"HEROKU","env":{"env":"NODE","includes":"/app/.heroku/node/bin/node"}},{"name":"Hudson","constant":"HUDSON","env":"HUDSON_URL"},{"name":"Jenkins","constant":"JENKINS","env":["JENKINS_URL","BUILD_ID"],"pr":{"any":["ghprbPullId","CHANGE_ID"]}},{"name":"LayerCI","constant":"LAYERCI","env":"LAYERCI","pr":"LAYERCI_PULL_REQUEST"},{"name":"Magnum CI","constant":"MAGNUM","env":"MAGNUM"},{"name":"Netlify CI","constant":"NETLIFY","env":"NETLIFY","pr":{"env":"PULL_REQUEST","ne":"false"}},{"name":"Nevercode","constant":"NEVERCODE","env":"NEVERCODE","pr":{"env":"NEVERCODE_PULL_REQUEST","ne":"false"}},{"name":"Prow","constant":"PROW","env":"PROW_JOB_ID"},{"name":"ReleaseHub","constant":"RELEASEHUB","env":"RELEASE_BUILD_ID"},{"name":"Render","constant":"RENDER","env":"RENDER","pr":{"IS_PULL_REQUEST":"true"}},{"name":"Sail CI","constant":"SAIL","env":"SAILCI","pr":"SAIL_PULL_REQUEST_NUMBER"},{"name":"Screwdriver","constant":"SCREWDRIVER","env":"SCREWDRIVER","pr":{"env":"SD_PULL_REQUEST","ne":"false"}},{"name":"Semaphore","constant":"SEMAPHORE","env":"SEMAPHORE","pr":"PULL_REQUEST_NUMBER"},{"name":"Sourcehut","constant":"SOURCEHUT","env":{"CI_NAME":"sourcehut"}},{"name":"Strider CD","constant":"STRIDER","env":"STRIDER"},{"name":"TaskCluster","constant":"TASKCLUSTER","env":["TASK_ID","RUN_ID"]},{"name":"TeamCity","constant":"TEAMCITY","env":"TEAMCITY_VERSION"},{"name":"Travis CI","constant":"TRAVIS","env":"TRAVIS","pr":{"env":"TRAVIS_PULL_REQUEST","ne":"false"}},{"name":"Vela","constant":"VELA","env":"VELA","pr":{"VELA_PULL_REQUEST":"1"}},{"name":"Vercel","constant":"VERCEL","env":{"any":["NOW_BUILDER","VERCEL"]},"pr":"VERCEL_GIT_PULL_REQUEST_ID"},{"name":"Visual Studio App Center","constant":"APPCENTER","env":"APPCENTER_BUILD_ID"},{"name":"Woodpecker","constant":"WOODPECKER","env":{"CI":"woodpecker"},"pr":{"CI_BUILD_EVENT":"pull_request"}},{"name":"Xcode Cloud","constant":"XCODE_CLOUD","env":"CI_XCODE_PROJECT","pr":"CI_PULL_REQUEST_NUMBER"},{"name":"Xcode Server","constant":"XCODE_SERVER","env":"XCS"}]')}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}return n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";const t=require("fs"),e=require("path");var r=n.n(e);const o=require("crypto"),i=require("os");var s=n.n(i);const a=require("node:fs");let c;function u(){return c??=function(){try{return a.statSync("/.dockerenv"),!0}catch{return!1}}()||function(){try{return a.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}()||function(){try{return a.readFileSync("/proc/self/mountinfo","utf8").includes("/docker/containers/")}catch{return!1}}(),c}var m=n(3389),E=n.n(m);const{isCI:p,name:_}=E(),l=p;function f(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const h="telemetry.enabled",I="telemetry.notifiedAt",R="telemetry.anonymousId",T="telemetry.salt";class v{ensureConfig(){try{const e=r().dirname(this.configPath);if((0,t.existsSync)(e)||(0,t.mkdirSync)(e,{recursive:!0}),(0,t.existsSync)(this.configPath)){const e=(0,t.readFileSync)(this.configPath,"utf-8");this.config=JSON.parse(e)}else this.config={}}catch(t){this.config={}}}get(t,e){if(!this.config)return e;const n=this.config[t];return void 0!==n?n:e}set(e,n){if(this.config){this.config[e]=n;try{(0,t.writeFileSync)(this.configPath,JSON.stringify(this.config,null,2),"utf-8")}catch(t){}}}notify(){!this.isDisabled&&this.config&&(this.get(I,"")||(this.set(I,Date.now().toString()),l||(console.log(""),console.log("xmcp collects anonymous usage data to improve the framework."),console.log(" No personal information is collected."),console.log(" You can learn more and opt-out by visiting: https://xmcp.dev/telemetry"),console.log(" Or disable with: npx xmcp telemetry disable"),console.log(""))))}get anonymousId(){this.notify();const t=this.get(R);if(t)return t;const e=(0,o.randomBytes)(32).toString("hex");return this.set(R,e),e}get salt(){const t=this.get(T);if(t)return t;const e=(0,o.randomBytes)(16).toString("hex");return this.set(T,e),e}get isDisabled(){return!(!this.XMCP_TELEMETRY_DISABLED&&this.config)||!1===this.get(h,!0)}get isEnabled(){return!this.XMCP_TELEMETRY_DISABLED&&!!this.config&&!1!==this.get(h,!0)}setEnabled(t){return this.set(h,!!t),this.configPath}oneWayHash(t){const e=(0,o.createHash)("sha256");return e.update(this.salt),e.update(t),e.digest("hex")}clear(){try{(0,t.existsSync)(this.configPath)&&(0,t.unlinkSync)(this.configPath)}catch(t){}}get configFilePath(){return this.configPath}constructor(t){f(this,"configPath",void 0),f(this,"config",null),f(this,"XMCP_TELEMETRY_DISABLED",void 0),this.configPath=function(t){if((l||u())&&t)return r().join(t,"cache","telemetry.json");const e=r().join(s().homedir(),"win32"===process.platform?"AppData/Local/xmcp":".config/xmcp");return r().join(e,"telemetry.json")}(t),this.XMCP_TELEMETRY_DISABLED=process.env.XMCP_TELEMETRY_DISABLED,this.ensureConfig()}}const d=require("node:process"),y=require("node:os");let S,C;function L(){return void 0===C&&(C=(()=>{try{return a.statSync("/run/.containerenv"),!0}catch{return!1}})()||(void 0===S&&(S=function(){try{return a.statSync("/.dockerenv"),!0}catch{return!1}}()||function(){try{return a.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}()),S)),C}const U=()=>{if("linux"!==d.platform)return!1;if(y.release().toLowerCase().includes("microsoft"))return!L();try{return!!a.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")&&!L()}catch{return!1}},D=d.env.__IS_WSL_TEST__?U:U(),{isCI:A,name:P}=E();let g;var O=n(3985),N=n.n(O);!async function(){const[e,n]=process.argv.slice(2);e&&n||(console.error("Usage: detached-flush <mode> <distDir>"),process.exit(1));const i=r().join(n,"_events.json");if((0,t.existsSync)(i))try{const e=(0,t.readFileSync)(i,"utf-8"),a=JSON.parse(e);if(0===a.length)return;const c=new v(n);if(c.isDisabled)return;const m=await async function(e){return e(await async function(){try{const e=r().join(process.cwd(),"package.json"),n=JSON.parse((0,t.readFileSync)(e,"utf-8"));return`${n.name||"unknown"}@${n.version||"0.0.0"}`}catch(t){return process.cwd()}}())}(c.oneWayHash.bind(c)),E=function(){if(g)return g;const t=s().cpus()||[];return g={systemPlatform:s().platform(),systemRelease:s().release(),systemArchitecture:s().arch(),cpuCount:t.length,cpuModel:t.length?t[0].model:null,cpuSpeed:t.length?t[0].speed:null,memoryInMb:Math.trunc(s().totalmem()/Math.pow(1024,2)),isDocker:u(),isWsl:D,isCI:A,ciName:A&&P||null},g}(),p=(0,o.randomBytes)(32).toString("hex"),_=function(t,e,n){return{context:t,meta:e,events:n}}({anonymousId:c.anonymousId,projectHash:m,sessionId:p},E,a.map(t=>({eventName:t.eventName,timestamp:(new Date).toISOString(),fields:t.fields})));await function(t,e){return!e&&"timeout"in AbortSignal&&(e=AbortSignal.timeout(5e3)),N()(async()=>{const n=await fetch("https://telemetry.xmcp.dev/api/telemetry/events",{method:"POST",body:JSON.stringify(t),headers:{"content-type":"application/json"},signal:e}),r=await n.text();let o;try{o=JSON.parse(r)}catch(t){}if(!n.ok){const t=new Error(`HTTP ${n.status}: ${n.statusText}`);throw t.response=n,t.responseData=o,t}},{minTimeout:500,retries:1,factor:1}).catch(t=>{}).then(()=>{},()=>{})}(_),(0,t.unlinkSync)(i)}catch(t){}}()})(),{}})());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xmcp",
3
3
  "description": "The MCP framework",
4
- "version": "0.4.0",
4
+ "version": "0.4.1-alpha.1",
5
5
  "author": {
6
6
  "name": "xmcp",
7
7
  "email": "support@xmcp.dev",
@@ -42,15 +42,19 @@
42
42
  ],
43
43
  "scripts": {
44
44
  "dev": "cross-env NODE_ENV=development tsx --watch --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
45
- "build": "cross-env NODE_ENV=production tsx --tsconfig ./bundler.tsconfig.json ./bundler/index.ts"
45
+ "build": "cross-env NODE_ENV=production tsx --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
46
+ "test:telemetry": "tsx src/telemetry/test-api.ts",
47
+ "test:telemetry:debug": "XMCP_TELEMETRY_DEBUG=1 tsx src/telemetry/test-api.ts"
46
48
  },
47
49
  "dependencies": {
48
50
  "@modelcontextprotocol/sdk": "^1.17.4",
49
51
  "@swc/core": "1.11.24",
50
52
  "@types/express": "^5.0.1",
51
53
  "@types/webpack-node-externals": "^3.0.4",
54
+ "async-retry": "^1.3.3",
52
55
  "chalk": "^5.3.0",
53
56
  "chokidar": "^3.6.0",
57
+ "ci-info": "^4.3.1",
54
58
  "clean-webpack-plugin": "^4.0.0",
55
59
  "commander": "^11.1.0",
56
60
  "content-type": "^1.0.5",
@@ -61,6 +65,8 @@
61
65
  "fork-ts-checker-webpack-plugin": "^8.0.0",
62
66
  "fs-extra": "^11.3.0",
63
67
  "glob": "^11.0.2",
68
+ "is-docker": "^4.0.0",
69
+ "is-wsl": "^3.1.0",
64
70
  "json5": "^2.2.3",
65
71
  "jsonwebtoken": "^9.0.2",
66
72
  "memfs": "^4.17.2",
@@ -72,6 +78,7 @@
72
78
  "webpack-virtual-modules": "^0.5.0"
73
79
  },
74
80
  "devDependencies": {
81
+ "@types/async-retry": "^1.4.9",
75
82
  "@types/content-type": "^1.1.9",
76
83
  "@types/fs-extra": "^11.0.4",
77
84
  "@types/jsonwebtoken": "^9.0.9",