docsMCP Server

MCP Server

smartchats-mcp exposes the SmartChats data layer over the Model Context Protocol. Add it to Claude Desktop, Claude Code or any other MCP client and the model can read, search and write your logs, metrics, todos and knowledge graph, run read-only queries, and import or export your data.

It uses the same data path as the web app and the CLI. Each tool in src/tools.ts is a thin wrapper that calls a query builder from smartchats-database (or an operation such as operations.exportBundle) against the active DataAPI handle. There is no MCP-only data plane.

Install and run

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

You don’t usually run it by hand. Your MCP client starts it and talks to it over stdio.

Targets

The server picks its data target at startup with --target:

  • --target=cloud (the default): your SmartChats cloud account.
  • --target=local: your local SmartChats install.

For cloud, the server signs in before the protocol starts. It shares the CLI’s credentials file, ~/.smartchats-mcp/credentials.json, so one smartchats login covers both.

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

In local mode the server connects to SurrealDB at ws://localhost:8000/rpc (namespace smartchats, database main) and calls the local server at http://localhost:3000/local-api for embeddings. Override these with the --local-url, --local-ns, --local-db, --local-user and --local-password flags, or the matching SMARTCHATS_MCP_LOCAL_* variables (SMARTCHATS_MCP_LOCAL_SERVER_URL for the local server). Run node dist/index.js --help for the full list.

Add it to Claude Desktop

Build the 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 the path with the path to your checkout. Use --target=local to point Claude at your local install instead of your cloud account.

Sign in once (cloud only)

Restart Claude Desktop. If you have not run smartchats login, the server starts a one-time browser sign-in. The URL appears in Claude Desktop’s MCP server logs. After that the cached refresh token renews the short-lived ID token on its own.

Use it

Ask Claude something like:

“Check my SmartChats logs from the last week and summarize what I’ve been thinking about.”

Claude calls get_recent_logs or search_logs, gets your data, and summarizes it.

Tools

The server registers 33 tools. Write tools stamp the event-time fields (ts, local_date, local_tz) for you. Tools that store text with an embedding (logs, entities, relations) embed it on insert, so callers never pass vectors.

Logs

ToolWhat it doesWrites
search_logsSubstring search across logs, with an optional category filterNo
semantic_search_logsVector search across logs by meaningNo
get_recent_logsMost recent logs, optionally by categoryNo
get_log_categoriesEvery category with its log countNo
insert_logAdd a log entry. event_time_override backfills an earlier dateYes
update_logPatch a log. Re-embeds when content changesYes
delete_logDelete a log by id and return the deleted rowYes
prepare_log_categoryRegister a category before it has any entriesYes

Metrics

ToolWhat it doesWrites
get_metricsMetric values, filtered by name, category or date rangeNo
get_metrics_summaryEvery tracked metric with units, counts, min/max and its latest valueNo
insert_metricRecord a metric value. source defaults to mcpYes
update_metricPatch value, category, note or source_textYes
delete_metricDelete a metric entry by idYes
prepare_metricRegister a metric before it has any valuesYes

Todos

ToolWhat it doesWrites
get_todosTodos, active by default or filtered by statusNo
insert_todoAdd a todo with status activeYes
record_todo_completionRecord a completion (for recurring todos). Leaves the status aloneYes
set_todo_statusSet status to active, completed, cancelled or deferredYes
reschedule_todoChange the due date, the recurrence rule, or bothYes
edit_todoEdit title, description, priority, category, due date, recurrence or metric linkYes
delete_todoDelete a todo. Does not delete its completionsYes
delete_todo_completionsDelete every completion record of a todoYes

Knowledge graph

ToolWhat it doesWrites
query_knowledge_graphFind entities and relations by nameNo
semantic_search_entitiesVector search across entity namesNo
semantic_search_relationsVector search across relation triplesNo
insert_kg_entityAdd an entity. Re-inserting a name creates a duplicateYes
insert_kg_relationAdd a directed relation between two existing entitiesYes
delete_kg_entityDelete an entity by name. Does not delete its relationsYes
delete_kg_relationDelete a relation by its composite nameYes
delete_kg_relations_touchingDelete every relation that touches an entityYes

