reply_message
Reply to a received message using keypair authentication, ensuring only the original recipient can respond.
Instructions
Reply to a received message. Only the original recipient can reply. Requires keypair auth.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message_id | Yes | The message ID to reply to | |
| body | Yes | Reply body text |
Implementation Reference
- packages/mcp/src/index.ts:542-567 (handler)The core handler implementation of the reply_message MCP tool. It requires keypair auth, calls POST /v1/messages/:id/reply via authedFetch, and returns the reply ID and status.
// ── reply_message ─────────────────────────────────────────────────────────── server.tool( 'reply_message', 'Reply to a received message. Only the original recipient can reply. Requires keypair auth.', { message_id: z.string().describe('The message ID to reply to'), body: z.string().describe('Reply body text'), }, async ({ message_id, body }) => { const kp = await getKeypair(); if (!kp) return noAuthResult(); const path = `/v1/messages/${encodeURIComponent(message_id)}/reply`; const data = await authedFetch('POST', path, { body }) as Record<string, unknown>; const lines = [ `Reply sent successfully.`, '', `**Reply ID:** \`${data.id}\``, `**In reply to:** \`${message_id}\``, `**Status:** ${data.status ?? 'pending'}`, ]; return { content: [{ type: 'text', text: lines.join('\n') }] }; } ); - packages/mcp/src/index.ts:546-549 (schema)Input schema for reply_message: message_id (string) and body (string), both validated with Zod.
{ message_id: z.string().describe('The message ID to reply to'), body: z.string().describe('Reply body text'), }, - packages/mcp/src/index.ts:543-567 (registration)Registration of the 'reply_message' tool with the MCP server via server.tool() with description, schema, and handler.
server.tool( 'reply_message', 'Reply to a received message. Only the original recipient can reply. Requires keypair auth.', { message_id: z.string().describe('The message ID to reply to'), body: z.string().describe('Reply body text'), }, async ({ message_id, body }) => { const kp = await getKeypair(); if (!kp) return noAuthResult(); const path = `/v1/messages/${encodeURIComponent(message_id)}/reply`; const data = await authedFetch('POST', path, { body }) as Record<string, unknown>; const lines = [ `Reply sent successfully.`, '', `**Reply ID:** \`${data.id}\``, `**In reply to:** \`${message_id}\``, `**Status:** ${data.status ?? 'pending'}`, ]; return { content: [{ type: 'text', text: lines.join('\n') }] }; } ); - packages/mcp/src/index.ts:131-156 (helper)authedFetch helper used by reply_message to make authenticated POST requests to the API with Ed25519 signatures.
async function authedFetch( method: string, path: string, body?: Record<string, unknown>, ): Promise<unknown> { const kp = await getKeypair(); if (!kp) throw new Error(AUTH_HELP); const bodyStr = body ? JSON.stringify(body) : ''; const { authorization, timestamp } = await signRequest(kp, method, path, bodyStr); const headers: Record<string, string> = { 'User-Agent': `basedagents-mcp/${VERSION}`, 'Authorization': authorization, 'X-Timestamp': timestamp, }; if (body) headers['Content-Type'] = 'application/json'; const res = await fetch(`${API}${path}`, { method, headers, ...(body ? { body: bodyStr } : {}), }); if (!res.ok) { const text = await res.text().catch(() => ''); throw new Error(`BasedAgents API returned ${res.status} for ${method} ${path}: ${text}`); } return res.json(); } - packages/mcp/src/index.ts:385-390 (helper)noAuthResult helper that returns an error response when authentication is not configured.
function noAuthResult() { return { content: [{ type: 'text' as const, text: `**Auth not configured.**\n\n${AUTH_HELP}` }], isError: true, }; }