Skip to content

Comments

Refactor MCPClient and improve article handling#176

Merged
pethers merged 3 commits intomainfrom
news23
Feb 14, 2026
Merged

Refactor MCPClient and improve article handling#176
pethers merged 3 commits intomainfrom
news23

Conversation

@pethers
Copy link
Member

@pethers pethers commented Feb 14, 2026

Refactor MCPClient to support direct server and gateway modes, enhancing error handling and tool lookup. Improve article templates with RTL support and print styles, while updating tests for multi-language content and tool requirements. Fix party abbreviation detection in the extractPartyMentions function.

- Updated MCPClient to handle tool name prefixes based on the server type (direct vs. gateway).
- Added logic to skip prefixing for direct server requests and retry without prefix on tool not found errors.
- Enhanced error handling for tool lookup failures.
- Updated tests to verify correct behavior for both server types.
- Removed mock MCP responses as they are no longer needed.
- Added print styles and RTL support for news articles in CSS.
- Improved article template tests to ensure correct HTML structure for different languages.
- Added comprehensive tests for multi-language content labels and article content generation.
@pethers pethers requested a review from Copilot February 14, 2026 21:20
@github-actions
Copy link
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

@github-actions
Copy link
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the MCPClient to support both direct server connections and MCP gateway routing, improves multi-language article handling with comprehensive support for all 14 languages (including RTL for Arabic and Hebrew), and fixes party abbreviation detection edge cases. The changes align test expectations with actual implementation to prevent validation failures.

Changes:

  • Refactored MCPClient with auto-detection for gateway vs direct server modes, using prefixed tool names for gateway and unprefixed for direct server
  • Added comprehensive multi-language content labels (CONTENT_LABELS) covering all 14 supported languages with localized strings for article templates
  • Implemented RTL support (Arabic & Hebrew) with dir="rtl" attribute and CSS overrides for proper text direction, borders, and layout
  • Fixed party abbreviation detection regex to handle HTML tags and unified the pattern for all variants using Unicode-aware boundaries
  • Externalized article CSS from embedded styles to styles.css link for better maintainability and consistency
  • Updated test expectations to match actual tool usage in news-types modules (REQUIRED_TOOLS)
  • Added detailed safe-outputs MCP tool usage instructions in workflow documentation for GitHub Agentic Workflows

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
scripts/mcp-client.js Added gateway detection logic and skipPrefix parameter for fallback retry, improved error messages with tool lookup error detection
tests/mcp-client-core-part1.test.js Updated tests to expect unprefixed tool names for direct server mode, added test for gateway mode with prefixed names
tests/mcp-client-core-part2.test.js Updated all tool name assertions to expect unprefixed names for direct server URL
scripts/party-variants.js Unified regex pattern for all party variants using Unicode-aware boundaries, removing special-case logic for single-letter codes
tests/party-variants.test.js Added test cases for party abbreviations after HTML tags (MP, SD, KD)
scripts/data-transformers.js Added CONTENT_LABELS object with translations for all 14 languages, implemented L() helper function for localized content generation
tests/data-transformers.test.js Added comprehensive test suite for multi-language content labels and article generation
scripts/article-template.js Added RTL detection and dir attribute, externalized CSS to styles.css link, removed embedded CSS generation
tests/article-template.test.js Updated tests to verify external CSS link and RTL dir attribute for Arabic/Hebrew
styles.css Added print styles and RTL overrides for news articles
tests/news-types/week-ahead.test.js Aligned REQUIRED_TOOLS test to match actual implementation (single tool)
tests/news-types/committee-reports.test.js Aligned REQUIRED_TOOLS test to match actual implementation (single tool)
tests/fixtures/mock-mcp-responses.json Removed unused mock data file
package-lock.json Updated dependency resolution (removed peer flags, added enquirer as optional)
.github/workflows/news-realtime-monitor.md Added detailed safe-outputs MCP tool documentation and sandbox networking guidance
.github/workflows/news-evening-analysis.md Added safe-outputs MCP tool usage instructions and MCP gateway configuration
.github/workflows/news-article-generator.md Added MCP_SERVER_URL export and safe-outputs tool documentation

@pethers pethers merged commit c612a06 into main Feb 14, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant