base64_encode_text
Convert text to Base64 encoding for data transmission or storage. This tool encodes plain text into Base64 format, which is commonly used in web development, APIs, and data handling to represent binary data as ASCII text.
Instructions
将文本转换为Base64编码
Args:
text: 要编码的文本
Returns:
Base64编码结果
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes |
Implementation Reference
- base64_server.py:22-37 (handler)The @mcp.tool() decorated function implementing the base64_encode_text tool. It encodes the input text string to Base64 format using base64.b64encode, handles UTF-8 encoding/decoding, and returns the result prefixed with 'Base64编码结果: '. Includes error handling.@mcp.tool() def base64_encode_text(text: str) -> str: """将文本转换为Base64编码 Args: text: 要编码的文本 Returns: Base64编码结果 """ try: encoded = base64.b64encode(text.encode("utf-8")).decode("utf-8") return f"Base64编码结果: {encoded}" except Exception as e: return f"编码失败: {str(e)}"