(text: string)
| 17 | |
| 18 | // Parse resource and polling updates from XML format |
| 19 | function parseUpdates(text: string): ParsedUpdate[] { |
| 20 | const updates: ParsedUpdate[] = []; |
| 21 | |
| 22 | // Match <mcp-resource-update server="..." uri="..."> |
| 23 | const resourceRegex = /<mcp-resource-update\s+server="([^"]+)"\s+uri="([^"]+)"[^>]*>(?:[\s\S]*?<reason>([^<]+)<\/reason>)?/g; |
| 24 | let match; |
| 25 | while ((match = resourceRegex.exec(text)) !== null) { |
| 26 | updates.push({ |
| 27 | kind: 'resource', |
| 28 | server: match[1] ?? '', |
| 29 | target: match[2] ?? '', |
| 30 | reason: match[3] |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | // Match <mcp-polling-update type="tool" server="..." tool="..."> |
| 35 | const pollingRegex = /<mcp-polling-update\s+type="([^"]+)"\s+server="([^"]+)"\s+tool="([^"]+)"[^>]*>(?:[\s\S]*?<reason>([^<]+)<\/reason>)?/g; |
| 36 | while ((match = pollingRegex.exec(text)) !== null) { |
| 37 | updates.push({ |
| 38 | kind: 'polling', |
| 39 | server: match[2] ?? '', |
| 40 | target: match[3] ?? '', |
| 41 | reason: match[4] |
| 42 | }); |
| 43 | } |
| 44 | return updates; |
| 45 | } |
| 46 | |
| 47 | // Format URI for display - show just the meaningful part |
| 48 | function formatUri(uri: string): string { |
no test coverage detected