Rust与MCP客户端集成功能

一个简单的Rust函数与MCP客户端的集成,用于在Claude Desktop中实现功能扩展和自动化测试。

  • by lotharschulz
  • TypeScript
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 lotharschulz/mcp-server-rust

使用说明

一个与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服务器)

第三步:克劳德桌面

启动克劳德桌面

请注意前端中的额外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.js

Rust导入失败

问题:

解决方案:

跑 npm run build:wasm:release 要释放绑定wasm的factorial导入依赖于