cdpm-mcp 0.1.3 → 0.1.4
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/CHANGELOG.md +5 -0
- package/README.ko.md +1 -0
- package/README.md +1 -0
- package/dist/chrome/launcher.js +16 -18
- package/dist/chrome/proxy.js +13 -25
- package/dist/orphan.js +49 -0
- package/dist/tools/register.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
버전 번호는 `package.json`에서 관리해요. 확인: `cdpm --version` (직접 받았으면 `node dist/cli.js --version`).
|
|
4
4
|
업데이트 방법은 README의 "업데이트" 항목을 보세요.
|
|
5
5
|
|
|
6
|
+
## 0.1.4 (2026-10-12)
|
|
7
|
+
|
|
8
|
+
- VS Code 등을 닫으면 슬롯 Chrome이 같이 꺼지던 문제를 고쳤어요. VS Code는 닫힐 때 자기가 띄운 프로세스를 자식의 자식까지 줄기째 강제 종료하는데, 슬롯 Chrome이 CDPM의 자식으로 남아 있었어요. 이제 중간 다리 프로세스로 띄워 부모 없는 프로세스로 만들어서, CDPM·Claude Code·VS Code가 꺼져도 슬롯은 살아 있어요. 프록시 중계 프로그램도 같아요.
|
|
9
|
+
- `browser_launch`: `url`은 켜는 모든 슬롯에 같은 주소를 연다는 점과, 슬롯마다 다르거나 일부만 열 때는 `urls`(열지 않을 슬롯은 "")를 쓰라는 안내를 분명히 했어요.
|
|
10
|
+
|
|
6
11
|
## 0.1.3 (2026-10-11)
|
|
7
12
|
|
|
8
13
|
- macOS Dock 아이콘: 켜면서 시작 주소를 바로 열면 빈 탭이 없어서 디자인이 다른 예비 아이콘이 들어가던 문제를 고쳤어요. 빈 탭이 없으면 열려 있는 일반 페이지 탭에서(페이지와 분리된 실행 공간) 그리고, 그래도 못 그렸으면 다음에 붙을 때 다시 그려 바꿔요.
|
package/README.ko.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
- **순수 CDP**: Playwright, Puppeteer, 우회 패치를 쓰지 않아요. 디버깅 포트만 연 일반 Chrome에 진짜 입력 이벤트를 보내요.
|
|
14
14
|
- **번호 슬롯**: 슬롯 N은 CDP 포트 `14049 + N`을 써요 (1번 = 14050 … 30번 = 14079). 흔히 쓰이는 9222와 부딪히지 않도록 고른 구간이고, 이 구간을 다른 프로그램이 쓰면 환경변수 `CDPM_PORT_BASE`로 시작 번호를 옮길 수 있어요. 슬롯마다 프로필 폴더가 따로 있어서 로그인이 슬롯별로 유지돼요. 범위 밖 포트는 다루지 않아요.
|
|
15
15
|
- **켜 달라고 할 때만 켜요**: 꺼진 슬롯은 다른 도구가 절대 켜지 않아요. 번호 없이 "켜줘"라고 하면 비어 있는 가장 작은 번호로 켜요.
|
|
16
|
+
- **슬롯은 따로 살아 있어요**: CDPM, Claude Code, VS Code를 닫아도(줄기째 강제 종료돼도) 슬롯 Chrome은 꺼지지 않아요. 슬롯을 끄는 건 `browser_close`·`cdpm close`나 그 Chrome 창을 직접 닫을 때뿐이에요.
|
|
16
17
|
- **슬롯마다 작업표시줄 버튼**: 슬롯 색 브라우저 창 모양에 번호가 들어간 아이콘으로 버튼이 따로 떠요. 작업표시줄이 아이콘을 줄여 그리는 방식을 미리 보정해서 24px에서도 또렷해요 (Windows 글꼴로 그려서 저장소에 글꼴 파일이 없어요). 창 제목도 "3번"으로 보여요 (Chrome 창 이름 기능이라 페이지는 알 수 없어요).
|
|
17
18
|
- **여러 에이전트용 설계**: 모든 도구에 `slot`을 명시해요. 탭마다 누가 열었고 누가 마지막으로 건드렸는지 기록하고, 남이 최근에 쓴 탭을 조작하면 막지 않고 알려줘요. 같은 탭에 동시에 온 명령은 줄 세워 하나씩 실행해요.
|
|
18
19
|
- **에이전트끼리 대화**: `slot_send` / `slot_inbox`. 안 읽은 메시지는 모든 도구 결과 맨 위에도 붙어요.
|
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ An MCP server that runs **Chrome slots 1–30** over the Chrome DevTools Protoco
|
|
|
13
13
|
- **Pure CDP.** No Playwright, no Puppeteer, no stealth patches. A normal Chrome with a debugging port, driven with real input events.
|
|
14
14
|
- **Numbered slots.** Slot *N* uses CDP port `14049 + N` (slot 1 = 14050 … slot 30 = 14079) and its own profile folder. The range avoids the common default 9222; set `CDPM_PORT_BASE` to move it if something else uses those ports. Ports outside that range are not managed.
|
|
15
15
|
- **Starts only when asked.** No tool ever starts a closed slot except `browser_launch`. Without a number, the lowest free slot is used.
|
|
16
|
+
- **Slots outlive their caller.** Closing CDPM, Claude Code or VS Code (even when it kills its whole process tree) does not close slot Chrome. Slots end only with `browser_close` / `cdpm close` or when you close that Chrome yourself.
|
|
16
17
|
- **One taskbar button per slot**, with a browser-window icon in the slot color and the slot number, pre-corrected so the taskbar shows it pixel-sharp (drawn with the system font via GDI+, so no font files ship in the repo). The window title shows "3번" via Chrome's own window-name feature (pages can't see it).
|
|
17
18
|
- **Built for many agents.** Every tool takes `slot` explicitly, records who opened each tab and who touched it last, warns (without blocking) when you act on a tab someone else just used, and serializes concurrent commands on the same tab.
|
|
18
19
|
- **Agents can talk** with `slot_send` / `slot_inbox`; unread messages are also delivered at the top of every result.
|
package/dist/chrome/launcher.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
1
|
import fs from 'node:fs';
|
|
3
2
|
import { probe } from '../cdp/targets.js';
|
|
4
3
|
import { CdpmError } from '../errors.js';
|
|
4
|
+
import { spawnOrphan } from '../orphan.js';
|
|
5
5
|
import { paths, readConfig } from '../paths.js';
|
|
6
6
|
import { portOf } from '../slots.js';
|
|
7
|
-
import { sleep } from '../util.js';
|
|
7
|
+
import { pidAlive, sleep } from '../util.js';
|
|
8
8
|
import { findChrome } from './finder.js';
|
|
9
9
|
import { proxyArgs } from './proxy.js';
|
|
10
10
|
const READY_TIMEOUT_MS = 30_000;
|
|
@@ -19,30 +19,28 @@ export function chromeArgs(slot, opts = {}) {
|
|
|
19
19
|
...(readConfig().extraArgs ?? []),
|
|
20
20
|
];
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* 슬롯 Chrome을 띄우고 CDP가 응답할 때까지 기다린다. CDPM·Claude Code·VS Code가 끝나도(줄기째 강제 종료돼도)
|
|
24
|
+
* Chrome은 살아 있도록 부모 없는 프로세스로 띄운다 (orphan.ts).
|
|
25
|
+
*/
|
|
23
26
|
export async function launchChrome(slot, opts = {}) {
|
|
24
27
|
const chrome = findChrome();
|
|
25
28
|
fs.mkdirSync(paths.profile(slot), { recursive: true });
|
|
26
29
|
const extra = opts.proxy ? await proxyArgs(slot, opts.proxy) : [];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
child.on('error', (e) => (spawnError = e));
|
|
35
|
-
child.on('exit', (code) => (exitedCode = code));
|
|
36
|
-
child.unref();
|
|
30
|
+
let pid;
|
|
31
|
+
try {
|
|
32
|
+
({ pid } = await spawnOrphan(chrome, [...chromeArgs(slot, opts), ...extra, opts.url || 'about:blank'], { hide: false }));
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
throw new CdpmError(`Chrome 실행 실패: ${e.message}`);
|
|
36
|
+
}
|
|
37
37
|
const deadline = Date.now() + READY_TIMEOUT_MS;
|
|
38
38
|
while (Date.now() < deadline) {
|
|
39
|
-
if (spawnError)
|
|
40
|
-
throw new CdpmError(`Chrome 실행 실패: ${spawnError.message}`);
|
|
41
39
|
const p = await probe(slot, 2000);
|
|
42
40
|
if (p.state === 'chrome')
|
|
43
|
-
return { pid
|
|
44
|
-
if (
|
|
45
|
-
throw new CdpmError(`${slot}번 Chrome이 켜지자마자
|
|
41
|
+
return { pid, version: p.version };
|
|
42
|
+
if (!pidAlive(pid)) {
|
|
43
|
+
throw new CdpmError(`${slot}번 Chrome이 켜지자마자 종료됐어요. ` +
|
|
46
44
|
`같은 프로필(${paths.profile(slot)})을 쓰는 Chrome이 디버깅 포트 없이 이미 떠 있으면, 새 Chrome은 그쪽에 창만 넘기고 끝나요. 그 창을 닫고 다시 켜 주세요.`);
|
|
47
45
|
}
|
|
48
46
|
await sleep(100);
|
package/dist/chrome/proxy.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// 사용자가 프록시를 써 달라고 할 때만 슬롯 Chrome에 프록시를 붙인다.
|
|
2
2
|
// 아이디·비밀번호가 없으면 --proxy-server로 바로 넘기고, 있으면(Chrome은 플래그로 인증을 받지 못함)
|
|
3
3
|
// 인증을 대신 붙여 주는 중계 프로그램(proxy-forwarder.js)을 이 슬롯 전용으로 띄워 Chrome이 그쪽을 보게 한다.
|
|
4
|
-
import { spawn } from 'node:child_process';
|
|
5
4
|
import { fileURLToPath } from 'node:url';
|
|
6
5
|
import { CdpmError } from '../errors.js';
|
|
6
|
+
import { spawnOrphan } from '../orphan.js';
|
|
7
7
|
import { portOf } from '../slots.js';
|
|
8
8
|
const SCHEMES = { http: 'http', https: 'https', socks: 'socks5', socks5: 'socks5', socks5h: 'socks5', socks4: 'socks4', socks4a: 'socks4' };
|
|
9
9
|
/**
|
|
@@ -81,29 +81,17 @@ export async function proxyArgs(slot, p) {
|
|
|
81
81
|
}
|
|
82
82
|
async function startForwarder(slot, p) {
|
|
83
83
|
const script = fileURLToPath(new URL('../proxy-forwarder.js', import.meta.url));
|
|
84
|
-
// 비밀번호가 프로세스 목록(명령줄)에 보이지 않도록 환경변수로
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const port = await new Promise((resolve, reject) => {
|
|
92
|
-
let buf = '';
|
|
93
|
-
const timer = setTimeout(() => reject(new CdpmError('프록시 중계 프로그램이 5초 안에 시작하지 않았어요.')), 5000);
|
|
94
|
-
child.stdout.on('data', (d) => {
|
|
95
|
-
buf += String(d);
|
|
96
|
-
const m = /LISTEN (\d+)/.exec(buf);
|
|
97
|
-
if (m) {
|
|
98
|
-
clearTimeout(timer);
|
|
99
|
-
resolve(Number(m[1]));
|
|
100
|
-
}
|
|
84
|
+
// 비밀번호가 프로세스 목록(명령줄)에 보이지 않도록 환경변수로 넘긴다.
|
|
85
|
+
// Chrome처럼 부모 없는 프로세스로 띄워서 VS Code 등이 닫히며 줄기째 종료해도 살아 있게 한다 (그 Chrome이 꺼지면 스스로 끝남).
|
|
86
|
+
try {
|
|
87
|
+
const { line } = await spawnOrphan(process.execPath, [script], {
|
|
88
|
+
hide: true,
|
|
89
|
+
waitLine: 'LISTEN [0-9]+',
|
|
90
|
+
env: { ...process.env, CDPM_PROXY_UPSTREAM: JSON.stringify(p), CDPM_PROXY_CDP_PORT: String(portOf(slot)) },
|
|
101
91
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
child.unref();
|
|
108
|
-
return port;
|
|
92
|
+
return Number(/LISTEN (\d+)/.exec(line ?? '')?.[1]);
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
throw new CdpmError(`프록시 중계 프로그램을 띄우지 못했어요: ${e.message}`);
|
|
96
|
+
}
|
|
109
97
|
}
|
package/dist/orphan.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// 슬롯 Chrome(과 프록시 중계 프로그램)을 CDPM·Claude Code·VS Code와 끊어서 띄운다.
|
|
2
|
+
// VS Code 등은 닫힐 때 자기가 띄운 프로세스를 "자식의 자식까지" 줄기째 강제 종료한다(taskkill /T 등).
|
|
3
|
+
// detached로 띄워도 Windows는 부모-자식 관계를 기억하므로 Chrome까지 같이 꺼진다.
|
|
4
|
+
// 그래서 중간 다리 프로세스가 대상을 띄우고 바로 끝난다 → 대상은 부모가 없는 프로세스가 되어 줄기 종료가 닿지 않는다.
|
|
5
|
+
// (macOS·Linux도 같음: 다리가 끝나면 대상은 launchd/init 밑으로 옮겨진다)
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import { CdpmError } from './errors.js';
|
|
8
|
+
const BRIDGE = `
|
|
9
|
+
const { spawn } = require('child_process');
|
|
10
|
+
const o = JSON.parse(process.env.CDPM_ORPHAN);
|
|
11
|
+
delete process.env.CDPM_ORPHAN;
|
|
12
|
+
const say = (s) => process.stdout.write(s + '\\n');
|
|
13
|
+
const c = spawn(o.cmd, o.args, { detached: true, stdio: ['ignore', o.waitLine ? 'pipe' : 'ignore', 'ignore'], windowsHide: !!o.hide });
|
|
14
|
+
c.on('error', (e) => { say('ERR ' + e.message); process.exit(1); });
|
|
15
|
+
if (!o.waitLine) { say('PID ' + c.pid); c.unref(); process.exit(0); }
|
|
16
|
+
else {
|
|
17
|
+
let buf = '';
|
|
18
|
+
c.stdout.on('data', (d) => {
|
|
19
|
+
buf += d;
|
|
20
|
+
const m = new RegExp(o.waitLine).exec(buf);
|
|
21
|
+
if (!m) return;
|
|
22
|
+
say('PID ' + c.pid); say('LINE ' + m[0]);
|
|
23
|
+
c.stdout.destroy(); c.unref(); process.exit(0);
|
|
24
|
+
});
|
|
25
|
+
c.on('exit', (code) => { say('EXIT ' + code); process.exit(1); });
|
|
26
|
+
setTimeout(() => { say('TIMEOUT'); process.exit(1); }, o.timeoutMs || 5000);
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
/** 대상을 부모 없는 프로세스로 띄우고 PID(와 기다린 줄)를 돌려준다. */
|
|
30
|
+
export function spawnOrphan(cmd, args, opts = {}) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const bridge = spawn(process.execPath, ['-e', BRIDGE], {
|
|
33
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
34
|
+
windowsHide: true,
|
|
35
|
+
env: { ...(opts.env ?? process.env), CDPM_ORPHAN: JSON.stringify({ cmd, args, hide: opts.hide, waitLine: opts.waitLine, timeoutMs: opts.timeoutMs }) },
|
|
36
|
+
});
|
|
37
|
+
let out = '';
|
|
38
|
+
bridge.stdout.on('data', (d) => (out += String(d)));
|
|
39
|
+
bridge.on('error', (e) => reject(new CdpmError(`실행하지 못했어요: ${e.message}`)));
|
|
40
|
+
bridge.on('exit', () => {
|
|
41
|
+
const pid = Number(/PID (\d+)/.exec(out)?.[1]);
|
|
42
|
+
const line = /LINE (.*)/.exec(out)?.[1];
|
|
43
|
+
if (pid && (!opts.waitLine || line))
|
|
44
|
+
return resolve({ pid, line });
|
|
45
|
+
const why = /ERR (.*)/.exec(out)?.[1] ?? (/EXIT (.*)/.exec(out) ? `바로 끝났어요 (종료 코드 ${/EXIT (.*)/.exec(out)[1]})` : /TIMEOUT/.test(out) ? '준비 신호가 오지 않았어요' : out.trim());
|
|
46
|
+
reject(new CdpmError(`실행하지 못했어요: ${why}`));
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
package/dist/tools/register.js
CHANGED
|
@@ -303,8 +303,8 @@ export function registerTools(server) {
|
|
|
303
303
|
slot: slotArg.optional().describe('켤 슬롯 하나 (1~30). 사용자가 번호를 말하지 않았으면 생략 → 비어 있는 가장 작은 번호'),
|
|
304
304
|
slots: z.array(slotArg).optional().describe('여러 슬롯을 한 번에 켤 때 번호 목록 (예: [1,2,3]). 작은 번호부터 차례로 켠다'),
|
|
305
305
|
count: z.number().int().min(1).max(MAX_SLOT).optional().describe('번호 없이 "3개 켜줘"처럼 개수만 말했을 때: 비어 있는 슬롯을 작은 번호부터 그 개수만큼 켠다'),
|
|
306
|
-
url: z.string().optional().describe('
|
|
307
|
-
urls: z.array(z.string()).optional().describe('슬롯마다 다른 시작 주소. slots에 준 순서(count면 켜지는 번호 순서)대로
|
|
306
|
+
url: z.string().optional().describe('켜는 모든 슬롯에 같은 주소를 연다 (예: "https://mail.google.com"). 슬롯마다 주소가 다르거나 일부 슬롯만 열 때는 url을 쓰지 말고 urls를 쓴다. 시작 페이지를 알면 넣어서, 서브에이전트가 따로 이동할 필요가 없게 한다'),
|
|
307
|
+
urls: z.array(z.string()).optional().describe('슬롯마다 다른 시작 주소. slots에 준 순서(count면 켜지는 번호 순서)대로 짝지어진다. 열지 않을 슬롯은 ""(빈 탭). 예: slots [1,2], urls ["https://www.wehago.com", "https://test.igel.kr"] → 1번은 위하고, 2번은 test.igel.kr'),
|
|
308
308
|
agent: agentArg,
|
|
309
309
|
headless: z.boolean().optional().describe('false = 창 모드(브라우저 보임), true = 헤드리스(안 보임). 사용자가 고른 값만 넣는다. 처음 켤 때만 적용'),
|
|
310
310
|
proxy: z.string().optional().describe('사용자가 프록시를 써 달라고 했을 때만 넣는다 (아니면 절대 넣지 않는다). 사용자가 준 그대로: "1.2.3.4:8080", "http://아이디:비번@주소:포트", "socks5://주소:포트", "주소:포트:아이디:비번" 등. 켜는 모든 슬롯에 적용, 처음 켤 때만'),
|
package/package.json
CHANGED