@defai.digital/ax-cli 4.1.18 → 4.2.0
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/README.md +23 -0
- package/dist/mcp/config.js +38 -5
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -1
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/provider-mcp-loader.d.ts +118 -0
- package/dist/mcp/provider-mcp-loader.js +219 -0
- package/dist/mcp/provider-mcp-loader.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -223,6 +223,29 @@ ax-glm memory status # View token distribution
|
|
|
223
223
|
|
|
224
224
|
## Changelog
|
|
225
225
|
|
|
226
|
+
### v4.2.0 - Provider-Specific MCP Configuration
|
|
227
|
+
|
|
228
|
+
**Provider MCP Isolation**: ax-glm and ax-grok now have separate MCP configurations, allowing both CLIs to run simultaneously without conflicts.
|
|
229
|
+
|
|
230
|
+
- **Claude Code Format Support**: New `.mcp.json` format following Claude Code best practices
|
|
231
|
+
- **Provider-Specific Directories**: `.ax-glm/.mcp.json` and `.ax-grok/.mcp.json` for isolated MCP server configs
|
|
232
|
+
- **Legacy Format Support**: Backward compatible with existing `mcp-config.json` files
|
|
233
|
+
- **Configuration Priority**: Clear priority order for MCP config loading (project settings > provider MCP > AutomatosX config)
|
|
234
|
+
- **Documentation Updates**: Comprehensive guides for multi-provider MCP setup
|
|
235
|
+
|
|
236
|
+
**MCP Configuration Example** (`.ax-glm/.mcp.json`):
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"mcpServers": {
|
|
240
|
+
"automatosx": {
|
|
241
|
+
"command": "automatosx",
|
|
242
|
+
"args": ["mcp", "server"],
|
|
243
|
+
"env": { "AUTOMATOSX_PROJECT_DIR": "/path/to/project" }
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
226
249
|
### v4.1.18 - CI/CD Fix
|
|
227
250
|
- **Fixed Tests**: Added missing `provider/config.ts` to root src for test compatibility
|
|
228
251
|
|
package/dist/mcp/config.js
CHANGED
|
@@ -6,6 +6,7 @@ import { migrateConfig } from "./config-migrator.js";
|
|
|
6
6
|
import { detectConfigFormat } from "./config-detector.js";
|
|
7
7
|
import { formatMCPConfigError, formatWarning, formatInfo } from "./error-formatter.js";
|
|
8
8
|
import { ZAI_SERVER_NAMES, isZAIServer } from "./zai-templates.js";
|
|
9
|
+
import { loadProviderMCPConfig } from "./provider-mcp-loader.js";
|
|
9
10
|
// Track if we've already shown migration warnings this session
|
|
10
11
|
let hasShownMigrationWarnings = false;
|
|
11
12
|
// Track which REPL warnings we've already shown
|
|
@@ -136,7 +137,23 @@ export function loadMCPConfig() {
|
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
// Load
|
|
140
|
+
// Load provider-specific MCP config following Claude Code best practices:
|
|
141
|
+
// 1. .ax-glm/.mcp.json or .ax-grok/.mcp.json (Claude Code format - recommended)
|
|
142
|
+
// 2. .ax-glm/mcp-config.json or .ax-grok/mcp-config.json (legacy format)
|
|
143
|
+
// This ensures ax-glm and ax-grok use their own config directories
|
|
144
|
+
const providerMCPResult = loadProviderMCPConfig();
|
|
145
|
+
const providerMCPServers = providerMCPResult.serverConfigs;
|
|
146
|
+
if (providerMCPResult.found && !hasShownMigrationWarnings) {
|
|
147
|
+
if (providerMCPResult.error) {
|
|
148
|
+
console.warn(formatWarning('Provider MCP config found but has errors:', [providerMCPResult.error]));
|
|
149
|
+
}
|
|
150
|
+
if (providerMCPResult.warnings.length > 0 && process.env.DEBUG) {
|
|
151
|
+
providerMCPResult.warnings.forEach(warning => {
|
|
152
|
+
console.warn(formatInfo(warning));
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Load AutomatosX servers from .automatosx/config.json (legacy location)
|
|
140
157
|
const automatosXResult = loadAutomatosXMCPServers();
|
|
141
158
|
if (automatosXResult.found && !hasShownMigrationWarnings) {
|
|
142
159
|
if (automatosXResult.errors.length > 0) {
|
|
@@ -148,10 +165,26 @@ export function loadMCPConfig() {
|
|
|
148
165
|
});
|
|
149
166
|
}
|
|
150
167
|
}
|
|
151
|
-
// Merge
|
|
168
|
+
// Merge all config sources with priority:
|
|
169
|
+
// 1. ax-cli project settings (highest priority)
|
|
170
|
+
// 2. Provider-specific MCP config (.ax-glm/mcp-config.json or .ax-grok/mcp-config.json)
|
|
171
|
+
// 3. AutomatosX config (.automatosx/config.json) (lowest priority)
|
|
152
172
|
let finalServers;
|
|
153
|
-
|
|
154
|
-
|
|
173
|
+
// Start with AutomatosX servers (lowest priority)
|
|
174
|
+
let mergedServers = automatosXResult.found && automatosXResult.servers.length > 0
|
|
175
|
+
? automatosXResult.servers
|
|
176
|
+
: [];
|
|
177
|
+
// Merge provider-specific MCP servers (higher priority than AutomatosX)
|
|
178
|
+
if (providerMCPServers.length > 0) {
|
|
179
|
+
const providerMergeResult = mergeConfigs(providerMCPServers, mergedServers);
|
|
180
|
+
mergedServers = providerMergeResult.servers;
|
|
181
|
+
if (!hasShownMigrationWarnings && process.env.DEBUG) {
|
|
182
|
+
console.log(formatInfo(`Loaded ${providerMCPServers.length} server(s) from provider MCP config`));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Merge ax-cli servers (highest priority)
|
|
186
|
+
if (axCliServers.length > 0 || mergedServers.length > 0) {
|
|
187
|
+
const mergeResult = mergeConfigs(axCliServers, mergedServers);
|
|
155
188
|
finalServers = mergeResult.servers;
|
|
156
189
|
// Show merge info only in debug mode or if there are conflicts
|
|
157
190
|
if (!hasShownMigrationWarnings && (mergeResult.conflicts.length > 0 || process.env.DEBUG)) {
|
|
@@ -168,7 +201,7 @@ export function loadMCPConfig() {
|
|
|
168
201
|
finalServers = axCliServers;
|
|
169
202
|
}
|
|
170
203
|
// Mark that we've shown warnings this session
|
|
171
|
-
if (axCliHadLegacy || automatosXResult.found) {
|
|
204
|
+
if (axCliHadLegacy || automatosXResult.found || providerMCPResult.found) {
|
|
172
205
|
hasShownMigrationWarnings = true;
|
|
173
206
|
}
|
|
174
207
|
return { servers: finalServers };
|
package/dist/mcp/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/mcp/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC5H,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/mcp/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC5H,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OA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,UAAkB;IAChD,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IACtD,MAAM,UAAU,GAAG,eAAe,CAAC,UAAU,CAAC;IAE9C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;QAC9B,OAAO,CAAC,oBAAoB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,MAAM,eAAe,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IACtD,OAAO,eAAe,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC;AAClD,CAAC;AAED,mBAAmB;AACnB,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export { MCPManagerV2, createServerName, createToolName, type ConnectionState, t
|
|
|
34
34
|
export type { ServerName, ToolName } from "./client-v2.js";
|
|
35
35
|
export { loadMCPConfig, addMCPServer, removeMCPServer, PREDEFINED_SERVERS, getTemplate, generateConfigFromTemplate, } from "./config.js";
|
|
36
36
|
export type { MCPConfig } from "./config.js";
|
|
37
|
+
export { loadProviderMCPConfig, getProviderMCPServers, providerMCPConfigExists, getClaudeCodeMCPConfigPath, getLegacyMCPConfigPath, } from "./provider-mcp-loader.js";
|
|
38
|
+
export type { ProviderMCPLoadResult, ClaudeCodeMCPConfig, LegacyProviderMCPConfig, } from "./provider-mcp-loader.js";
|
|
37
39
|
export { detectConfigFormat, detectMultipleConfigs, getDetectionSummary } from "./config-detector.js";
|
|
38
40
|
export { migrateConfig, batchMigrateConfigs, formatBatchMigrationResult } from "./config-migrator.js";
|
|
39
41
|
export { createTransport, type MCPTransport, type TransportType, type TransportConfig, type StdioFraming, } from "./transports.js";
|
|
@@ -42,7 +44,8 @@ export { CancellationManager, getCancellationManager, resetCancellationManager,
|
|
|
42
44
|
export { SubscriptionManager, getSubscriptionManager, resetSubscriptionManager, type ResourceSubscription, } from "./subscriptions.js";
|
|
43
45
|
export { ToolOutputValidator, getToolOutputValidator, resetToolOutputValidator, type SchemaValidationResult, type SchemaValidationStatus, } from "./schema-validator.js";
|
|
44
46
|
export { MCP_TIMEOUTS, MCP_LIMITS, MCP_ERROR_CODES, MCP_RECONNECTION, MCP_TRANSPORT_DEFAULTS, MCP_PATTERNS, } from "./constants.js";
|
|
45
|
-
export {
|
|
47
|
+
export { Ok, Err, toError } from "./type-safety.js";
|
|
48
|
+
export type { Result } from "./type-safety.js";
|
|
46
49
|
export { matchErrorPattern, getTransportHints, getEnvVarHints, ERROR_REMEDIATION, type Remediation } from "./error-remediation.js";
|
|
47
50
|
export { resolveMCPReferences, extractMCPReferences } from "./resources.js";
|
|
48
51
|
export { parseMCPIdentifier, promptToSlashCommand, parsePromptCommand, formatPromptResult, getPromptDescription, } from "./prompts.js";
|
package/dist/mcp/index.js
CHANGED
|
@@ -40,6 +40,8 @@ export { MCPManagerV2, createServerName, createToolName, } from "./client-v2.js"
|
|
|
40
40
|
// ============================================================================
|
|
41
41
|
// Config loading and management
|
|
42
42
|
export { loadMCPConfig, addMCPServer, removeMCPServer, PREDEFINED_SERVERS, getTemplate, generateConfigFromTemplate, } from "./config.js";
|
|
43
|
+
// Provider-specific MCP config loading (Claude Code format support)
|
|
44
|
+
export { loadProviderMCPConfig, getProviderMCPServers, providerMCPConfigExists, getClaudeCodeMCPConfigPath, getLegacyMCPConfigPath, } from "./provider-mcp-loader.js";
|
|
43
45
|
// Config detection and migration
|
|
44
46
|
export { detectConfigFormat, detectMultipleConfigs, getDetectionSummary } from "./config-detector.js";
|
|
45
47
|
export { migrateConfig, batchMigrateConfigs, formatBatchMigrationResult } from "./config-migrator.js";
|
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E,kEAAkE;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,+DAA+D;AAC/D,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,cAAc,GAIf,MAAM,gBAAgB,CAAC;AAGxB,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,gCAAgC;AAChC,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAGrB,iCAAiC;AACjC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACtG,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAEtG,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,OAAO,EACL,eAAe,GAKhB,MAAM,iBAAiB,CAAC;AAEzB,+EAA+E;AAC/E,0CAA0C;AAC1C,+EAA+E;AAE/E,oBAAoB;AACpB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AAEvB,uBAAuB;AACvB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,GAGrB,MAAM,mBAAmB,CAAC;AAE3B,yBAAyB;AACzB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,GAEzB,MAAM,oBAAoB,CAAC;AAE5B,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AE5B,wCAAwC;AACxC,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,eAAe,GAEhB,MAAM,mBAAmB,CAAC;AAE3B,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,GAOrB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-Specific MCP Configuration Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads MCP configurations from provider-specific directories following
|
|
5
|
+
* Claude Code best practices:
|
|
6
|
+
*
|
|
7
|
+
* Priority (highest to lowest):
|
|
8
|
+
* 1. .ax-glm/.mcp.json or .ax-grok/.mcp.json (Claude Code format - recommended)
|
|
9
|
+
* 2. .ax-glm/mcp-config.json or .ax-grok/mcp-config.json (legacy format)
|
|
10
|
+
*
|
|
11
|
+
* Claude Code Format (.mcp.json):
|
|
12
|
+
* ```json
|
|
13
|
+
* {
|
|
14
|
+
* "mcpServers": {
|
|
15
|
+
* "serverName": {
|
|
16
|
+
* "command": "...",
|
|
17
|
+
* "args": [...],
|
|
18
|
+
* "env": {...}
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* This ensures that when both ax-glm and ax-grok are installed,
|
|
25
|
+
* they maintain separate MCP configurations without conflicts.
|
|
26
|
+
*/
|
|
27
|
+
import type { MCPServerConfig } from '../schemas/settings-schemas.js';
|
|
28
|
+
/**
|
|
29
|
+
* Claude Code MCP format (.mcp.json)
|
|
30
|
+
* This is the recommended format, same as Claude Code
|
|
31
|
+
*/
|
|
32
|
+
export interface ClaudeCodeMCPConfig {
|
|
33
|
+
mcpServers?: Record<string, {
|
|
34
|
+
command: string;
|
|
35
|
+
args?: string[];
|
|
36
|
+
env?: Record<string, string>;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Legacy provider-specific MCP configuration format
|
|
42
|
+
* This is the format used in .ax-glm/mcp-config.json and .ax-grok/mcp-config.json
|
|
43
|
+
*/
|
|
44
|
+
export interface LegacyProviderMCPConfig {
|
|
45
|
+
mcp?: {
|
|
46
|
+
/** Whether MCP is enabled for this provider */
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
/** Command to start the MCP server */
|
|
49
|
+
serverCommand?: string;
|
|
50
|
+
/** Arguments for the MCP server command */
|
|
51
|
+
serverArgs?: string[];
|
|
52
|
+
/** Whether to auto-connect on startup */
|
|
53
|
+
autoConnect?: boolean;
|
|
54
|
+
/** Connection timeout in milliseconds */
|
|
55
|
+
timeout?: number;
|
|
56
|
+
/** Environment variables for the MCP server */
|
|
57
|
+
env?: Record<string, string>;
|
|
58
|
+
};
|
|
59
|
+
provider?: {
|
|
60
|
+
/** Provider name (e.g., 'glm', 'grok') */
|
|
61
|
+
name?: string;
|
|
62
|
+
/** Environment variable for API key */
|
|
63
|
+
apiKeyEnv?: string;
|
|
64
|
+
/** Default model */
|
|
65
|
+
defaultModel?: string;
|
|
66
|
+
};
|
|
67
|
+
integration?: {
|
|
68
|
+
/** Use AutomatosX memory system */
|
|
69
|
+
useMemory?: boolean;
|
|
70
|
+
/** Use agent context for enhanced prompts */
|
|
71
|
+
useAgentContext?: boolean;
|
|
72
|
+
/** Save responses to memory */
|
|
73
|
+
saveResponsesToMemory?: boolean;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Result of loading provider-specific MCP config
|
|
78
|
+
*/
|
|
79
|
+
export interface ProviderMCPLoadResult {
|
|
80
|
+
/** Whether config was found */
|
|
81
|
+
found: boolean;
|
|
82
|
+
/** Path to config file */
|
|
83
|
+
configPath?: string;
|
|
84
|
+
/** Format of the config file */
|
|
85
|
+
format?: 'claude-code' | 'legacy';
|
|
86
|
+
/** Converted MCPServerConfigs (if found and valid) */
|
|
87
|
+
serverConfigs: MCPServerConfig[];
|
|
88
|
+
/** Error message if loading failed */
|
|
89
|
+
error?: string;
|
|
90
|
+
/** Warnings during loading */
|
|
91
|
+
warnings: string[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the path to the Claude Code format MCP config file (.mcp.json)
|
|
95
|
+
*/
|
|
96
|
+
export declare function getClaudeCodeMCPConfigPath(projectRoot?: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* Get the path to the legacy MCP config file (mcp-config.json)
|
|
99
|
+
*/
|
|
100
|
+
export declare function getLegacyMCPConfigPath(projectRoot?: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* Check if provider-specific MCP config exists (either format)
|
|
103
|
+
*/
|
|
104
|
+
export declare function providerMCPConfigExists(projectRoot?: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Load provider-specific MCP configuration
|
|
107
|
+
*
|
|
108
|
+
* This function:
|
|
109
|
+
* 1. First tries to load Claude Code format (.mcp.json) - recommended
|
|
110
|
+
* 2. Falls back to legacy format (mcp-config.json)
|
|
111
|
+
* 3. Converts to MCPServerConfig[] format
|
|
112
|
+
* 4. Returns the configs or error information
|
|
113
|
+
*/
|
|
114
|
+
export declare function loadProviderMCPConfig(projectRoot?: string): ProviderMCPLoadResult;
|
|
115
|
+
/**
|
|
116
|
+
* Get provider MCP servers ready to be merged with other sources
|
|
117
|
+
*/
|
|
118
|
+
export declare function getProviderMCPServers(projectRoot?: string): MCPServerConfig[];
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-Specific MCP Configuration Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads MCP configurations from provider-specific directories following
|
|
5
|
+
* Claude Code best practices:
|
|
6
|
+
*
|
|
7
|
+
* Priority (highest to lowest):
|
|
8
|
+
* 1. .ax-glm/.mcp.json or .ax-grok/.mcp.json (Claude Code format - recommended)
|
|
9
|
+
* 2. .ax-glm/mcp-config.json or .ax-grok/mcp-config.json (legacy format)
|
|
10
|
+
*
|
|
11
|
+
* Claude Code Format (.mcp.json):
|
|
12
|
+
* ```json
|
|
13
|
+
* {
|
|
14
|
+
* "mcpServers": {
|
|
15
|
+
* "serverName": {
|
|
16
|
+
* "command": "...",
|
|
17
|
+
* "args": [...],
|
|
18
|
+
* "env": {...}
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* This ensures that when both ax-glm and ax-grok are installed,
|
|
25
|
+
* they maintain separate MCP configurations without conflicts.
|
|
26
|
+
*/
|
|
27
|
+
import fs from 'fs';
|
|
28
|
+
import path from 'path';
|
|
29
|
+
import { getActiveConfigPaths, getActiveProvider } from '../provider/config.js';
|
|
30
|
+
import { extractErrorMessage } from '../utils/error-handler.js';
|
|
31
|
+
/**
|
|
32
|
+
* Get the path to the Claude Code format MCP config file (.mcp.json)
|
|
33
|
+
*/
|
|
34
|
+
export function getClaudeCodeMCPConfigPath(projectRoot) {
|
|
35
|
+
const configPaths = getActiveConfigPaths();
|
|
36
|
+
const root = projectRoot || process.cwd();
|
|
37
|
+
return path.join(root, configPaths.DIR_NAME, '.mcp.json');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the path to the legacy MCP config file (mcp-config.json)
|
|
41
|
+
*/
|
|
42
|
+
export function getLegacyMCPConfigPath(projectRoot) {
|
|
43
|
+
const configPaths = getActiveConfigPaths();
|
|
44
|
+
const root = projectRoot || process.cwd();
|
|
45
|
+
return path.join(root, configPaths.DIR_NAME, 'mcp-config.json');
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Check if provider-specific MCP config exists (either format)
|
|
49
|
+
*/
|
|
50
|
+
export function providerMCPConfigExists(projectRoot) {
|
|
51
|
+
return fs.existsSync(getClaudeCodeMCPConfigPath(projectRoot)) ||
|
|
52
|
+
fs.existsSync(getLegacyMCPConfigPath(projectRoot));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Load provider-specific MCP configuration
|
|
56
|
+
*
|
|
57
|
+
* This function:
|
|
58
|
+
* 1. First tries to load Claude Code format (.mcp.json) - recommended
|
|
59
|
+
* 2. Falls back to legacy format (mcp-config.json)
|
|
60
|
+
* 3. Converts to MCPServerConfig[] format
|
|
61
|
+
* 4. Returns the configs or error information
|
|
62
|
+
*/
|
|
63
|
+
export function loadProviderMCPConfig(projectRoot) {
|
|
64
|
+
const warnings = [];
|
|
65
|
+
const claudeCodePath = getClaudeCodeMCPConfigPath(projectRoot);
|
|
66
|
+
const legacyPath = getLegacyMCPConfigPath(projectRoot);
|
|
67
|
+
// Try Claude Code format first (.mcp.json)
|
|
68
|
+
if (fs.existsSync(claudeCodePath)) {
|
|
69
|
+
try {
|
|
70
|
+
const raw = fs.readFileSync(claudeCodePath, 'utf-8');
|
|
71
|
+
const config = JSON.parse(raw);
|
|
72
|
+
const serverConfigs = convertClaudeCodeFormat(config);
|
|
73
|
+
return {
|
|
74
|
+
found: true,
|
|
75
|
+
configPath: claudeCodePath,
|
|
76
|
+
format: 'claude-code',
|
|
77
|
+
serverConfigs,
|
|
78
|
+
warnings,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
return {
|
|
83
|
+
found: true,
|
|
84
|
+
configPath: claudeCodePath,
|
|
85
|
+
format: 'claude-code',
|
|
86
|
+
serverConfigs: [],
|
|
87
|
+
error: `Failed to parse .mcp.json: ${extractErrorMessage(error)}`,
|
|
88
|
+
warnings,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Fall back to legacy format (mcp-config.json)
|
|
93
|
+
if (fs.existsSync(legacyPath)) {
|
|
94
|
+
warnings.push(`Using legacy mcp-config.json format. Consider migrating to .mcp.json (Claude Code format)`);
|
|
95
|
+
try {
|
|
96
|
+
const raw = fs.readFileSync(legacyPath, 'utf-8');
|
|
97
|
+
const config = JSON.parse(raw);
|
|
98
|
+
const serverConfigs = convertLegacyFormat(config);
|
|
99
|
+
return {
|
|
100
|
+
found: true,
|
|
101
|
+
configPath: legacyPath,
|
|
102
|
+
format: 'legacy',
|
|
103
|
+
serverConfigs,
|
|
104
|
+
warnings,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
return {
|
|
109
|
+
found: true,
|
|
110
|
+
configPath: legacyPath,
|
|
111
|
+
format: 'legacy',
|
|
112
|
+
serverConfigs: [],
|
|
113
|
+
error: `Failed to parse mcp-config.json: ${extractErrorMessage(error)}`,
|
|
114
|
+
warnings,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// No config found
|
|
119
|
+
return {
|
|
120
|
+
found: false,
|
|
121
|
+
serverConfigs: [],
|
|
122
|
+
warnings,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Convert Claude Code format (.mcp.json) to MCPServerConfig[]
|
|
127
|
+
*/
|
|
128
|
+
function convertClaudeCodeFormat(config) {
|
|
129
|
+
if (!config.mcpServers || typeof config.mcpServers !== 'object') {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
const servers = [];
|
|
133
|
+
for (const [name, serverDef] of Object.entries(config.mcpServers)) {
|
|
134
|
+
if (serverDef.disabled) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
// Build environment variables
|
|
138
|
+
const env = {
|
|
139
|
+
AUTOMATOSX_PROJECT_DIR: process.cwd(),
|
|
140
|
+
...(serverDef.env || {}),
|
|
141
|
+
};
|
|
142
|
+
const transport = {
|
|
143
|
+
type: 'stdio',
|
|
144
|
+
command: serverDef.command,
|
|
145
|
+
args: serverDef.args || [],
|
|
146
|
+
env,
|
|
147
|
+
};
|
|
148
|
+
servers.push({
|
|
149
|
+
name,
|
|
150
|
+
enabled: true,
|
|
151
|
+
transport,
|
|
152
|
+
// Default timeout for provider MCP servers
|
|
153
|
+
initTimeout: 30000,
|
|
154
|
+
// Suppress verbose output by default
|
|
155
|
+
quiet: true,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return servers;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Convert legacy format (mcp-config.json) to MCPServerConfig[]
|
|
162
|
+
*/
|
|
163
|
+
function convertLegacyFormat(config) {
|
|
164
|
+
const mcp = config.mcp;
|
|
165
|
+
if (!mcp?.serverCommand) {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
// Check if MCP is disabled
|
|
169
|
+
if (mcp.enabled === false) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
const provider = getActiveProvider();
|
|
173
|
+
// Build the server name based on provider
|
|
174
|
+
// e.g., "automatosx-glm" or "automatosx-grok"
|
|
175
|
+
const serverName = `automatosx-${provider.name}`;
|
|
176
|
+
// Build environment variables
|
|
177
|
+
const env = {
|
|
178
|
+
AUTOMATOSX_PROJECT_DIR: process.cwd(),
|
|
179
|
+
...(mcp.env || {}),
|
|
180
|
+
};
|
|
181
|
+
// Add provider-specific env vars from the config
|
|
182
|
+
if (config.provider?.apiKeyEnv) {
|
|
183
|
+
env.AUTOMATOSX_API_KEY_ENV = config.provider.apiKeyEnv;
|
|
184
|
+
}
|
|
185
|
+
// Add integration settings as env vars
|
|
186
|
+
if (config.integration) {
|
|
187
|
+
if (config.integration.useMemory !== undefined) {
|
|
188
|
+
env.AUTOMATOSX_USE_MEMORY = String(config.integration.useMemory);
|
|
189
|
+
}
|
|
190
|
+
if (config.integration.useAgentContext !== undefined) {
|
|
191
|
+
env.AUTOMATOSX_USE_AGENT_CONTEXT = String(config.integration.useAgentContext);
|
|
192
|
+
}
|
|
193
|
+
if (config.integration.saveResponsesToMemory !== undefined) {
|
|
194
|
+
env.AUTOMATOSX_SAVE_RESPONSES = String(config.integration.saveResponsesToMemory);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const transport = {
|
|
198
|
+
type: 'stdio',
|
|
199
|
+
command: mcp.serverCommand,
|
|
200
|
+
args: mcp.serverArgs || [],
|
|
201
|
+
env,
|
|
202
|
+
};
|
|
203
|
+
return [{
|
|
204
|
+
name: serverName,
|
|
205
|
+
enabled: true,
|
|
206
|
+
transport,
|
|
207
|
+
initTimeout: mcp.timeout || 30000,
|
|
208
|
+
// Suppress verbose output by default
|
|
209
|
+
quiet: true,
|
|
210
|
+
}];
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get provider MCP servers ready to be merged with other sources
|
|
214
|
+
*/
|
|
215
|
+
export function getProviderMCPServers(projectRoot) {
|
|
216
|
+
const result = loadProviderMCPConfig(projectRoot);
|
|
217
|
+
return result.serverConfigs;
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=provider-mcp-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-mcp-loader.js","sourceRoot":"","sources":["../../src/mcp/provider-mcp-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAsEhE;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAAoB;IAC7D,MAAM,WAAW,GAAG,oBAAoB,EAAE,CAAC;IAC3C,MAAM,IAAI,GAAG,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC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CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defai.digital/ax-cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"sdkVersion": "1.4.0",
|
|
5
5
|
"description": "Enterprise-Class AI Command Line Interface - Primary support for GLM (General Language Model) with multi-provider AI orchestration powered by AutomatosX.",
|
|
6
6
|
"type": "module",
|