mcpField
G
Genify

Genify

本地服务
github.com/daxartio开发工具212 周前更新

关于 Genify

Genify 是面向 AI 编码 Agent 的文件变更 MCP 服务和命令行工具,也可用于重复生成项目。它能在指定项目根目录内规划、预览、验证并应用结构化编辑,应用变更需明确批准。

主要功能

  1. 01规划文件操作
  2. 02预览统一差异
  3. 03应用已批准的变更
  4. 04验证生成配置
  5. 05根据模板生成项目

适用场景

  1. 01应用前审查项目变更
  2. 02生成一致的项目结构
  3. 03用共享配置更新多个项目

MCP 相关

Genify 通过 STDIO 向 MCP 客户端提供规划、差异预览、验证、模板列表和应用工具。文件访问受配置的根目录限制,应用变更需明确批准。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

genify

面向 AI 编码 Agent 的 MCP 工具,可在项目根目录内安全地规划、比较差异并应用结构化文件更改。

使用 genify 可重复执行代码库编辑:写入文件、替换文本、在标记周围插入区块、移动/复制/删除路径、创建目录、更改模式,以及在应用更改前生成试运行差异。

Crates.io Docs.rs CI Coverage Status

将单个文件转变为完整项目

核心思路是使用单个源文件,配合不同的配置文件,快速、一致地生成或更新完整的项目结构。

共有三种模式:

  • CLI 交互模式——用于手动操作和快速输入。
  • 代码模式——用于自动化、可配置的项目生成。
  • MCP 服务模式——供通过 STDIO 调用结构化工具的 AI 编码 Agent 使用。

功能:

  • 根据配置从模板创建文件。
  • 使用正则表达式替换内容。
  • 向现有文件追加或前置内容。
  • 使用共享配置轻松更新多个项目。

安装

Cargo
  • 按照本指南安装 Rust 工具链,以便安装 cargo。
  • 运行
    cargo install genify --features cli
    

快速开始

CLI
Turn one file into a complete project

Usage: genify [OPTIONS] [PATH]
       genify <COMMAND>

Arguments:
  [PATH]  Path to a config file or http(s) URL

Options:
  -p, --props-json <JSON>  Override props using a JSON object (Array/Map supported)
  -n, --no-interaction     Do not ask any interactive question
  -h, --help               Print help
  -V, --version            Print version

Commands:
  mcp   Start genify as an MCP server over STDIO
  help  Print this message or the help of the given subcommand(s)

example.toml

[props]
value = "value"
dir = "tmp"
val = "val"
other = "{{ val }}"
override = "1"

[[rules]]
type = "write"
path = "{{ dir }}/some.txt"  # if the file exists will be error
content = "{{ val }} {{ value }} {{ other | pascal_case }} {{ override }} - should be replaced"
if_exists = "error"

[[rules]]
type = "replace"
path = "{{ dir }}/some.txt"
replace = "should.*replaced"
content = "replaced {{ value }}"

[[rules]]
type = "prepend"
path = "{{ dir }}/some.txt"
content = "prepend {{ value }}"

[[rules]]
type = "append"
path = "{{ dir }}/some.txt"
content = "append {{ value }}"
genify example.toml

使用 JSON 从 CLI 覆盖属性(包括 Array/Map):

genify example.toml --props-json '{"tags": ["cli", "json"], "meta": {"license": "MIT"}}'

tmp/some.txt

prepend value
val value Val 1 - replaced value
append value
MCP

使用标准 STDIO 传输方式,将 genify 作为 MCP 服务运行:

genify mcp --root .

用于只读 Agent 会话:

genify mcp --root . --read-only

Codex 配置示例:

[mcp_servers.genify]
command = "genify"
args = ["mcp", "--root", "."]

MCP 服务仅向 stdout 写入协议消息;日志和诊断信息写入 stderr。 所有文件系统访问均限制在 --root 范围内。

可用工具:

工具行为
genify_plan返回计划执行的文件操作和受影响的路径,不写入文件。
genify_diff以试运行模式执行生成操作,并返回统一差异。
genify_apply仅当 explicit_approval 为 true 或 confirm_token 为 "apply" 时应用更改。
genify_validate_config验证配置解析、渲染和生成的路径。
genify_list_templates列出 MCP 根目录下的 .toml 配置和模板文件。

genify_plan、genify_diff 和 genify_apply 接受作为 MCP 工具参数直接传入的 JSON 配置。 无需临时 TOML 配置或模板文件。

{
  "config": {
    "rules": [
      {
        "type": "replace",
        "path": "src/application.rs",
        "replace": "old text",
        "content": "new text"
      }
    ]
  },
  "root": "."
}

支持的规则类型:

类型字段
writepath、content、if_exists(overwrite、error 或 skip)
deletepath
rename / movefrom、to
copyfrom、to
mkdirpath
chmodpath、mode
append / append_once / prependpath、content
insert_before / insert_afterpath、marker、content
replace / replace_or_appendpath、replace、content、可选的 replace_all、可选的 expected_matches
managed_blockpath、start_marker、end_marker、content

默认情况下,replace 会严格校验:当 replace_all 为 false 或未提供时,如果正则匹配数不等于 expected_matches,操作就会失败;expected_matches 默认为 1。

支持的规则示例:

{
  "config": {
    "rules": [
      {
        "type": "write",
        "path": "new/file.rs",
        "content": "...",
        "if_exists": "error"
      }
    ]
  }
}
{
  "config": {
    "rules": [
      {
        "type": "append_once",
        "path": "README.md",
        "content": "..."
      }
    ]
  }
}
{
  "config": {
    "rules": [
      {
        "type": "managed_block",
        "path": "README.md",
        "start_marker": "",
        "end_marker": "",
        "content": "..."
      }
    ]
  }
}
{
  "config": {
    "rules": [
      {
        "type": "insert_after",
        "path": "README.md",
        "marker": "## Usage",
        "content": "..."
      }
    ]
  }
}
{
  "config": {
    "rules": [
      {
        "type": "move",
        "from": "old/file.rs",
        "to": "new/file.rs"
      }
    ]
  }
}

当配置缺失或无效时,genify_validate_config 会返回结构化的 hint.minimal_config 和各操作的示例。

支持的变量类型
类型描述CLI 交互式支持
String文本值✅ 支持
Integer整数✅ 支持
Float小数✅ 支持
Booleantrue 或 false✅ 支持
Array值列表✅ JSON 输入
Map键值对✅ JSON 输入

注意: 对于 Array 和 Map,请在提示时输入 JSON,或使用 --props-json 预先提供。

代码
fn main() {
    genify::generate(
        Path::new("."),
        &genify::parse_toml(
            fs::read_to_string("example.toml")
                .unwrap()
                .as_str(),
        )
        .expect("The config should be valid"),
        Some(vec![(
            "value".to_string(),
            genify::Value::String("val".to_string()),
        )]),
    )
    .expect("The generation should be successful");
}

许可证

贡献

CONTRIBUTING.md

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。