Tableau VDS端点集成工具

通过MCP服务器暴露Tableau VDS端点并与Claude桌面客户端集成的原型工具,用于数据查询和分析。

  • by joeconstantino
  • Python
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 joeconstantino/test-tableau-mcp

使用说明

mcp测试表

该项目是一个快速原型,通过MCP服务器公开Tableau VDS端点,并将其与Claude Desktop客户端集成。

要运行此MCP服务器并将其连接到Claude Desktop,请执行以下步骤。这些说明改编自 MCP操作指南。这些说明假定您使用的是MacOS/Linux。如果您运行的是Windows,请参阅上面链接的操作指南。

系统要求

已安装Python 3.10或更高版本。 您必须使用Python MCP SDK 1.2.0或更高版本。

设置您的环境

如果还没有,请安装UV。

curl -LsSf https://astral.sh/uv/install.sh | sh

确保之后重新启动终端,以确保收到uv命令。

现在,创建并设置您的虚拟环境:

# Create virtual environment and activate it
uv venv
source .venv/bin/activate

# Install dependencies
uv add "mcp[cli]" httpx

硬编码所需的环境变量

这个简单的原型要求你在vds.py文件中编写4个变量:

  1. 您的服务器url位于 VIZQL_API_BASE
  2. 您的服务器url位于 METADATA_GRAPHQL
  3. 要在其中查询的数据源的数据源LUID DS_LUID
  4. 中的有效会话令牌 AUTH_TOKEN

运行服务器

uv --directory <ABSOLUTE PATH TO PROJECT> run vds.py

使用Claude for Desktop测试您的服务器

首先,确保您安装了Claude for Desktop。您可以安装 此处为最新版本。如果您已经有Claude for Desktop,请确保它已更新到最新版本。

我们需要为您想要使用的任何MCP服务器配置Claude for Desktop。为此,请在以下位置打开Claude for Desktop App配置 ~/Library/Application Support/Claude/claude_desktop_config.json 在文本编辑器中。如果文件不存在,请确保创建该文件。

例如,如果您安装了VS Code: code ~/Library/Application\ Support/Claude/claude_desktop_config.json

然后,您将在mcpServers密钥中添加服务器。如果至少有一台服务器配置正确,MCP UI元素将仅显示在Claude for Desktop中。

在这种情况下,我们将添加单个vds服务器,如下所示:

{
    "mcpServers": {
        "vds": {
            "command": "uv",
            "args": [
                "--directory",
                "/ABSOLUTE/PATH/TO/PARENT/FOLDER/test-tableau-mcp/",
                "run",
                "vds.py"
            ]
        }
    }
}

您可能需要在命令字段中输入uv可执行文件的完整路径。你可以通过跑步来获得这个 which uv 在MacOS/Linux或 where uv 在Windows上。

此消息克劳德桌面:

有一个名为“vds”的MCP服务器。通过运行以下命令启动它 uv --directory /ABSOLUTE/PATH/TO/PARENT/FOLDER/ run vds.py。保存文件,然后重新启动Claude for Desktop。

在Claude中运行查询以触发工具

VDS API语法在MCP工具中没有明确传递,因此通过传递一些上下文中的示例来开始会话,这些示例向Claude展示如何正确格式化 Query 物体。你可以复制samples.py中的字典数组。向Claude发送一条初始消息,如下所示: 确保根据以下语法生成有效载荷:

in_context_samples = [
  {
    "fields": [
      { "fieldCaption": "Segment" },
      { "fieldCaption": "Sales", "function": "SUM" }
    ]
  },
  {
    "fields": [
      { "fieldCaption": "Category" },
      { "fieldCaption": "Profit", "function": "SUM", "sortDirection": "DESC" }
    ]
  },
  {
    "fields": [
      { "fieldCaption": "State/Province" },
      { "fieldCaption": "Sales", "function": "SUM", "sortDirection": "DESC" }
    ],
    "filters": [
      {
        "field": { "fieldCaption": "Segment" },
        "filterType": "SET",
        "values": ["Consumer"],
        "exclude": false
      },
      {
        "field": { "fieldCaption": "Order Date" },
        "filterType": "RANGE",
        "min": "2021-01-01",
        "max": "2021-12-31"
      }
    ],
    "limit": 5
  }
]

do the states with the most sales also have the most profit?