使用说明
Ressl分配-带文件搜索工具的MCP服务器
该项目使用文件关键字搜索工具实现了一个模型上下文协议(MCP)服务器。
特性
- 搜索文件工具:在文件中搜索指定的关键字并返回:
- 匹配发生的行号
- 每场比赛的背景
- 总比赛次数
先决条件
- Node.js(v18或更高版本)
- npm或纱线
- TypeScript(通过npm安装)
安装
- 克隆此存储库:
git clone <your-repo-url>
cd resselai
- 安装依赖项:
npm install
- 构建项目:
npm run build
用法
运行MCP服务器
服务器在stdio(标准输入/输出)上运行,并通过JSON-RPC进行通信:
npm start
与MCP检查器一起使用
-
运行MCP检查器:
npx @modelcontextprotocol/inspector这将启动MCP检查器,并在默认web浏览器中自动打开它。
-
在MCP检查器中配置连接:
- 传输类型:选择
STDIO - 命令:输入
node - 参数(空格分隔):输入
dist/index.js - 确保您在项目目录中(
C:\Users\musud\resselai)
- 传输类型:选择
-
连接:
- 点击 "▷ 连接“ 按钮
- 等待连接建立
- 你应该看看
search_file工具出现在界面中
-
测试工具:
- 选择
search_file工具 - 输入测试参数:
- 文件路径:
test-sample.txt - 关键词:
search
- 文件路径:
- 点击“呼叫工具”或提交
- 使用行号和上下文查看结果
- 选择
注: 如果使用绝对路径,则参数为: C:\Users\musud\resselai\dist\index.js
工具:搜索文件
参数:
filepath(必填):要搜索的文件的路径(相对或绝对)keyword(必填):要搜索的关键字或短语contextLines(可选):每个匹配项周围的上下文行数(默认值:2)
请求示例:
{
"tool": "search_file",
"arguments": {
"filepath": "src/index.ts",
"keyword": "search_file",
"contextLines": 3
}
}
示例响应:
Search Results for keyword "search_file" in file: src/index.ts
Total matches found: 5
--- Match 1 (Line 42) ---
>>> 42: name: "search_file",
40: this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
41: tools: [
42: {
43: name: "search_file",
...
发展
在监视模式下运行TypeScript编译器:
npm run dev
项目结构
resselai/
├── src/
│ └── index.ts # Main MCP server implementation
├── dist/ # Compiled JavaScript (generated)
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── README.md # This file
└── .gitignore # Git ignore rules
测试
MCP检验员快速测试
-
构建项目 (如果尚未完成):
npm run build -
运行MCP检查器:
npx @modelcontextprotocol/inspector这将在浏览器中自动打开检查器。
-
配置连接:
- 传输类型:
STDIO - 命令:
node - 参数:
dist/index.js - 点击 "▷ 连接“
- 传输类型:
-
测试search_file工具:
- 选择
search_file工具 - 输入:
- 文件路径:
test-sample.txt - 关键词:
search
- 文件路径:
- 查看带有行号和上下文的结果
- 选择
故障排除
连接错误:
- 验证
dist/index.js存在(运行npm run build) - 检查命令是否准确
node(不是mcp-server-everything) - 尝试绝对路径:
C:\Users\musud\resselai\dist\index.js
项目结构
resselai/
├── src/
│ └── index.ts # Main MCP server implementation
├── dist/ # Compiled JavaScript (generated, gitignored)
├── node_modules/ # Dependencies (gitignored)
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .gitignore # Git ignore rules
├── README.md # This file
├── test-sample.txt # Sample file for testing
└── mcp-config-example.json # Example config for Claude Desktop
许可证
麻省理工学院
