Run the MCP Client
未知
MCP客户端快速启动指南
准备工作
确保服务器已经启动并正在运行。更多信息请参见:https://github.com/dazzaji/filesystem
1. 创建环境
mkdir mcp-client-py
cd mcp-client-py
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
2. 配置环境变量
创建.env
文件:
SERVER_PATH=/Users/dazzagreenwood/filesystem/dist/index.js
ALLOWED_DIRECTORY=/Users/dazzagreenwood/mcp-hello/module1/files
# 可选测试参数
#TOOL=list_directory
#ARGS='{"path": "/Users/dazzagreenwood/mcp-hello/module1/files", "recursive": true}'
3. 运行客户端
基本运行:
python client.py
带参数运行:
python client.py --tool "list_directory" --args '{"path": "/path/to/directory", "recursive": true}'
4. 验证
成功运行后,检查:
- 控制台输出中的可用工具列表
- 如果使用
write_file
,验证testfile.txt
是否已创建 - 使用其他工具时,确认输出符合预期
测试流程示例
启动服务器
cd /path/to/filesystem
node dist/index.js "/path/to/allowed/directory"
测试不同功能
# 写入文件测试
python client.py
# 列出目录测试
python client.py --tool list_directory --args '{"path": "/path/to/directory", "recursive": true}'
# 读取文件测试
python client.py --tool read_file --args '{"path": "/path/to/directory/test.txt"}'