@topolo/mcp 0.11.9 → 0.11.10

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 (2) hide show
  1. package/dist/index.js +51 -45
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -2818,52 +2818,58 @@ async function refreshCredentialIfNeeded(environment = selectedEnvironment(), op
2818
2818
  if (process.env[`${prefix}_API_KEY`] || process.env[`${prefix}_ACCESS_TOKEN`] || environment === "production" && process.env.TOPOLO_API_KEY || environment === "production" && process.env.TOPOLO_ACCESS_TOKEN) {
2819
2819
  return resolveCredential(environment);
2820
2820
  }
2821
- const config = await readConfig();
2822
- const profile = profileForEnvironment(config, environment);
2823
- const cred = profile.credential;
2824
- if (!cred || cred.kind !== "access_token") return cred ?? null;
2825
- if (!cred.refreshToken || !profile.oauthClientId) return cred;
2826
- const now = Math.floor(Date.now() / 1e3);
2827
- if (!options.force && cred.expiresAt && cred.expiresAt - REFRESH_SKEW_SECONDS > now) return cred;
2828
- const serviceUrls = resolveServiceUrls(profile.serviceUrls, environment);
2829
- if (environment === "local" && !serviceUrls?.auth) {
2830
- throw new TopoloSdkError2(
2831
- "environment_service_url_required",
2832
- "Local Topolo credential refresh requires an explicit local Auth service origin."
2833
- );
2834
- }
2835
- try {
2836
- const oauth = new TopoloOAuth({
2837
- serviceUrls
2838
- });
2839
- const tokens = await oauth.refreshToken({
2840
- clientId: profile.oauthClientId,
2841
- refreshToken: cred.refreshToken
2842
- });
2843
- const refreshed = {
2844
- kind: "access_token",
2845
- accessToken: tokens.access_token,
2846
- ...tokens.refresh_token ? { refreshToken: tokens.refresh_token } : { refreshToken: cred.refreshToken },
2847
- expiresAt: Math.floor(Date.now() / 1e3) + tokens.expires_in
2848
- };
2849
- const activeContext = profile.activeContext;
2850
- const activeEntry = activeContext ? profile.contexts?.[activeContext] : void 0;
2851
- const updated = activeContext && activeEntry ? writeProfileConfig(config, environment, {
2852
- credential: refreshed,
2853
- contexts: {
2854
- ...profile.contexts ?? {},
2855
- [activeContext]: {
2856
- ...activeEntry,
2857
- credential: refreshed,
2858
- oauthClientId: activeEntry.oauthClientId ?? profile.oauthClientId
2821
+ const observed = profileForEnvironment(await readConfig(), environment).credential;
2822
+ return withConfigWriteLock(async () => {
2823
+ const config = await readConfig();
2824
+ const profile = profileForEnvironment(config, environment);
2825
+ const cred = profile.credential;
2826
+ if (!cred || cred.kind !== "access_token") return cred ?? null;
2827
+ if (!cred.refreshToken || !profile.oauthClientId) return cred;
2828
+ if (options.force && observed?.kind === "access_token" && observed.accessToken !== cred.accessToken) {
2829
+ return cred;
2830
+ }
2831
+ const now = Math.floor(Date.now() / 1e3);
2832
+ if (!options.force && cred.expiresAt && cred.expiresAt - REFRESH_SKEW_SECONDS > now) return cred;
2833
+ const serviceUrls = resolveServiceUrls(profile.serviceUrls, environment);
2834
+ if (environment === "local" && !serviceUrls?.auth) {
2835
+ throw new TopoloSdkError2(
2836
+ "environment_service_url_required",
2837
+ "Local Topolo credential refresh requires an explicit local Auth service origin."
2838
+ );
2839
+ }
2840
+ try {
2841
+ const oauth = new TopoloOAuth({
2842
+ serviceUrls
2843
+ });
2844
+ const tokens = await oauth.refreshToken({
2845
+ clientId: profile.oauthClientId,
2846
+ refreshToken: cred.refreshToken
2847
+ });
2848
+ const refreshed = {
2849
+ kind: "access_token",
2850
+ accessToken: tokens.access_token,
2851
+ ...tokens.refresh_token ? { refreshToken: tokens.refresh_token } : { refreshToken: cred.refreshToken },
2852
+ expiresAt: Math.floor(Date.now() / 1e3) + tokens.expires_in
2853
+ };
2854
+ const activeContext = profile.activeContext;
2855
+ const activeEntry = activeContext ? profile.contexts?.[activeContext] : void 0;
2856
+ const updated = activeContext && activeEntry ? writeProfileConfig(config, environment, {
2857
+ credential: refreshed,
2858
+ contexts: {
2859
+ ...profile.contexts ?? {},
2860
+ [activeContext]: {
2861
+ ...activeEntry,
2862
+ credential: refreshed,
2863
+ oauthClientId: activeEntry.oauthClientId ?? profile.oauthClientId
2864
+ }
2859
2865
  }
2860
- }
2861
- }) : environment === "production" && !config.profiles?.production ? { ...config, credential: refreshed } : writeProfileConfig(config, environment, { credential: refreshed });
2862
- await writeConfig(updated);
2863
- return refreshed;
2864
- } catch {
2865
- return cred;
2866
- }
2866
+ }) : environment === "production" && !config.profiles?.production ? { ...config, credential: refreshed } : writeProfileConfig(config, environment, { credential: refreshed });
2867
+ await writeConfig(updated);
2868
+ return refreshed;
2869
+ } catch {
2870
+ return cred;
2871
+ }
2872
+ });
2867
2873
  }
2868
2874
  async function refreshContextCredentialIfNeeded(environment, key, options = {}) {
2869
2875
  return withConfigWriteLock(async () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@topolo/mcp",
3
- "version": "0.11.9",
4
- "topoloPublishedVersion": "0.11.9",
3
+ "version": "0.11.10",
4
+ "topoloPublishedVersion": "0.11.10",
5
5
  "description": "Model Context Protocol server for the Topolo platform. Exposes scope-gated tools that third-party agents (Claude, Codex, etc.) can call natively.",
6
6
  "license": "UNLICENSED",
7
7
  "author": "Topolo",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@modelcontextprotocol/sdk": "^1.0.0",
38
- "@topolo/sdk": "0.11.9"
38
+ "@topolo/sdk": "0.11.10"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^20.12.0",