Skip to content

Commit 1431205

Browse files
napoleondclaude
andcommitted
feat: add phone mark-read CLI command
Adds `npx atxp phone mark-read <id> [id...]` to mark SMS messages as read via the new phone_mark_read MCP tool. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fc75f8b commit 1431205

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

packages/atxp/src/commands/phone.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function showPhoneHelp(): void {
2828
console.log(chalk.bold(' SMS:'));
2929
console.log(' ' + chalk.cyan('npx atxp phone sms') + ' ' + chalk.yellow('[--unread-only] [--direction <dir>]') + ' ' + 'Check SMS inbox');
3030
console.log(' ' + chalk.cyan('npx atxp phone read-sms') + ' ' + chalk.yellow('<messageId>') + ' ' + 'Read a specific SMS');
31+
console.log(' ' + chalk.cyan('npx atxp phone mark-read') + ' ' + chalk.yellow('<id> [id...]') + ' ' + 'Mark messages as read');
3132
console.log(' ' + chalk.cyan('npx atxp phone send-sms') + ' ' + chalk.yellow('<options>') + ' ' + 'Send an SMS ($0.05)');
3233
console.log(' ' + chalk.cyan('npx atxp phone get-attachment') + ' ' + chalk.yellow('<options>') + ' ' + 'Download an MMS attachment');
3334
console.log();
@@ -70,6 +71,8 @@ function showPhoneHelp(): void {
7071
console.log(' npx atxp phone sms --direction incoming');
7172
console.log(' npx atxp phone sms --unread-only --direction incoming');
7273
console.log(' npx atxp phone read-sms sms_abc123');
74+
console.log(' npx atxp phone mark-read sms_abc123');
75+
console.log(' npx atxp phone mark-read sms_abc123 sms_def456');
7376
console.log(' npx atxp phone send-sms --to "+14155551234" --body "Hello!"');
7477
console.log(' npx atxp phone send-sms --to "+14155551234" --body "Check this" --media "https://example.com/image.jpg"');
7578
console.log(' npx atxp phone call --to "+14155551234" --instruction "Ask about their business hours"');
@@ -86,6 +89,7 @@ function showPhoneHelp(): void {
8689
console.log(' Configure voice: ' + chalk.green('FREE'));
8790
console.log(' Check SMS: ' + chalk.green('FREE'));
8891
console.log(' Read SMS: ' + chalk.green('FREE'));
92+
console.log(' Mark read: ' + chalk.green('FREE'));
8993
console.log(' Send SMS: ' + chalk.yellow('$0.05 per message'));
9094
console.log(' Get attachment: ' + chalk.green('FREE'));
9195
console.log(' Make call: ' + chalk.yellow('$0.10 per call'));
@@ -121,6 +125,10 @@ export async function phoneCommand(subCommand: string, options: PhoneOptions, po
121125
await readSms(positionalArg);
122126
break;
123127

128+
case 'mark-read':
129+
await markRead(positionalArg);
130+
break;
131+
124132
case 'send-sms':
125133
await sendSms(options);
126134
break;
@@ -336,6 +344,34 @@ async function readSms(messageId?: string): Promise<void> {
336344
}
337345
}
338346

347+
async function markRead(firstId?: string): Promise<void> {
348+
// Collect all positional args after "mark-read"
349+
const markReadIdx = process.argv.findIndex((arg) => arg === 'mark-read');
350+
const ids = markReadIdx !== -1 ? process.argv.slice(markReadIdx + 1).filter((a) => !a.startsWith('-')) : [];
351+
if (firstId && !ids.includes(firstId)) ids.unshift(firstId);
352+
353+
if (ids.length === 0) {
354+
console.error(chalk.red('Error: at least one message ID is required'));
355+
console.log(`Usage: ${chalk.cyan('npx atxp phone mark-read <id> [id...]')}`);
356+
console.log(chalk.gray('Use `npx atxp phone sms --unread-only` to see unread message IDs'));
357+
process.exit(1);
358+
}
359+
360+
const result = await callTool(SERVER, 'phone_mark_read', { message_ids: ids });
361+
362+
try {
363+
const parsed = JSON.parse(result);
364+
if (parsed.status === 'error') {
365+
console.error(chalk.red('Error: ' + parsed.errorMessage));
366+
process.exit(1);
367+
}
368+
369+
console.log(chalk.green(`Marked ${parsed.markedCount} message(s) as read.`));
370+
} catch {
371+
console.log(result);
372+
}
373+
}
374+
339375
async function sendSms(options: PhoneOptions): Promise<void> {
340376
const { to, body } = options;
341377

0 commit comments

Comments
 (0)