一个与MCP客户端集成的简单Rust函数。
步骤1:转发Rust和Javascript/TS代码
发布
npm run build:wasm:release // release rust code
npm install // create javascript file and install all npm dependencies步骤2:克劳德桌面配置
在以下位置创建配置文件:
{
"mcpServers": {
"mcp-server": {
"command": "node",
"args": [
"[your local path]/mcpserver/build/index.js"
]
}
}
}位置:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 窗户:
%APPDATA%\Claude\claude_desktop_config.json
(来源:https://modelcontextprotocol.info/docs/quickstart/user/#2-添加文件系统mcp服务器)
第三步:克劳德桌面
启动克劳德桌面
Claude Desktop Initial View 请注意前端中的额外mcp服务器图标
同意使用mcp服务器功能:
观察mcp服务器功能:
视频
在此处观看视频教程: YouTube视频
杂项
测试锈蚀代码
npm run test:rust或
cd src/lib/rust-functions-lib
cargo test && cargo fmt --all -- --check清理输出文件和文件夹
npm run clean构建防锈代码-替代方案
npm
npm run build:wasm
使用wasm工具的替代方法
cd src/lib/rust-functions-lib
wasm-pack build --target bundler只构建ts代码(npm)
npm build复制构建Rust代码
手动复制到正确的位置-包含在 npm run build:wasm:release
mkdir -p build/lib/rust-functions-lib/pkg && cp src/lib/rust-functions-lib/pkg/rust_funcations_lib.js build/lib/rust-functions-lib/pkg/rust_funcations_lib.jsRust导入失败
问题:
解决方案:
跑 npm run build:wasm:release 要释放绑定wasm的factorial导入依赖于