Queries and data movement

ToolWhat it doesWrites
run_queryRaw SurrealQL, scoped to you. SELECT statements onlyNo
export_user_dataWrite the active target’s data to a JSON bundle on diskNo (writes a local file)
import_user_dataUpsert a JSON bundle into a SurrealDB instance, by idYes

run_query rejects anything other than a read. To change data, use the write tools above.

export_user_data and import_user_data call the same operations.exportBundle and operations.importBundle as smartchats data export and smartchats data import. import_user_data accepts per-call overrides (target_url, target_namespace, target_database, target_user, target_password) and dry_run, so a server started with --target=cloud can import a bundle into a local install.

Semantic search needs an embedding endpoint. On the cloud target it uses your account. On the local target it calls the local server’s /local-api/embeddings/embed, so the local server must be running with an OpenAI key. The write tools that embed need the same.

Example calls

You ask: “Find logs about my morning routine.”

Claude calls:

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

The server returns matching logs:

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

Authentication

Cloud target: the server acts as you. Every read and write is scoped to your account, and the cloud enforces isolation between users.

Local target: a local install has one user. The server connects to your local SurrealDB directly with the root credentials.

How it fits

The MCP server is one more consumer of the shared data layer:

        ┌─────────────────────────────────────────┐
        │      Operations + query builders        │   shared
        │   smartchats-database/src/{operations,  │
        │                            queries}/    │
        └─────────────────────────────────────────┘
            ▲                  ▲                ▲
            │                  │                │
       smartchats         smartchats       smartchats-mcp
         web app             CLI                ▲
                                          stdio JSON-RPC
                                                ▲
                                     Claude Desktop, Claude Code, ...

A new query builder in smartchats-database/src/queries/ becomes an MCP tool with about ten lines in tools.ts. See Architecture for the full picture.

smartchats-mcp-bridge

smartchats-mcp-bridge is a different MCP server. smartchats-mcp gives a model your data. The bridge lets a coding agent (Claude Code, Codex, Gemini CLI, any MCP client) talk with you live through the SmartChats app, by text or voice. This is called patch-through.

The agent starts the bridge as a stdio subprocess. The bridge opens a WebSocket to the SmartChats relay with your cloud sign-in, and the relay delivers messages between the agent and your browser.

coding agent ──stdio MCP──► smartchats-mcp-bridge ──WSS──► relay ──► SmartChats app

It registers these tools:

ToolWhat it does
send_message_to_userSend you a message. Does not wait for a reply
wait_for_messageBlock until you or a peer agent sends a message, or the timeout fires
poll_messagesNon-blocking read of retained messages since a timestamp
ask_userSend a question and wait for your reply, in one call
respond_and_waitSend a reply and wait for your next message. The tool to loop on in a conversation
list_peersList your other connected agents
send_message_to_peerSend a message to another of your agents
{
  "mcpServers": {
    "smartchats-patch-through": {
      "command": "node",
      "args": ["/absolute/path/to/smartchats/packages/smartchats-mcp-bridge/dist/index.js"],
      "env": { "SMARTCHATS_AGENT_LABEL": "claude-code @ my-laptop" }
    }
  }
}

SMARTCHATS_RELAY overrides the relay endpoint and SMARTCHATS_AGENT_MODEL adds a model hint to the agent list. The bridge needs a cloud sign-in (smartchats login).

On a machine running smartchats-hub, point agents at the hub instead. The hub holds one relay connection and one token for every agent, and keeps a durable inbox per agent. It exposes the same tool names. The bridge is the fallback for machines without a hub. See Hub and Relay.

Troubleshooting

⚠️

“Authentication failed” at startup: run smartchats login first. The MCP server and the CLI share one credentials file.

⚠️

Local target times out: your local install isn’t running. Start it with smartchats start, then check smartchats status.

Logs go to stderr. The server writes protocol messages to stdout and readable logs to stderr. To capture both while debugging, run node dist/index.js 2>&1 | tee mcp.log.

See also