Skip to main content
Glama
onion-ai

onion-mcp-server

Official
by onion-ai

sys_hash

Compute hash values for text using MD5, SHA1, SHA256, or SHA512 algorithms. Output as hex or base64.

Instructions

计算字符串或文本的哈希值。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes要计算哈希的文本
algorithmNo哈希算法(默认 sha256)sha256
encodingNo输出编码:hex(默认)或 base64hex

Implementation Reference

  • The _sys_hash function executes the sys_hash tool logic: takes text, algorithm (md5/sha1/sha256/sha512), and encoding (hex/base64) parameters, computes the hash using hashlib, and returns the result.
    def _sys_hash(args: dict) -> list[types.TextContent]:
        text      = args["text"]
        algorithm = args.get("algorithm", "sha256")
        encoding  = args.get("encoding", "hex")
    
        h = hashlib.new(algorithm, text.encode("utf-8"))
    
        if encoding == "base64":
            result = base64.b64encode(h.digest()).decode()
        else:
            result = h.hexdigest()
    
        return [types.TextContent(type="text", text=(
            f"算法:   {algorithm.upper()}\n"
            f"编码:   {encoding}\n"
            f"输入:   {text[:80]}{'...' if len(text) > 80 else ''}\n"
            f"结果:   {result}"
        ))]
  • The sys_hash tool registration with its input schema: requires 'text' (string), optional 'algorithm' (enum: md5/sha1/sha256/sha512, default sha256), optional 'encoding' (enum: hex/base64, default hex).
    types.Tool(
        name="sys_hash",
        description="计算字符串或文本的哈希值。",
        inputSchema={
            "type": "object",
            "properties": {
                "text": {
                    "type":        "string",
                    "description": "要计算哈希的文本",
                },
                "algorithm": {
                    "type":        "string",
                    "description": "哈希算法(默认 sha256)",
                    "enum":        ["md5", "sha1", "sha256", "sha512"],
                    "default":     "sha256",
                },
                "encoding": {
                    "type":        "string",
                    "description": "输出编码:hex(默认)或 base64",
                    "enum":        ["hex", "base64"],
                    "default":     "hex",
                },
            },
            "required": ["text"],
        },
  • The handle_system dispatcher maps tool names to handler functions. For sys_hash, it routes to _sys_hash via 'sys_hash': _sys_hash entry.
    async def handle_system(name: str, arguments: dict) -> list[types.TextContent]:
        handlers = {
            "sys_time":       _sys_time,
            "sys_uuid":       _sys_uuid,
            "sys_hash":       _sys_hash,
            "sys_base64":     _sys_base64,
            "sys_url_encode": _sys_url_encode,
            "sys_json_valid": _sys_json_valid,
        }
        fn = handlers.get(name)
        if fn is None:
            raise ValueError(f"未知 system 工具: {name}")
        return fn(arguments)
  • In the main server registration, SYSTEM_TOOLS tools (including sys_hash) are mapped to handle_system dispatcher, which routes to _sys_hash.
    for _t in SYSTEM_TOOLS: 
        _HANDLERS[_t.name] = handle_system
  • SYSTEM_TOOLS (which includes sys_hash) is included in the ALL_TOOLS list returned by list_tools for MCP capability discovery.
    ALL_TOOLS: list[types.Tool] = [
        *AI_TOOLS,
        *CODE_TOOLS,
        *TEXT_TOOLS,
        *DATA_TOOLS,
        *WEB_TOOLS,
        *SYSTEM_TOOLS,
    ]
Behavior2/5

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

No annotations are present, so the description should disclose behavioral traits. It only states the basic function, omitting whether the operation is idempotent, has side effects, or performance characteristics. No mention of supported string encoding or handling of empty input.

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

Conciseness4/5

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

The description is a single sentence with no wasted words. However, it could be slightly more informative without becoming verbose.

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?

Given no output schema, the description should mention the return value (e.g., 'returns the hash as a string'). It also lacks details about algorithm behavior or encoding defaults. Incomplete for a 3-parameter tool.

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 schema already documents each parameter. The description adds no additional semantic meaning beyond the schema. Baseline of 3 is appropriate.

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 it calculates the hash value of a string or text, using a specific verb and resource. It is easily distinguishable from sibling tools like sys_base64 or sys_uuid.

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?

The description provides no guidance on when to use this tool vs alternatives. No context about prerequisites, limitations, or comparison to other hash-related tools.

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