Skip to main content
Glama
tndfame
by tndfame

push_flex_message

Send customizable flex messages to LINE users with bubble or carousel layouts for interactive content delivery.

Instructions

Push a highly customizable flex message to a user via LINE. Supports both bubble (single container) and carousel (multiple swipeable bubbles) layouts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userIdNoThe user ID to receive a message. Defaults to DESTINATION_USER_ID.U1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p
messageYes

Implementation Reference

  • The core handler function that validates the userId, pushes the flex message to the LINE API client, and returns success or error response.
    async ({ userId, message }) => {
      if (!userId) {
        return createErrorResponse(NO_USER_ID_ERROR);
      }
    
      try {
        const response = await this.client.pushMessage({
          to: userId,
          messages: [message as unknown as messagingApi.Message],
        });
        return createSuccessResponse(response);
      } catch (error) {
        return createErrorResponse(
          `Failed to push flex message: ${error.message}`,
        );
      }
    },
  • Zod schema defining the structure of the flex message input, including type, altText, and contents (bubble or carousel).
    export const flexMessageSchema = z.object({
      type: z.literal("flex").default("flex"),
      altText: z
        .string()
        .describe("Alternative text shown when flex message cannot be displayed."),
      contents: z
        .object({
          type: z
            .enum(["bubble", "carousel"])
            .describe(
              "Type of the container. 'bubble' for single container, 'carousel' for multiple swipeable bubbles.",
            ),
        })
        .passthrough()
        .describe(
          "Flexible container structure following LINE Flex Message format. For 'bubble' type, can include header, " +
            "hero, body, footer, and styles sections. For 'carousel' type, includes an array of bubble containers in " +
            "the 'contents' property.",
        ),
    });
  • Registers the 'push_flex_message' tool with the MCP server, specifying the name, description, input schema (userId and message), and the handler function.
    server.tool(
      "push_flex_message",
      "Push a highly customizable flex message to a user via LINE. Supports both bubble (single container) and carousel " +
        "(multiple swipeable bubbles) layouts.",
      {
        userId: userIdSchema,
        message: flexMessageSchema,
      },
      async ({ userId, message }) => {
        if (!userId) {
          return createErrorResponse(NO_USER_ID_ERROR);
        }
    
        try {
          const response = await this.client.pushMessage({
            to: userId,
            messages: [message as unknown as messagingApi.Message],
          });
          return createSuccessResponse(response);
        } catch (error) {
          return createErrorResponse(
            `Failed to push flex message: ${error.message}`,
          );
        }
      },
    );
  • src/index.ts:62-62 (registration)
    Instantiates the PushFlexMessage class with the messaging API client and destination ID, then calls register to add the tool to the MCP server.
    new PushFlexMessage(messagingApiClient, destinationId).register(server);
  • Zod schema for the userId parameter, with default value from destinationId and description.
    const userIdSchema = z
      .string()
      .default(this.destinationId)
      .describe(
        "The user ID to receive a message. Defaults to DESTINATION_USER_ID.",
      );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tndfame/mcp_management'

If you have feedback or need assistance with the MCP directory API, please join our Discord server