Skip to content

test(mcp-integrations): add MCP plugin and backend integration tests#3232

Open
HusneShabbir wants to merge 2 commits into
redhat-developer:mainfrom
HusneShabbir:test/mcp-integrations-integration-tests
Open

test(mcp-integrations): add MCP plugin and backend integration tests#3232
HusneShabbir wants to merge 2 commits into
redhat-developer:mainfrom
HusneShabbir:test/mcp-integrations-integration-tests

Conversation

@HusneShabbir
Copy link
Copy Markdown
Contributor

@HusneShabbir HusneShabbir commented May 24, 2026

Summary

Adds integration tests for MCP overlay plugins: lightweight plugin wiring checks (action registration) and a backend HTTP suite against /api/mcp-actions/v1 (tools/list, tools/call, auth).

Also adds test:unit / test:integration scripts (--watch=false so local runs exit instead of staying in Backstage’s default Jest watch mode) and backend test dependencies for the MCP client.

Test file structure

workspaces/mcp-integrations/
├── plugins/
│   ├── software-catalog-mcp-extras/src/
│   │   └── plugin.integration.test.ts          # 1 test
│   ├── techdocs-mcp-extras/src/
│   │   └── plugin.integration.test.ts          # 1 test
│   └── scaffolder-mcp-extras/src/
│       └── plugin.integration.test.ts          # 1 test
└── packages/backend/src/
    └── mcp-tools.integration.test.ts           # 8 tests

Total: 4 files · 11 integration tests (included in CI via yarn test:all)


Plugin tests — “does the plugin register the right actions?”

Each file starts startTestBackend, captures actionsRegistry.register(), and asserts action names and count.

File Actions
software-catalog-mcp-extras/.../plugin.integration.test.ts query-catalog-entities (1)
techdocs-mcp-extras/.../plugin.integration.test.ts fetch-techdocs, analyze-techdocs-coverage, retrieve-techdocs-content (3)
scaffolder-mcp-extras/.../plugin.integration.test.ts execute-template, fetch-template-metadata, get-scaffolder-task-logs, list-scaffolder-actions, list-scaffolder-tasks, validate-scaffolder (6)

Backend test — “does the MCP server work over HTTP?”

packages/backend/src/mcp-tools.integration.test.ts — Streamable HTTP MCP client against a real test backend (shared backend for full pluginSources; MCP session teardown via terminateSession + client.close).

Group Scenario
tools/list (all sources) 10 overlay tools, names, descriptions, inputSchema, read-only/destructive MCP hints (actions that declare attributes only)
tools/call query-catalog-entities{ entities: [] }
analyze-techdocs-coverage → zero coverage stats
fetch-template-metadata{ templates: [] }
pluginSources Catalog-only config → single query-catalog-entities tool
auth Missing / invalid Bearer → 401 with expected error message
Valid Bearer → tools/list succeeds

Supporting changes

  • attributes on fetch-techdocs and retrieve-techdocs-content (read-only MCP hints covered by the backend test; scaffolder read-only/destructive tools already had attributes on main)
  • Backend devDependencies: @backstage/backend-test-utils, @modelcontextprotocol/sdk, @backstage/backend-plugin-api, @backstage/errors, @backstage/plugin-catalog-node
  • Scripts: workspace + plugin test:unit / test:integration; backend test:integration for the HTTP suite; --watch=false on integration scripts so they exit locally (CI already sets CI=true)

CI

When workspaces/mcp-integrations changes, Test changed packages runs yarn test:all, which includes these integration tests alongside existing unit tests (no separate job required).

@rhdh-gh-app
Copy link
Copy Markdown

