Back to MCP directory
publicPublicdnsLocal runtime

rust-mcp-schema

Rust实现的Model Context Protocol (MCP) 模式上下文协议类型安全实现,支持所有官方发布的版本,包括2024_11_05、2025_03_26和草案版本。

article

README

🚀 Rust MCP Schema 项目文档

rust-mcp-schema 是一个专门为 Minecraft Bedrock Edition (BE) 和 Java Edition (JE) 打造的 Rust 库,它提供了 MCP (MineCraft Forge 的官方反编译器) 模式支持。该库能助力开发者更轻松地处理 Minecraft 游戏内的数据结构与协议,提升开发效率。

🚀 快速开始

rust-mcp-schema 能帮助开发者高效处理 Minecraft 游戏内数据,通过定义 MCP Schema 可自动生成 Rust 结构体,还能对反编译后的数据进行解析。

✨ 主要特性

  • MCP Schema 支持:该库完整实现了 MCP Schema 格式的定义,允许用户借助易读的 JSON 文件来描述 Minecraft 的游戏内类型。
  • 自动生成 Rust 类型:基于 MCP Schema,可自动生成对应的 Rust 数据结构,让处理 Minecraft 数据变得更加直观和高效。
  • 反编译器支持:具备对 Minecraft 反编译器输出的数据进行解析的能力,有助于开发者分析和理解游戏内部的工作机制。

💻 使用示例

基础用法

定义一个简单的 MCP Schema:

{
    "type": "object",
    "name": "Position",
    "fields": [
        { "type": "int", "name": "x" },
        { "type": "int", "name": "y" },
        { "type": "int", "name": "z" }
    ]
}

生成的 Rust 结构体:

#[derive(Debug, Clone)]
pub struct Position {
    pub x: i32,
    pub y: i32,
    pub z: i32,
}

高级用法

假设我们有一个 MCP 反编译后的数据文件,例如:

{
    "id": 15,
    "jsonrpc": "2.0",
    "result": {
        "capabilities": {
            "prompts": { "listChanged": true },
            "resources": { "listChanged": true, "subscribe": true },
            "tools": { "listChanged": true }
        },
        "instructions": "mcp server instructions....",
        "_meta": { "feature-xyz": true, "meta 1": "meta-value", "meta 2": 225 },
        "protocolVersion": "2024-11-05",
        "serverInfo": {
            "name": "example-servers/everything",
            "version": "1.0.0"
        }
    }
}

使用 rust-mcp-schema 进行解析:

let json_payload = message.to_string();
// 解析 JSON 数据
let mcp_message: JsonrpcMessage = serde_json::from_str(&json_payload)?;

match mcp_message {
    JsonrpcMessage::Response(response) => {
        // 处理响应数据
        if let Some(server_info) = response.result.serverInfo {
            println!("Server name: {}", server_info.name);
            println!("Server version: {}", server_info.version);
        }
    },
    _ => {}
}

📚 详细文档

贡献指南

我们热烈欢迎社区的贡献!若你有任何问题或建议,可随时提交 Issues 或 Pull Requests。

提交代码前的要求

  1. 格式检查:确保所有 Rust 代码遵循 Rust 的编码规范(例如:cargo fmt --all)。
  2. 单元测试:在提交代码之前,运行项目的所有单元测试以确保没有引入错误。
  3. 文档更新:如果你的更改影响了 API 或功能,请相应地更新相关的文档和注释。

项目结构

  • schemas:包含 MCP Schema 的定义文件。
  • src:包含 Rust 库的核心实现,包括反编译器支持、类型生成等模块。
  • examples:提供了一些使用示例,帮助用户理解如何使用该库。
  • Cargo.toml:项目依赖管理和构建配置。

📄 许可证

该项目遵循 MIT 许可证。请查看 LICENSE 文件以获取详细信息。


感谢你对 rust-mcp-schema 的兴趣和支持!希望这个库能为 Minecraft 开发者提供便利,并促进社区的发展。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client