Repository navigation
feat(mcp): add line tool for source-line probes - #3287
Closed
yy568821795-max wants to merge 1 commit into
Closed
yy568821795-max wants to merge 1 commit into
yy568821795-max wants to merge 1 commit into
Conversation
yy568821795-max
force-pushed
the
feat/mcp-line-tool
branch
from
November 4, 2026 06:26
310bf32 to
9f8efd8
Compare
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.
背景
line命令已在 #3210 合入(4.3.x),但 MCP 工具层com.taobao.arthas.core.mcp.tool.function没有对应实现,tools/list返回的工具集里没有line,AI 客户端只能通过 HTTP API 或 telnet 手工执行。本 PR 按现有
WatchTool/TraceTool的约定补齐该工具,属于工具覆盖度补齐,不改变任何已有命令行为。改动
core/src/main/java/com/taobao/arthas/core/mcp/tool/function/monitor200/LineTool.javalineMCP 工具arthas-mcp-integration-test/src/test/java/com/taobao/arthas/mcp/it/ArthasMcpToolsIT.javaline --list-lines验证返回line-listsite/docs/doc/mcp-server.md、site/docs/en/doc/mcp-server.mdline条目;顺带补齐文档中缺失的version/stop/upload_file条目并修正工具计数参数映射
classPattern--classmethodPattern--methodmethodDesc--descline--linelistLines=true时非必填express--express{params, localVarMap}condition--conditionlistLines--list-linesLineNumberTable,不增强类regex-EexpandLevel-xmaxMatchCount-msizeLimit-Mstack--stackstackDepth--stack-depthnumberOfExecutions-ntimeout--timeout执行模型
listLines=true):走executeSync。只读取LineNumberTable,不增强目标类,无副作用,适合让 Agent 先探测可插桩行号。watch/trace/monitor一致,streamable = true、taskSupport = OPTIONAL,走executeStreamable,命中numberOfExecutions次或超时后自动结束,并复用现有的interruptJob清理逻辑。验证
本机(Windows + JDK 17)已执行:
./mvnw -pl core -DskipTests compile→ BUILD SUCCESS./mvnw -pl core -Dtest=ArthasMcpServerTest test→ Tests run: 1, Failures: 0, Errors: 0DefaultToolCallbackProvider扫描工具包):toolCount=33(新增前 32)line已注册,streamable=true、taskSupport=OPTIONALinputSchema.required=["classPattern"],其余 14 个参数均为可选git diff --check无空白问题集成测试
ArthasMcpToolsIT在本机按既有逻辑跳过(Assumptions.assumeFalse(isWindows())),需由 CI 执行。兼容性
tools/list仅新增一个line工具。line依赖目标类的LineNumberTable(编译需带-g);局部变量依赖LocalVariableTable,缺失时localVarMap可能为空。这是命令本身已有的约束,工具描述中已注明。watch/trace一样可通过reset或重启恢复。