Skip to content

fix: expose MCP health probes - #47

Merged
kl3inIT merged 1 commit into
mainfrom
fix/production-mcp-health-probes
Jul 25, 2026
Merged

fix: expose MCP health probes#47
kl3inIT merged 1 commit into
mainfrom
fix/production-mcp-health-probes

Conversation

@kl3inIT

@kl3inIT kl3inIT commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • permit MCP liveness/readiness probes without a bearer token
  • keep the public MCP endpoint authenticated and all other routes denied
  • add a Spring context security regression test

Verification

  • focused MCP context/security test passed
  • JetBrains inspection: production file has no new errors; existing toolSpecs qualifier false positive remains runtime-proven

Summary by CodeRabbit

  • New Features
    • Added public liveness and readiness health endpoints for monitoring availability.
  • Bug Fixes
    • Ensured health probes remain accessible without authentication while the MCP endpoint continues to require authentication.
  • Tests
    • Added endpoint checks confirming successful health responses and unauthorized access to the protected MCP endpoint.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The MCP security configuration now permits unauthenticated liveness and readiness actuator probes. Context tests use MockMvc to verify both probes return 200 and /mcp returns 401 without authentication.

Changes

Health probe security

Layer / File(s) Summary
Permit health probes and validate access
apps/mcp/src/main/java/com/orgmemory/mcp/McpSecurityConfiguration.java, apps/mcp/src/test/java/com/orgmemory/mcp/OrgMemoryMcpContextTests.java
Health liveness and readiness endpoints are added to the unauthenticated matchers, with MockMvc assertions covering probe accessibility and authentication enforcement for /mcp.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: exposing MCP health probes while keeping MCP authenticated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/production-mcp-health-probes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kl3inIT
kl3inIT merged commit 2cf3523 into main Jul 25, 2026
10 of 11 checks passed
@kl3inIT
kl3inIT deleted the fix/production-mcp-health-probes branch July 25, 2026 14:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/mcp/src/test/java/com/orgmemory/mcp/OrgMemoryMcpContextTests.java`:
- Around line 50-57: Extend
healthProbesRemainPublicWhileTheMcpEndpointRequiresAuthentication with a request
to a non-allowlisted route such as /unmatched, and assert that it returns 403
Forbidden while preserving the existing health and /mcp assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fef90ff0-c4cc-4f7a-8ac0-034f0063c7e0

📥 Commits

Reviewing files that changed from the base of the PR and between 2621302 and b0cb363.

⛔ Files ignored due to path filters (1)
  • docs/increments/active/2026-07-25-production-cicd-zm/design.md is excluded by !docs/**
📒 Files selected for processing (2)
  • apps/mcp/src/main/java/com/orgmemory/mcp/McpSecurityConfiguration.java
  • apps/mcp/src/test/java/com/orgmemory/mcp/OrgMemoryMcpContextTests.java
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Backend · Java 25
🧰 Additional context used
📓 Path-based instructions (2)
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

**/*: Record current behavior in architecture/specification documentation only after it exists in code; keep intended behavior in vision, roadmap, or an active increment, and do not duplicate state.
Before using unfamiliar Spring Boot 4, Spring Modulith 2, Spring AI 2, Gradle, React, Vite, Tailwind, or TypeScript APIs, consult current official documentation via Context7 and the project orgmemory-* verification skills.
Before retrieval, AI, MCP, permission, upload, graph, or export work, read docs/guidelines/agent-safety.md.
Never commit .env files, provider keys, tokens, or customer data.
Run the relevant verification gates from docs/guidelines/testing-harness.md; use a terminating clean test as the context gate, and do not treat bootRun as verification.

Files:

  • apps/mcp/src/main/java/com/orgmemory/mcp/McpSecurityConfiguration.java
  • apps/mcp/src/test/java/com/orgmemory/mcp/OrgMemoryMcpContextTests.java
**/*.{java,kt}

📄 CodeRabbit inference engine (CLAUDE.md)

JetBrains IDE inspection is a verification gate for the Java backend.

Files:

  • apps/mcp/src/main/java/com/orgmemory/mcp/McpSecurityConfiguration.java
  • apps/mcp/src/test/java/com/orgmemory/mcp/OrgMemoryMcpContextTests.java
🔇 Additional comments (2)
apps/mcp/src/main/java/com/orgmemory/mcp/McpSecurityConfiguration.java (1)

22-26: LGTM!

apps/mcp/src/test/java/com/orgmemory/mcp/OrgMemoryMcpContextTests.java (1)

5-22: LGTM!

Also applies to: 36-38

Comment on lines +50 to +57
@Test
void healthProbesRemainPublicWhileTheMcpEndpointRequiresAuthentication()
throws Exception {
mvc.perform(get("/actuator/health/liveness")).andExpect(status().isOk());
mvc.perform(get("/actuator/health/readiness")).andExpect(status().isOk());
mvc.perform(get("/mcp")).andExpect(status().isUnauthorized());
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the deny-all route contract.

Add an assertion for a non-allowlisted route, such as /unmatched, expecting 403 Forbidden; otherwise a regression that permits another route would remain undetected.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/mcp/src/test/java/com/orgmemory/mcp/OrgMemoryMcpContextTests.java`
around lines 50 - 57, Extend
healthProbesRemainPublicWhileTheMcpEndpointRequiresAuthentication with a request
to a non-allowlisted route such as /unmatched, and assert that it returns 403
Forbidden while preserving the existing health and /mcp assertions.

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