Skip to content

MCP Server

The Logchef MCP server lets AI assistants query logs, explore schemas, manage alerts, and administer your Logchef deployment through the Model Context Protocol. It exposes 37 tools across 10 categories, plus resources and guided investigation prompts.

Before configuring your client, you need:

  1. A running Logchef instance — the MCP server connects to Logchef’s HTTP API.
  2. An API token — generate one from your Logchef profile settings page. The token determines what data the MCP server can access.

Pick your client and follow the setup instructions.

Terminal window
claude mcp add logchef -- logchef-mcp

Set the required environment variables before launching Claude Code:

Terminal window
export LOGCHEF_URL=https://your-logchef-instance.com
export LOGCHEF_API_KEY=your_api_token

Or pass them inline:

Terminal window
LOGCHEF_URL=https://your-logchef-instance.com \
LOGCHEF_API_KEY=your_api_token \
claude

The MCP server is a standalone Go binary distributed separately from Logchef.

Pre-built binaries — download from the releases page and place in your $PATH.

Dockerdocker pull ghcr.io/mr-karan/logchef-mcp:latest

Build from source (requires Go):

Terminal window
git clone https://github.com/mr-karan/logchef-mcp.git
cd logchef-mcp
go build -o logchef-mcp ./cmd/logchef-mcp

37 tools organized into 10 categories. Each tool includes MCP annotations indicating whether it is read-only, non-destructive, or destructive.

ToolDescription
get_profileGet current user profile, including email, role, and API token info
get_teamsList teams you belong to with your role and member counts
get_metaServer version and configuration details
ToolDescription
get_sourcesAll sources accessible to you, aggregated across all team memberships
get_team_sourcesSources belonging to a specific team
ToolDescription
query_logsExecute raw ClickHouse SQL against a log source (max 100 rows)
get_source_schemaGet column names and ClickHouse types for a source
get_log_histogramTime-series histogram of log volume with optional grouping
get_collectionsList saved query collections for a team/source
get_collectionGet a specific saved query by ID
create_collectionSave a new query collection
update_collectionUpdate an existing saved query
delete_collectionDelete a saved query permanently
ToolDescription
query_logchefqlExecute a LogchefQL query (max 500 rows)
translate_logchefqlTranslate LogchefQL to ClickHouse SQL without executing
validate_logchefqlCheck LogchefQL syntax for errors without executing
ToolDescription
get_field_valuesTop distinct values for a field in a time range
get_log_contextSurrounding log entries before/after a timestamp
list_alertsAll alert rules configured for a source
get_alert_historyEvaluation history for a specific alert
ToolDescription
compare_windowsRun the same query across two time windows and compare row counts
top_valuesGet top values for multiple fields in one call
ToolDescription
generate_queryGenerate a ClickHouse SQL query from natural language (requires AI enabled on Logchef)
get_all_field_dimensionsGet top values for all LowCardinality fields in one call
ToolDescription
get_query_telemetryRecent query performance from ClickHouse system.query_log
ToolDescription
list_all_teamsList all teams
get_teamGet team details
create_teamCreate a new team
update_teamUpdate team name/description
delete_teamDelete a team permanently
list_team_membersList members of a team
add_team_memberAdd a user to a team with a role
remove_team_memberRemove a user from a team
link_source_to_teamGrant a team access to a source
unlink_source_from_teamRevoke a team’s access to a source
list_all_usersList all users
get_userGet user details
create_userCreate a user
update_userUpdate user info
delete_userDelete a user
list_all_sourcesList all sources
create_sourceCreate a ClickHouse log source
validate_source_connectionTest ClickHouse connectivity
delete_sourceDelete a source
get_admin_source_statsClickHouse table stats — row count, sizes, compression
list_api_tokensList your API tokens
create_api_tokenCreate a new API token
delete_api_tokenDelete an API token

Resources provide read-only data that AI assistants can access without explicit tool calls.

URI TemplateDescription
logchef://team/{team_id}/source/{source_id}/schemaClickHouse schema for a source
logchef://team/{team_id}/source/{source_id}/collectionsList of saved queries
logchef://team/{team_id}/source/{source_id}/collection/{collection_id}A single saved query

Prompts provide guided multi-step investigation workflows.

Walks through error spike diagnosis: schema discovery, error volume assessment, pattern identification, timeline correlation, and root cause analysis.

ArgumentRequiredDescription
team_idYesTeam ID
source_idYesSource ID
time_rangeNoe.g., “last 1h” (defaults to last 1 hour)

Investigates a specific alert: review configuration, check evaluation history, reproduce the alert query, explore context, and summarize findings.

ArgumentRequiredDescription
team_idYesTeam ID
source_idYesSource ID
alert_idYesAlert ID

Disable tool categories you do not need to reduce the tool surface exposed to the AI assistant:

Terminal window
# Disable individual categories
logchef-mcp --disable-admin --disable-telemetry
# Or enable only specific categories
logchef-mcp --enabled-tools "profile,sources,logs,logchefql"

Available --disable-* flags:

FlagCategory disabled
--disable-profileProfile and metadata tools
--disable-sourcesSource management tools
--disable-logsLog querying and collection tools
--disable-logchefqlLogchefQL tools
--disable-investigateInvestigation tools
--disable-adminAdministration tools
--disable-analysisAnalysis tools
--disable-telemetryTelemetry tools
--disable-discoverDiscovery tools

The --enabled-tools flag accepts a comma-separated list of category names: profile, sources, logs, logchefql, investigate, admin, analysis, telemetry, discover. When used, only the listed categories are enabled.

Stdio mode (Claude Code, Claude Desktop, Cursor, etc.)

Section titled “Stdio mode (Claude Code, Claude Desktop, Cursor, etc.)”

Credentials are passed as environment variables:

Terminal window
export LOGCHEF_URL=https://your-logchef-instance.com
export LOGCHEF_API_KEY=your_api_token

When running the MCP server as a remote HTTP service, clients can pass credentials via HTTP headers instead of environment variables. This is useful when the server handles multiple clients with different Logchef instances.

HeaderDescription
X-Logchef-URLLogchef instance URL
X-Logchef-API-KeyAPI token

If headers are not provided, the server falls back to environment variables.

ModeFlagEndpointUse case
Stdio-t stdio (default for binary)Direct integration with desktop clients
SSE-t ssehttp://localhost:8000/sseWeb-based or remote clients
Streamable HTTP-t streamable-httphttp://localhost:8000/mcpMulti-client remote setups

Enable detailed HTTP request/response logging:

Terminal window
logchef-mcp -debug