Skip to content

Conversation

@ZWJzhangwanjie
Copy link
Contributor

@ZWJzhangwanjie ZWJzhangwanjie commented Jul 20, 2025

[feat] mcp streamable http

Make sure that:

  • [Y] You have read the contribution guidelines.
  • [Y] You submit test cases (unit or integration tests) that back your changes.
  • [Y] Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

how to use mcp plugin ?
https://o6qjqhqozq.feishu.cn/docx/HXgEdSf1SoAjZKxsN4GcIjPTnYb?from=from_copylink

what is the architectural design for mcp
https://o6qjqhqozq.feishu.cn/docx/HFfwd66Hbosvznx0G2hc5fFynec?from=from_copylink

@ZWJzhangwanjie ZWJzhangwanjie changed the title Feat mcp streamable http [feat] mcp streamable http Jul 20, 2025
@Aias00 Aias00 requested a review from Copilot July 21, 2025 03:08
Copy link
Contributor

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.

Pull Request Overview

This PR introduces support for Streamable HTTP transport protocol to the MCP (Model Context Protocol) server plugin, expanding beyond the existing SSE (Server-Sent Events) protocol. The implementation provides a unified architecture where both SSE and Streamable HTTP protocols share the same MCP server instance per path, enabling AI models to interact with Shenyu Gateway services through multiple transport protocols.

  • Enhanced MCP server manager with shared server instances supporting multiple transport protocols
  • Added Streamable HTTP transport provider with session management and automatic recovery capabilities
  • Improved parameter handling and response processing with protocol-specific decorators

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
JsonSchemaUtil.java Fixed parameter type handling to use actual parameter type instead of hardcoded "string"
ShenyuStreamableHttpServerTransportProvider.java New transport provider implementing Streamable HTTP protocol with comprehensive session management
NonCommittingMcpResponseDecorator.java New response decorator for Streamable HTTP that captures responses without committing to original response
RequestConfigHelper.java Refactored path building logic with improved URL handling and removed unused methods
ParameterFormatter.java New utility for JSON parameter formatting and type conversion
BodyWriterExchange.java Enhanced request body handling using cached output messages
ShenyuMcpServerManager.java Major refactor to support shared servers across multiple transport protocols
McpServerPluginDataHandler.java Added default message endpoint configuration
ShenyuToolCallback.java Enhanced tool callback with protocol-aware processing and improved session management
McpServerPlugin.java Updated plugin to route requests based on protocol type (SSE vs Streamable HTTP)
MCP_TOOL_EXAMPLES_EN.md New comprehensive examples documentation in English
MCP_TOOL_EXAMPLES.md New comprehensive examples documentation in Chinese
Comments suppressed due to low confidence (1)

shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallback.java:209

  • Similar Javadoc formatting issue. The description should follow proper Javadoc formatting conventions.
        final ServerWebExchange decoratedExchange = buildDecoratedExchange(

}
}
}
} No newline at end of file
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

This file is extremely large (1257 lines) which makes it difficult to maintain and understand. Consider breaking it down into smaller, more focused classes such as separate classes for session management, message handling, and transport operations.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have separated it into multiple classes to ensure it is under 1,000 lines

builder.header(SESSION_ID_HEADER, result.getSessionId());
}

// 统一使用 application/json 格式返回响应
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Comments should be in English to maintain consistency with the rest of the codebase. This Chinese comment should be translated.

Suggested change
// 统一使用 application/json 格式返回响应
// Use application/json format uniformly for the response

Copilot uses AI. Check for mistakes.
return value;
}
}
// 首先检查输入值是否已经是一个完整的 URL
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Comments should be in English to maintain consistency with the rest of the codebase. Multiple Chinese comments throughout this file should be translated.

Suggested change
// 首先检查输入值是否已经是一个完整的 URL
// First, check if the input value is already a complete URL

Copilot uses AI. Check for mistakes.

/**
* Processes response data by applying response template transformations.
* If no response template is configured, returns the original response body unchanged.
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

The Javadoc formatting is incorrect. The description should start on the same line as the opening /** or use proper line continuation with proper indentation.

Suggested change
* If no response template is configured, returns the original response body unchanged.
* If no response template is configured, returns the original response body unchanged.

Copilot uses AI. Check for mistakes.

/**
* Applies placeholder substitution to a text template using response data.
* Supports simple placeholder format: ${fieldName}
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Similar Javadoc formatting issue. The description should follow proper Javadoc formatting conventions.

Suggested change
* Supports simple placeholder format: ${fieldName}
* Supports simple placeholder format: ${fieldName}

Copilot uses AI. Check for mistakes.
/**
* Extract sessionId from request parameters or headers.
* Extracts session ID from request parameters or headers.
* Searches in the following order:
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Similar Javadoc formatting issue. The description should follow proper Javadoc formatting conventions.

Suggested change
* Searches in the following order:
* Searches in the following order:

Copilot uses AI. Check for mistakes.

// handle new query parameters

// 处理新的查询参数
Copy link
Contributor

Choose a reason for hiding this comment

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

change Chinese to English pls

// 处理新的查询参数
basePath = processArguments(argsPosition, inputJson, basePath, queryBuilder);

// 清理未替换的模板变量
Copy link
Contributor

Choose a reason for hiding this comment

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

here too

} else if ("query".equals(position) && inputJson.has(key)) {
// handle query parameters
if (!existingQuery.contains(key + "=")) {
// 处理查询参数
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

// add new query parameters if any

// 添加查询参数
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes , I'm dealing with it

@ZWJzhangwanjie ZWJzhangwanjie requested a review from Aias00 July 21, 2025 07:38
@Aias00 Aias00 merged commit 7de2558 into apache:master Jul 21, 2025
45 checks passed
@Aias00 Aias00 added this to the 2.7.0.2 milestone Jul 28, 2025
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.

2 participants