Skip to content

Implement MCP consumer for HTTP/WebSocket server endpoints#5

Merged
rdobrik merged 6 commits intomainfrom
copilot/implement-mcp-consumer-processors
Feb 9, 2026
Merged

Implement MCP consumer for HTTP/WebSocket server endpoints#5
rdobrik merged 6 commits intomainfrom
copilot/implement-mcp-consumer-processors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 9, 2026

Adds consumer implementation enabling Camel routes to act as MCP protocol servers via component URIs.

Changes

Consumer Implementation

  • McpConsumer.doStart() creates Undertow HTTP/WebSocket endpoints programmatically
  • Processor pipeline: size guard → HTTP validator → rate limit → JSON-RPC envelope parser → user processor → JSON serialization
  • McpConsumer.doStop() handles cleanup and server shutdown
  • Exchange properties populated: mcp.jsonrpc.method, mcp.jsonrpc.id, mcp.jsonrpc.type, mcp.tool.name

Configuration

  • Added consumer options to McpConfiguration: websocket, sendToAll, allowedOrigins, httpMethodRestrict
  • Fixed McpComponent to set URI from remaining path parameter

Testing

  • McpConsumerTest covers HTTP/WebSocket startup, JSON-RPC parsing, lifecycle management
  • 86/86 tests passing (4 new consumer tests)

Usage

// HTTP server
from("mcp:http://localhost:8080/mcp")
    .process(exchange -> {
        String method = exchange.getProperty("mcp.jsonrpc.method", String.class);
        // Handle MCP request, return Map response
    });

// WebSocket server
from("mcp:http://localhost:8090/mcp?websocket=true")
    .process(myMcpProcessor);

YAML:

- route:
    id: mcp-server
    from:
      uri: "mcp:http://0.0.0.0:8080/mcp"
      steps:
        - choice:
            when:
              - simple: "${exchangeProperty.mcp.jsonrpc.method} == 'tools/list'"
                steps:
                  - setBody: # MCP response

Requests require headers: Content-Type: application/json, Accept: application/json, text/event-stream

Original prompt

This section details on the original issue you should resolve

<issue_title>Implement fully compatible MCP consumer processors (HTTP and WebSocket support, with implementation plan and acceptance test plan)</issue_title>
<issue_description>Implement the MCP consumer side so that Camel endpoints can act as MCP protocol servers, fully handling JSON-RPC 2.0 requests (e.g., initialize, tools/list, tools/call) per the MCP specification.

Requirements:

  • Integrate both HTTP and WebSocket listeners (Undertow or equivalent) to receive incoming JSON-RPC requests on configurable endpoints.
  • Unmarshal incoming requests as MCP protocol messages using Jackson (reusing producer-side ObjectMapper logic).
  • Route requests via Camel's Processor abstraction, returning correct MCP response objects with appropriate schema and error handling.
  • Ensure consumer coverage for all standard MCP methods (initialize, resources/list, resources/get, tools/call).
  • Provide robust error, startup, and shutdown handling within the Camel component lifecycle.

Relevant code references for the MCP consumer processor implementation:

  • McpEndpoint.java: Exposes createConsumer(Processor processor) returning a new McpConsumer.
  • McpConsumer.java: Skeleton/stub for the consumer, with doStart() placeholder for HTTP/WebSocket integration.
  • processor/: JSON-RPC request/response helpers and individual MCP method processors (e.g., McpResourcesGetProcessor, McpResourcesListProcessor, McpInitializeProcessor).
  • README project layout: Directory and class structure overview for consumer, producer, and processor code.
  • Related planning and implementation notes: CAMEL_MCP_APPS_BRIDGE_PLAN.md
  • Acceptance and integration test plan: docs/TEST_PLAN.md

