Token导航 LogoToken导航TokenDH.com
Kodegen MCP Tool logo
开发工具未说明官方级别未说明来源级核验

Kodegen MCP Tool

MCP Server

一个用于构建模型上下文协议(MCP)工具的Rust库,提供简单API、自动JSON模式生成、内置工具历史记录等功能。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
代码生成开发工具RustClaudeClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

cyrup-ai

提供方

cyrup-ai

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

编码器_mcp_tool

用于代码生成代理的内存高效、超快的MCP工具。

特性

  • 简单API -实现一个特性,自动获得RMCP集成、模式生成和历史跟踪
  • 自动JSON模式 -衍生自 JsonSchema 全局缓存实现零开销
  • 内置工具历史记录 -即发即弃录制,具有持久的JSONL存储,从不阻止执行
  • 行为注释 -声明工具语义(read_only, destructive, idempotent, open_world)
  • 提示系统 -教代理如何使用带有对话风格提示的工具
  • 性能优化 -模式缓存、Arc优化、后台I/O以实现最大吞吐量
  • 全面错误 - McpError 枚举,可自动转换为RMCP错误类型
  • 生产就绪 -线程安全,异步优先,具有原子文件操作和旋转

需求

  • 每晚生锈 -此库使用Rust 2024版
  • 东京 运行 时间 -异步执行由Tokio提供支持

安装

添加到您的 Cargo.toml:

[dependencies]
kodegen_mcp_tool = "0.1.0"

或者从git安装:

[dependencies]
kodegen_mcp_tool = { git = "https://github.com/cyrup-ai/kodegen-mcp-tool" }

快速开始

下面是一个实现工具的最小示例:

use kodegen_mcp_tool::{Tool, error::McpError};
use serde::{Deserialize, Serialize};
use schemars::JsonSchema;
use serde_json::Value;
use rmcp::model::{PromptArgument, PromptMessage};

// 1. Define your tool struct (holds dependencies)
pub struct EchoTool;

// 2. Define input arguments
#[derive(Deserialize, Serialize, JsonSchema)]
pub struct EchoArgs {
    message: String,
}

// 3. Define prompt arguments
#[derive(Deserialize, Serialize, JsonSchema)]
pub struct EchoPromptArgs {}

// 4. Implement the Tool trait
impl Tool for EchoTool {
    type Args = EchoArgs;
    type PromptArgs = EchoPromptArgs;

    fn name() -> &'static str { "echo" }
    fn description() -> &'static str { "Echoes back your message" }

    async fn execute(&self, args: Self::Args) -> Result {
        Ok(serde_json::json!({
            "echo": args.message
        }))
    }

    fn prompt_arguments() -> Vec
 {
        vec![]
    }

    async fn prompt(&self, _args: Self::PromptArgs) -> Result {
        Ok(vec![])
    }
}

// 5. Register with RMCP router
use rmcp::handler::server::router::RouterService;

#[tokio::main]
async fn main() {
    // Initialize tool history
    kodegen_mcp_tool::tool_history::init_global_history("my-server".to_string()).await;

    // Create router and register tool
    let router = RouterService::new("echo-server")
        .tool(EchoTool.into_tool_route())
        .prompt(EchoTool.into_prompt_route());

    // Start server (example with stdio transport)
    // ... your transport setup here ...
}

行为注释

工具可以通过重写trait方法来声明它们的行为:

impl Tool for MyTool {
    // ... other trait methods ...

    fn read_only() -> bool { false }      // Tool modifies state
    fn destructive() -> bool { true }     // Can delete/overwrite data
    fn idempotent() -> bool { false }     // Each call has different effect
    fn open_world() -> bool { true }      // Interacts with external systems
}

这些注释会自动转换为RMCP ToolAnnotations 并帮助代理了解工具安全特性。

工具历史记录

自动跟踪所有工具的工具调用历史:

// Initialize once at startup
kodegen_mcp_tool::tool_history::init_global_history("server-id".to_string()).await;

// Access anywhere in your code
if let Some(history) = kodegen_mcp_tool::tool_history::get_global_history() {
    let recent_calls = history.get_recent_calls(
        100,                    // max results
        0,                      // offset (negative = tail)
        Some("my_tool"),        // filter by tool name
        None,                   // filter by timestamp
    ).await;
}

特征:

  • 即发即弃记录(从不阻止工具执行)
  • 内存缓存(最后1000个条目)
  • 持久JSONL存储
  • 自动文件轮换5000个条目
  • 后台磁盘I/O(1秒刷新间隔)

文档

生成并查看API文档:

cargo doc --open

有关使用此代码库的更多详细指导,请参阅 CLAUDE.md.

建筑亮点

  • 基于结构的工具 -工具是保持其依赖关系的有状态结构,而不是单例或静态函数
  • 架构缓存 -JSON模式每种工具类型计算一次,并使用全局缓存 LazyLock
  • 电弧优化 - arc_into_tool_route() 变体避免了预包装工具的双圆弧分配
  • 后台处理 -工具历史记录对所有磁盘I/O使用专用后台任务

许可证

双重许可:

由您选择。

链接

______________________________________________________________________

KODEGEN -建造于 青榨槭

目录标签

目录标签

代码生成开发工具RustClaude本地部署Rust库MCP工具自动化工具

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP