Rulemorph MCP Server

平台与服务

by vinhphatfsg

基于 YAML rules 的 MCP server,用于 CSV/JSON 数据转换与处理,便于自动化编排。

什么是 Rulemorph MCP Server

基于 YAML rules 的 MCP server,用于 CSV/JSON 数据转换与处理,便于自动化编排。

README

<p align="center"> <img src="assets/ogp.png" alt="Rulemorph" width="600"> </p> <p align="center"> <a href="https://crates.io/crates/rulemorph"><img src="https://img.shields.io/crates/v/rulemorph.svg" alt="Crates.io"></a> <a href="https://docs.rs/rulemorph"><img src="https://docs.rs/rulemorph/badge.svg" alt="docs.rs"></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a> </p>

Rulemorph transforms data from external APIs, CSV, JSON, YAML, TOML, XML, HTML, Markdown, and Excel into predictable JSON using declarative YAML/JSON rules.

Instead of adding another custom script for every input source, you can keep transformation behavior in rule files. The same rules can be reused from the CLI, embedded in Rust, served through a local UI/API server, or exposed to AI assistants through MCP.

Try it in your browser: playground.rulemorph.com

What It Solves

Rulemorph moves growing transformation code into reviewable, versioned rules.

  • Normalize vendor API responses into your internal schema
  • Bring CSV / Excel imports into a JSON pipeline
  • Extract values from HTML or XML and process them with the same rule model
  • Review, replace, and version transformation behavior as YAML/JSON
  • Reuse the same transformation from the CLI, a local API, or an AI assistant

It is not meant to replace application code for arbitrary execution, complex domain logic, or long-running workflow orchestration. For those cases, normal application code or a workflow engine is usually a better fit.

Quick Start

Transform a users array from an external API response into the JSON shape your application expects.

rules.yaml

yaml
version: 2
input:
  format: json
  json:
    records_path: "users"
mappings:
  - target: "id"
    source: "user_id"
  - target: "name"
    expr: ["@input.full_name", trim]
  - target: "email"
    expr: ["@input.username", concat: ["lit:@example.com"]]

input.json

json
{ "users": [{ "user_id": 1, "full_name": " Alice ", "username": "alice" }] }

Run

sh
rulemorph transform -r rules.yaml -i input.json

You can also pipe input to transform:

sh
cat input.json | rulemorph transform -r rules.yaml
cat input.json | rulemorph transform -r rules.yaml -i -

Output

<details> <summary>Show output</summary>
json
[{ "id": 1, "name": "Alice", "email": "alice@example.com" }]
</details>

For quick one-off transformations without a rule file, use direct mode.

Evaluate a single expression against JSON or ad-hoc CSV:

sh
echo '{ "test": 1 }' | rulemorph -rule '@input.test'
echo '{ "a": 1, "b": 2 }' | rulemorph --rule '["@input.a", {"+": ["@input.b"]}]'
echo 'a,test,1' | rulemorph -rule '@input.0'
echo 'a,test,1' | rulemorph -H 'id,name,age' -rule '@input.id'
<details> <summary>Show output</summary>
text
1
3
"a"
"a"
</details>

Use -F/--field when you want a small output object and field order matters:

sh
echo 'u1,Alice,42' | rulemorph -H 'id,name,age' \
  -F id='@input.id' \
  -F name='["@input.name","trim","uppercase"]' \
  -F age='["@input.age","int"]'
<details> <summary>Show output</summary>
json
{ "id": "u1", "name": "ALICE", "age": 42 }
</details>

Use --output-map when a compact nested target map is easier to read:

sh
echo 'u1,Alice,42' | rulemorph -H 'id,name,age' \
  --output-map '{"user.id":"@input.id","user.name":["@input.name","trim"],"age":["@input.age","int"]}'
<details> <summary>Show output</summary>
json
{ "user": { "id": "u1", "name": "Alice" }, "age": 42 }
</details>

For multi-record direct input, add --ndjson to emit one JSON value per line:

sh
printf 'u1,Alice,42\nu2,Bob,7\n' | rulemorph --ndjson -H 'id,name,age' \
  --output-map '{"id":"@input.id","age":["@input.age","int"]}'
<details> <summary>Show output</summary>
jsonl
{"age":42,"id":"u1"}
{"age":7,"id":"u2"}
</details>

Direct mode can also read CSV or Excel files. CSV headers are inferred from .csv files; use -H/--headers for headerless CSV. For Excel, select the header row and data range explicitly:

sh
rulemorph --rule '@input.id' -i users.csv
rulemorph -H 'id,name,age' --rule '@input.id' -i headerless-users.csv
rulemorph --rule '@input.id' -i users.xlsx --excel-header-row 1 --excel-data-range A2:D20
<details> <summary>Show output</summary>
text
"u1"
"u1"
["u1","u2"]
</details> <p align="center"> <img src="assets/transform-scene.gif" alt="Rulemorph Demo" width="800"> </p>

