docsMCP Server

MCP Server

smartchats-mcp exposes the SmartChats data layer over the Model Context Protocol. Wire it into Claude Desktop (or any MCP-aware LLM client) and the LLM can read your logs, search your knowledge graph, browse metrics, run scoped queries, and import/export your data — all under your authentication.

It’s the same data path as the web app and the CLI: tools.ts is a thin wrapper that calls into operations.X(handle.data, args) or queries.X(args) and returns the result. There’s no separate MCP-only data plane; behavior matches the web app and CLI exactly.

Install + run

cd packages/smartchats-mcp
npm run build
node dist/index.js --target=cloud   # or --target=local

You typically don’t run this manually — your MCP client launches it over stdio.

Targets

The MCP server picks its data target at startup via --target:

  • --target=cloud — your authenticated SmartChats cloud account.
  • --target=local — your locally-running SmartChats instance.

For cloud, the server pre-authenticates before the protocol takes over (the browser-login flow needs interactive output). It uses the same credentials file as the CLI: ~/.smartchats-mcp/credentials.json — sign in once with smartchats login and both surfaces are authenticated.

# Cloud (default)
smartchats login                # one time
node dist/index.js --target=cloud
 
# Local
node dist/index.js --target=local

Local-mode connection details (URL, credentials, etc.) accept overrides via --local-* flags or matching SMARTCHATS_MCP_LOCAL_* env vars. Run smartchats-mcp --help to see them all.

Wire into Claude Desktop

Build the MCP server

cd packages/smartchats-mcp
npm run build

Add it to Claude Desktop’s config

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "smartchats": {
      "command": "node",
      "args": [
        "/absolute/path/to/smartchats/packages/smartchats-mcp/dist/index.js",
        "--target=cloud"
      ]
    }
  }
}

Replace /absolute/path/to/smartchats/... with the actual path to your local checkout. Use --target=local if you want Claude to read your local SmartChats instance instead of your cloud account.

Sign in once (cloud only)

Restart Claude Desktop. On the first SmartChats tool call, the MCP server will prompt for a one-time browser login. The URL is printed in Claude Desktop’s MCP server logs — open it in a browser, sign in, and the credentials cache for ~hour-long ID tokens with infinite refresh.

Use it

Talk to Claude. Try:

“Can you check my SmartChats logs from the last week and summarize the topics I’ve been thinking about?”

Claude will call get_recent_logs (or search_logs), receive your actual data, and summarize.

Tools exposed

10 tools, organized by domain.

Read tools

ToolWhat it doesArgs
search_logsSubstring search across logsquery, category?, limit?
get_recent_logsMost recent N logscategory?, limit?
get_log_categoriesAll categories with counts
get_metricsTracked metrics with date rangemetric_name?, category?, from_date?, to_date?, limit?
get_metrics_summaryAggregated overview + 10 most-recent entries
query_knowledge_graphSearch KG entities + relations by namequery, limit?
get_todosActive todos (or filter by status)status?, limit?
run_queryRaw SurrealQL passthroughquery, variables?

run_query currently restricts to SELECT statements. Write capability — so MCP clients (and the CLI) can ingest data on your behalf as well as read it — is on the near roadmap.

Data movement tools

ToolWhat it doesArgs
export_user_dataDump active-target data to a JSON bundleoutput_path, tables?, include_sensitive?
import_user_dataPush a JSON bundle into a SurrealDB instanceinput_path, target_url?, target_namespace?, target_database?, target_user?, target_password?, tables?, dry_run?

These delegate to the same operations.exportBundle / operations.importBundle the CLI uses. import_user_data accepts per-call URL/creds overrides for cross-environment imports — useful if you started the MCP in --target=cloud mode but want to import a bundle into your local AIO.

Example interactions

User to Claude: “Find logs about my morning routine.”

Claude calls:

{
  "tool": "search_logs",
  "args": { "query": "morning routine", "limit": 10 }
}

MCP server returns:

[
  { "id": "logs:abc", "category": "wellness", "content": "Morning routine: ...", "ts": "2026-04-30T13:00:00Z", "local_date": "2026-04-30", "local_tz": "America/Chicago" },
  ...
]

Claude summarizes for you.

Authentication notes

Cloud target: the MCP server authenticates as you. Every read and write is scoped to your account; the cloud surface enforces strict isolation between users.

Local target: your local SmartChats instance is yours alone — the MCP runs against it without an auth gate.

In both cases, your data stays your data. No cross-account leakage on the cloud side, no telemetry on the local side.

Architecture relationship

The MCP server is a consumer of the same shared infrastructure as the web app and the CLI:

        ┌─────────────────────────────────────────┐
        │         Operations + Query Builders     │   ← shared
        │       smartchats-database/{operations,  │
        │                            queries}/    │
        └─────────────────────────────────────────┘
            ▲                  ▲                ▲
            │                  │                │
       smartchats         smartchats         smartchats-mcp
         web app             CLI                ↑
                                          stdio JSON-RPC

                                        Claude Desktop / etc.

When you add a new query builder in smartchats-database/src/queries/, the MCP can expose it as a tool with ~10 lines in tools.ts. There’s no duplicated logic between the CLI’s data subcommands and the MCP’s import_user_data / export_user_data tools — both call into operations.importBundle / operations.exportBundle.

See Architecture for the full picture.

Troubleshooting

⚠️

“Authentication failed” at startup → run smartchats login first. The MCP shares its credentials file with the CLI; logging in on either side authenticates both.

⚠️

Local-target connection times out → your local SmartChats instance isn’t running. Start it with bin/aio (the all-in-one container).

Stdio transport quirk: the MCP server writes to stdout for protocol messages and stderr for human-readable logs. If you’re debugging via node dist/index.js | tee mcp.log, redirect stderr too: node dist/index.js 2>&1 | tee mcp.log.

See also

  • CLI Reference — same operations, just for humans instead of LLMs.
  • Architecture — the layered model that makes MCP a thin wrapper.
  • Contributing — how to add a new MCP tool in 10 lines.