@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.
@@ -1,81 +1,23 @@
1
1
  /**
2
- * Yomi MCP server — LINE query + reply surface over stdio.
2
+ * Yomi MCP server.
3
3
  *
4
- * On startup resumes any persisted LINE session. Exposes forty-one tools:
5
- * login, login_complete, list_conversations, get_chat_messages,
6
- * get_message_image, get_message_media, get_unread_digest, get_insight,
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/sdk/server/index.js';
67
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
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 = 'SESSION ERRORS — if a tool fails with a login-required or signed-out ' +
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 server = new Server({ name: 'yomi', version: YOMI_VERSION }, { capabilities: { tools: {}, resources: {} }, instructions });
136
- // Ground truth for whether a connected client actually supports
137
- // elicitation (needed by the `login` tool) — observe it, don't assume it.
138
- server.oninitialized = () => {
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
- // MCP Apps UI resource (the `login` view) is only advertised to clients
145
- // that negotiated support for it (see ./ui/capability.ts) — a client
146
- // without it must see `resources/list` return empty and `login`'s schema
147
- // stay byte-for-byte what it always was.
148
- server.setRequestHandler(ListResourcesRequestSchema, async () => {
149
- const supportsUi = supportsMcpApps(server.getClientCapabilities());
150
- const count = supportsUi ? 1 : 0;
151
- log.info('resources.list', { supportsUi, count });
152
- return { resources: supportsUi ? [LOGIN_UI_RESOURCE_LISTING] : [] };
153
- });
154
- server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
155
- log.info('resources.read', { uri: request.params.uri });
156
- if (request.params.uri !== LOGIN_UI_RESOURCE_URI) {
157
- throw new Error(`Unknown resource: ${request.params.uri}`);
158
- }
159
- return { contents: [LOGIN_UI_RESOURCE_CONTENTS] };
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
- if (!service.client) {
194
- return sessionRequiredError();
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
- try {
198
- switch (name) {
199
- case 'login':
200
- return await handleLogin(server, service, (args ?? {}));
201
- case 'login_complete':
202
- return await handleLoginComplete();
203
- case 'list_conversations':
204
- return await handleListConversations(service, (args ?? {}));
205
- case 'get_chat_messages':
206
- return await handleGetChatMessages(service, (args ?? {}));
207
- case 'get_message_image':
208
- return await handleGetMessageImage(service, (args ?? {}));
209
- case 'get_message_media':
210
- return await handleGetMessageMedia(service, (args ?? {}));
211
- case 'get_unread_digest':
212
- return await handleGetUnreadDigest(service, (args ?? {}));
213
- case 'get_insight':
214
- return await handleGetInsight(service, (args ?? {}));
215
- case 'mark_read':
216
- return await handleMarkRead(service, (args ?? {}));
217
- case 'send_message':
218
- return await handleSendMessage(service, (args ?? {}));
219
- case 'send_image':
220
- return await handleSendImage(service, (args ?? {}));
221
- case 'send_file':
222
- return await handleSendFile(service, (args ?? {}));
223
- case 'send_audio':
224
- return await handleSendAudio(service, (args ?? {}));
225
- case 'send_video':
226
- return await handleSendVideo(service, (args ?? {}));
227
- case 'send_location':
228
- return await handleSendLocation(service, (args ?? {}));
229
- case 'send_contact':
230
- return await handleSendContact(service, (args ?? {}));
231
- case 'send_sticker':
232
- return await handleSendSticker(service, (args ?? {}));
233
- case 'list_stickers':
234
- return await handleListStickers(service, (args ?? {}));
235
- case 'search_stickers':
236
- return await handleSearchStickers(service, (args ?? {}));
237
- case 'preview_sticker':
238
- return await handlePreviewSticker(service, (args ?? {}));
239
- case 'find_contact':
240
- return await handleFindContact(service, (args ?? {}));
241
- case 'list_contacts':
242
- return await handleListContacts(service);
243
- case 'get_group_members':
244
- return await handleGetGroupMembers(service, (args ?? {}));
245
- case 'rename_group':
246
- return await handleRenameGroup(service, (args ?? {}));
247
- case 'invite_member':
248
- return await handleInviteMember(service, (args ?? {}));
249
- case 'kick_member':
250
- return await handleKickMember(service, (args ?? {}));
251
- case 'leave_group':
252
- return await handleLeaveGroup(service, (args ?? {}));
253
- case 'create_group':
254
- return await handleCreateGroup(service, (args ?? {}));
255
- case 'react_message':
256
- return await handleReactMessage(service, (args ?? {}));
257
- case 'cancel_reaction':
258
- return await handleCancelReaction(service, (args ?? {}));
259
- case 'unsend_message':
260
- return await handleUnsendMessage(service, (args ?? {}));
261
- case 'add_friend':
262
- return await handleAddFriend(service, (args ?? {}));
263
- case 'block_contact':
264
- return await handleBlockContact(service, (args ?? {}));
265
- case 'unblock_contact':
266
- return await handleUnblockContact(service, (args ?? {}));
267
- case 'accept_invitation':
268
- return await handleAcceptInvitation(service, (args ?? {}));
269
- case 'collect_messages':
270
- return await handleCollectMessages(service, (args ?? {}));
271
- case 'search_messages':
272
- return await handleSearchMessages(service, (args ?? {}));
273
- case 'exclude_chats':
274
- return await handleExcludeChats((args ?? {}));
275
- case 'include_chats':
276
- return await handleIncludeChats((args ?? {}));
277
- case 'list_excluded_chats':
278
- return await handleListExcludedChats(service);
279
- case 'get_scope_policy':
280
- return await handleGetScopePolicy(service);
281
- default:
282
- return toolError(`Unknown tool: ${name}`);
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
- catch (error) {
286
- const message = error?.message ?? String(error);
287
- // A mid-session LINE token invalidation (e.g. V3_TOKEN_CLIENT_LOGGED_OUT
288
- // after a competing login) is not a tool bug — flag the service so
289
- // subsequent calls short-circuit at the gate above, and translate the
290
- // raw protocol error into an actionable re-login message.
291
- if (isLineAuthInvalidatedError(error)) {
292
- service.loginRequired = true;
293
- service.loginReason = 'revoked';
294
- log.warn('tool.session_revoked', { error: message, tool: name });
295
- return sessionRevokedError(message);
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
- log.error('tool.failed', { error: message, tool: name });
298
- return toolError(message);
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: '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.',
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: {},
@@ -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, gated on client capability (see ./capability.ts) so a client
5
- * without MCP Apps support sees an empty resource list, unchanged from
6
- * before this feature existed.
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
- * but only for clients that negotiated MCP Apps support (see
4
- * ./capability.ts) — on a client without it, the tool list served must stay
5
- * byte-for-byte what it always was. Kept separate from ../tools.ts (a flat,
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
  /**