feat: Add MCP (Model Context Protocol) base protocol implementation with Netty#3039
Merged
hengyunabc merged 14 commits intoalibaba:mcpfrom Jul 30, 2025
Merged
feat: Add MCP (Model Context Protocol) base protocol implementation with Netty#3039hengyunabc merged 14 commits intoalibaba:mcpfrom
hengyunabc merged 14 commits intoalibaba:mcpfrom
Conversation
Collaborator
Collaborator
Contributor
Author
Contributor
Author
hengyunabc
reviewed
Jul 27, 2025
hengyunabc
reviewed
Jul 27, 2025
hengyunabc
reviewed
Jul 27, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds a comprehensive MCP (Model Context Protocol) base protocol implementation using Netty for Arthas. The purpose is to enable Arthas to expose its diagnostic capabilities through a standardized protocol that can be consumed by AI models and other clients.
Key changes include:
- Implements MCP 2024-11-05 protocol specification with JSON-RPC message handling
- Provides HTTP/SSE transport layer using Netty for real-time communication
- Integrates 20+ Arthas diagnostic tools (JVM, class loading, memory analysis) as MCP tools
- Establishes layered architecture with transport, session, server, and features layers
Reviewed Changes
Copilot reviewed 60 out of 60 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pom.xml | Adds new arthas-mcp-server module to the build |
| McpSchema.java | Comprehensive MCP protocol schema definitions and JSON-RPC message types |
| McpServer.java | Main server interface and builder for configuring MCP server instances |
| McpRequestHandler.java | HTTP request handler managing SSE connections and message routing |
| Tool implementations | 20+ tool classes wrapping Arthas commands (jvm, memory, classloader, etc.) |
| Utility classes | JSON parsing, schema generation, assertion helpers, and type conversion utilities |
labs/arthas-mcp-server/src/main/java/com/taobao/arthas/mcp/server/tool/util/McpToolUtils.java
Show resolved
Hide resolved
...mcp-server/src/main/java/com/taobao/arthas/mcp/server/tool/function/jvm300/VMOptionTool.java
Outdated
Show resolved
Hide resolved
...s-mcp-server/src/main/java/com/taobao/arthas/mcp/server/tool/function/jvm300/SysEnvTool.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/com/taobao/arthas/mcp/server/protocol/server/handler/McpRequestHandler.java
Outdated
Show resolved
Hide resolved
...p-server/src/main/java/com/taobao/arthas/mcp/server/tool/function/ArthasCommandExecutor.java
Outdated
Show resolved
Hide resolved
...er/src/main/java/com/taobao/arthas/mcp/server/tool/function/klass100/MemoryCompilerTool.java
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




#3013
协议部分 (2024-11-05)
采用分层架构,主要分为以下几层:
TransportProvider : Transport : McpSession : 客户端 = 1 : N : N : N
TransportProvider 作为工厂类,为每个新的客户端连接创建新的 Transport,Transport 负责与单个客户端之间的消息传输 ,McpSession 管理单个客户端的所有会话状态。
工具架构
由于现在仅支持旧版本的mcp协议(2024-11-05),暂未支持Streamable http,支持的工具只是单次调用的,支持列表:
jvm相关
class/classloader 相关
.java文件为.class文件.class文件,redefine 到 JVM 里.class文件,retransform 到 JVM 里Todo