rhdh-gh-app Bot commented May 24, 2026

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @red-hat-developer-hub/backstage-plugin-scaffolder-mcp-extras
  • @red-hat-developer-hub/backstage-plugin-software-catalog-mcp-extras
  • @red-hat-developer-hub/backstage-plugin-techdocs-mcp-extras

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
backend workspaces/mcp-integrations/packages/backend none v0.0.0
@red-hat-developer-hub/backstage-plugin-scaffolder-mcp-extras workspaces/mcp-integrations/plugins/scaffolder-mcp-extras none v0.4.2
@red-hat-developer-hub/backstage-plugin-software-catalog-mcp-extras workspaces/mcp-integrations/plugins/software-catalog-mcp-extras none v0.2.3
@red-hat-developer-hub/backstage-plugin-techdocs-mcp-extras workspaces/mcp-integrations/plugins/techdocs-mcp-extras none v0.2.4

@HusneShabbir HusneShabbir requested a review from jrichter1 May 24, 2026 08:39
@codecov
Copy link
Copy Markdown

codecov Bot commented May 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.00%. Comparing base (815580b) to head (d638018).
⚠️ Report is 34 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3232      +/-   ##
==========================================
+ Coverage   60.97%   61.00%   +0.03%     
==========================================
  Files        2098     2098              
  Lines       65140    65150      +10     
  Branches    17029    17029              
==========================================
+ Hits        39721    39747      +26     
+ Misses      25180    25164      -16     
  Partials      239      239              
Flag Coverage Δ *Carryforward flag
adoption-insights 83.58% <ø> (ø) Carriedforward from 827b7fe
ai-integrations 70.03% <ø> (ø) Carriedforward from 827b7fe
app-defaults 69.60% <ø> (ø) Carriedforward from 827b7fe
augment 69.36% <ø> (ø) Carriedforward from 827b7fe
bulk-import 72.86% <ø> (ø) Carriedforward from 827b7fe
cost-management 16.49% <ø> (ø) Carriedforward from 827b7fe
dcm 32.85% <ø> (ø) Carriedforward from 827b7fe
extensions 61.79% <ø> (ø) Carriedforward from 827b7fe
global-floating-action-button 74.30% <ø> (ø) Carriedforward from 827b7fe
global-header 61.68% <ø> (ø) Carriedforward from 827b7fe
homepage 50.95% <ø> (ø) Carriedforward from 827b7fe
konflux 91.01% <ø> (ø) Carriedforward from 827b7fe
lightspeed 68.33% <ø> (ø) Carriedforward from 827b7fe
mcp-integrations 85.46% <ø> (+3.86%) ⬆️
orchestrator 36.36% <ø> (ø) Carriedforward from 827b7fe
quickstart 62.88% <ø> (ø) Carriedforward from 827b7fe
sandbox 79.42% <ø> (ø) Carriedforward from 827b7fe
scorecard 83.72% <ø> (ø) Carriedforward from 827b7fe
theme 64.54% <ø> (ø) Carriedforward from 827b7fe
translations 8.49% <ø> (ø) Carriedforward from 827b7fe
x2a 78.28% <ø> (ø) Carriedforward from 827b7fe

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 815580b...d638018. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@HusneShabbir HusneShabbir force-pushed the test/mcp-integrations-integration-tests branch 2 times, most recently from 4921c97 to f1a9e17 Compare May 24, 2026 10:46
Add integration tests for action registration and MCP tools/list/call coverage,
including auth and pluginSources filtering. Mark read-only actions with MCP
attributes and configure backend test runner to exit cleanly after integration runs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@HusneShabbir HusneShabbir force-pushed the test/mcp-integrations-integration-tests branch from f1a9e17 to 827b7fe Compare May 24, 2026 10:52
Copy link
Copy Markdown
Member

@johnmcollier johnmcollier left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good, left some review comments. Also make sure you add changesets for the changed plugins

Comment thread workspaces/mcp-integrations/packages/backend/src/mcp-tools.integration.test.ts Outdated
Comment thread workspaces/mcp-integrations/packages/backend/package.json Outdated
Remove MCP readOnly attributes on actions not covered by hint assertions.
Consolidate backend integration tests, tighten 401 auth checks, and add
test:unit/test:integration scripts with --watch=false for clean local exits.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud
Copy link
Copy Markdown

@HusneShabbir HusneShabbir requested a review from johnmcollier May 26, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants