Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions mcp_clickhouse/mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from fastmcp.server.auth.providers.jwt import StaticTokenVerifier
from fastmcp.server.dependencies import get_context
from fastmcp.tools import Tool
from mcp.types import ToolAnnotations
from starlette.requests import Request
from starlette.responses import PlainTextResponse

Expand Down Expand Up @@ -817,6 +818,7 @@ def _register_chdb_tools():
run_chdb_select_query_async,
name="run_chdb_select_query",
description="Run SQL in chDB, an in-process ClickHouse engine",
annotations=ToolAnnotations(readOnlyHint=True),
)
)
chdb_prompt = Prompt.from_function(
Expand All @@ -830,8 +832,8 @@ def _register_chdb_tools():

# Register tools based on configuration
if os.getenv("CLICKHOUSE_ENABLED", "true").lower() == "true":
mcp.add_tool(Tool.from_function(list_databases))
mcp.add_tool(Tool.from_function(list_tables))
mcp.add_tool(Tool.from_function(list_databases, annotations=ToolAnnotations(readOnlyHint=True)))
mcp.add_tool(Tool.from_function(list_tables, annotations=ToolAnnotations(readOnlyHint=True)))
mcp.add_tool(
Tool.from_function(
run_query_async,
Expand All @@ -841,6 +843,7 @@ def _register_chdb_tools():
"Set CLICKHOUSE_ALLOW_WRITE_ACCESS=true to allow DDL and DML operations. "
"Set CLICKHOUSE_ALLOW_DROP=true to additionally allow destructive operations (DROP, TRUNCATE)."
),
annotations=ToolAnnotations(readOnlyHint=not get_config().allow_write_access),
)
)
logger.info("ClickHouse tools registered")
Expand Down