Skip to content

Commit 78c7ce9

Browse files
committed
chore: add detailed daemon status
1 parent bdbbc84 commit 78c7ce9

4 files changed

Lines changed: 46 additions & 11 deletions

File tree

src/bin/chrome-devtools.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ y.command(
7272
y.command('status', 'Checks if chrome-devtools-mcp is running', async () => {
7373
if (isDaemonRunning()) {
7474
console.log('chrome-devtools-mcp daemon is running.');
75+
const response = await sendCommand({
76+
method: 'status',
77+
});
78+
if (response.success) {
79+
const data = JSON.parse(response.result) as {
80+
pid: number | null;
81+
socketPath: string;
82+
startDate: string;
83+
version: string;
84+
};
85+
console.log(
86+
`pid=${data.pid} socket=${data.socketPath} start-date=${data.startDate} version=${data.version}`,
87+
);
88+
} else {
89+
console.error('Error:', response.error);
90+
process.exit(1);
91+
}
7592
} else {
7693
console.log('chrome-devtools-mcp daemon is not running.');
7794
}

src/daemon/daemon.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ logger(`Writing ${process.pid.toString()} to ${pidFilePath}`);
4242

4343
const socketPath = getSocketPath();
4444

45+
const startDate = new Date();
46+
4547
let mcpClient: Client | null = null;
4648
let mcpTransport: StdioClientTransport | null = null;
4749
let server: Server | null = null;
@@ -107,7 +109,18 @@ async function handleRequest(msg: DaemonMessage) {
107109
success: true,
108110
message: 'stopping',
109111
};
110-
} else {
112+
} else if (msg.method === 'status') {
113+
return {
114+
success: true,
115+
result: JSON.stringify({
116+
pid: process.pid,
117+
socketPath,
118+
startDate: startDate.toISOString(),
119+
version: VERSION,
120+
}),
121+
};
122+
}
123+
{
111124
return {
112125
success: false,
113126
error: `Unknown method: ${JSON.stringify(msg, null, 2)}`,

src/daemon/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export type DaemonMessage =
88
| {
99
method: 'stop';
1010
}
11+
| {
12+
method: 'status';
13+
}
1114
| {
1215
method: 'invoke_tool';
1316
tool: string;

tests/e2e/chrome-devtools.test.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ describe('chrome-devtools', () => {
2222
);
2323
}
2424

25+
function assertDaemonIsRunning() {
26+
const result = spawnSync('node', [CLI_PATH, 'status']);
27+
assert.ok(
28+
result.stdout
29+
.toString()
30+
.startsWith('chrome-devtools-mcp daemon is running.\n'),
31+
'chrome-devtools-mcp daemon is not running',
32+
);
33+
}
34+
2535
beforeEach(() => {
2636
spawnSync('node', [CLI_PATH, 'stop']);
2737
assertDaemonIsNotRunning();
@@ -42,11 +52,7 @@ describe('chrome-devtools', () => {
4252
`start command failed: ${startResult.stderr.toString()}`,
4353
);
4454

45-
const result = spawnSync('node', [CLI_PATH, 'status']);
46-
assert.strictEqual(
47-
result.stdout.toString(),
48-
'chrome-devtools-mcp daemon is running.\n',
49-
);
55+
assertDaemonIsRunning();
5056
});
5157

5258
it('can start and stop the daemon', () => {
@@ -101,11 +107,7 @@ describe('chrome-devtools', () => {
101107
);
102108

103109
// Daemon should now be running.
104-
const result = spawnSync('node', [CLI_PATH, 'status']);
105-
assert.strictEqual(
106-
result.stdout.toString(),
107-
'chrome-devtools-mcp daemon is running.\n',
108-
);
110+
assertDaemonIsNotRunning();
109111
});
110112

111113
it('forwards disclaimers to stderr on start', () => {

0 commit comments

Comments
 (0)