tool-telemetry.mjs
38 lines 1.2 KB
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 11 days ago
1 /**
2 * MCP Phase H — progress notifications (notifications/progress) and logging (notifications/message).
3 * @see docs/MCP-PHASE-H.md
4 */
5
6 /**
7 * @param {Record<string, unknown>} extra - McpServer tool handler extra (from SDK)
8 * @param {{ progress: number, total?: number, message?: string }} params
9 */
10 export async function sendMcpToolProgress(extra, params) {
11 const token = extra?._meta?.progressToken;
12 if (token === undefined || typeof extra?.sendNotification !== 'function') return;
13 try {
14 await extra.sendNotification({
15 method: 'notifications/progress',
16 params: {
17 progressToken: token,
18 progress: params.progress,
19 ...(params.total !== undefined ? { total: params.total } : {}),
20 ...(params.message ? { message: params.message } : {}),
21 },
22 });
23 } catch (_) {
24 /* client may not support progress */
25 }
26 }
27
28 /**
29 * @param {import('@modelcontextprotocol/sdk/server/mcp.js').McpServer} mcpServer
30 * @param {'debug'|'info'|'notice'|'warning'|'error'|'critical'|'alert'|'emergency'} level
31 * @param {unknown} data
32 */
33 export async function sendMcpLog(mcpServer, level, data) {
34 if (!mcpServer?.isConnected?.()) return;
35 try {
36 await mcpServer.sendLoggingMessage({ level, data });
37 } catch (_) {}
38 }
File History 4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 11 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b fix(7C-L1b): route hosted delegation proposals through cani… Human minor 31 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 50 days ago