Rust MCP Stdio Server Test

Rust MCP Stdio Server Test

site icon
2025.04.03 5
RustMCP 协议实现调试工具开发效率
mcp-rust-sdk 是一个基于 Rust 实现的 Model Context Protocol (MCP) 服务器示例,主要用于学习和调试目的。它支持 MCP 初始化握手和基本的列表命令(如 `tools/list`、`resources/list`、`prompts/list`)以及一个模拟的工具调用(`tools/call`)。该服务器通过 newline-delimited JSON stdio 传输进行通信。
View on GitHub

Overview

基本能力

产品定位

mcp-rust-sdk 是一个用于学习和调试的 MCP 服务器示例,旨在帮助开发者理解和使用 Model Context Protocol (MCP)。

核心功能

  • 支持 MCP 初始化握手
  • 处理基本的列表命令:
  • tools/list
  • resources/list
  • prompts/list
  • 模拟工具调用:tools/call
  • 通过 newline-delimited JSON stdio 传输进行通信

适用场景

  • 学习和理解 MCP 协议
  • 调试 MCP 客户端(如 Claude Desktop)
  • 开发 MCP 相关工具和服务的原型

工具列表

  • tools/list: 列出可用工具
  • resources/list: 列出可用资源
  • prompts/list: 列出可用提示
  • tools/call: 模拟工具调用

常见问题解答

  • 日志文件位置:$HOME/.screenpipe/logs/rust_stdio_test_logs/
  • 日志级别控制:通过 RUST_LOG 环境变量设置(如 RUST_LOG=debugRUST_LOG=trace

使用教程

使用依赖

  • 需要安装 Rust 工具链

安装教程

  1. 构建服务器: bash cargo build
  2. 配置 MCP 客户端(如 Claude Desktop)以启动构建的可执行文件(位于 target/debug/mcp-rust-sdk)。 在客户端配置文件中添加类似以下内容(使用绝对路径): json { "mcpServers": { "rust_stdio_test": { "command": "/path/to/your/mcp-rust-sdk/target/debug/mcp-rust-sdk" } // ... other servers ... } }

调试方式

  • 设置 RUST_LOG 环境变量以控制日志详细程度: bash export RUST_LOG=debugbash export RUST_LOG=trace
  • 日志文件位于:$HOME/.screenpipe/logs/rust_stdio_test_logs/

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。