Skip to content

Commit e84e762

Browse files
committed
feat: add get_follower_ids tool, update README, and remove unused code (#40)
Update src/index.ts Co-authored-by: Yuta Euchi <[email protected]> Update src/index.ts Co-authored-by: Yuta Euchi <[email protected]> Update src/index.ts Co-authored-by: Yuta Euchi <[email protected]> Update README.md Co-authored-by: Yuta Euchi <[email protected]> Update README.ja.md Co-authored-by: Yuta Euchi <[email protected]> Update README.ja.md Co-authored-by: Yuta Euchi <[email protected]> chore(deps): update pnpm to v10.11.0 (#67) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> chore(deps): update dependency @types/node to v22.15.18 (#69) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> fix(deps): update dependency @modelcontextprotocol/sdk to v1.11.3 (#70) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Update README.md Co-authored-by: Yuta Euchi <[email protected]> ✨ Add get_follower_ids tool to retrieve user IDs of followers for LINE Official Account 📝 Update README.ja.md to remove redundant information and clarify get_follower_ids tool details. refactor(code): remove unused get_message_quota tool
1 parent 6163456 commit e84e762

File tree

5 files changed

+80
-24
lines changed

5 files changed

+80
-24
lines changed

README.ja.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,29 @@ LINE公式アカウントとAI Agentを接続するために、LINE Messaging AP
4141
- LINE公式アカウントのメッセージ容量と消費量を取得します。月間メッセージ制限と現在の使用量が表示されます。
4242
- **入力:**
4343
- なし
44+
7. **get_follower_ids**
45+
- LINE公式アカウントを友だち追加したユーザーのユーザーID一覧を取得します。
46+
- **入力:**
47+
- `start` (string?): ページネーション用の継続トークン。省略時は先頭から取得します。
48+
- `limit` (number?): 取得するユーザーIDの最大数(1~1000)。デフォルトは1000。
49+
- **出力:**
50+
- `userIds` (配列): ユーザーIDのリスト。
51+
- `next` (string?): 次ページ取得用トークン。存在する場合はこの値で再度リクエストしてください。
52+
- `total` (number?): ユーザーIDの総数(取得できる場合)。
53+
- **注意:**
54+
- 認証済みまたはプレミアムアカウントのみ利用可能です。
55+
- 一部ユーザーIDはプライバシーやユーザー操作により取得できない場合があります(詳細は[こちら](https://developers.line.biz/ja/reference/messaging-api/#get-follower-ids-obtainable-ids)を参照してください)。
4456

4557
## インストール (npxを使用)
4658

4759
要件:
60+
4861
- Node.js v20 以上
4962

5063
### Step 1: LINE公式アカウントを作成
5164

5265
このMCP ServerはLINE公式アカウントを利用しています。公式アカウントをお持ちでない場合は、[こちらの手順](https://developers.line.biz/ja/docs/messaging-api/getting-started/#create-oa)に従って作成してください。
5366

54-
LINE公式アカウントをお持ちであれば、[こちらの手順](https://developers.line.biz/ja/docs/messaging-api/getting-started/#using-oa-manager)に従ってMessaging APIを有効にしてください。
55-
5667
### Step 2: AI Agentを設定
5768

5869
Claude DesktopやClaudeなどのAI Agentに次の設定を追加してください。
@@ -96,6 +107,7 @@ git clone [email protected]:line/line-bot-mcp-server.git
96107
```
97108

98109
Dockerイメージをビルドします:
110+
99111
```
100112
docker build -t line/line-bot-mcp-server .
101113
```

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,34 @@
4343
- Get the message quota and consumption of the LINE Official Account. This shows the monthly message limit and current usage.
4444
- **Inputs:**
4545
- None
46+
7. **get_follower_ids**
47+
- Gets the list of User IDs of users who have added your LINE Official Account as a friend.
48+
- **Inputs:**
49+
- `start` (string?): Continuation token for pagination. If omitted, fetches from the beginning.
50+
- `limit` (number?): Maximum number of user IDs to retrieve (1-1000). Default is 1000.
51+
- **Returns:**
52+
- `userIds` (array): List of user IDs.
53+
- `next` (string?): Token for the next page. If present, repeat the request with this value to get more user IDs.
54+
- `total` (number?): Total number of user IDs (if available).
55+
- **Notes:**
56+
- Only available for verified or premium accounts.
57+
- Some user IDs may not be included due to privacy or user actions (see [documents](https://developers.line.biz/en/reference/messaging-api/#get-follower-ids-obtainable-ids) for details).
4658

4759
## Installation (Using npx)
4860

4961
requirements:
62+
5063
- Node.js v20 or later
5164

5265
### Step 1: Create LINE Official Account
5366

54-
This MCP server utilizes a LINE Official Account. If you do not have one, please create it by following [this instructions](https://developers.line.biz/en/docs/messaging-api/getting-started/#create-oa).
67+
This MCP server utilizes a LINE Official Account. If you do not have one, please create it by following [this instructions](https://developers.line.biz/en/docs/messaging-api/getting-started/#create-oa).
5568

5669
If you have a LINE Official Account, enable the Messaging API for your LINE Official Account by following [this instructions](https://developers.line.biz/en/docs/messaging-api/getting-started/#using-oa-manager).
5770

5871
### Step 2: Configure AI Agent
5972

60-
Please add the following configuration for an AI Agent like Claude Desktop or Cline.
73+
Please add the following configuration for an AI Agent like Claude Desktop or Cline.
6174

6275
Set the environment variables or arguments as follows:
6376

@@ -89,7 +102,6 @@ This MCP server utilizes a LINE Official Account. If you do not have one, please
89102

90103
If you have a LINE Official Account, enable the Messaging API for your LINE Official Account by following [this instructions](https://developers.line.biz/en/docs/messaging-api/getting-started/#using-oa-manager).
91104

92-
93105
### Step 2: Build line-bot-mcp-server image
94106

95107
Clone this repository:
@@ -115,7 +127,6 @@ Set the environment variables or arguments as follows:
115127
- `DESTINATION_USER_ID`: (optional) The default user ID of the recipient. If the Tool's input does not include `user_id`, `DESTINATION_USER_ID` is required.
116128
You can confirm this by following [this instructions](https://developers.line.biz/en/docs/messaging-api/getting-user-ids/#get-own-user-id).
117129

118-
119130
```json
120131
{
121132
"mcpServers": {
@@ -144,7 +155,7 @@ You can confirm this by following [this instructions](https://developers.line.bi
144155

145156
This project respects semantic versioning
146157

147-
See http://semver.org/
158+
See <http://semver.org/>
148159

149160
## Contributing
150161

package-lock.json

Lines changed: 7 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"dependencies": {
3737
"@line/bot-sdk": "^9.8.0",
3838
"@modelcontextprotocol/sdk": "^1.8.0",
39+
"axios": "^1.9.0",
3940
"zod": "^3.24.2"
4041
},
4142
"devDependencies": {

src/index.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
2121
import * as line from "@line/bot-sdk";
2222
import { z } from "zod";
2323
import { LINE_BOT_MCP_SERVER_VERSION, USER_AGENT } from "./version.js";
24+
import pkg from "../package.json" with { type: "json" };
25+
import axios from "axios";
2426

2527
const NO_USER_ID_ERROR =
2628
"Error: Specify the userId or set the DESTINATION_USER_ID in the environment variables of this MCP Server.";
@@ -229,6 +231,46 @@ server.tool(
229231
},
230232
);
231233

234+
server.tool(
235+
"get_follower_ids",
236+
"Gets the list of User IDs of users who have added your LINE Official Account as a friend.",
237+
{
238+
start: z
239+
.string()
240+
.optional()
241+
.describe(
242+
"Continuation token for pagination. If omitted, fetches from the beginning.",
243+
),
244+
limit: z
245+
.number()
246+
.int()
247+
.min(1)
248+
.max(1000)
249+
.optional()
250+
.describe(
251+
"Maximum number of user IDs to retrieve (1-1000). Default is 1000.",
252+
),
253+
},
254+
async ({ start, limit }: { start?: string; limit?: number }) => {
255+
try {
256+
const params = new URLSearchParams();
257+
if (limit) params.append("limit", limit.toString());
258+
if (start) params.append("start", start);
259+
const res = await axios.get("https://api.line.me/v2/bot/followers/ids", {
260+
params,
261+
headers: {
262+
Authorization: `Bearer ${channelAccessToken}`,
263+
},
264+
});
265+
return createSuccessResponse(res.data);
266+
} catch (error) {
267+
return createErrorResponse(
268+
`Failed to get follower ids: ${error.message}`,
269+
);
270+
}
271+
},
272+
);
273+
232274
async function main() {
233275
if (!process.env.CHANNEL_ACCESS_TOKEN) {
234276
console.error("Please set CHANNEL_ACCESS_TOKEN");

0 commit comments

Comments
 (0)