Skip to content

Move HttpTransport hook registration to boot()#222

Open
mathetos wants to merge 1 commit into
WordPress:trunkfrom
mathetos:fix/http-transport-boot-lifecycle
Open

Move HttpTransport hook registration to boot()#222
mathetos wants to merge 1 commit into
WordPress:trunkfrom
mathetos:fix/http-transport-boot-lifecycle

Conversation

@mathetos

Copy link
Copy Markdown

Summary

Follow-up to #52 (review comment on #48): HttpTransport no longer registers
est_api_init in its constructor.

  • Add boot() to McpTransportInterface for WordPress hook registration after construction
  • McpTransportFactory calls boot() immediately after instantiating each transport
  • HttpTransport::boot() keeps the existing rest_api_init priority (16) behavior
  • Update custom transport docs and add a small unit test for the boot lifecycle

Motivation

Constructors should set up dependencies only; hook registration is explicit and easier to test in isolation. Happy to adjust naming or scope if maintainers prefer a lighter-touch approach (e.g. factory-only hook without an interface change).

Closes #52

Test plan

  • CI unit/integration suite passes
  • HttpTransportBootTest confirms the constructor does not register hooks and boot() registers rest_api_init at priority 16
  • Smoke: MCP REST route still resolves after plugin activation (rest_url( 'mcp/mcp-adapter-default-server' ))

Add boot() to McpTransportInterface so transports register WordPress hooks
after construction. McpTransportFactory calls boot() immediately after
instantiation. Closes WordPress#52.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mathetos <webdevmattcrom@git.wordpress.org>
Co-authored-by: galatanovidiu <ovidiu-galatan@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.86%. Comparing base (90252e7) to head (08a2b4d).

Additional details and impacted files
@@            Coverage Diff            @@
##              trunk     #222   +/-   ##
=========================================
  Coverage     87.86%   87.86%           
- Complexity     1245     1246    +1     
=========================================
  Files            53       53           
  Lines          4037     4039    +2     
=========================================
+ Hits           3547     3549    +2     
  Misses          490      490           
Flag Coverage Δ
unit 87.86% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Follow-up #48: Can we move this to an initialize() method or somewhere else? I think it's better to not have hooks as a side-effect of constructors.

1 participant