Skip to content

Add support for MCP Camel consumer over WebSockets #1

@rdobrik

Description

@rdobrik

Feature Request: MCP Camel Consumer Over WebSockets

Goal:
Enable the MCP Camel consumer to receive and process messages over WebSockets, allowing real-time bidirectional MCP JSON-RPC communication in addition to existing HTTP flows.

Background:

  • The core MCP Camel consumer logic resides in src/main/java/io/dscope/camel/mcp/McpConsumer.java, which currently acts as a stub with a placeholder for Undertow listener integration.
  • The MCP endpoint and component classes (McpEndpoint, McpComponent) are found in the same package and are responsible for configuration and consumer instantiation.
  • Existing sample flows for HTTP and WebSocket endpoints are managed in samples/mcp-service and described in the sample README. WebSocket endpoints are exposed at ws://localhost:8090/mcp.
  • The sample service boots both HTTP and WebSocket helper routes, using YAML configuration (routes/mcp-service-ws.yaml).

Proposed Solution:

  • Implement the missing WebSocket server logic in McpConsumer using Undertow (or Camel’s built-in WebSocket support).
  • Ensure compatibility with existing MCP JSON-RPC methods (initialize, ping, resources/get, tools/list, tools/call).
  • Support per-connection replies according to the documented wscat usage:
    • Example: { "jsonrpc": "2.0", "id": "ws-1", "method": "resources/get", ... }
  • Add configuration options to select HTTP or WebSocket consumer mode.
  • Document sample usage and update the integration tests.

Relevant Code:

public class McpConsumer extends DefaultConsumer {
    private final McpEndpoint endpoint;
    public McpConsumer(McpEndpoint endpoint, Processor processor) {
        super(endpoint, processor);
        this.endpoint = endpoint;
    }
    @Override
    protected void doStart() throws Exception {
        super.doStart();
        // Placeholder for Undertow listener integration
    }
}
public class McpEndpoint extends DefaultEndpoint {
    ...
    @Override public Consumer createConsumer(Processor processor) { return new McpConsumer(this, processor); }
    ...
}

Acceptance Criteria:

  • MCP Camel consumer supports WebSocket connections and processes MCP JSON-RPC requests and notifications.
  • WebSocket endpoint is configurable and documented.
  • Sample flows and integration tests validate WebSocket support.

References:


Copilot is powered by AI, so mistakes are possible. Leave a comment via the 👍 👎 to share your feedback and help improve the experience.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions