本指南旨在帮助您完成 MCP 服务器的配置,介绍其当前功能、测试方法以及未来的功能规划,让您能更好地使用 MCP 服务器进行文本匹配和解析树获取等操作。
http://localhost:3001 将服务器添加到 AMP 中,并命名为 get-text-matches。node server.js。MCP 服务器支持两种工具,这两个工具都会递归遍历指定目录中的所有文件:
http://localhost:3001 将服务器添加到 AMP 中,并命名为 get-text-matches。node server.js。要开始,请在新目录中运行以下命令创建示例客户端文件:
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
提示 MCP 服务器执行以下命令:
use the get-text-match tool to find temp_x, specify the full path
提示 MCP 服务器执行以下命令:
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
或
where is temp_x defined in include_scope 和 where 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 服务器必须信任客户端告诉它要检查的本地目录。如果有需要,可以硬编码路径。
node_modules 的目录中搜索 "import" 时会超出令牌限制。