Skip to main content
Glama

Code Refactor

重构代码

refactor_code

把遗留代码重构为现代规范代码,行为保持不变。会做语义化重命名、补全类型标注、生成中文注释、优化结构。适用于 Python / JavaScript / TypeScript / Java / Go / Rust / C / C++。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes待重构的原始代码全文。
taskYes重构要求,自然语言描述。例如:把函数名与变量名改为有意义的命名,补充类型标注与中文注释,保持行为不变。
languageNo代码语言,如 python / javascript / java / go。留空或 auto 表示自动识别。

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description carries the full burden and it does deliver real behavioral content: the behavior-preservation guarantee and the disclosure that it injects Chinese comments and type annotations into the code. However, it is silent on the things an agent most needs — whether refactored code is returned as text or written to files, whether changes are reversible, size/length limits, and any auth requirements. That is a meaningful gap for a mutation-style tool.

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?

Two tight sentences, front-loaded with the core action and the behavior-preservation contract before the transformation list and language scope. No filler, no repetition of the title.

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?

For a code-transformation tool with zero annotations and no output schema, the definition covers input expectations well but leaves the return contract entirely unstated — the agent cannot tell whether it receives refactored source, a diff, or a file write. Adequate but with a clear, load-bearing gap.

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 description coverage is 100%, so the baseline is 3 and the schema already explains 'code', 'task' (with an example prompt), and 'language' (including the auto-detect convention). The description's language list loosely reinforces the 'language' parameter but adds no syntax, format, or constraint detail beyond 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?

States a specific verb+resource (refactor legacy code into modern idiomatic code) plus the invariant contract ('行为保持不变') and the exact set of transformations performed. The supported-language list further bounds scope, so an agent knows precisely what this tool does without opening the schema. The only sibling, check_status, is unrelated, so no sibling differentiation is needed or possible.

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

Usage Guidelines3/5

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

Applicability is only implied through '适用于 Python / JavaScript / ...' — it tells the agent which inputs qualify but not when to prefer refactoring over, say, generating code fresh, nor any exclusions or prerequisites. With no comparable sibling there is no alternative to route to, but the description still never says when this tool is the right call.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.