Skip to content

Conversation

@4geru
Copy link
Contributor

@4geru 4geru commented May 28, 2025

Hello! This is 4geru.

MCP is a helpful tool for development.
I'm planning to add some rich menu APIs on MCP.

This is a 1st PR for rich menu.

added in this PR

  • setDefaultRichMenu
  • cancelDefaultRichMenu
  • deleteRichMenu
  • getRichMenuList

planning in other PR

Related to development APIs

  • createRichMenu
  • setRichMenuImage
  • createRichMenuAlias
  • deleteRichMenuAlias
  • getRichMenuAlias
  • getRichMenuAliasList
  • updateRichMenuAlias

not planning in other PR

Not related to development APIs

  • getDefaultRichMenuId
  • getRichMenu
  • getRichMenuIdOfUser
  • linkRichMenuIdToUser
  • linkRichMenuIdToUsers
  • richMenuBatch
  • unlinkRichMenuIdFromUser
  • unlinkRichMenuIdFromUsers
  • getRichMenuBatchProgress
  • validateRichMenuBatchRequest
  • validateRichMenuObject

Comment on lines +241 to +273
server.tool(
"get_rich_menu_list",
"Get the list of rich menus associated with your LINE Official Account.",
{},
async () => {
try {
const response = await messagingApiClient.getRichMenuList();
return createSuccessResponse(response);
} catch (error) {
return createErrorResponse(
`Failed to broadcast message: ${error.message}`,
);
}
},
);

server.tool(
"delete_rich_menu",
"Delete a rich menu from your LINE Official Account.",
{
richMenuId: z.string().describe("The ID of the rich menu to delete."),
},
async ({ richMenuId }) => {
try {
const response = await messagingApiClient.deleteRichMenu(richMenuId);
return createSuccessResponse(response);
} catch (error) {
return createErrorResponse(
`Failed to delete rich menu: ${error.message}`,
);
}
},
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete and list

スクリーンショット 2025-05-29 8 26 37

src/index.ts Outdated
);
}
},
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set rich menu image

スクリーンショット 2025-05-29 9 00 37

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
Hmm, I'm not sure about the best practice for passing images to the MCP Server...

I tried verifying whether we could pass images through chat from AI agents like Claude by changing the tool argument from a path to base64, but I ran into character limits. (like this)

With the method you implemented, we need to prepare images in advance within the local mcp-server repository, but maybe this approach will not work with the npx installation method (though I can't think of any better alternatives...).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command needs to be discussed further. Therefore, I will separate the PR.

const response = await messagingApiClient.setDefaultRichMenu(richMenuId);
return createSuccessResponse(response);
},
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set default

スクリーンショット 2025-05-29 9 02 18

const response = await messagingApiClient.cancelDefaultRichMenu();
return createSuccessResponse(response);
},
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

スクリーンショット 2025-05-29 9 04 02

@4geru 4geru mentioned this pull request May 29, 2025
Copy link
Contributor

@eucyt eucyt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This comment is not related to this PR directly)

I believe the createRichMenu tool would be in higher demand than the *Aliace tools. This is because you need to create a rich menu first before setting images.

src/index.ts Outdated
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import * as line from "@line/bot-sdk";
import { z } from "zod";
import pkg from "../package.json" with { type: "json" };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is not available in Node v20.9 or earlier...
Instead, use ./version.js, so this import is unnecessary.

Related to #61

src/index.ts Outdated
Comment on lines 45 to 50
const lineBlobClient = new line.messagingApi.MessagingApiBlobClient({
channelAccessToken: channelAccessToken,
defaultHeaders: {
"User-Agent": `${pkg.name}/${pkg.version}`,
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const lineBlobClient = new line.messagingApi.MessagingApiBlobClient({
channelAccessToken: channelAccessToken,
defaultHeaders: {
"User-Agent": `${pkg.name}/${pkg.version}`,
},
});
const lineBlobClient = new line.messagingApi.MessagingApiBlobClient({
channelAccessToken: channelAccessToken,
defaultHeaders: {
"User-Agent": USER_AGENT,
},
});

Please use ./version.js as shown 🙏

Related to #61

src/index.ts Outdated
);
}
},
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
Hmm, I'm not sure about the best practice for passing images to the MCP Server...

I tried verifying whether we could pass images through chat from AI agents like Claude by changing the tool argument from a path to base64, but I ran into character limits. (like this)

With the method you implemented, we need to prepare images in advance within the local mcp-server repository, but maybe this approach will not work with the npx installation method (though I can't think of any better alternatives...).

@4geru 4geru force-pushed the 4geru/add-rich-menu-list-set-default-apis branch from 54abac3 to 595c7fd Compare June 8, 2025 14:24
@4geru 4geru requested a review from eucyt June 8, 2025 14:25
Copy link
Contributor

@eucyt eucyt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

@eucyt eucyt added this pull request to the merge queue Jun 9, 2025
Merged via the queue into line:main with commit ba33224 Jun 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants