Skip to main content
Glama
wenb1n-dev

mysql_mcp_server

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
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool's function but lacks details on behavioral traits such as error handling (e.g., for non-Chinese text), performance considerations, or output format. The description does not contradict annotations, but it fails to provide sufficient context for safe and effective use.

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 concise and front-loaded, consisting of a single sentence that directly states the tool's purpose. There is no wasted verbiage, and it efficiently communicates the core function. However, it could be slightly improved by structuring it to include usage context more explicitly.

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 the complexity of text conversion and the lack of annotations and output schema, the description is incomplete. It does not explain what the tool returns (e.g., a string of initials, a list, or an error message), nor does it address edge cases or dependencies. For a tool with no structured output documentation, this leaves significant gaps for the agent.

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?

The input schema has 100% description coverage, with the 'text' parameter documented as 'Chinese text to get pinyin initials, separated by commas.' The description adds no additional parameter semantics beyond what the schema provides, such as examples or constraints. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 the verb ('convert') and resource ('Chinese field names'), though it doesn't explicitly differentiate from sibling tools like get_table_desc or get_table_name, which appear to be related to table metadata but serve different functions.

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 minimal usage guidance, only mentioning 'when creating table structures.' It does not specify when to use this tool versus alternatives (e.g., whether it's for database design, data migration, or other contexts), nor does it mention prerequisites or exclusions. This leaves the agent with little context for appropriate invocation.

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

Related 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/wenb1n-dev/mysql_mcp_server_pro'

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