Skip to content

Integrate World Bank MCP server for economic context in news generation#653

Open
Copilot wants to merge 5 commits intomainfrom
copilot/analyze-news-generation-improvements
Open

Integrate World Bank MCP server for economic context in news generation#653
Copilot wants to merge 5 commits intomainfrom
copilot/analyze-news-generation-improvements

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

  • Analyze World Bank MCP Server capabilities
  • Add World Bank MCP server to .github/copilot-mcp.json (pinned @smithery/cli@4.4.0)
  • Create scripts/world-bank-client.ts — REST client with date-descending sort
  • Create scripts/world-bank-context.ts — Economic context with empty-query guard and Swedish inflection support
  • Integrate economic context detection into scripts/article-quality-enhancer.ts
  • Update workflow files with World Bank data instructions
  • Add tests (69 world-bank tests, 2106 total passing)
  • Address PR review feedback:
    • Sort getIndicator() results by date descending
    • Change WorldBankDataPoint.value type to number (nulls already filtered)
    • Guard findRelevantIndicators() against empty/whitespace queries
    • Fix Swedish patterns to match inflected forms (försvarsutgifterna, forskningsutgifterna)
    • Pin @smithery/cli to 4.4.0 for reproducibility

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Add world-bank MCP server to .github/copilot-mcp.json
- Create scripts/world-bank-client.ts (TypeScript REST client for World Bank API)
- Create scripts/world-bank-context.ts (economic context provider with Swedish indicators)
- Integrate economic context detection into article-quality-enhancer.ts
- Update news-evening-analysis.md workflow with World Bank data instructions
- Update news-article-generator.md workflow with World Bank reference
- Add tests/world-bank-client.test.ts (30 tests)
- Add tests/world-bank-context.test.ts (35 tests)
- All 2102 tests pass

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions github-actions bot added documentation Documentation updates workflow GitHub Actions workflows riksdag-data Riksdag-Regering MCP data ci-cd CI/CD pipeline changes testing Test coverage refactor Code refactoring news News articles and content generation agentic-workflow Agentic workflow changes size-xl Extra large change (> 1000 lines) labels Feb 28, 2026
@github-actions
Copy link
Contributor

🏷️ Automatic Labeling Summary

This PR has been automatically labeled based on the files changed and PR metadata.

Applied Labels: documentation,workflow,riksdag-data,ci-cd,testing,refactor,size-xl,news,agentic-workflow

Label Categories

  • 🗳️ Content: news, dashboard, visualization, intelligence
  • 💻 Technology: html-css, javascript, workflow, security
  • 📊 Data: cia-data, riksdag-data, data-pipeline, schema
  • 🌍 I18n: i18n, translation, rtl
  • 🔒 ISMS: isms, iso-27001, nist-csf, cis-controls
  • 🏗️ Infrastructure: ci-cd, deployment, performance, monitoring
  • 🔄 Quality: testing, accessibility, documentation, refactor
  • 🤖 AI: agent, skill, agentic-workflow

For more information, see .github/labeler.yml.

@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

…egex comment

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze use of world_bank_mcp_server for news generation Integrate World Bank MCP server for economic context in news generation Feb 28, 2026
@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

Integrates World Bank economic indicator support into the news-generation toolchain to optionally enrich articles with macroeconomic context and to surface a non-blocking quality recommendation for including that context.

Changes:

  • Added a World Bank REST client and an economic-context mapping/provider (indicators → policy areas/committees + localized headings).
  • Extended article quality scoring inputs with an optional hasEconomicContext metric and a non-blocking “recommend economic context” warning.
  • Updated agentic workflow docs and added Vitest coverage for the new client/context modules.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
scripts/world-bank-client.ts New World Bank API client with retry/timeout, indicator/country constants, and helper methods.
scripts/world-bank-context.ts New indicator→policy/committee mapping, localized section headings, and economic-context detection helpers.
scripts/article-quality-enhancer.ts Adds hasEconomicContext metric collection and a non-blocking recommendation warning.
scripts/types/validation.ts Extends QualityThresholds/QualityMetrics with optional economic-context fields.
tests/world-bank-client.test.ts Unit tests for client behavior (fetching, retry, error handling, compareCountries, constants).
tests/world-bank-context.test.ts Unit tests for mappings, headings, indicator lookup, and context detection.
.github/workflows/news-evening-analysis.md Documents optional World Bank MCP usage and indicator references for evening analysis.
.github/workflows/news-article-generator.md Documents optional World Bank MCP usage and indicator references for article generation.
.github/copilot-mcp.json Adds world-bank MCP server configuration via @smithery/cli.