Acceptance Criteria:

  • An MCPConsumer can be configured via endpoint URI and starts listening on both HTTP and WebSocket endpoints
  • JSON-RPC 2.0 requests are correctly deserialized, routed, and responded to over both protocols
  • Unit and YAML route tests cover all successful, error, and edge case behaviors for the consumer processor
  • Task and architecture plan is provided in CAMEL_MCP_APPS_BRIDGE_PLAN.md (extend if necessary with consumer support sections)
  • End-to-end acceptance testing is covered explicitly in docs/TEST_PLAN.md and must validate all critical MCP workflows (HTTP & WebSocket) including initialize, resources/list, resources/get, tools/list, tools/call, and error/notification flows.

See architecture notes and TODOs in McpConsumer.java, docs/architecture.md, CAMEL_MCP_APPS_BRIDGE_PLAN.md, and docs/TEST_PLAN.md for additional implementation and acceptance test background.</issue_description>

Comments on the Issue (you are @copilot in this section)


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

@rdobrik
Copy link
Copy Markdown
Contributor

rdobrik commented Feb 9, 2026

Use Java 21

@rdobrik rdobrik requested a review from Copilot February 9, 2026 19:31
Copy link
Copy Markdown

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.

Copilot wasn't able to review any files in this pull request.

Copilot AI and others added 4 commits February 9, 2026 19:38
- Enhanced McpConfiguration with consumer-specific options (websocket, sendToAll, allowedOrigins, httpMethodRestrict)
- Implemented McpConsumer.doStart() to programmatically create Undertow HTTP/WebSocket endpoints
- Added processor chain integration: request size guard, rate limit, JSON-RPC envelope parsing, user processor
- Added automatic JSON serialization of response bodies
- Implemented proper shutdown in McpConsumer.doStop()
- Created McpConsumerTest with HTTP and WebSocket test scenarios
- Consumer wraps Undertow component to provide MCP server functionality via component URIs

Co-authored-by: rdobrik <8812511+rdobrik@users.noreply.github.com>
- Fixed test to include proper MCP headers (Content-Type, Accept)
- Added error handling and logging in consumer processor chain
- Updated WebSocket test to verify context and route startup
- All 4 McpConsumer tests now pass
- Full test suite (86 tests) passes successfully
- Consumer correctly serializes JSON responses
- Consumer properly integrates MCP processor pipeline

Co-authored-by: rdobrik <8812511+rdobrik@users.noreply.github.com>
- Updated README.md with consumer/server mode examples (Java and YAML)
- Added consumer configuration options to Configuration section
- Updated docs/architecture.md with detailed consumer flow diagram
- Extended docs/TEST_PLAN.md with consumer test scenarios and automation info
- Updated CAMEL_MCP_APPS_BRIDGE_PLAN.md with consumer implementation status
- Documented exchange properties set by consumer
- Included usage examples for HTTP and WebSocket servers
- All tests still passing (86/86)

Co-authored-by: rdobrik <8812511+rdobrik@users.noreply.github.com>
- Improved JSON serialization error messages with body type and preview
- Removed debug print statement from test
- Refactored duplicated query parameter appending logic into helper method
- All 86 tests passing

Co-authored-by: rdobrik <8812511+rdobrik@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement fully compatible MCP consumer processors Implement MCP consumer for HTTP/WebSocket server endpoints Feb 9, 2026
- Introduced `McpComponentConfigurer` and `McpEndpointConfigurer` for configuring component and endpoint properties.
- Created `McpEndpointUriFactory` to support URI creation for MCP endpoints.
- Added logging configuration for the MCP consumer.
- Generated JSON metadata for the MCP component, including properties and supported methods.
- Implemented Karavan metadata generation for MCP component and kamelets.
- Added documentation for the MCP component, including usage examples for producer and consumer.
- Created kamelet descriptors for MCP REST and WebSocket services.
@rdobrik rdobrik marked this pull request as ready for review February 9, 2026 22:10
@rdobrik rdobrik merged commit 40091a0 into main Feb 9, 2026
1 check passed
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.

Implement fully compatible MCP consumer processors (HTTP and WebSocket support, with implementation plan and acceptance test plan)

3 participants