nworks_message_send
Send messages to users or channels in NAVER WORKS using Service Account authentication. Supports text, button, and list message types for automated communication.
Instructions
NAVER WORKS 메시지를 전송합니다 (봇이 사용자 또는 채널에 발송). Service Account 인증 사용 (nworks_setup에서 serviceAccount, botId 설정 + 환경변수 NWORKS_PRIVATE_KEY_PATH 필요. User OAuth 불필요)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | 수신자 userId (channel과 택 1). nworks_directory_members로 userId 조회 가능 | |
| channel | No | 채널 channelId (to와 택 1). nworks_message_members로 채널 구성원 확인 가능 | |
| text | Yes | 메시지 본문 | |
| type | No | 메시지 타입 (기본: text) | |
| actions | No | 버튼 액션 JSON (type=button일 때) | |
| elements | No | 리스트 항목 JSON (type=list일 때) |
Implementation Reference
- src/mcp/tools.ts:135-154 (handler)MCP tool handler for "nworks_message_send".
async ({ to, channel, text, type, actions, elements }) => { try { const result = await messageApi.send({ to, channel, text, type, actions, elements, }); return { content: [{ type: "text" as const, text: JSON.stringify(result) }], }; } catch (err) { return { content: [{ type: "text" as const, text: mcpErrorHint(err) }], isError: true, }; } } - src/api/message.ts:63-97 (handler)Actual implementation logic for sending messages via NAVER WORKS API.
export async function send(opts: SendOptions): Promise<SendResult> { const profile = opts.profile ?? "default"; const creds = await loadCredentials(profile); if (!creds.botId) { throw new Error( "Bot ID is required for sending messages.\n" + "Run `nworks login` with --bot-id flag to set up bot credentials." ); } const content = buildContent(opts); const body = { content }; if (opts.to) { const result = await request<{ messageId?: string }>({ method: "POST", path: `/bots/${sanitizePathSegment(creds.botId)}/users/${sanitizePathSegment(opts.to)}/messages`, body, profile, }); return { success: true, messageId: result?.messageId }; } if (opts.channel) { const result = await request<{ messageId?: string }>({ method: "POST", path: `/bots/${sanitizePathSegment(creds.botId)}/channels/${sanitizePathSegment(opts.channel)}/messages`, body, profile, }); return { success: true, messageId: result?.messageId }; } throw new Error("Either --to (userId) or --channel (channelId) is required."); } - src/mcp/tools.ts:115-134 (registration)Registration and schema definition of "nworks_message_send" tool.
server.tool( "nworks_message_send", "NAVER WORKS 메시지를 전송합니다 (봇이 사용자 또는 채널에 발송). Service Account 인증 사용 (nworks_setup에서 serviceAccount, botId 설정 + 환경변수 NWORKS_PRIVATE_KEY_PATH 필요. User OAuth 불필요)", { to: z.string().optional().describe("수신자 userId (channel과 택 1). nworks_directory_members로 userId 조회 가능"), channel: z.string().optional().describe("채널 channelId (to와 택 1). nworks_message_members로 채널 구성원 확인 가능"), text: z.string().describe("메시지 본문"), type: z .enum(["text", "button", "list"]) .optional() .describe("메시지 타입 (기본: text)"), actions: z .string() .optional() .describe("버튼 액션 JSON (type=button일 때)"), elements: z .string() .optional() .describe("리스트 항목 JSON (type=list일 때)"), },