push_messages
Send text or flex messages to LINE users through the LINE Messaging API. Specify user ID and message content to deliver communications to individual recipients.
Instructions
Push one or more LINE messages to a user (generic).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messages | Yes | Array of LINE messages (text/flex) | |
| userId | No | User ID to receive messages. Defaults to DESTINATION_USER_ID | U1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p |
Implementation Reference
- src/tools/pushMessages.ts:41-54 (handler)Handler function that pushes LINE messages to the specified userId using the messaging API client, handling errors and returning appropriate responses.async ({ userId, messages }) => { if (!userId) return createErrorResponse(NO_USER_ID_ERROR); try { const resp = await this.client.pushMessage({ to: userId, messages: messages as unknown as messagingApi.Message[], }); return createSuccessResponse(resp); } catch (e: any) { return createErrorResponse( `Failed to push messages: ${e?.message || e}`, ); } },
- src/tools/pushMessages.ts:13-36 (schema)Defines lineMessageSchema as a union of textMessageSchema and flexMessageSchema, and tool input schemas for userId (string with default) and messages (non-empty array of line messages).const lineMessageSchema = z .union([textMessageSchema, flexMessageSchema]) .or(z.any()); export default class PushMessages extends AbstractTool { private client: messagingApi.MessagingApiClient; private destinationId: string; constructor(client: messagingApi.MessagingApiClient, destinationId: string) { super(); this.client = client; this.destinationId = destinationId; } register(server: McpServer) { const userId = z .string() .default(this.destinationId) .describe("User ID to receive messages. Defaults to DESTINATION_USER_ID"); const messages = z .array(lineMessageSchema) .min(1) .describe("Array of LINE messages (text/flex)");
- src/tools/pushMessages.ts:37-55 (registration)Registers the "push_messages" tool on the MCP server using server.tool(), providing name, description, input schema, and handler function.server.tool( "push_messages", "Push one or more LINE messages to a user (generic).", { userId, messages }, async ({ userId, messages }) => { if (!userId) return createErrorResponse(NO_USER_ID_ERROR); try { const resp = await this.client.pushMessage({ to: userId, messages: messages as unknown as messagingApi.Message[], }); return createSuccessResponse(resp); } catch (e: any) { return createErrorResponse( `Failed to push messages: ${e?.message || e}`, ); } }, );
- src/index.ts:74-74 (registration)Top-level instantiation of PushMessages tool with LINE messaging client and destination ID, followed by registration on the main MCP server instance.new PushMessages(messagingApiClient, destinationId).register(server);