Skip to content

Operate a running server

This page is for whoever keeps a deployed server healthy. It assumes the stack from Deploy with Docker Compose; the same applies to any deployment.

sklad logs one event per MCP tool call at INFO. Set SKLAD_LOG_FORMAT=json for one JSON object per line (the reference compose file does). A tool call looks like this:

{"timestamp":"2026-12-04T14:06:38.834102Z","level":"INFO","fields":{"message":"tool call","request_id":"32fc7ca1","token_id":"ymsw0ag0","token_name":"laptop","scopes_granted":"kb:read","tool":"kb_search","args_sha":"0174…300f","duration_ms":4,"outcome":"success","commit_sha":"","path":"","dry_run":false}}
Field Meaning
request_id Random per call; correlates related lines
token_id, token_name, scopes_granted The caller’s token
tool The MCP tool
args_sha SHA-256 of the arguments; the arguments themselves are not logged at INFO
duration_ms Time from dispatch to result
outcome success, tool_error, conflict, policy_violation, error, forbidden, or unauthorized
error_code The JSON-RPC error code, present only when the call failed with one
commit_sha, path The commit and file of a successful write; empty for reads
dry_run Whether the caller asked for a dry run

The fields sit under .fields. Other lines are not tool calls, and fromjson? skips any that are not JSON:

Terminal window
docker compose logs --no-log-prefix sklad | jq -cR 'fromjson? | select(.fields.outcome? == "conflict")'
docker compose logs --no-log-prefix sklad | jq -cR 'fromjson? | select(.fields.duration_ms? > 1000) | .fields | {tool, duration_ms}'

To see a tool’s arguments, raise its log level, such as RUST_LOG=sklad_tools=trace.

Prometheus metrics are served on a separate listener, metrics_listen, default 127.0.0.1:9090. In the compose stack it stays inside the compose network.

Metric Type and labels
sklad_requests_total counter, outcome
sklad_tool_calls_total counter, tool, outcome
sklad_request_duration_seconds histogram, tool; buckets 1 ms to 10 s; tool calls that pass authentication
sklad_write_conflicts_total counter, tool
sklad_policy_hits_total counter, category
sklad_index_entities, sklad_index_sections gauges, set on every index rebuild
sklad_watcher_events_total counter, kind
sklad_framework_reload_failures_total counter: a changed .kb/ failed to load
sklad_git_repo_size_bytes gauge, sampled hourly
sklad_git_preflight_total counter, result: the push check at startup
sklad_git_auto_push_total, sklad_git_auto_push_failures_total counters; failures carry reason
sklad_git_pull_total counter, result: up_to_date, updated, diverged, fetch_failed, timeout, spawn_failed, stuck_state
sklad_git_pull_conflicts_total counter
kb_repo_behind_remote gauge: 1 when the checkout could not catch up with the remote
sklad_jwks_refresh_total counter, result: ok or fail
sklad_share_views_total counter, tier, path
sklad_share_lookup_failures_total counter, reason: unknown, revoked, malformed, missing_file, internal

Labels hold only bounded values, except path on sklad_share_views_total: it counts only paths that resolved to a real note, but grows with every distinct note viewed until the process restarts.

Alerts worth having:

  • rate(sklad_requests_total{outcome="error"}[5m]) above zero for a while.
  • sklad_write_conflicts_total rising: something else edits the files the server writes.
  • Any sklad_policy_hits_total: a write was blocked or flagged by the [policy] scan.
  • sklad_git_auto_push_failures_total rising while sklad_git_auto_push_total does not: writes are not reaching the remote.
  • kb_repo_behind_remote == 1.

With git.auto_push on (the default), every commit the server makes is pushed to git.remote and git.branch (default origin and main). A failed push is logged, counted in sklad_git_auto_push_failures_total, and not retried inline; the write result’s pushed field is false and kb_health reports the commits as unpushed.

When something else also pushes to the remote, such as another machine or a sync tool, enable git.auto_pull so the server integrates those commits:

Terminal window
SKLAD_GIT__AUTO_PULL__ENABLED=true
SKLAD_GIT__AUTO_PULL__STRATEGY=rebase
SKLAD_GIT__AUTO_PULL__INTERVAL_SECS=300
Strategy Behavior
rebase Replays the server’s unpushed commits on top of the remote and pushes them. A conflict aborts the rebase, leaves the tree clean, and raises kb_repo_behind_remote and sklad_git_pull_conflicts_total.
ff-only Integrates only when the server has no commits of its own; otherwise skips and raises kb_repo_behind_remote. Suits read-only replicas.

The interval must lie between 30 and 86400 seconds, default 300; a value outside that range stops the server at startup. A pull pauses writes while it runs, and the index is rebuilt only when HEAD moved. A stuck_state result, a conflict whose abort also failed, stops the pull loop: resolve the checkout by hand and restart.

What Why
The token database, auth_db_path (default state/auth.sqlite) Bearer tokens and share links. Losing it revokes all of them. Copy it with sqlite3 auth.sqlite ".backup <target>" while the server runs.
The deploy key, state/git-key Lets the server push. Keep it with your other private keys.
The knowledge base A git repository; with auto_push its remote already holds every commit.

The search index lives in memory and is rebuilt on start, so there is nothing to back up for it.

The server exits with “knowledge base at … is not initialized”. The directory is not a git repository, or its .gitignore lacks sklad’s sidecar patterns. Run sklad init on it; it only adds what is missing.

Edits made outside the server do not show up. The file watcher picks them up within about 250 ms. If it does not, check whether it is disabled (SKLAD_WATCH=false) and restart the server. With the watcher off, out-of-band edits appear only after the server’s next write or a restart. Turn it off only when the server is the only thing that writes the directory.

kb_health reports unpushed commits. A push failed, often because something else pushed to the branch first. Enable auto_pull with strategy = "rebase", or integrate by hand in the checkout: git pull --rebase and git push.

Clients get 401. The token is unknown or revoked: create a new one with sklad token create. For OAuth clients, see the troubleshooting table in Authenticate MCP clients.

OAuth calls fail after the identity provider restarted. sklad cannot fetch the JWKS, or the keys rotated. Check that jwks_uri is reachable from the sklad container; the cache refreshes on an unknown key and every jwks_refresh_seconds.