Mcp Server For Find Reference

Mcp Server For Find Reference

🚀 MCP 服务器配置指南(用于查找引用)

本指南旨在帮助您完成 MCP 服务器的配置,介绍其当前功能、测试方法以及未来的功能规划,让您能更好地使用 MCP 服务器进行文本匹配和解析树获取等操作。

🚀 快速开始

配置 MCP 服务器

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

✨ 主要特性

MCP 服务器支持两种工具,这两个工具都会递归遍历指定目录中的所有文件:

  • get-text-matches 工具:返回一个包含 {file, line, column} 的列表,其中显示精确文本匹配的位置。
  • get-parse-tree 工具:返回指定字符串的解析树元数据。

📦 安装指南

配置 MCP 服务器

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

💻 使用示例

测试 MCP 服务器

示例目录

要开始,请在新目录中运行以下命令创建示例客户端文件:

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

提示 MCP 服务器执行以下命令: use the get-text-match tool to find temp_x, specify the full path

get-parse-tree

提示 MCP 服务器执行以下命令: 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_xwhere is temp_x defined in include_scopewhere is temp_x defined in exclude_scope 这些提示可以组合成更复杂的查询,例如: what variable type is temp_x in the scope of include_scope

故障排除

如果 MCP 服务器选择了错误的工具,您可以指示它不使用特定工具。例如: use the parse tree tool, not get text, to find temp_x, specify the full path 有时不需要指定完整路径,但偶尔它会决定将当前目录设为 .,因此需要明确指定。MCP 服务器必须信任客户端告诉它要检查的本地目录。如果有需要,可以硬编码路径。

📚 详细文档

未来功能规划

  1. 实现大小写不敏感匹配。
  2. 允许忽略特定文件/文件夹。例如,在包含 node_modules 的目录中搜索 "import" 时会超出令牌限制。
  3. 提供更美观、简洁的解析树输出格式。
  • 0 关注
  • 0 收藏,18 浏览
  • system 提出于 2025-09-21 16:33

相似服务问题

相关AI产品