Comment on lines +150 to +154
return (data[1] as RawIndicatorValue[])
.filter((item): item is RawIndicatorValue & { value: number } => item.value !== null && item.value !== undefined)
.map((item) => ({
countryId: item.country?.id ?? countryCode,
countryName: item.country?.value ?? countryCode,
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

getIndicator()’s JSDoc says results are sorted by date descending, but the implementation currently returns the API order without sorting. Since getLatestIndicator() and compareCountries() assume index 0 is the most recent, please sort the mapped results by numeric year (descending) (and optionally push empty/invalid dates to the end) before returning.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a75983e. getIndicator() now sorts mapped results by numeric year descending, with invalid/empty dates pushed to the end. Added a dedicated test should sort results by date descending that verifies out-of-order API responses are correctly reordered.

readonly indicatorId: string;
readonly indicatorName: string;
readonly date: string;
readonly value: number | null;
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

WorldBankDataPoint.value is typed as number | null, but getIndicator() filters out all null/undefined values, so callers will never see a data point with value: null. To avoid confusion for API consumers, either (a) change the type to number for returned data points (and keep filtering), or (b) stop filtering and let value be null when the API reports missing data (and update getLatestIndicator() accordingly).

Suggested change
readonly value: number | null;
readonly value: number;

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a75983e. Changed value type from number | null to number since the filter already excludes all null/undefined entries before returning.

Comment on lines 270 to 274
const lowerQuery = query.toLowerCase();
return ECONOMIC_INDICATORS.filter(
(indicator) =>
indicator.policyAreas.some((area) => area.toLowerCase().includes(lowerQuery)) ||
indicator.committees.some((c) => c.toLowerCase() === lowerQuery),
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

findRelevantIndicators() lowercases the query but doesn’t trim or guard against an empty/whitespace query. Because "" is contained in every string, an empty query will match every indicator via includes(''). Consider using const q = query.trim().toLowerCase(); and returning [] early when q.length === 0.

Suggested change
const lowerQuery = query.toLowerCase();
return ECONOMIC_INDICATORS.filter(
(indicator) =>
indicator.policyAreas.some((area) => area.toLowerCase().includes(lowerQuery)) ||
indicator.committees.some((c) => c.toLowerCase() === lowerQuery),
const q = query.trim().toLowerCase();
if (q.length === 0) {
return [];
}
return ECONOMIC_INDICATORS.filter(
(indicator) =>
indicator.policyAreas.some((area) => area.toLowerCase().includes(q)) ||
indicator.committees.some((c) => c.toLowerCase() === q),

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a75983e. findRelevantIndicators() now trims and checks for empty query, returning [] early when q.length === 0. Added tests for both empty string and whitespace-only inputs.

Comment on lines 312 to 313
/\bförsvarsutgifter\b/i, // Swedish: defense expenditure
/\bforskningsutgifter\b/i, // Swedish: R&D expenditure
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

In hasEconomicContext(), patterns like \bförsvarsutgifter\b / \bforskningsutgifter\b will miss common inflected forms (e.g. försvarsutgifterna, forskningsutgifterna) due to the trailing word-boundary. Consider matching on the stem (e.g. försvarsutgift / forskningsutgift) or relaxing the end boundary so plural/definite forms are detected too.

Suggested change
/\bförsvarsutgifter\b/i, // Swedish: defense expenditure
/\bforskningsutgifter\b/i, // Swedish: R&D expenditure
/\bförsvarsutgift/i, // Swedish: defense expenditure (försvarsutgift, försvarsutgifter, försvarsutgifterna, etc.)
/\bforskningsutgift/i, // Swedish: R&D expenditure (forskningsutgift, forskningsutgifter, forskningsutgifterna, etc.)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a75983e. Changed /\bförsvarsutgifter\b/i/\bförsvarsutgift/i and /\bforskningsutgifter\b/i/\bforskningsutgift/i to match the stem, covering definite/plural forms (försvarsutgifterna, forskningsutgifterna, etc.). Added a test should detect Swedish inflected forms (definite, plural) for these patterns.

Comment on lines 12 to 16
"-y",
"@smithery/cli@latest",
"run",
"@anshumax/world_bank_mcp_server"
],
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

The new MCP server config uses npx -y @smithery/cli@latest run @anshumax/world_bank_mcp_server which pulls whatever versions are current at runtime. For reproducibility and supply-chain risk reduction, consider pinning both packages to explicit versions (and updating them deliberately via dependency bumps).

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a75983e. Pinned @smithery/cli to 4.4.0. Note: @anshumax/world_bank_mcp_server is a Python package (v0.1.0) hosted on Smithery's registry — it doesn't support npm-style version pinning in the run command. The @smithery/cli version pin controls the client-side tooling.

@pethers
Copy link
Member

pethers commented Feb 28, 2026

@copilot apply changes based on the comments in this thread

…wedish inflections, pin versions

- Sort getIndicator() results by date descending (most recent first)
- Change WorldBankDataPoint.value type from `number | null` to `number`
- Guard findRelevantIndicators() against empty/whitespace queries
- Fix Swedish word patterns to match inflected forms (försvarsutgifterna, etc.)
- Pin @smithery/cli to v4.4.0 for supply-chain safety
- Add 4 new tests covering sort, empty query, inflected forms

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 28, 2026

@copilot apply changes based on the comments in this thread

All 5 review comments addressed in a75983e:

  1. getIndicator() now sorts by date descending
  2. WorldBankDataPoint.value type narrowed to number
  3. findRelevantIndicators() guards against empty/whitespace
  4. Swedish patterns match inflected forms (stem-based matching)
  5. @smithery/cli pinned to 4.4.0

4 new tests added, 2106 total passing.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • registry.smithery.ai
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@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

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

@pethers pethers marked this pull request as ready for review February 28, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentic-workflow Agentic workflow changes ci-cd CI/CD pipeline changes documentation Documentation updates news News articles and content generation refactor Code refactoring riksdag-data Riksdag-Regering MCP data size-xl Extra large change (> 1000 lines) testing Test coverage workflow GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants