文档首页/ 华为云码道(CodeArts)代码智能体/ 常见问题/ 如何让MCP工具支持高精度数字参数?
更新时间:2026-05-07 GMT+08:00
分享

如何让MCP工具支持高精度数字参数?

问题现象

在华为云码道中配置MCP服务器后,通过MCP协议调用接口时,返回的参数值与实际输入的参数值不一致。

原因分析

华为云码道没有内置高精度数字处理机制,超出安全整数范围的数字会在JSON解释阶段丢失精度。

解决方法

在MCP服务端,建议使用String类型传递高精度数字,即将高精度数字参数的JSON Schema类型设置为“string”

{
  "inputSchema": {
    "type": "object",
    "properties": {
      "amount": {
        "type": "string",
        "description": "Amount in wei (high-precision integer as decimal string, e.g., '1000000000000000000')"
      }
    }
  }
}

相关文档