Skip to main content
Glama
onion-ai

onion-mcp-server

Official
by onion-ai

code_review

Analyze code to detect bugs, security vulnerabilities, performance issues, and style problems. Optionally specify programming language and focus areas.

Instructions

审查代码,找出 Bug、安全漏洞、性能问题和代码风格问题。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes要审查的代码
languageNo编程语言
focusNo

Implementation Reference

  • Handler for the code_review tool: builds a prompt instructing the LLM to review the code focusing on bug, security, performance, and/or style issues, then calls llm_call.
    elif name == "code_review":
        focus     = a.get("focus", ["all"])
        focus_str = "所有方面(Bug、安全、性能、代码风格)" if "all" in focus else "、".join(focus)
        lang      = a.get("language", "") or ""
        prompt = (
            f"请对以下 {lang} 代码进行代码审查,重点关注:{focus_str}。\n"
            f"请按以下格式输出:\n"
            f"1. 问题列表(严重程度 + 描述 + 修复建议)\n"
            f"2. 整体评分(1-10)\n"
            f"3. 改进后的代码(如有必要)\n\n"
            f"```\n{a['code']}\n```"
        )
  • Schema definition for code_review tool: requires 'code', optional 'language' and 'focus' (array with choices bug/security/performance/style/all).
    types.Tool(
        name="code_review",
        description="审查代码,找出 Bug、安全漏洞、性能问题和代码风格问题。",
        inputSchema={
            "type": "object",
            "properties": {
                "code":     {"type": "string", "description": "要审查的代码"},
                "language": {"type": "string", "description": "编程语言", "default": ""},
                "focus":    {
                    "type":    "array",
                    "items":   {"type": "string", "enum": ["bug", "security", "performance", "style", "all"]},
                    "default": ["all"],
                },
            },
            "required": ["code"],
        },
    ),
  • Registration: code_review (as part of CODE_TOOLS) is mapped to the handle_code handler function in the _HANDLERS routing table.
    for _t in CODE_TOOLS:   
        _HANDLERS[_t.name] = handle_code
  • Helper: llm_call utility invoked by handle_code to send the constructed prompt to the LLM and return the response.
    async def llm_call(
        prompt: str,
        system: Optional[str] = None,
        temperature: float = 0.7,
    ) -> str:
        """单轮调用"""
        messages = []
        if system:
            messages.append({"role": "system", "content": system})
        messages.append({"role": "user", "content": prompt})
        return await llm_chat(messages, temperature=temperature)
Behavior2/5

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

No annotations provided, so description carries full burden. Only states it 'finds' issues but does not disclose whether it modifies code, side effects, permissions needed, or output format.

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?

Single sentence, efficient, no redundancy. All words earn their place.

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

Completeness2/5

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

Tool has no output schema, but description does not indicate return format (e.g., list of issues with locations/severity). Lacks detail on language support or limitations.

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?

Input schema coverage is 67% (descriptions for 'code' and 'focus'). Tool description adds no extra meaning beyond schema; language parameter has minimal description. Baseline 3 given coverage.

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?

Description clearly states the verb 'review', resource 'code', and specific outcomes (bugs, security, performance, style issues). Distinguishes from sibling tools like code_fix or code_explain.

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 explicit guidance on when to use this vs alternatives. Does not mention prerequisites or exclusions, leaving the agent to infer from sibling names.

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