Add embedded MCP server with shared API facade

This commit is contained in:
影烨
2026-03-23 23:53:54 +08:00
parent 72813c24d9
commit fe130caf4b
16 changed files with 2311 additions and 377 deletions
+41
View File
@@ -0,0 +1,41 @@
const { spawn } = require('child_process')
const path = require('path')
const electronBinary = require('electron')
const rootDir = path.resolve(__dirname, '..')
const entry = path.join(rootDir, 'dist-electron', 'mcp.js')
const child = spawn(electronBinary, [entry], {
cwd: rootDir,
env: {
...process.env,
ELECTRON_RUN_AS_NODE: '1'
},
stdio: ['pipe', 'pipe', 'pipe'],
windowsHide: true
})
if (process.stdin) {
process.stdin.pipe(child.stdin)
}
if (child.stdout) {
child.stdout.pipe(process.stdout)
}
if (child.stderr) {
child.stderr.pipe(process.stderr)
}
child.on('exit', (code, signal) => {
if (signal) {
process.kill(process.pid, signal)
return
}
process.exit(code ?? 0)
})
child.on('error', (error) => {
process.stderr.write(`[CipherTalk MCP Runner] failed: ${String(error)}\n`)
process.exit(1)
})