距离计算服务

使用Google Distance Matrix API计算两个位置之间距离的服务。

  • by sp13ceg
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 sp13ceg/distance-calculator-mcp

使用说明

距离计算器MCP服务器

该项目使用Google distance Matrix API计算两个位置之间的距离。

设置

  1. 安装依赖项:

    pip install -r requirements.txt
    
  2. 创建一个 config.ini 项目根目录中的文件,内容如下:

    [google]
    api_key = YOUR_API_KEY
    

    替换 YOUR_API_KEY 使用您的实际Google Distance Matrix API密钥。

运行应用程序

  1. 启动服务器:

    uvicorn main:app --reload
    
  2. API将于 http://127.0.0.1:8000.

API使用

向发送POST请求 /distance JSON有效载荷如下:

{
  "origin": {
    "location": "90210"
  },
  "destination": {
    "location": "New York, NY"
  }
}

运行MCP服务器

  1. 请确保已在中配置API密钥 config.ini 如“设置”部分所述。

  2. 启动MCP服务器:

    python mcp_server.py
    
  3. MCP服务器将在 http://127.0.0.1:8001.

gemini CLI示例