@rikaidev/yomi 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/mcp/handlers/login.js +3 -28
- package/dist/mcp/server.js +171 -228
- package/dist/mcp/tools.js +0 -12
- package/dist/mcp/ui/resource.js +3 -3
- package/dist/mcp/ui/tools-with-ui.js +3 -4
- package/dist/version.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -36,6 +36,9 @@ reply, who ties your world together, and what has gone overdue.
|
|
|
36
36
|
No official API, no bot account, no webhook. Yomi logs in as a secondary device
|
|
37
37
|
on your own account.
|
|
38
38
|
|
|
39
|
+
Guides: **[What is a LINE MCP server?](https://rikaidev.github.io/yomi/line-mcp/)**
|
|
40
|
+
· **[LINE MCP 是什麼?Yomi、官方 Bot 與桌面自動化的差異](https://rikaidev.github.io/yomi/zh-tw/line-mcp/)**.
|
|
41
|
+
|
|
39
42
|
   
|
|
40
43
|
|
|
41
44
|
> **Unofficial.** Yomi is an independent personal project, not affiliated with or
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Yomi MCP `login`/`login_complete` handlers.
|
|
3
|
-
*
|
|
4
|
-
* Split out of handlers.ts purely to keep that file (the general tool
|
|
5
|
-
* handler surface) under the project's 500-scc-line module cap; behavior
|
|
6
|
-
* owned here is otherwise unchanged in spirit from what previously lived
|
|
7
|
-
* inline there.
|
|
8
|
-
*
|
|
9
|
-
* Two login paths exist, dispatched by client capability:
|
|
10
|
-
*
|
|
11
|
-
* - Elicitation clients: the original single-call flow — elicit phone/
|
|
12
|
-
* region, elicit PIN acknowledgement, block to completion. Unchanged.
|
|
13
|
-
*
|
|
14
|
-
* - Non-elicitation clients (e.g. Claude Desktop, confirmed empirically —
|
|
15
|
-
* it does not support MCP elicitation): the PIN has nowhere to go if we
|
|
16
|
-
* block, since it is produced mid-flow and stderr is invisible to the
|
|
17
|
-
* human, but a tool RESULT is visible. So the flow is split across two
|
|
18
|
-
* tool calls: `login` starts the passwordless flow and returns the PIN
|
|
19
|
-
* as soon as LINE issues it (bounded wait), then `login_complete`
|
|
20
|
-
* awaits the same in-flight login to finish once the human has acted
|
|
21
|
-
* on their phone.
|
|
22
|
-
*
|
|
23
|
-
* Both paths call the ONE shared login sequence in ../cli/login.ts
|
|
24
|
-
* (`runPwlessLogin`) — neither duplicates it.
|
|
25
|
-
*/
|
|
26
1
|
import { runPwlessLogin } from '../../cli/login.js';
|
|
27
2
|
import { LINE_PIN_CODE_LIFETIME_MS, PAAK_AUTH_CLIENT_CEILING_MS, PIN_VERIFY_CLIENT_CEILING_MS, } from '../../line/auth/pwless/index.js';
|
|
28
3
|
import { createCliLogger } from '../../util/log.js';
|
|
@@ -431,11 +406,11 @@ async function handleLoginNoElicitation(service, args, supportsUi) {
|
|
|
431
406
|
* @param args - Tool arguments.
|
|
432
407
|
* @returns MCP tool result.
|
|
433
408
|
*/
|
|
434
|
-
export async function handleLogin(server, service, args) {
|
|
435
|
-
if (
|
|
409
|
+
export async function handleLogin(server, service, args, capabilities = server.getClientCapabilities(), allowPushElicitation = true) {
|
|
410
|
+
if (allowPushElicitation && capabilities?.elicitation) {
|
|
436
411
|
return handleLoginElicitation(server, service, args);
|
|
437
412
|
}
|
|
438
|
-
return handleLoginNoElicitation(service, args, supportsMcpApps(
|
|
413
|
+
return handleLoginNoElicitation(service, args, supportsMcpApps(capabilities));
|
|
439
414
|
}
|
|
440
415
|
/**
|
|
441
416
|
* Handle `login_complete` — finish a login started by a prior `login` call
|
package/dist/mcp/server.js
CHANGED
|
@@ -1,71 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Yomi MCP server
|
|
2
|
+
* Yomi MCP server.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* mark_read,
|
|
8
|
-
* send_message, send_image, send_file, send_audio, send_video,
|
|
9
|
-
* send_location, send_contact, send_sticker, list_stickers, search_stickers,
|
|
10
|
-
* preview_sticker, find_contact, list_contacts, get_group_members,
|
|
11
|
-
* rename_group, invite_member, kick_member, leave_group, create_group,
|
|
12
|
-
* react_message, cancel_reaction, unsend_message, add_friend, block_contact,
|
|
13
|
-
* unblock_contact, accept_invitation, collect_messages, search_messages,
|
|
14
|
-
* exclude_chats, include_chats, list_excluded_chats, get_scope_policy.
|
|
15
|
-
*
|
|
16
|
-
* find_contact/list_contacts/get_group_members expose LINE's raw
|
|
17
|
-
* people/membership data only — no affinity scoring, no interaction-
|
|
18
|
-
* frequency ranking, no relationship-graph computation. That
|
|
19
|
-
* intelligence layer belongs to the host app, not this server.
|
|
20
|
-
*
|
|
21
|
-
* collect_messages/search_messages add cross-conversation search (LINE has
|
|
22
|
-
* no such primitive): collect_messages explicitly fetches and indexes
|
|
23
|
-
* recent messages locally (see ../search/), embedding them for semantic
|
|
24
|
-
* search along the way; search_messages ranks by cosine similarity when
|
|
25
|
-
* vectors exist, falling back to FTS5 keyword search otherwise. No
|
|
26
|
-
* relationship graph, no affinity scoring either way.
|
|
27
|
-
*
|
|
28
|
-
* exclude_chats/include_chats/list_excluded_chats manage a scoping
|
|
29
|
-
* DENYLIST (see ../search/scope.ts): excluded chats are skipped by
|
|
30
|
-
* collect_messages and have their already-indexed data purged, not just
|
|
31
|
-
* filtered at query time. These are local-index operations too, so they
|
|
32
|
-
* work without a live LINE session (list_excluded_chats degrades its name
|
|
33
|
-
* resolution gracefully when there is none).
|
|
34
|
-
*
|
|
35
|
-
* Hard rules:
|
|
36
|
-
* - `login`/`login_complete` are the only tools callable without a live
|
|
37
|
-
* session; together they drive the passwordless flow and persist the
|
|
38
|
-
* result. Two calls are needed only on MCP clients that don't support
|
|
39
|
-
* elicitation (confirmed empirically for Claude Desktop) — `login`
|
|
40
|
-
* starts the flow and returns the PIN as a visible tool result instead
|
|
41
|
-
* of blocking, then `login_complete` finishes it once the human has
|
|
42
|
-
* acted on their phone; clients with elicitation get the original
|
|
43
|
-
* single-call flow via `login` alone. `search_messages` also runs
|
|
44
|
-
* without a live session, reading the local index as-is (with a live
|
|
45
|
-
* session it also auto-collects a first-time empty index).
|
|
46
|
-
* `exclude_chats`/`include_chats`/`list_excluded_chats` are local-index
|
|
47
|
-
* operations and likewise run without a live session.
|
|
48
|
-
* Every other tool returns a clear error until a session exists.
|
|
49
|
-
* - Runs a background capture loop (see ../search/capture.ts): on startup
|
|
50
|
-
* it starts LINE's poll loop and indexes new incoming messages into the
|
|
51
|
-
* local search index. This is SILENT — SYNC4 sync never sends read
|
|
52
|
-
* receipts — and denylist-gated. It never sends messages and never
|
|
53
|
-
* marks anything read. The only read-receipt path is the explicit
|
|
54
|
-
* mark_read tool and the auto-read that follows a successful
|
|
55
|
-
* send_message/send_image/send_file (replying implies reading).
|
|
56
|
-
* - `send_message`/`send_image`/`send_file` perform exactly one real,
|
|
57
|
-
* E2EE-encrypted send per call — no auto-send, no retry loop, no
|
|
58
|
-
* background send. Each also best-effort sends a read receipt for that
|
|
59
|
-
* chat after a successful send (see the `read` field in the response).
|
|
60
|
-
*
|
|
61
|
-
* Tool handler bodies live in the handlers/ folder (one single-responsibility
|
|
62
|
-
* module per domain, re-exported through handlers/index.ts) and the tool
|
|
63
|
-
* schema list lives in tools.ts, to keep this file, the wiring/dispatch
|
|
64
|
-
* surface, under the project's 200-scc-line cap for MCP server files.
|
|
4
|
+
* `serveStdio` negotiates both the stateless MCP 2026-07-28 era and legacy
|
|
5
|
+
* initialize-based clients. One factory instance is pinned to the selected
|
|
6
|
+
* era for the lifetime of the stdio connection.
|
|
65
7
|
*/
|
|
66
|
-
import { Server } from '@modelcontextprotocol/
|
|
67
|
-
import {
|
|
68
|
-
import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
import { ResourceNotFoundError, Server, } from '@modelcontextprotocol/server';
|
|
9
|
+
import { serveStdio } from '@modelcontextprotocol/server/stdio';
|
|
69
10
|
import { isLineAuthInvalidatedError } from '../line/client/index.js';
|
|
70
11
|
import { LineProtocolService } from '../line/core/service.js';
|
|
71
12
|
import { startCapture } from '../search/capture.js';
|
|
@@ -75,7 +16,6 @@ import { YOMI_VERSION } from '../version.js';
|
|
|
75
16
|
import { handleAcceptInvitation, handleAddFriend, handleBlockContact, handleCancelReaction, handleCollectMessages, handleCreateGroup, handleExcludeChats, handleFindContact, handleGetChatMessages, handleGetGroupMembers, handleGetInsight, handleGetMessageImage, handleGetMessageMedia, handleGetScopePolicy, handleGetUnreadDigest, handleIncludeChats, handleInviteMember, handleKickMember, handleLeaveGroup, handleListContacts, handleListConversations, handleListExcludedChats, handleListStickers, handleLogin, handleLoginComplete, handleMarkRead, handlePreviewSticker, handleReactMessage, handleRenameGroup, handleSearchMessages, handleSearchStickers, handleSendAudio, handleSendContact, handleSendFile, handleSendImage, handleSendLocation, handleSendMessage, handleSendSticker, handleSendVideo, handleUnblockContact, handleUnsendMessage, NO_CREDENTIALS_MESSAGE, sessionExpiredError, sessionRequiredError, sessionRevokedError, toolError, } from './handlers/index.js';
|
|
76
17
|
import { getPrivacyPolicyText } from './policy.js';
|
|
77
18
|
import { TOOLS } from './tools.js';
|
|
78
|
-
import { supportsMcpApps } from './ui/capability.js';
|
|
79
19
|
import { LOGIN_UI_RESOURCE_CONTENTS, LOGIN_UI_RESOURCE_LISTING, LOGIN_UI_RESOURCE_URI, } from './ui/resource.js';
|
|
80
20
|
import { toolsForClient } from './ui/tools-with-ui.js';
|
|
81
21
|
const log = createCliLogger('Yomi');
|
|
@@ -132,174 +72,177 @@ async function main() {
|
|
|
132
72
|
'policy; call get_scope_policy only when the user asks to see the policy again or ' +
|
|
133
73
|
'wants the current exclusion list. Policy follows:\n\n' +
|
|
134
74
|
getPrivacyPolicyText();
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const capabilities = server.getClientCapabilities();
|
|
140
|
-
log.info('client.capabilities', {
|
|
141
|
-
capabilities: JSON.stringify(capabilities ?? null),
|
|
75
|
+
const buildServer = ({ era }) => {
|
|
76
|
+
const server = new Server({ name: 'yomi', version: YOMI_VERSION }, {
|
|
77
|
+
capabilities: { tools: {}, resources: {} },
|
|
78
|
+
instructions,
|
|
142
79
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
162
|
-
const supportsUi = supportsMcpApps(server.getClientCapabilities());
|
|
163
|
-
return { tools: toolsForClient(TOOLS, supportsUi) };
|
|
164
|
-
});
|
|
165
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
166
|
-
const { name, arguments: args } = request.params;
|
|
167
|
-
// `login` is the one tool allowed without an existing session — it is
|
|
168
|
-
// how a session gets created. `search_messages` also runs without a
|
|
169
|
-
// live session: it reads the local search index (and, when a session
|
|
170
|
-
// does exist, auto-collects a first-time empty index). exclude_chats/
|
|
171
|
-
// include_chats/list_excluded_chats are local-index scoping operations
|
|
172
|
-
// over ../search/scope.ts and likewise need no live client (list's name
|
|
173
|
-
// resolution just degrades to null without one). Everything else needs
|
|
174
|
-
// a live client.
|
|
175
|
-
const noSessionExempt = name === 'login' ||
|
|
176
|
-
name === 'login_complete' ||
|
|
177
|
-
name === 'search_messages' ||
|
|
178
|
-
name === 'exclude_chats' ||
|
|
179
|
-
name === 'include_chats' ||
|
|
180
|
-
name === 'list_excluded_chats' ||
|
|
181
|
-
name === 'get_scope_policy';
|
|
182
|
-
if (!noSessionExempt) {
|
|
183
|
-
// Three distinct "no session" stories, and the user gets sent looking in
|
|
184
|
-
// the wrong place if we conflate them: LINE revoked this device's token
|
|
185
|
-
// (someone logged in elsewhere), the token merely aged out and the silent
|
|
186
|
-
// refresh failed (nobody logged in anywhere), or we never logged in at
|
|
187
|
-
// all. All three recover via `login`; only the explanation differs.
|
|
188
|
-
if (service.loginRequired) {
|
|
189
|
-
return service.loginReason === 'expired'
|
|
190
|
-
? sessionExpiredError()
|
|
191
|
-
: sessionRevokedError();
|
|
80
|
+
// Ground truth for whether a connected client actually supports
|
|
81
|
+
// elicitation (needed by the `login` tool) — observe it, don't assume it.
|
|
82
|
+
server.oninitialized = () => {
|
|
83
|
+
const capabilities = server.getClientCapabilities();
|
|
84
|
+
log.info('client.capabilities', {
|
|
85
|
+
capabilities: JSON.stringify(capabilities ?? null),
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
// MCP 2026-07-28 requires list endpoints to be connection-independent.
|
|
89
|
+
// Older hosts safely ignore the MCP Apps MIME type and `_meta.ui`.
|
|
90
|
+
server.setRequestHandler('resources/list', async () => {
|
|
91
|
+
log.info('resources.list', { count: 1 });
|
|
92
|
+
return { resources: [LOGIN_UI_RESOURCE_LISTING] };
|
|
93
|
+
});
|
|
94
|
+
server.setRequestHandler('resources/read', async (request) => {
|
|
95
|
+
log.info('resources.read', { uri: request.params.uri });
|
|
96
|
+
if (request.params.uri !== LOGIN_UI_RESOURCE_URI) {
|
|
97
|
+
throw new ResourceNotFoundError(request.params.uri);
|
|
192
98
|
}
|
|
193
|
-
|
|
194
|
-
|
|
99
|
+
return { contents: [LOGIN_UI_RESOURCE_CONTENTS] };
|
|
100
|
+
});
|
|
101
|
+
server.setRequestHandler('tools/list', async () => {
|
|
102
|
+
return { tools: toolsForClient(TOOLS, true) };
|
|
103
|
+
});
|
|
104
|
+
server.setRequestHandler('tools/call', async (request) => {
|
|
105
|
+
const { name, arguments: args } = request.params;
|
|
106
|
+
// `login` is the one tool allowed without an existing session — it is
|
|
107
|
+
// how a session gets created. `search_messages` also runs without a
|
|
108
|
+
// live session: it reads the local search index (and, when a session
|
|
109
|
+
// does exist, auto-collects a first-time empty index). exclude_chats/
|
|
110
|
+
// include_chats/list_excluded_chats are local-index scoping operations
|
|
111
|
+
// over ../search/scope.ts and likewise need no live client (list's name
|
|
112
|
+
// resolution just degrades to null without one). Everything else needs
|
|
113
|
+
// a live client.
|
|
114
|
+
const noSessionExempt = name === 'login' ||
|
|
115
|
+
name === 'login_complete' ||
|
|
116
|
+
name === 'search_messages' ||
|
|
117
|
+
name === 'exclude_chats' ||
|
|
118
|
+
name === 'include_chats' ||
|
|
119
|
+
name === 'list_excluded_chats' ||
|
|
120
|
+
name === 'get_scope_policy';
|
|
121
|
+
if (!noSessionExempt) {
|
|
122
|
+
// Three distinct "no session" stories, and the user gets sent looking in
|
|
123
|
+
// the wrong place if we conflate them: LINE revoked this device's token
|
|
124
|
+
// (someone logged in elsewhere), the token merely aged out and the silent
|
|
125
|
+
// refresh failed (nobody logged in anywhere), or we never logged in at
|
|
126
|
+
// all. All three recover via `login`; only the explanation differs.
|
|
127
|
+
if (service.loginRequired) {
|
|
128
|
+
return service.loginReason === 'expired'
|
|
129
|
+
? sessionExpiredError()
|
|
130
|
+
: sessionRevokedError();
|
|
131
|
+
}
|
|
132
|
+
if (!service.client) {
|
|
133
|
+
return sessionRequiredError();
|
|
134
|
+
}
|
|
195
135
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
136
|
+
try {
|
|
137
|
+
switch (name) {
|
|
138
|
+
case 'login':
|
|
139
|
+
return await handleLogin(server, service, (args ?? {}), server.getClientCapabilities(), era === 'legacy');
|
|
140
|
+
case 'login_complete':
|
|
141
|
+
return await handleLoginComplete();
|
|
142
|
+
case 'list_conversations':
|
|
143
|
+
return await handleListConversations(service, (args ?? {}));
|
|
144
|
+
case 'get_chat_messages':
|
|
145
|
+
return await handleGetChatMessages(service, (args ?? {}));
|
|
146
|
+
case 'get_message_image':
|
|
147
|
+
return await handleGetMessageImage(service, (args ?? {}));
|
|
148
|
+
case 'get_message_media':
|
|
149
|
+
return await handleGetMessageMedia(service, (args ?? {}));
|
|
150
|
+
case 'get_unread_digest':
|
|
151
|
+
return await handleGetUnreadDigest(service, (args ?? {}));
|
|
152
|
+
case 'get_insight':
|
|
153
|
+
return await handleGetInsight(service, (args ?? {}));
|
|
154
|
+
case 'mark_read':
|
|
155
|
+
return await handleMarkRead(service, (args ?? {}));
|
|
156
|
+
case 'send_message':
|
|
157
|
+
return await handleSendMessage(service, (args ?? {}));
|
|
158
|
+
case 'send_image':
|
|
159
|
+
return await handleSendImage(service, (args ?? {}));
|
|
160
|
+
case 'send_file':
|
|
161
|
+
return await handleSendFile(service, (args ?? {}));
|
|
162
|
+
case 'send_audio':
|
|
163
|
+
return await handleSendAudio(service, (args ?? {}));
|
|
164
|
+
case 'send_video':
|
|
165
|
+
return await handleSendVideo(service, (args ?? {}));
|
|
166
|
+
case 'send_location':
|
|
167
|
+
return await handleSendLocation(service, (args ?? {}));
|
|
168
|
+
case 'send_contact':
|
|
169
|
+
return await handleSendContact(service, (args ?? {}));
|
|
170
|
+
case 'send_sticker':
|
|
171
|
+
return await handleSendSticker(service, (args ?? {}));
|
|
172
|
+
case 'list_stickers':
|
|
173
|
+
return await handleListStickers(service, (args ?? {}));
|
|
174
|
+
case 'search_stickers':
|
|
175
|
+
return await handleSearchStickers(service, (args ?? {}));
|
|
176
|
+
case 'preview_sticker':
|
|
177
|
+
return await handlePreviewSticker(service, (args ?? {}));
|
|
178
|
+
case 'find_contact':
|
|
179
|
+
return await handleFindContact(service, (args ?? {}));
|
|
180
|
+
case 'list_contacts':
|
|
181
|
+
return await handleListContacts(service);
|
|
182
|
+
case 'get_group_members':
|
|
183
|
+
return await handleGetGroupMembers(service, (args ?? {}));
|
|
184
|
+
case 'rename_group':
|
|
185
|
+
return await handleRenameGroup(service, (args ?? {}));
|
|
186
|
+
case 'invite_member':
|
|
187
|
+
return await handleInviteMember(service, (args ?? {}));
|
|
188
|
+
case 'kick_member':
|
|
189
|
+
return await handleKickMember(service, (args ?? {}));
|
|
190
|
+
case 'leave_group':
|
|
191
|
+
return await handleLeaveGroup(service, (args ?? {}));
|
|
192
|
+
case 'create_group':
|
|
193
|
+
return await handleCreateGroup(service, (args ?? {}));
|
|
194
|
+
case 'react_message':
|
|
195
|
+
return await handleReactMessage(service, (args ?? {}));
|
|
196
|
+
case 'cancel_reaction':
|
|
197
|
+
return await handleCancelReaction(service, (args ?? {}));
|
|
198
|
+
case 'unsend_message':
|
|
199
|
+
return await handleUnsendMessage(service, (args ?? {}));
|
|
200
|
+
case 'add_friend':
|
|
201
|
+
return await handleAddFriend(service, (args ?? {}));
|
|
202
|
+
case 'block_contact':
|
|
203
|
+
return await handleBlockContact(service, (args ?? {}));
|
|
204
|
+
case 'unblock_contact':
|
|
205
|
+
return await handleUnblockContact(service, (args ?? {}));
|
|
206
|
+
case 'accept_invitation':
|
|
207
|
+
return await handleAcceptInvitation(service, (args ?? {}));
|
|
208
|
+
case 'collect_messages':
|
|
209
|
+
return await handleCollectMessages(service, (args ?? {}));
|
|
210
|
+
case 'search_messages':
|
|
211
|
+
return await handleSearchMessages(service, (args ?? {}));
|
|
212
|
+
case 'exclude_chats':
|
|
213
|
+
return await handleExcludeChats((args ?? {}));
|
|
214
|
+
case 'include_chats':
|
|
215
|
+
return await handleIncludeChats((args ?? {}));
|
|
216
|
+
case 'list_excluded_chats':
|
|
217
|
+
return await handleListExcludedChats(service);
|
|
218
|
+
case 'get_scope_policy':
|
|
219
|
+
return await handleGetScopePolicy(service);
|
|
220
|
+
default:
|
|
221
|
+
return toolError(`Unknown tool: ${name}`);
|
|
222
|
+
}
|
|
283
223
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
224
|
+
catch (error) {
|
|
225
|
+
const message = error?.message ?? String(error);
|
|
226
|
+
// A mid-session LINE token invalidation (e.g. V3_TOKEN_CLIENT_LOGGED_OUT
|
|
227
|
+
// after a competing login) is not a tool bug — flag the service so
|
|
228
|
+
// subsequent calls short-circuit at the gate above, and translate the
|
|
229
|
+
// raw protocol error into an actionable re-login message.
|
|
230
|
+
if (isLineAuthInvalidatedError(error)) {
|
|
231
|
+
service.loginRequired = true;
|
|
232
|
+
service.loginReason = 'revoked';
|
|
233
|
+
log.warn('tool.session_revoked', { error: message, tool: name });
|
|
234
|
+
return sessionRevokedError(message);
|
|
235
|
+
}
|
|
236
|
+
log.error('tool.failed', { error: message, tool: name });
|
|
237
|
+
return toolError(message);
|
|
296
238
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
239
|
+
});
|
|
240
|
+
return server;
|
|
241
|
+
};
|
|
242
|
+
serveStdio(buildServer, {
|
|
243
|
+
legacy: 'serve',
|
|
244
|
+
onerror: (error) => log.error('server.protocol_error', { error: error.message }),
|
|
300
245
|
});
|
|
301
|
-
const transport = new StdioServerTransport();
|
|
302
|
-
await server.connect(transport);
|
|
303
246
|
log.info('server.started', { tools: TOOLS.length });
|
|
304
247
|
}
|
|
305
248
|
main().catch((error) => {
|
package/dist/mcp/tools.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Yomi MCP tool schemas — the full TOOLS list served by ListToolsRequest
|
|
3
|
-
* and dispatched by CallToolRequest in server.ts.
|
|
4
|
-
*
|
|
5
|
-
* Split out from server.ts purely to keep server.ts (the wiring/dispatch
|
|
6
|
-
* file) under the project's 200-scc-line cap; behavior owned here is
|
|
7
|
-
* unchanged from what previously lived inline in server.ts.
|
|
8
|
-
*
|
|
9
|
-
* Descriptions are deliberately terse: the tool list renders at prompt
|
|
10
|
-
* position 0 on every request, so trimming boilerplate here directly lowers
|
|
11
|
-
* the fixed per-request token cost every connected client pays.
|
|
12
|
-
*/
|
|
13
1
|
export const TOOLS = [
|
|
14
2
|
{
|
|
15
3
|
description: 'Log in to LINE via the passwordless secondary-device flow. Requires 允許自其他裝置登入 enabled on the primary phone. On MCP clients with elicitation, this call prompts for phone/region and PIN and completes login by itself. On clients without it (e.g. Claude Desktop), phone/region come from the arguments or a persisted login, and this returns as soon as LINE issues the PIN (or reports none needed) — then call login_complete IMMEDIATELY (do not wait for the human). LINE gives ~3 minutes from PIN display to confirm on the phone; login_complete blocks past that, so calling it late only wastes that window.',
|
package/dist/mcp/ui/resource.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The single MCP Apps UI resource this server exposes: the login view.
|
|
3
3
|
* Registered by ../server.ts's `resources/list` and `resources/read`
|
|
4
|
-
* handlers
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* handlers. MCP 2026-07-28 requires list results to be independent of a
|
|
5
|
+
* connection, so this resource is always advertised; hosts without MCP Apps
|
|
6
|
+
* support safely ignore the MIME type and `_meta.ui`.
|
|
7
7
|
*
|
|
8
8
|
* The `csp` key within `_meta.ui` is deliberately omitted: the login view
|
|
9
9
|
* makes no outbound connections and loads nothing external, so the host's
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Attaches the MCP Apps `_meta.ui` linkage to the `login` tool definition,
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* static schema registry) because this step is per-connection, not static.
|
|
3
|
+
* when requested by the caller. The MCP 2026-07-28 server always requests it
|
|
4
|
+
* because list results may not vary by connection; the conditional remains
|
|
5
|
+
* useful to callers that serialize the legacy plain registry directly.
|
|
7
6
|
*/
|
|
8
7
|
import { LOGIN_UI_RESOURCE_URI } from './resource.js';
|
|
9
8
|
/**
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"engines": {
|
|
4
4
|
"node": ">=22.13.0 <23.0.0 || >=23.4.0"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.4.0",
|
|
7
7
|
"description": "Open-source personal LINE MCP server for AI agents. Read, reply, send images, and search LINE conversations locally with Letter-Sealing E2EE.",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"license": "MIT",
|
|
@@ -50,13 +50,14 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@huggingface/transformers": "^4.2.0",
|
|
53
|
-
"@modelcontextprotocol/
|
|
53
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
54
54
|
"@toon-format/toon": "^2.3.1",
|
|
55
55
|
"curve25519-js": "^0.0.4",
|
|
56
56
|
"tweetnacl": "^1.0.3"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@biomejs/biome": "^2.5.3",
|
|
60
|
+
"@modelcontextprotocol/client": "^2.0.0",
|
|
60
61
|
"@types/bun": "^1.3.14",
|
|
61
62
|
"@types/node": "^22.10.0",
|
|
62
63
|
"knip": "^6.27.0",
|