Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
ClickHouse launches Claude-powered Agents and House Mates partner program at Open House 2026 Read more →
了解如何使用 Claude Agent SDK 和 ClickHouse MCP 服务器构建 AI Agent
pip
pip install -q --upgrade pip pip install -q claude-agent-sdk pip install -q ipywidgets
import os, getpass os.environ["ANTHROPIC_API_KEY"] = getpass.getpass("Enter Anthropic API Key:")
Enter Anthropic API Key: ········
env = { "CLICKHOUSE_HOST": "sql-clickhouse.clickhouse.com", "CLICKHOUSE_PORT": "8443", "CLICKHOUSE_USER": "demo", "CLICKHOUSE_PASSWORD": "", "CLICKHOUSE_SECURE": "true" }
from claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, UserMessage, TextBlock, ToolUseBlock
options = ClaudeAgentOptions( allowed_tools=[ "mcp__mcp-clickhouse__list_databases", "mcp__mcp-clickhouse__list_tables", "mcp__mcp-clickhouse__run_select_query", "mcp__mcp-clickhouse__run_chdb_select_query" ], mcp_servers={ "mcp-clickhouse": { "command": "uv", "args": [ "run", "--with", "mcp-clickhouse", "--python", "3.10", "mcp-clickhouse" ], "env": env } } ) async for message in query(prompt="Tell me something interesting about UK property sales", options=options): if isinstance(message, AssistantMessage): for block in message.content: if isinstance(block, TextBlock): print(f"🤖 {block.text}") if isinstance(block, ToolUseBlock): print(f"🛠️ {block.name} {block.input}") elif isinstance(message, UserMessage): for block in message.content: if isinstance(block, TextBlock): print(block.text)
for
🤖 我会查询 ClickHouse 数据库,找一些关于英国房产交易的有趣信息。 先让我看看有哪些数据库可用: 🛠️ mcp__mcp-clickhouse__list_databases {} 🤖 很好!这里有一个 “uk” 数据库。让我看看有哪些表可用: 🛠️ mcp__mcp-clickhouse__list_tables {'database': 'uk'} 🤖 太好了!`uk_price_paid` 表中有超过 3000 万条房产交易记录。让我找点有意思的内容: 🛠️ mcp__mcp-clickhouse__run_select_query {'query': "\nSELECT \n street,\n town,\n max(price) as max_price,\n min(price) as min_price,\n max(price) - min(price) as price_difference,\n count() as sales_count\nFROM uk.uk_price_paid\nWHERE street != ''\nGROUP BY street, town\nHAVING sales_count > 100\nORDER BY price_difference DESC\nLIMIT 1\n"} 🤖 这里有个很有意思的发现:**伦敦的 Baker Street**(没错,就是福尔摩斯那条著名的街道!)在所有成交超过 100 笔的街道中,房价区间最大——最低成交价仅为 **£2,500**,最高则达到 **£5.943 亿**,惊人的价差超过 **5.94 亿英镑**! 这也说得通,因为 Baker Street 是伦敦最负盛名的地址之一,穿过 Marylebone 等富裕地区,而且在这个数据集中一共记录了 541 笔成交。
此页面对您有帮助吗?