@bigbrain-work/mcp-connect 1.2.0 → 1.2.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.
- package/package.json +1 -1
- package/src/configurators.js +54 -1
- package/src/constants.js +1 -1
package/package.json
CHANGED
package/src/configurators.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
1
2
|
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises'
|
|
2
3
|
import path from 'node:path'
|
|
3
4
|
import { spawnSync } from 'node:child_process'
|
|
@@ -42,13 +43,65 @@ function commandText(command, args) {
|
|
|
42
43
|
)).join(' ')
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
export function commandInvocation(command, args, {
|
|
47
|
+
platform = process.platform,
|
|
48
|
+
env = process.env,
|
|
49
|
+
fileExists = existsSync,
|
|
50
|
+
nodeExecutable = process.execPath,
|
|
51
|
+
} = {}) {
|
|
52
|
+
if (platform !== 'win32') {
|
|
53
|
+
return { command, args }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const searchPath = env.PATH || env.Path || ''
|
|
57
|
+
const npmDirectory = searchPath
|
|
58
|
+
.split(';')
|
|
59
|
+
.map((entry) => entry.trim().replace(/^"|"$/gu, ''))
|
|
60
|
+
.filter(Boolean)
|
|
61
|
+
.find((entry) => fileExists(path.join(entry, `${command}.cmd`)))
|
|
62
|
+
|
|
63
|
+
if (!npmDirectory) {
|
|
64
|
+
return { command, args }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (command === 'claude') {
|
|
68
|
+
const executable = path.join(
|
|
69
|
+
npmDirectory,
|
|
70
|
+
'node_modules',
|
|
71
|
+
'@anthropic-ai',
|
|
72
|
+
'claude-code',
|
|
73
|
+
'bin',
|
|
74
|
+
'claude.exe',
|
|
75
|
+
)
|
|
76
|
+
if (fileExists(executable)) {
|
|
77
|
+
return { command: executable, args }
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (command === 'codex') {
|
|
81
|
+
const script = path.join(
|
|
82
|
+
npmDirectory,
|
|
83
|
+
'node_modules',
|
|
84
|
+
'@openai',
|
|
85
|
+
'codex',
|
|
86
|
+
'bin',
|
|
87
|
+
'codex.js',
|
|
88
|
+
)
|
|
89
|
+
if (fileExists(script)) {
|
|
90
|
+
return { command: nodeExecutable, args: [script, ...args] }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return { command, args }
|
|
95
|
+
}
|
|
96
|
+
|
|
45
97
|
function execute(command, args, { dryRun = false } = {}) {
|
|
46
98
|
if (dryRun) {
|
|
47
99
|
console.log(`[dry-run] ${commandText(command, args)}`)
|
|
48
100
|
return
|
|
49
101
|
}
|
|
50
102
|
|
|
51
|
-
const
|
|
103
|
+
const invocation = commandInvocation(command, args)
|
|
104
|
+
const result = spawnSync(invocation.command, invocation.args, {
|
|
52
105
|
encoding: 'utf8',
|
|
53
106
|
windowsHide: true,
|
|
54
107
|
shell: false,
|
package/src/constants.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const PACKAGE_NAME = '@bigbrain-work/mcp-connect'
|
|
2
|
-
export const PACKAGE_VERSION = '1.2.
|
|
2
|
+
export const PACKAGE_VERSION = '1.2.1'
|
|
3
3
|
export const SERVER_NAME = 'shiliu_mcp'
|
|
4
4
|
export const MCP_URL = 'https://api.bigbrain.work/shiliu/mcp'
|
|
5
5
|
export const API_KEY_ENV = 'SHILIU_AI_API_KEY'
|