@artyfacts/claude 1.3.17 → 1.3.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.
package/dist/cli.js CHANGED
@@ -876,8 +876,17 @@ function addMcpServer(options) {
876
876
  } else {
877
877
  const error = result.stderr || result.stdout || `Exit code ${result.status}`;
878
878
  if (error.includes("already exists")) {
879
- console.log(`[MCP] Server ${name} already configured - treating as success`);
880
- return { success: true, alreadyExists: true };
879
+ console.log(`[MCP] Server ${name} exists - removing old config...`);
880
+ (0, import_child_process2.spawnSync)("claude", ["mcp", "remove", name], { encoding: "utf-8" });
881
+ const retryResult = (0, import_child_process2.spawnSync)("claude", cliArgs, {
882
+ encoding: "utf-8",
883
+ stdio: ["pipe", "pipe", "pipe"]
884
+ });
885
+ if (retryResult.status === 0) {
886
+ return { success: true, replaced: true };
887
+ } else {
888
+ return { success: false, error: retryResult.stderr || retryResult.stdout || "Failed after removing old config" };
889
+ }
881
890
  }
882
891
  return { success: false, error };
883
892
  }
@@ -902,26 +911,32 @@ var McpHandler = class {
902
911
  if (oauthServer) {
903
912
  const result = addMcpServer({
904
913
  name: serverName,
905
- transport: "stdio",
906
- command: "npx",
907
- args: ["-y", "mcp-remote", oauthServer.url]
914
+ transport: "http",
915
+ url: oauthServer.url
908
916
  });
909
917
  if (!result.success) {
910
918
  throw new Error(`Failed to add ${platform} MCP: ${result.error}`);
911
919
  }
912
- console.log(`[MCP] Added ${serverName} via mcp-remote`);
913
- console.log(`[MCP] Triggering ${platform} OAuth...`);
914
- const oauthProcess = (0, import_child_process2.spawnSync)("npx", ["-y", "mcp-remote", oauthServer.url], {
920
+ console.log(`[MCP] Added ${serverName} \u2192 ${oauthServer.url}`);
921
+ console.log(`[MCP] Triggering ${platform} OAuth via Claude...`);
922
+ const oauthProcess = (0, import_child_process2.spawnSync)("claude", [
923
+ "-p",
924
+ `Please list the available tools from the ${platform} MCP server. Just list them briefly.`,
925
+ "--allowedTools",
926
+ `mcp__${serverName}__*`,
927
+ "--permission-mode",
928
+ "default"
929
+ ], {
915
930
  encoding: "utf-8",
916
931
  stdio: "inherit",
917
- // Show output and allow browser to open
932
+ // Show output and allow browser interaction
918
933
  timeout: 12e4
919
934
  // 2 minute timeout for user to complete OAuth
920
935
  });
921
936
  if (oauthProcess.status === 0) {
922
937
  console.log(`[MCP] ${platform} OAuth completed!`);
923
938
  } else {
924
- console.log(`[MCP] OAuth process ended - check browser for login`);
939
+ console.log(`[MCP] OAuth may need completion - try using ${platform} tools in Claude`);
925
940
  }
926
941
  } else {
927
942
  const configBuilder = CREDENTIAL_MCP_CONFIGS[platform];
package/dist/cli.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  getCredentials,
8
8
  loadCredentials,
9
9
  promptForApiKey
10
- } from "./chunk-GZQ2C7RT.mjs";
10
+ } from "./chunk-4BEMUW57.mjs";
11
11
 
12
12
  // src/cli.ts
13
13
  import { Command } from "commander";
package/dist/index.js CHANGED
@@ -6069,8 +6069,17 @@ function addMcpServer(options) {
6069
6069
  } else {
6070
6070
  const error = result.stderr || result.stdout || `Exit code ${result.status}`;
6071
6071
  if (error.includes("already exists")) {
6072
- console.log(`[MCP] Server ${name} already configured - treating as success`);
6073
- return { success: true, alreadyExists: true };
6072
+ console.log(`[MCP] Server ${name} exists - removing old config...`);
6073
+ (0, import_child_process2.spawnSync)("claude", ["mcp", "remove", name], { encoding: "utf-8" });
6074
+ const retryResult = (0, import_child_process2.spawnSync)("claude", cliArgs, {
6075
+ encoding: "utf-8",
6076
+ stdio: ["pipe", "pipe", "pipe"]
6077
+ });
6078
+ if (retryResult.status === 0) {
6079
+ return { success: true, replaced: true };
6080
+ } else {
6081
+ return { success: false, error: retryResult.stderr || retryResult.stdout || "Failed after removing old config" };
6082
+ }
6074
6083
  }
6075
6084
  return { success: false, error };
6076
6085
  }
@@ -6095,26 +6104,32 @@ var McpHandler = class {
6095
6104
  if (oauthServer) {
6096
6105
  const result = addMcpServer({
6097
6106
  name: serverName,
6098
- transport: "stdio",
6099
- command: "npx",
6100
- args: ["-y", "mcp-remote", oauthServer.url]
6107
+ transport: "http",
6108
+ url: oauthServer.url
6101
6109
  });
6102
6110
  if (!result.success) {
6103
6111
  throw new Error(`Failed to add ${platform} MCP: ${result.error}`);
6104
6112
  }
6105
- console.log(`[MCP] Added ${serverName} via mcp-remote`);
6106
- console.log(`[MCP] Triggering ${platform} OAuth...`);
6107
- const oauthProcess = (0, import_child_process2.spawnSync)("npx", ["-y", "mcp-remote", oauthServer.url], {
6113
+ console.log(`[MCP] Added ${serverName} \u2192 ${oauthServer.url}`);
6114
+ console.log(`[MCP] Triggering ${platform} OAuth via Claude...`);
6115
+ const oauthProcess = (0, import_child_process2.spawnSync)("claude", [
6116
+ "-p",
6117
+ `Please list the available tools from the ${platform} MCP server. Just list them briefly.`,
6118
+ "--allowedTools",
6119
+ `mcp__${serverName}__*`,
6120
+ "--permission-mode",
6121
+ "default"
6122
+ ], {
6108
6123
  encoding: "utf-8",
6109
6124
  stdio: "inherit",
6110
- // Show output and allow browser to open
6125
+ // Show output and allow browser interaction
6111
6126
  timeout: 12e4
6112
6127
  // 2 minute timeout for user to complete OAuth
6113
6128
  });
6114
6129
  if (oauthProcess.status === 0) {
6115
6130
  console.log(`[MCP] ${platform} OAuth completed!`);
6116
6131
  } else {
6117
- console.log(`[MCP] OAuth process ended - check browser for login`);
6132
+ console.log(`[MCP] OAuth may need completion - try using ${platform} tools in Claude`);
6118
6133
  }
6119
6134
  } else {
6120
6135
  const configBuilder = CREDENTIAL_MCP_CONFIGS[platform];
package/dist/index.mjs CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  promptForApiKey,
15
15
  runDeviceAuth,
16
16
  saveCredentials
17
- } from "./chunk-GZQ2C7RT.mjs";
17
+ } from "./chunk-4BEMUW57.mjs";
18
18
 
19
19
  // node_modules/@anthropic-ai/sdk/internal/tslib.mjs
20
20
  function __classPrivateFieldSet(receiver, state, value, kind, f) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artyfacts/claude",
3
- "version": "1.3.17",
3
+ "version": "1.3.19",
4
4
  "description": "Claude adapter for Artyfacts - Execute tasks using Claude Code CLI",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/mcp.ts CHANGED
@@ -101,7 +101,7 @@ function addMcpServer(options: {
101
101
  args?: string[];
102
102
  env?: Record<string, string>;
103
103
  scope?: 'local' | 'user' | 'project';
104
- }): { success: boolean; error?: string; alreadyExists?: boolean } {
104
+ }): { success: boolean; error?: string; replaced?: boolean } {
105
105
  const { name, transport, url, command, args = [], env = {}, scope = 'user' } = options;
106
106
 
107
107
  const cliArgs = ['mcp', 'add', '-s', scope, '-t', transport];
@@ -136,10 +136,22 @@ function addMcpServer(options: {
136
136
  } else {
137
137
  const error = result.stderr || result.stdout || `Exit code ${result.status}`;
138
138
 
139
- // "Already exists" is not an error - the server is configured
139
+ // "Already exists" - remove and retry to ensure fresh config
140
140
  if (error.includes('already exists')) {
141
- console.log(`[MCP] Server ${name} already configured - treating as success`);
142
- return { success: true, alreadyExists: true };
141
+ console.log(`[MCP] Server ${name} exists - removing old config...`);
142
+ spawnSync('claude', ['mcp', 'remove', name], { encoding: 'utf-8' });
143
+
144
+ // Retry the add
145
+ const retryResult = spawnSync('claude', cliArgs, {
146
+ encoding: 'utf-8',
147
+ stdio: ['pipe', 'pipe', 'pipe'],
148
+ });
149
+
150
+ if (retryResult.status === 0) {
151
+ return { success: true, replaced: true };
152
+ } else {
153
+ return { success: false, error: retryResult.stderr || retryResult.stdout || 'Failed after removing old config' };
154
+ }
143
155
  }
144
156
 
145
157
  return { success: false, error };
@@ -173,32 +185,36 @@ export class McpHandler {
173
185
  // Check if this is an OAuth-based server
174
186
  const oauthServer = OAUTH_MCP_SERVERS[platform];
175
187
  if (oauthServer) {
176
- // Use mcp-remote for OAuth handling - it opens browser automatically
188
+ // Use http transport - Claude handles OAuth natively
177
189
  const result = addMcpServer({
178
190
  name: serverName,
179
- transport: 'stdio',
180
- command: 'npx',
181
- args: ['-y', 'mcp-remote', oauthServer.url],
191
+ transport: 'http',
192
+ url: oauthServer.url,
182
193
  });
183
194
 
184
195
  if (!result.success) {
185
196
  throw new Error(`Failed to add ${platform} MCP: ${result.error}`);
186
197
  }
187
198
 
188
- console.log(`[MCP] Added ${serverName} via mcp-remote`);
199
+ console.log(`[MCP] Added ${serverName} ${oauthServer.url}`);
189
200
 
190
- // Trigger OAuth by running the MCP server - mcp-remote will open browser
191
- console.log(`[MCP] Triggering ${platform} OAuth...`);
192
- const oauthProcess = spawnSync('npx', ['-y', 'mcp-remote', oauthServer.url], {
201
+ // Trigger OAuth by asking Claude to use the MCP - this opens browser!
202
+ console.log(`[MCP] Triggering ${platform} OAuth via Claude...`);
203
+ const oauthProcess = spawnSync('claude', [
204
+ '-p',
205
+ `Please list the available tools from the ${platform} MCP server. Just list them briefly.`,
206
+ '--allowedTools', `mcp__${serverName}__*`,
207
+ '--permission-mode', 'default',
208
+ ], {
193
209
  encoding: 'utf-8',
194
- stdio: 'inherit', // Show output and allow browser to open
210
+ stdio: 'inherit', // Show output and allow browser interaction
195
211
  timeout: 120000, // 2 minute timeout for user to complete OAuth
196
212
  });
197
213
 
198
214
  if (oauthProcess.status === 0) {
199
215
  console.log(`[MCP] ${platform} OAuth completed!`);
200
216
  } else {
201
- console.log(`[MCP] OAuth process ended - check browser for login`);
217
+ console.log(`[MCP] OAuth may need completion - try using ${platform} tools in Claude`);
202
218
  }
203
219
  } else {
204
220
  // Command-based MCP server - needs credentials