Skip to main content
Glama
onion-ai

onion-mcp-server

Official
by onion-ai

ai_rewrite

Rewrite text in four styles: formal, casual, concise, or expand. Apply custom instructions to tailor the output.

Instructions

改写文本,支持正式化、口语化、简洁化、扩写四种模式。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes要改写的文本
modeNo改写模式: formal(正式)/ casual(口语)/ concise(简洁)/ expand(扩写)formal
instructionNo额外改写要求(可选),如:'保持技术术语不变'

Implementation Reference

  • Tool definition (schema) for ai_rewrite: name, description, and inputSchema with text (required), mode (formal/casual/concise/expand, default formal), and optional instruction.
    types.Tool(
        name="ai_rewrite",
        description="改写文本,支持正式化、口语化、简洁化、扩写四种模式。",
        inputSchema={
            "type": "object",
            "properties": {
                "text": {
                    "type":        "string",
                    "description": "要改写的文本",
                },
                "mode": {
                    "type":        "string",
                    "description": "改写模式: formal(正式)/ casual(口语)/ concise(简洁)/ expand(扩写)",
                    "enum":        ["formal", "casual", "concise", "expand"],
                    "default":     "formal",
                },
                "instruction": {
                    "type":        "string",
                    "description": "额外改写要求(可选),如:'保持技术术语不变'",
                    "default":     "",
                },
            },
            "required": ["text"],
        },
    ),
  • Handler logic for ai_rewrite: maps mode to rewrite instruction, optionally appends extra instruction, builds a prompt, and calls llm_call to rewrite the text.
    elif name == "ai_rewrite":
        mode_map = {
            "formal":  "改写为正式、专业的表达,适合商务或学术场景",
            "casual":  "改写为轻松、口语化的表达,适合日常对话",
            "concise": "精简改写,去除冗余,保留核心意思,尽量简短",
            "expand":  "扩写,补充细节、背景和论据,使内容更丰富",
        }
        instruction = mode_map.get(a.get("mode", "formal"), "改写为正式表达")
        extra        = f"\n额外要求:{a['instruction']}" if a.get("instruction") else ""
        prompt = (
            f"请对以下文本进行改写:{instruction}。{extra}\n"
            f"只输出改写后的文本,不要解释。\n\n"
            f"{a['text']}"
        )
        reply = await llm_call(prompt)
        return [types.TextContent(type="text", text=reply)]
  • Registration/routing: ai_rewrite is added via AI_TOOLS to ALL_TOOLS, and its name is mapped to the handle_ai handler in the _HANDLERS routing table.
    # ── 路由表 ────────────────────────────────────────────────────
    _HANDLERS: dict = {}
    for _t in AI_TOOLS:     
        _HANDLERS[_t.name] = handle_ai
    for _t in CODE_TOOLS:   
        _HANDLERS[_t.name] = handle_code
    for _t in TEXT_TOOLS:   
        _HANDLERS[_t.name] = handle_text
    for _t in DATA_TOOLS:   
        _HANDLERS[_t.name] = handle_data
    for _t in WEB_TOOLS:    
        _HANDLERS[_t.name] = handle_web
    for _t in SYSTEM_TOOLS: 
        _HANDLERS[_t.name] = handle_system
  • AI_TOOLS list (includes ai_rewrite at lines 115-139) is exported and aggregated into the server's ALL_TOOLS list.
    AI_TOOLS: list[types.Tool] = [
        types.Tool(
            name="ai_chat",
            description=(
                "与 AI 进行多轮对话。支持传入历史消息以保持上下文,"
                "支持自定义 system prompt。"
            ),
            inputSchema={
                "type": "object",
                "properties": {
                    "message": {
                        "type":        "string",
                        "description": "用户消息",
                    },
                    "system": {
                        "type":        "string",
                        "description": "系统提示词(设定 AI 角色和行为)",
                        "default":     "",
                    },
                    "history": {
                        "type":        "array",
                        "description": "历史消息列表,格式: [{\"role\":\"user\",\"content\":\"...\"},{\"role\":\"assistant\",\"content\":\"...\"}]",
                        "items": {
                            "type": "object",
                            "properties": {
                                "role":    {"type": "string", "enum": ["user", "assistant"]},
                                "content": {"type": "string"},
                            },
                        },
                        "default": [],
                    },
                    "temperature": {
                        "type":    "number",
                        "description": "温度 0.0~2.0(默认 0.7,越高越有创意)",
                        "default": 0.7,
                    },
                },
                "required": ["message"],
            },
        ),
        types.Tool(
            name="ai_translate",
            description=(
                "将文本翻译为目标语言。自动检测源语言,"
                "支持中文、英文、日文、韩文、法文、德文、西班牙文等 40+ 语言。"
            ),
            inputSchema={
                "type": "object",
                "properties": {
                    "text": {
                        "type":        "string",
                        "description": "要翻译的文本",
                    },
                    "target_language": {
                        "type":        "string",
                        "description": "目标语言,如:中文、英文、日文、法文、德文、西班牙文、韩文、俄文等",
                        "default":     "中文",
                    },
                    "style": {
                        "type":        "string",
                        "description": "翻译风格: formal(正式)/ casual(口语)/ literal(直译)",
                        "enum":        ["formal", "casual", "literal"],
                        "default":     "formal",
                    },
                },
                "required": ["text"],
            },
        ),
        types.Tool(
            name="ai_summarize",
            description="对长文本进行摘要,支持要点列表、段落摘要、一句话摘要三种模式。",
            inputSchema={
                "type": "object",
                "properties": {
                    "text": {
                        "type":        "string",
                        "description": "要摘要的文本",
                    },
                    "mode": {
                        "type":        "string",
                        "description": "摘要模式: bullets(要点列表)/ paragraph(段落)/ one_line(一句话)",
                        "enum":        ["bullets", "paragraph", "one_line"],
                        "default":     "bullets",
                    },
                    "max_points": {
                        "type":        "integer",
                        "description": "要点数量(bullets 模式有效,默认 5)",
                        "default":     5,
                    },
                    "language": {
                        "type":        "string",
                        "description": "输出语言(默认与原文相同)",
                        "default":     "",
                    },
                },
                "required": ["text"],
            },
        ),
        types.Tool(
            name="ai_rewrite",
            description="改写文本,支持正式化、口语化、简洁化、扩写四种模式。",
            inputSchema={
                "type": "object",
                "properties": {
                    "text": {
                        "type":        "string",
                        "description": "要改写的文本",
                    },
                    "mode": {
                        "type":        "string",
                        "description": "改写模式: formal(正式)/ casual(口语)/ concise(简洁)/ expand(扩写)",
                        "enum":        ["formal", "casual", "concise", "expand"],
                        "default":     "formal",
                    },
                    "instruction": {
                        "type":        "string",
                        "description": "额外改写要求(可选),如:'保持技术术语不变'",
                        "default":     "",
                    },
                },
                "required": ["text"],
            },
        ),
        types.Tool(
            name="ai_extract",
            description=(
                "从文本中提取结构化信息,支持:人名、地名、时间、"
                "关键词、数字、邮箱、URL、自定义字段。"
            ),
            inputSchema={
                "type": "object",
                "properties": {
                    "text": {
                        "type":        "string",
                        "description": "要提取信息的文本",
                    },
                    "fields": {
                        "type":        "array",
                        "items":       {"type": "string"},
                        "description": (
                            "要提取的字段列表,如: [\"人名\",\"地名\",\"时间\",\"关键词\",\"数字\",\"邮箱\",\"URL\"] "
                            "或自定义字段如 [\"产品名\",\"价格\",\"联系方式\"]"
                        ),
                        "default":     ["关键词", "人名", "地名", "时间"],
                    },
                    "output_format": {
                        "type":        "string",
                        "description": "输出格式: json / markdown(默认 markdown)",
                        "enum":        ["json", "markdown"],
                        "default":     "markdown",
                    },
                },
                "required": ["text"],
            },
        ),
        types.Tool(
            name="ai_classify",
            description="对文本进行分类,支持情感分析、主题分类、意图识别,或自定义分类标签。",
            inputSchema={
                "type": "object",
                "properties": {
                    "text": {
                        "type":        "string",
                        "description": "要分类的文本",
                    },
                    "task": {
                        "type":        "string",
                        "description": "分类任务: sentiment(情感)/ topic(主题)/ intent(意图)/ custom(自定义)",
                        "enum":        ["sentiment", "topic", "intent", "custom"],
                        "default":     "sentiment",
                    },
                    "labels": {
                        "type":        "array",
                        "items":       {"type": "string"},
                        "description": "自定义分类标签(task=custom 时必填),如 [\"投诉\",\"咨询\",\"建议\"]",
                        "default":     [],
                    },
                    "explain": {
                        "type":        "boolean",
                        "description": "是否输出分类理由(默认 true)",
                        "default":     True,
                    },
                },
                "required": ["text"],
            },
        ),
    ]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, and the description fails to disclose any behavioral traits (e.g., limitations, output format, or potential side effects). Only lists modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise single sentence, front-loaded with the action and modes, no extraneous information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a simple tool with full schema coverage, but lacks information on return value, which is missing since there is no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds minimal meaning beyond the schema; it simply reiterates the modes. Parameter details are adequately covered by the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool rewrites text and lists four specific modes (formal, casual, concise, expand), distinguishing it from siblings like summarization or translation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like ai_summarize or ai_translate. No conditions or exclusions provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/onion-ai/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server