-
Notifications
You must be signed in to change notification settings - Fork 3k
[feat] mcp streamable http #6061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…support for Streamable http.
…ssion support for Streamable http.
…rtMap & streamableHttpTransportMap.
There was a problem hiding this 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 |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 格式返回响应 |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
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.
| // 统一使用 application/json 格式返回响应 | |
| // Use application/json format uniformly for the response |
| return value; | ||
| } | ||
| } | ||
| // 首先检查输入值是否已经是一个完整的 URL |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
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.
| // 首先检查输入值是否已经是一个完整的 URL | |
| // First, check if the input value is already a complete URL |
|
|
||
| /** | ||
| * Processes response data by applying response template transformations. | ||
| * If no response template is configured, returns the original response body unchanged. |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
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.
| * If no response template is configured, returns the original response body unchanged. | |
| * If no response template is configured, returns the original response body unchanged. |
|
|
||
| /** | ||
| * Applies placeholder substitution to a text template using response data. | ||
| * Supports simple placeholder format: ${fieldName} |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
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.
| * Supports simple placeholder format: ${fieldName} | |
| * Supports simple placeholder format: ${fieldName} |
| /** | ||
| * Extract sessionId from request parameters or headers. | ||
| * Extracts session ID from request parameters or headers. | ||
| * Searches in the following order: |
Copilot
AI
Jul 21, 2025
There was a problem hiding this comment.
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.
| * Searches in the following order: | |
| * Searches in the following order: |
|
|
||
| // handle new query parameters | ||
|
|
||
| // 处理新的查询参数 |
There was a problem hiding this comment.
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); | ||
|
|
||
| // 清理未替换的模板变量 |
There was a problem hiding this comment.
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 + "=")) { | ||
| // 处理查询参数 |
There was a problem hiding this comment.
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 | ||
|
|
||
| // 添加查询参数 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
There was a problem hiding this comment.
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
[feat] mcp streamable http
Make sure that:
./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