feat: tag MCP health check requests with BifrostContextKeyMCPHealthCheckRequest context marker - #4207
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds a context flag to distinguish internal MCP health-check requests from regular caller-initiated requests. The constant is defined, protected as a reserved key to prevent caller overwrites, and applied when performing health checks to propagate the indicator through hooks. ChangesHealth-check request context flag
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
|
Confidence Score: 5/5Safe to merge — the change is purely additive plumbing with no mutations to existing request paths or plugin ordering. The BifrostContext wrapper is created correctly: the timeout deadline propagates via parent lookup, the watchCancellation goroutine exits promptly when defer cancel() fires, and the marker is visible to plugin hooks through the standard parent-delegation chain inside gateCtx.Value(). The reservedKeys addition follows the established pattern. No existing call sites are altered beyond the context construction in performHealthCheck. No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "feat: adds healthcheck info in ctx for m..." | Re-trigger Greptile |
560574c to
b8e13bb
Compare
1b7031f to
21740c1
Compare
Merge activity
|
b8e13bb to
1ab318f
Compare
…heckRequest` context marker (#4207) ## Summary Introduces a new context key, `BifrostContextKeyMCPHealthCheckRequest`, that marks MCP ping and `list_tools` requests as internally generated by Bifrost's health monitor. This allows plugins, hooks, and other middleware to distinguish these internal probes from caller-initiated requests. ## Changes - Added `BifrostContextKeyMCPHealthCheckRequest` context key (`"bifrost-mcp-health-check-request"`) to the set of reserved Bifrost context keys. - In `performHealthCheck`, the timeout context is now wrapped in a `BifrostContext` with the new key set to `true` before being passed to `runPingWithHooks` / `runListToolsWithHooks`, ensuring the marker propagates through the entire health check call chain. - The key is reserved (added to `reservedKeys`) so it cannot be overridden externally — the comment explicitly notes it should not be set manually. ## Type of change - [ ] Bug fix - [x] Feature - [ ] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [x] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [x] Plugins - [ ] UI (React) - [ ] Docs ## How to test Write a plugin or hook that inspects the incoming context for `BifrostContextKeyMCPHealthCheckRequest`. Trigger a health check cycle and verify the key is present and set to `true` for ping/list_tools probes, while being absent for normal caller-initiated requests. ```sh go test ./... ``` ## Breaking changes - [ ] Yes - [x] No ## Security considerations The new context key is reserved and explicitly documented as not to be set manually, preventing external callers from spoofing health check requests to bypass plugin logic that gates on this marker. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
Introduces a new context key,
BifrostContextKeyMCPHealthCheckRequest, that marks MCP ping andlist_toolsrequests as internally generated by Bifrost's health monitor. This allows plugins, hooks, and other middleware to distinguish these internal probes from caller-initiated requests.Changes
BifrostContextKeyMCPHealthCheckRequestcontext key ("bifrost-mcp-health-check-request") to the set of reserved Bifrost context keys.performHealthCheck, the timeout context is now wrapped in aBifrostContextwith the new key set totruebefore being passed torunPingWithHooks/runListToolsWithHooks, ensuring the marker propagates through the entire health check call chain.reservedKeys) so it cannot be overridden externally — the comment explicitly notes it should not be set manually.Type of change
Affected areas
How to test
Write a plugin or hook that inspects the incoming context for
BifrostContextKeyMCPHealthCheckRequest. Trigger a health check cycle and verify the key is present and set totruefor ping/list_tools probes, while being absent for normal caller-initiated requests.go test ./...Breaking changes
Security considerations
The new context key is reserved and explicitly documented as not to be set manually, preventing external callers from spoofing health check requests to bypass plugin logic that gates on this marker.
Checklist
docs/contributing/README.mdand followed the guidelinesSummary by CodeRabbit