feat: [OSS26] 按方法名查实现 find_implementations_by_method_name (#132) - #149
Open
wryyyds7 wants to merge 4 commits into
Open
feat: [OSS26] 按方法名查实现 find_implementations_by_method_name (#132)#149wryyyds7 wants to merge 4 commits into
wryyyds7 wants to merge 4 commits into
Conversation
Implement the unified MCP Server framework as the runtime base for all upcoming YASA MCP tools (Issue antgroup#129). Framework: - Dual transport: stdio (default) / streamable-http - Tool registration via @mcp_tool decorator + auto-discovery - Unified input validation (Pydantic), error handling, logging (stderr) - Health check endpoint GET /healthz in HTTP mode - Built-in demo tool ping returning server status Modules: - yasa_mcp/config.py: CLI args + env var parsing - yasa_mcp/server.py: FastMCP lifecycle management - yasa_mcp/registry.py: decorator-based tool auto-registration - yasa_mcp/transport/http.py: streamable-http + /healthz - yasa_mcp/tools/ping.py: demo health-check tool - yasa_mcp/errors.py: unified error codes - yasa_mcp/logging_config.py: stderr logging with level control Tests (44 passing): - test_registry.py: tool registration, auto-discovery, schema - test_validation.py: param validation, error handling - test_logging.py: stderr output, format, level filtering - test_config.py: CLI parsing, env vars, error exit Docs: - docs/mcp/requirements.md: functional/non-functional requirements - docs/mcp/system-design.md: architecture, module design, data flow - docs/mcp/development-guide.md: step-by-step implementation guide - yasa_mcp/README.md: usage + Claude Desktop/Cline config examples
- registry.py: prevent duplicate tool registration via __module__ check - http.py: use app.add_route() instead of direct app.routes manipulation - http.py: remove unused Route import - http.py + server.py: pass log_level to uvicorn instead of hardcoding - errors.py: fix empty string message fallback bug - test_registry.py: use asyncio.run() instead of deprecated get_event_loop() - test_validation.py: remove unused imports - config.py: convert repo_root to absolute path - logging_config.py: precise logger namespace check - pyproject.toml: fix build-backend to setuptools.build_meta - .gitignore: add .venv/ and Python project ignore rules
…p#132) - Implement method-level interface implementation finder - Reuse antgroup#128's class index (_build_class_index, _find_implementations) - Add Java method parsing via regex (annotations, modifiers, return type, params) - Support method overload disambiguation via parameter_types - Skip abstract method declarations (only return concrete implementations) - Detect @OverRide annotation presence - Build method_signature string (e.g. 'validate(Object): boolean') - Support anonymous class method parsing - 26 tests covering: direct impl, overloads, generics, abstract skip, indirect inheritance, anonymous class, inner class, empty results, parameter matching, MCP registration
wryyyds7
requested review from
AntJiuFo,
Arielwyy and
alipaydeshui
as code owners
July 29, 2026 09:07
Author
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.
概述
实现
find_implementations_by_method_nameMCP 工具,给定接口的全限定名 + 方法名(可选形参类型消歧),返回所有实现该方法的位置——包括所在类、方法签名、文件路径、行号。实现
类索引复用
复用 #128 的
_build_class_index、_find_implementations、_find_anonymous_impls确定实现类列表。Java 方法解析 (
_parse_java_methods)_METHOD_PATTERN: 正则匹配 Java 方法定义,支持:@Override,@SuppressWarnings("unchecked")等)ResponseEntity<User>){或声明;参数列表解析
_split_params: 按顶层逗号分割参数列表,忽略泛型尖括号内的逗号 (Map<String, Object>不被错误分割)_parse_method_params: 从每个参数中提取类型 (去掉参数名、final修饰符、可变参数...)方法签名构建 (
_build_method_signature)拼接返回类型 + 方法名 + 参数类型列表,如
public ResponseEntity<User> getUser(HttpServletRequest, String)匿名类方法解析 (
_parse_anonymous_class_methods)_find_matching_brace定位匿名类方法体范围参数类型消歧 (
_params_match)测试
Closes #132