
MCP Server for Find Reference

2025.03.31
0
JavaScript代码分析文本匹配开发效率
MCP-Server是一个用于代码分析和文本匹配的服务,主要用于在代码库中查找特定文本的匹配位置和解析代码的语法树。它支持递归遍历目录中的所有文件,提供精确的文本匹配和语法树元数据提取功能。
View on GitHub
Overview
基本能力
产品定位
MCP-Server是一个代码分析和文本匹配工具,主要用于开发者在代码库中查找特定文本的匹配位置和解析代码的语法树。
核心功能
- get-text-matches工具:返回一个包含{file, line, column}的列表,显示在给定目录中找到的精确文本匹配位置。
- get-parse-tree工具:返回给定字符串的语法树元数据,用于分析代码结构。
适用场景
- 在大型代码库中查找特定变量或函数的引用位置。
- 分析代码的语法结构,例如变量类型、定义位置等。
- 开发工具集成,提供代码分析和文本匹配功能。
工具列表
- get-text-matches:用于查找代码中特定文本的精确匹配位置。
- get-parse-tree:用于解析代码的语法树,提取元数据。
常见问题解答
- 工具选择错误:如果MCP服务器选择了错误的工具,可以通过明确指定工具来解决,例如:
use the parse tree tool, not get text, to find temp_x, specify the full path
。 - 路径问题:有时服务器会使用
.
作为目录而不是完整路径,需要明确指定完整路径。 - 信任问题:MCP服务器必须信任客户端告诉它要检查的本地目录。
使用教程
使用依赖
- 确保已安装Node.js环境。
安装教程
- 将服务器添加到AMP,使用
http://localhost:3001
并命名为get-text-matches
。 - 运行服务器:
node server.js
。
调试方式
- 创建示例目录:
bash mkdir client && cd client && echo -e "import { temp_x } from './scope.js';\n\ntemp_x = 5;\n\ntemp_x = 7 + 4;\n\nconsole.log(temp_x);" > include_scope.js && echo -e "let temp_x = 5;\n\ntemp_x = 7 + 4;\n\nconsole.log(temp_x);" > exclude_scope.js && echo -e "let temp_x = \"Hello\";\n\nif(true){\n let temp_x = 10;\n console.log(temp_x);\n}\n\ntemp_x = \"World\";\n\n{\n temp_x;\n}" > scope.js
- 使用get-text-matches工具:
use the get-text-match tool to find temp_x, specify the full path
- 使用get-parse-tree工具:
use the get-parse-tree tool to find temp_x, specify the full path
可以进一步提问,例如:what are the different node types of temp_x
或what type of variable is temp_x
许可证
None