@rikaidev/yomi 0.3.1 → 0.4.1
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/PRIVACY.md +14 -0
- package/README.md +3 -0
- package/dist/auth/credential-store.js +11 -1
- package/dist/mcp/client-capabilities.js +55 -0
- package/dist/mcp/handlers/login-copy.js +200 -0
- package/dist/mcp/handlers/login-mrtr.js +150 -0
- package/dist/mcp/handlers/login-session.js +132 -0
- package/dist/mcp/handlers/login.js +67 -239
- package/dist/mcp/server.js +191 -229
- package/dist/mcp/tools.js +3 -14
- package/dist/mcp/ui/resource.js +3 -3
- package/dist/mcp/ui/tools-with-ui.js +3 -4
- package/dist/util/update-check.js +121 -0
- package/dist/version.js +1 -1
- package/package.json +3 -2
package/dist/mcp/server.js
CHANGED
|
@@ -1,81 +1,23 @@
|
|
|
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';
|
|
72
13
|
import { getDefaultEmbedder } from '../search/default-embedder.js';
|
|
73
14
|
import { createCliLogger } from '../util/log.js';
|
|
15
|
+
import { checkForUpdate } from '../util/update-check.js';
|
|
74
16
|
import { YOMI_VERSION } from '../version.js';
|
|
17
|
+
import { clientCapabilitiesOf } from './client-capabilities.js';
|
|
75
18
|
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
19
|
import { getPrivacyPolicyText } from './policy.js';
|
|
77
20
|
import { TOOLS } from './tools.js';
|
|
78
|
-
import { supportsMcpApps } from './ui/capability.js';
|
|
79
21
|
import { LOGIN_UI_RESOURCE_CONTENTS, LOGIN_UI_RESOURCE_LISTING, LOGIN_UI_RESOURCE_URI, } from './ui/resource.js';
|
|
80
22
|
import { toolsForClient } from './ui/tools-with-ui.js';
|
|
81
23
|
const log = createCliLogger('Yomi');
|
|
@@ -102,12 +44,21 @@ async function main() {
|
|
|
102
44
|
});
|
|
103
45
|
});
|
|
104
46
|
}
|
|
47
|
+
// Asked once per process, bounded, best-effort: a hand-installed .mcpb
|
|
48
|
+
// bundle never auto-updates, so this notice is the only way a GUI-only user
|
|
49
|
+
// learns a newer Yomi exists (see ../util/update-check.ts). Awaited here
|
|
50
|
+
// because `instructions` is built once, before any client connects.
|
|
51
|
+
const updateNotice = await checkForUpdate();
|
|
52
|
+
if (updateNotice) {
|
|
53
|
+
log.info('update.available', { current: YOMI_VERSION });
|
|
54
|
+
}
|
|
105
55
|
// `instructions` is surfaced by the MCP SDK to the client/model on
|
|
106
56
|
// initialize — a "TOS on connect" privacy disclosure. It is a consent
|
|
107
57
|
// notice, not decoration. A short model directive precedes the canonical
|
|
108
58
|
// policy prose, which lives ONLY in PRIVACY.md (see ./policy.ts) so the
|
|
109
59
|
// disclosure is single-sourced and never drifts from get_scope_policy.
|
|
110
|
-
const instructions =
|
|
60
|
+
const instructions = (updateNotice ? `${updateNotice}\n\n` : '') +
|
|
61
|
+
'SESSION ERRORS — if a tool fails with a login-required or signed-out ' +
|
|
111
62
|
'error, the MCP server and its connection are healthy: LINE revoked this ' +
|
|
112
63
|
"device's session (usually because the same account logged in somewhere " +
|
|
113
64
|
'else). Tell the user that plainly and offer the `login` tool. Never ' +
|
|
@@ -132,174 +83,185 @@ async function main() {
|
|
|
132
83
|
'policy; call get_scope_policy only when the user asks to see the policy again or ' +
|
|
133
84
|
'wants the current exclusion list. Policy follows:\n\n' +
|
|
134
85
|
getPrivacyPolicyText();
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const capabilities = server.getClientCapabilities();
|
|
140
|
-
log.info('client.capabilities', {
|
|
141
|
-
capabilities: JSON.stringify(capabilities ?? null),
|
|
86
|
+
const buildServer = ({ era }) => {
|
|
87
|
+
const server = new Server({ name: 'yomi', version: YOMI_VERSION }, {
|
|
88
|
+
capabilities: { tools: {}, resources: {} },
|
|
89
|
+
instructions,
|
|
142
90
|
});
|
|
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();
|
|
91
|
+
// Ground truth for whether a connected client actually supports
|
|
92
|
+
// elicitation (needed by the `login` tool) — observe it, don't assume it.
|
|
93
|
+
server.oninitialized = () => {
|
|
94
|
+
const capabilities = server.getClientCapabilities();
|
|
95
|
+
log.info('client.capabilities', {
|
|
96
|
+
capabilities: JSON.stringify(capabilities ?? null),
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
// MCP 2026-07-28 requires list endpoints to be connection-independent.
|
|
100
|
+
// Older hosts safely ignore the MCP Apps MIME type and `_meta.ui`.
|
|
101
|
+
server.setRequestHandler('resources/list', async () => {
|
|
102
|
+
log.info('resources.list', { count: 1 });
|
|
103
|
+
return { resources: [LOGIN_UI_RESOURCE_LISTING] };
|
|
104
|
+
});
|
|
105
|
+
server.setRequestHandler('resources/read', async (request) => {
|
|
106
|
+
log.info('resources.read', { uri: request.params.uri });
|
|
107
|
+
if (request.params.uri !== LOGIN_UI_RESOURCE_URI) {
|
|
108
|
+
throw new ResourceNotFoundError(request.params.uri);
|
|
192
109
|
}
|
|
193
|
-
|
|
194
|
-
|
|
110
|
+
return { contents: [LOGIN_UI_RESOURCE_CONTENTS] };
|
|
111
|
+
});
|
|
112
|
+
server.setRequestHandler('tools/list', async () => {
|
|
113
|
+
return { tools: toolsForClient(TOOLS, true) };
|
|
114
|
+
});
|
|
115
|
+
server.setRequestHandler('tools/call', async (request, ctx) => {
|
|
116
|
+
const { name, arguments: args } = request.params;
|
|
117
|
+
// `login` is the one tool allowed without an existing session — it is
|
|
118
|
+
// how a session gets created. `search_messages` also runs without a
|
|
119
|
+
// live session: it reads the local search index (and, when a session
|
|
120
|
+
// does exist, auto-collects a first-time empty index). exclude_chats/
|
|
121
|
+
// include_chats/list_excluded_chats are local-index scoping operations
|
|
122
|
+
// over ../search/scope.ts and likewise need no live client (list's name
|
|
123
|
+
// resolution just degrades to null without one). Everything else needs
|
|
124
|
+
// a live client.
|
|
125
|
+
const noSessionExempt = name === 'login' ||
|
|
126
|
+
name === 'login_complete' ||
|
|
127
|
+
name === 'search_messages' ||
|
|
128
|
+
name === 'exclude_chats' ||
|
|
129
|
+
name === 'include_chats' ||
|
|
130
|
+
name === 'list_excluded_chats' ||
|
|
131
|
+
name === 'get_scope_policy';
|
|
132
|
+
if (!noSessionExempt) {
|
|
133
|
+
// Three distinct "no session" stories, and the user gets sent looking in
|
|
134
|
+
// the wrong place if we conflate them: LINE revoked this device's token
|
|
135
|
+
// (someone logged in elsewhere), the token merely aged out and the silent
|
|
136
|
+
// refresh failed (nobody logged in anywhere), or we never logged in at
|
|
137
|
+
// all. All three recover via `login`; only the explanation differs.
|
|
138
|
+
if (service.loginRequired) {
|
|
139
|
+
return service.loginReason === 'expired'
|
|
140
|
+
? sessionExpiredError()
|
|
141
|
+
: sessionRevokedError();
|
|
142
|
+
}
|
|
143
|
+
if (!service.client) {
|
|
144
|
+
return sessionRequiredError();
|
|
145
|
+
}
|
|
195
146
|
}
|
|
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
|
-
|
|
147
|
+
try {
|
|
148
|
+
switch (name) {
|
|
149
|
+
case 'login':
|
|
150
|
+
// `era` selects HOW the login talks to the human: the legacy era
|
|
151
|
+
// can push `elicitation/create`, the modern one answers with
|
|
152
|
+
// multi-round-trip `input_required` results the client fulfils
|
|
153
|
+
// and retries (`ctx.mcpReq.inputResponses` carries the answers).
|
|
154
|
+
return await handleLogin(server, service, (args ?? {}), {
|
|
155
|
+
era,
|
|
156
|
+
capabilities: clientCapabilitiesOf(server, ctx),
|
|
157
|
+
inputResponses: ctx.mcpReq.inputResponses,
|
|
158
|
+
});
|
|
159
|
+
case 'login_complete':
|
|
160
|
+
return await handleLoginComplete();
|
|
161
|
+
case 'list_conversations':
|
|
162
|
+
return await handleListConversations(service, (args ?? {}));
|
|
163
|
+
case 'get_chat_messages':
|
|
164
|
+
return await handleGetChatMessages(service, (args ?? {}));
|
|
165
|
+
case 'get_message_image':
|
|
166
|
+
return await handleGetMessageImage(service, (args ?? {}));
|
|
167
|
+
case 'get_message_media':
|
|
168
|
+
return await handleGetMessageMedia(service, (args ?? {}));
|
|
169
|
+
case 'get_unread_digest':
|
|
170
|
+
return await handleGetUnreadDigest(service, (args ?? {}));
|
|
171
|
+
case 'get_insight':
|
|
172
|
+
return await handleGetInsight(service, (args ?? {}));
|
|
173
|
+
case 'mark_read':
|
|
174
|
+
return await handleMarkRead(service, (args ?? {}));
|
|
175
|
+
case 'send_message':
|
|
176
|
+
return await handleSendMessage(service, (args ?? {}));
|
|
177
|
+
case 'send_image':
|
|
178
|
+
return await handleSendImage(service, (args ?? {}));
|
|
179
|
+
case 'send_file':
|
|
180
|
+
return await handleSendFile(service, (args ?? {}));
|
|
181
|
+
case 'send_audio':
|
|
182
|
+
return await handleSendAudio(service, (args ?? {}));
|
|
183
|
+
case 'send_video':
|
|
184
|
+
return await handleSendVideo(service, (args ?? {}));
|
|
185
|
+
case 'send_location':
|
|
186
|
+
return await handleSendLocation(service, (args ?? {}));
|
|
187
|
+
case 'send_contact':
|
|
188
|
+
return await handleSendContact(service, (args ?? {}));
|
|
189
|
+
case 'send_sticker':
|
|
190
|
+
return await handleSendSticker(service, (args ?? {}));
|
|
191
|
+
case 'list_stickers':
|
|
192
|
+
return await handleListStickers(service, (args ?? {}));
|
|
193
|
+
case 'search_stickers':
|
|
194
|
+
return await handleSearchStickers(service, (args ?? {}));
|
|
195
|
+
case 'preview_sticker':
|
|
196
|
+
return await handlePreviewSticker(service, (args ?? {}));
|
|
197
|
+
case 'find_contact':
|
|
198
|
+
return await handleFindContact(service, (args ?? {}));
|
|
199
|
+
case 'list_contacts':
|
|
200
|
+
return await handleListContacts(service);
|
|
201
|
+
case 'get_group_members':
|
|
202
|
+
return await handleGetGroupMembers(service, (args ?? {}));
|
|
203
|
+
case 'rename_group':
|
|
204
|
+
return await handleRenameGroup(service, (args ?? {}));
|
|
205
|
+
case 'invite_member':
|
|
206
|
+
return await handleInviteMember(service, (args ?? {}));
|
|
207
|
+
case 'kick_member':
|
|
208
|
+
return await handleKickMember(service, (args ?? {}));
|
|
209
|
+
case 'leave_group':
|
|
210
|
+
return await handleLeaveGroup(service, (args ?? {}));
|
|
211
|
+
case 'create_group':
|
|
212
|
+
return await handleCreateGroup(service, (args ?? {}));
|
|
213
|
+
case 'react_message':
|
|
214
|
+
return await handleReactMessage(service, (args ?? {}));
|
|
215
|
+
case 'cancel_reaction':
|
|
216
|
+
return await handleCancelReaction(service, (args ?? {}));
|
|
217
|
+
case 'unsend_message':
|
|
218
|
+
return await handleUnsendMessage(service, (args ?? {}));
|
|
219
|
+
case 'add_friend':
|
|
220
|
+
return await handleAddFriend(service, (args ?? {}));
|
|
221
|
+
case 'block_contact':
|
|
222
|
+
return await handleBlockContact(service, (args ?? {}));
|
|
223
|
+
case 'unblock_contact':
|
|
224
|
+
return await handleUnblockContact(service, (args ?? {}));
|
|
225
|
+
case 'accept_invitation':
|
|
226
|
+
return await handleAcceptInvitation(service, (args ?? {}));
|
|
227
|
+
case 'collect_messages':
|
|
228
|
+
return await handleCollectMessages(service, (args ?? {}));
|
|
229
|
+
case 'search_messages':
|
|
230
|
+
return await handleSearchMessages(service, (args ?? {}));
|
|
231
|
+
case 'exclude_chats':
|
|
232
|
+
return await handleExcludeChats((args ?? {}));
|
|
233
|
+
case 'include_chats':
|
|
234
|
+
return await handleIncludeChats((args ?? {}));
|
|
235
|
+
case 'list_excluded_chats':
|
|
236
|
+
return await handleListExcludedChats(service);
|
|
237
|
+
case 'get_scope_policy':
|
|
238
|
+
return await handleGetScopePolicy(service);
|
|
239
|
+
default:
|
|
240
|
+
return toolError(`Unknown tool: ${name}`);
|
|
241
|
+
}
|
|
283
242
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
243
|
+
catch (error) {
|
|
244
|
+
const message = error?.message ?? String(error);
|
|
245
|
+
// A mid-session LINE token invalidation (e.g. V3_TOKEN_CLIENT_LOGGED_OUT
|
|
246
|
+
// after a competing login) is not a tool bug — flag the service so
|
|
247
|
+
// subsequent calls short-circuit at the gate above, and translate the
|
|
248
|
+
// raw protocol error into an actionable re-login message.
|
|
249
|
+
if (isLineAuthInvalidatedError(error)) {
|
|
250
|
+
service.loginRequired = true;
|
|
251
|
+
service.loginReason = 'revoked';
|
|
252
|
+
log.warn('tool.session_revoked', { error: message, tool: name });
|
|
253
|
+
return sessionRevokedError(message);
|
|
254
|
+
}
|
|
255
|
+
log.error('tool.failed', { error: message, tool: name });
|
|
256
|
+
return toolError(message);
|
|
296
257
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
258
|
+
});
|
|
259
|
+
return server;
|
|
260
|
+
};
|
|
261
|
+
serveStdio(buildServer, {
|
|
262
|
+
legacy: 'serve',
|
|
263
|
+
onerror: (error) => log.error('server.protocol_error', { error: error.message }),
|
|
300
264
|
});
|
|
301
|
-
const transport = new StdioServerTransport();
|
|
302
|
-
await server.connect(transport);
|
|
303
265
|
log.info('server.started', { tools: TOOLS.length });
|
|
304
266
|
}
|
|
305
267
|
main().catch((error) => {
|
package/dist/mcp/tools.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
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
|
-
*/
|
|
1
|
+
import { PRIMARY_DEVICE_SETTING_PATH } from './handlers/login-copy.js';
|
|
13
2
|
export const TOOLS = [
|
|
14
3
|
{
|
|
15
|
-
description:
|
|
4
|
+
description: `Log in to LINE via the passwordless secondary-device flow. Requires ${PRIMARY_DEVICE_SETTING_PATH} enabled on the primary phone — with it off LINE never prompts that phone and NO login can succeed, so raise this with the human up front rather than after a failure. On MCP clients with form elicitation, this call first confirms that setting, then prompts for phone/region and PIN and completes login by itself; if the human says the setting is off, it returns the enabling steps without starting a login (relay them verbatim, then call \`login\` again). 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.`,
|
|
16
5
|
inputSchema: {
|
|
17
6
|
type: 'object',
|
|
18
7
|
properties: {
|
|
@@ -29,7 +18,7 @@ export const TOOLS = [
|
|
|
29
18
|
name: 'login',
|
|
30
19
|
},
|
|
31
20
|
{
|
|
32
|
-
description: "Finish a passwordless login that `login` started on a client without elicitation (not needed on elicitation-capable clients). No arguments. Call immediately after `login` returns — do not wait for the human. Blocks while they enter the PIN (skipped if a stored certificate is valid) and approve the device, then returns the profile. LINE's real deadline is ~3 minutes from PIN display. Errors if no login is pending.",
|
|
21
|
+
description: "Finish a passwordless login that `login` started on a client without form elicitation (not needed on form-elicitation-capable clients). No arguments. Call immediately after `login` returns — do not wait for the human. Blocks while they enter the PIN (skipped if a stored certificate is valid) and approve the device, then returns the profile. LINE's real deadline is ~3 minutes from PIN display. Errors if no login is pending.",
|
|
33
22
|
inputSchema: {
|
|
34
23
|
type: 'object',
|
|
35
24
|
properties: {},
|
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
|
/**
|