Which Package To Use

GoalUse
Try rules without installing anythingRulemorph Playground
File transforms, DTO generation, CI validationrulemorph CLI
Embed transformations in a Rust applicationrulemorph crate
Run the local UI or YAML-defined APIsrulemorph-server
Use transforms, validation, and DTO generation from an AI assistantrulemorph-mcp

Installation

Prebuilt binaries for the CLI, server, and MCP server are available from GitHub Releases.

CLI

sh
brew install vinhphatfsg/tap/rulemorph

Build from source for development:

sh
cargo build -p rulemorph_cli --release
./target/release/rulemorph --help

UI / API Server

sh
brew install vinhphatfsg/tap/rulemorph-server
rulemorph-server --rules-dir ./api_rules --api-mode rules

For full startup steps, see the UI Server Guide.

MCP Server

rulemorph-mcp exposes Rulemorph capabilities to AI assistants through the Model Context Protocol.

  • transform: transform data
  • validate_rules: validate rules
  • generate_dto: generate DTOs
  • analyze_input: summarize input structure

Claude Code setup:

sh
claude mcp add rulemorph -- rulemorph-mcp

Key Features

  • Normalize CSV / JSON / YAML / TOML / XML / HTML / Markdown / .xlsx Excel into JSON records
  • Build output fields with mappings
  • Transform values with v2 pipe expressions: trim, case conversion, concatenation, numeric operations, lookups, and array operations
  • Define rule-local custom OPs with defs to reuse typed v2 pipes or mapping bodies
  • Use numeric helpers such as sqrt, mod, pow, clamp, and range for bounded generated sequences
  • Control behavior with record_when, when, and asserts
  • Use steps, branch, and finalize for ordered execution and output-array processing
  • Generate inferred DTOs for Rust, TypeScript, Python, Go, Java, Kotlin, and Swift. Explicit type wins; dynamic or unsafe shapes fall back to JSON-friendly types.
  • Inspect semantic traces for built-in and custom OP execution without changing transform output
  • Run a local UI/API server or expose the same engine through MCP

Input parsers are designed to be conservative. HTML parsing does not execute JavaScript or fetch URLs, Markdown raw HTML is preserved only as source text, and Excel parsing does not execute macros or evaluate formulas. XML DTD/entities and JSON/YAML duplicate keys are rejected to avoid ambiguous or side-effectful input behavior.

Rule Structure

yaml
version: 2
input:
  format: json # csv | json | yaml | toml | xml | html | markdown | excel
  json:
    records_path: "items"
mappings:
  - target: "output.field"
    source: "input.field"
    type: string
    when:
      eq: ["@input.status", "active"]

New rule files should use version: 2. version: 1 rule files are still accepted during migration, but validation and runtime entry points emit a deprecation warning. A later release will move version: 1 rule files behind an explicit legacy opt-in before removing that syntax.

For the full rule specification, see Transformation Rules Spec. The Japanese version is also available in Japanese.

DTO Generation

sh
rulemorph generate -r rules.yaml -l typescript
typescript
export interface Record {
  id: number;
  name: string;
  email: string;
}

Supported languages: rust, typescript, python, go, java, kotlin, swift

DTO generation uses explicit mapping types first, then infers simple scalar, array, map, and nested object shapes from literals and v2 pipe expressions. If a shape is dynamic or too broad to infer safely, the generated DTO uses each language's JSON fallback type.

Library Usage

toml
[dependencies]
rulemorph = "0.3.4"

The html, excel, and markdown input parsers are enabled by default. Library users that only need core CSV, JSON, YAML, TOML, and XML support can disable them to reduce optional parser dependencies:

toml
[dependencies]
rulemorph = { version = "0.3.4", default-features = false }

Re-enable parsers explicitly with features such as ["html"], ["excel"], or ["markdown"]. If a disabled parser is selected by a rule, transformation fails with invalid_input (for Markdown: input format markdown is not enabled in this build).

rust
use rulemorph::{parse_rule_file, transform};

let rule = parse_rule_file(&std::fs::read_to_string("rules.yaml")?)?;
let input = std::fs::read_to_string("input.json")?;
let output = transform(&rule, &input, None)?;

Documentation

常见问题

Rulemorph MCP Server 是什么?

基于 YAML rules 的 MCP server,用于 CSV/JSON 数据转换与处理,便于自动化编排。

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描171.4k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描171.4k

接口测试套件

by alirezarezvani

Universal
热门

扫描 Next.js、Express、FastAPI、Django REST 的 API 路由,自动生成覆盖鉴权、参数校验、错误码、分页、上传与限流场景的 Vitest 或 Pytest 测试套件。

帮你把API与集成测试自动化跑顺,减少回归漏测;能力全面,尤其适合复杂接口场景的QA团队。

平台与服务
未扫描24.9k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
89.7k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
80.0k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
72.9k

评论