MCP Server for Find Reference

MCP Server for Find Reference

site icon
2025.03.31 0
JavaScript代码分析文本匹配开发效率
MCP-Server是一个用于代码分析和文本匹配的服务,主要用于在代码库中查找特定文本的匹配位置和解析代码的语法树。它支持递归遍历目录中的所有文件,提供精确的文本匹配和语法树元数据提取功能。
View on GitHub

Overview

基本能力

产品定位

MCP-Server是一个代码分析和文本匹配工具,主要用于开发者在代码库中查找特定文本的匹配位置和解析代码的语法树。

核心功能

  1. get-text-matches工具:返回一个包含{file, line, column}的列表,显示在给定目录中找到的精确文本匹配位置。
  2. get-parse-tree工具:返回给定字符串的语法树元数据,用于分析代码结构。

适用场景

  1. 在大型代码库中查找特定变量或函数的引用位置。
  2. 分析代码的语法结构,例如变量类型、定义位置等。
  3. 开发工具集成,提供代码分析和文本匹配功能。

工具列表

  1. get-text-matches:用于查找代码中特定文本的精确匹配位置。
  2. get-parse-tree:用于解析代码的语法树,提取元数据。

常见问题解答

  1. 工具选择错误:如果MCP服务器选择了错误的工具,可以通过明确指定工具来解决,例如:use the parse tree tool, not get text, to find temp_x, specify the full path
  2. 路径问题:有时服务器会使用.作为目录而不是完整路径,需要明确指定完整路径。
  3. 信任问题:MCP服务器必须信任客户端告诉它要检查的本地目录。

使用教程

使用依赖

  1. 确保已安装Node.js环境。

安装教程

  1. 将服务器添加到AMP,使用http://localhost:3001并命名为get-text-matches
  2. 运行服务器:node server.js

调试方式

  1. 创建示例目录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
  2. 使用get-text-matches工具use the get-text-match tool to find temp_x, specify the full path
  3. 使用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_xwhat type of variable is temp_x

许可证

None