Skip to main content
Glama
wenb1n-dev

mysql_mcp_server

by wenb1n-dev

get_chinese_initials

Convert Chinese field names to their pinyin initials during table creation in MySQL. Simplifies database schema design by automating the transformation of Chinese characters into usable identifiers.

Instructions

创建表结构时,将中文字段名转换为拼音首字母字段

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes要获取拼音首字母的汉字文本,以“,”分隔

Implementation Reference

  • Core tool execution logic: converts Chinese words separated by Chinese commas to uppercase pinyin initials using the pypinyin library and returns as TextContent.
    async def run_tool(self, arguments: Dict[str, Any]) -> Sequence[TextContent]:
            """将中文文本转换为拼音首字母
    
            参数:
                text (str): 要转换的中文文本,以中文逗号分隔
    
            返回:
                list[TextContent]: 包含转换结果的TextContent列表
                - 每个词的首字母会被转换为大写
                - 多个词的结果以英文逗号连接
    
            示例:
                get_chinese_initials("用户名,密码")
                [TextContent(type="text", text="YHM,MM")]
            """
            try:
                if "text" not in arguments:
                    raise ValueError("缺少查询语句")
    
                text = arguments["text"]
    
                # 将文本按逗号分割
                words = text.split(',')
    
                # 存储每个词的首字母
                initials = []
    
                for word in words:
                    # 获取每个字的拼音首字母
                    word_pinyin = pinyin(word, style=Style.FIRST_LETTER)
                    # 将每个字的首字母连接起来
                    word_initials = ''.join([p[0].upper() for p in word_pinyin])
                    initials.append(word_initials)
    
                # 用逗号连接所有结果
                return [TextContent(type="text", text=','.join(initials))]
    
            except Exception as e:
                return [TextContent(type="text", text=f"执行查询时出错: {str(e)}")]
  • Defines the tool schema with input parameter 'text' (string) describing Chinese text separated by commas for initials extraction.
    def get_tool_description(self) -> Tool:
        return Tool(
            name=self.name,
            description=self.description,
            inputSchema={
                "type": "object",
                "properties": {
                    "text": {
                        "type": "string",
                        "description": "要获取拼音首字母的汉字文本,以“,”分隔"
                    }
                },
                "required": ["text"]
            }
        )
  • Automatic registration mechanism in BaseHandler base class that registers subclasses like GetChineseInitials to ToolRegistry when defined.
    def __init_subclass__(cls, **kwargs):
        """子类初始化时自动注册到工具注册表"""
        super().__init_subclass__(**kwargs)
        if cls.name:  # 只注册有名称的工具
            ToolRegistry.register(cls)
  • Import statement in handles __init__.py that loads the GetChineseInitials class, triggering its automatic registration.
    from .get_chinese_initials import GetChineseInitials

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.1/5.0
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While it describes the conversion function, it doesn't mention important behavioral aspects like whether this is a read-only operation, what format the output takes, error handling for non-Chinese text, or performance characteristics. The description is functional but lacks operational context.

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?

The description is a single, efficient sentence that directly states the tool's purpose without any wasted words. It's appropriately sized for a simple transformation tool and gets straight to the point.

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 single-parameter transformation tool with no output schema, the description adequately explains what the tool does. However, it lacks information about the output format (what the pinyin initials look like) and doesn't address edge cases or limitations, which would be helpful given the absence of annotations.

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% with the parameter 'text' well-documented in the schema. The description doesn't add any parameter-specific information beyond what the schema already provides about the comma-separated Chinese text input. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the tool's purpose: converting Chinese field names to pinyin initials during table structure creation. It specifies both the action ('转换' - convert) and the resource ('中文字段名' - Chinese field names), though it doesn't explicitly differentiate from sibling tools like get_table_name or get_table_desc.

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 versus alternatives. It mentions '创建表结构时' (during table structure creation) which gives some context, but doesn't specify prerequisites, limitations, or when other tools might be more appropriate given the sibling tools available.

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

Deploy Server

Other Tools

Related Tools