| chTKCat_mcp_http_server | R Documentation |
Start a Model Context Protocol (MCP)
server available through HTTP (Streamable HTTP transport) to give remote
MCP clients (e.g., Claude Code) access to the MDBs of a chTKCat instance.
The server provides the same read-only tools as chTKCat_mcp_server().
chTKCat_mcp_http_server(
mcpHost = Sys.getenv("TKCAT_MCP_HOST", "127.0.0.1"),
mcpPort = as.integer(Sys.getenv("TKCAT_MCP_PORT", "8800")),
mcpPath = "/mcp",
host = Sys.getenv("TKCAT_HOST", "localhost"),
port = as.integer(Sys.getenv("TKCAT_PORT", "9111")),
https = as.logical(Sys.getenv("TKCAT_HTTPS", "FALSE")),
anonymousUser = Sys.getenv("TKCAT_MCP_ANONYMOUS_USER", NA),
anonymousPassword = Sys.getenv("TKCAT_MCP_ANONYMOUS_PASSWORD", ""),
allowedOrigins = NULL,
maxRows = 1000L,
maxChars = 60000L,
maxExecutionTime = 300L,
maxBodySize = 2^20,
cacheTime = 3600,
...
)
mcpHost |
the address on which the MCP server listens
(default: |
mcpPort |
the port on which the MCP server listens
(default: |
mcpPath |
the path of the MCP endpoint (default: "/mcp") |
host |
a character string specifying the host heberging the
chTKCat database (default: |
port |
an integer specifying the port on which the
database is listening (default: |
https |
a logical indicating if the HTTPS protocol should be used
to connect to the database
(default: |
anonymousUser |
the ClickHouse user to use for requests without
|
anonymousPassword |
the password of |
allowedOrigins |
requests with an |
maxRows |
maximum number of rows returned by a query (default: 1000) |
maxChars |
maximum number of characters returned by a tool call (default: 60000). Longer outputs are truncated. |
maxExecutionTime |
maximum execution time of a query in seconds (default: 300) |
maxBodySize |
maximum size of a request body in bytes (default: 1048576) |
cacheTime |
number of seconds during which user connections and MDB data models are kept in memory (default: 3600) |
... |
additional parameters for |
The server is meant to be run as a service behind a reverse proxy
(e.g., nginx) providing HTTPS: by default it only listens on the local
interface (mcpHost = "127.0.0.1").
See vignette("TKCat-MCP", package = "TKCat") for deployment instructions.
Authentication. Clients authenticate with their chTKCat (ClickHouse)
credentials provided in an HTTP Basic Authorization header
(Authorization: Basic <base64 of "user:password">). Credentials are
checked by ClickHouse and each client gets access to the MDBs readable by
its own user. No credential is stored by the server, except in memory
to keep the connections open (during cacheTime seconds).
If anonymousUser is set (e.g., "default"), requests without
Authorization header are processed with this user and
anonymousPassword.
Credentials are sent in clear text if HTTPS is not used.
Read-only access. As for chTKCat_mcp_server(), ClickHouse sessions
are opened with the readonly = 2 setting and SQL queries are checked
before being sent.
Protocol. The server is stateless: it does not create MCP sessions and answers each POST request with a single JSON response. It does not provide server-sent event streams (GET requests are rejected with a 405 status). Several instances can thus be run behind a load balancer.
Logging. Tool calls are logged on the standard error output (time, client address, user and tool name).
No return value, called for side effects: the function runs the server until it is interrupted.
chTKCat_mcp_server(), chTKCat()
## Not run:
## From a terminal (normally run as a service)
# TKCAT_HOST=localhost TKCAT_PORT=9111 \
# Rscript -e "TKCat::chTKCat_mcp_http_server(mcpPort = 8800)"
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.