StateJar docs

MCP server

StateJar's memory as Model Context Protocol tools at https://statejar.com/mcp, for any client that speaks MCP over HTTP. Ten tools; sign in with OAuth from the client or paste a developer key; the same limits, checks and audit trail as the REST API.

What it does

https://statejar.com/mcp is a hosted MCP server: Streamable HTTP, stateless, JSON responses, answering both the current protocol revision (2026-07-28, one exchange per request) and the earlier handshake revisions. A client that speaks MCP over HTTP gets these ten tools:

ToolNeedsWhat it does
rememberwriteStores the facts in a message. Secrets are removed first. The reply lists what was stored, held until said again, or declined, each with its reason. Your client's own model may pass the facts it read as facts (attribute, value, the exact evidence); StateJar checks each against the text and its own gates, stores what passes with your client named as the source, and returns the refused ones with reasons. An optional assistant_reply is accepted and ignored on statejar.com (assistant-side memory is switched off there).
searchreadThe memory a question needs, as memory_context, with the handle it came from and the audit id of the disclosure.
getreadThe current state, one fact of it, or the state a handle names. The handle is re-derived first.
listreadEvery fact of the current state, as path and value.
updatewriteA correction in your own words, stored as a new version; facts as in remember.
deletewriteRemoves one fact from the current state as a new version. History keeps it.
historyreadThe versions, newest first, by handle, each with what it changed against its parent (every fact set, replaced or removed, with the old and the new value). Pass field (a word such as budget, or a path such as constraints.budget) to get only the versions that changed that fact, which answers "what was it before?". Newest 20 by default (limit up to 50); more says older versions exist.
auditreadWhat was disclosed, newest first.
verifyreadRe-derives a handle from the stored state.
exportreadEvery version with its handle and state.

Each tool calls StateJar's own REST routes as your account. The same plan limits, the same type checks and the same audit rows apply as on the REST API.

Two ways to sign a client in:

Install

There is nothing to install on a server. Add https://statejar.com/mcp to your client. One subsection per client; the commands and file formats are from each client's own documentation, read again on 2026-10-27. Each subsection says what was tested and how: on 27 Oct 2026, our client test script ran Claude Code, Gemini CLI, Codex and OpenCode (and the MCP Inspector) against a local StateJar server, a key entry and an OAuth sign-in each, up to the connection and the tool list. No client was given a prompt, so no tool call through a client's own model was made; the Inspector called every tool. Claude Desktop, claude.ai, ChatGPT, Cursor, VS Code and Windsurf were not run: their subsections follow their current documentation. Where that documentation does not say how the client does OAuth, the line says UNVERIFIED.

Claude Code

claude mcp add --transport http statejar https://statejar.com/mcp

Then /mcp in Claude Code → Authenticate, or claude mcp login statejar: the browser opens StateJar's consent page. Claude Code uses its published client identity (https://claude.ai/oauth/claude-code-client-metadata); --callback-port 8080 fixes the local port if your firewall needs it, and --client-id uses a client you registered. With a key instead (single quotes, so the file keeps the variable's name and Claude Code reads the key when it connects):

claude mcp add --transport http statejar https://statejar.com/mcp --header 'Authorization: Bearer ${STATEJAR_API_KEY}'

Tested on 27 Oct with Claude Code 2.1.311: the key entry: claude mcp list ✔ Connected, its tools/list answered with the 10 tools. OAuth: claude mcp login --no-browser signed in with its published identity (also with --callback-port, and with a registered --client-id), then ✔ Connected with 10 tools. It never registered dynamically. Tool calls go through its model and were not run.

As a project file (.mcp.json): {"mcpServers": {"statejar": {"type": "http", "url": "https://statejar.com/mcp"}}}, with "headers": {"Authorization": "Bearer ${STATEJAR_API_KEY}"} for the key form.

Claude Desktop and claude.ai (custom connector)

Remote servers are added by URL as custom connectors on your Claude account, the same for claude.ai, Desktop, mobile and Cowork (a desktop extension is only for a server that runs on your computer): Customize → Connectors → Add custom connector → URL https://statejar.com/mcp (Free, Pro, Max; one custom connector on Free). On Team and Enterprise an Owner adds it under Organization settings → Connectors → Add → Custom → Web, and each member then clicks Connect. For Authentication choose Sign in now or Sign in when needed. Under the OAuth client choices, Use Claude's published identity (the default) works: StateJar advertises client_id_metadata_document_supported and the none token-endpoint method that Claude requires for it; Register automatically works too. Claude's servers reach statejar.com from 160.79.104.0/21. Claude.ai's static request headers (a key instead of OAuth) are a beta for a limited set of organisations, so use OAuth here. Not run here (it needs a Claude account); what this server must do for it (CIMD with the none method, PKCE S256, scope on the 401, iss, refresh rotation, the callback https://claude.ai/api/mcp/auth_callback) is covered by the server's tests.

ChatGPT (custom MCP server)

ChatGPT Plugins → + → Add custom MCP server → a name and description → under Connection the URL https://statejar.com/mcp → authentication OAuth → accept the risk warning → Create as a plugin, then review the tools it found. ChatGPT uses its published identity (https://chatgpt.com/oauth/client.json, with the stable callback https://chatgpt.com/connector_platform_oauth_redirect, because this server sends iss) and needs exactly what this server publishes: protected-resource metadata, authorization-server metadata with code_challenge_methods_supported, PKCE S256, resource, and refresh tokens. ChatGPT does not support API keys or custom headers, so OAuth is the only way in. Which plans can add custom servers: OpenAI's docs say only that account and workspace policies apply (UNVERIFIED which plans). ChatGPT's identity document offers two token-endpoint methods, none and private_key_jwt, with private_key_jwt as its legacy preference; ChatGPT picks from the ones both sides support, so here it signs in as a public client. Until 27 Oct this server read only the preference and refused ChatGPT's identity; that is fixed and tested against the document as ChatGPT publishes it. Not run here (it needs a ChatGPT account).

Gemini CLI

In settings.json:

{ "mcpServers": { "statejar": { "httpUrl": "https://statejar.com/mcp" } } }

Then /mcp auth statejar: Gemini CLI detects the 401, discovers the endpoints and registers dynamically (authProviderType: dynamic_discovery, its default). With a key: "headers": {"Authorization": "Bearer ${STATEJAR_API_KEY}"} on the same entry; Gemini CLI reads the variable when it connects. (gemini mcp add -H "Authorization: Bearer $STATEJAR_API_KEY" works too, but writes the key itself into settings.json.) A server in a folder Gemini CLI does not trust stays disabled until you trust the folder.

Tested on 27 Oct with Gemini CLI 0.65.0: the key entry: gemini mcp list Connected (that command only connects); /mcp list in the interactive CLI showed "statejar - Ready (10 tools)", mcp_statejar_audit … mcp_statejar_verify. OAuth: /mcp auth registered dynamically ("Gemini CLI MCP Client"), signed in through the consent page and showed "statejar-oauth - Ready (10 tools)"; it did not use a client metadata document. Tool calls go through its model and were not run.

Codex

codex mcp add statejar --url https://statejar.com/mcp
codex mcp login statejar

Codex "supports OAuth Client ID Metadata Documents (CIMD) and Dynamic Client Registration (DCR)" and picks one itself; --oauth-client-registration dcr forces registration. Its callback is http://127.0.0.1/callback on a per-install port (mcp_oauth_callback_port in ~/.codex/config.toml); this server accepts any loopback port. With a key: codex mcp add statejar --url https://statejar.com/mcp --bearer-token-env-var STATEJAR_API_KEY.

Tested on 27 Oct with Codex 0.164.0: the key entry: codex mcp list shows it enabled with a bearer token (that command reads the configuration only); /mcp in the Codex UI showed "statejar: connected (10 tools)". OAuth: codex mcp add of the server started the sign-in itself with its published identity (https://chatgpt.com/oauth/codex/client.json, callback http://127.0.0.1:PORT/callback (any free port)); --oauth-client-registration dcr registered dynamically; both signed in, and /mcp showed "statejar-oauth: connected (10 tools)". Tool calls go through its model and were not run.

Cursor

.cursor/mcp.json (project) or ~/.cursor/mcp.json:

{ "mcpServers": { "statejar": { "url": "https://statejar.com/mcp" } } }

Cursor "supports OAuth for servers that require it" with PKCE, reads the protected-resource metadata, and with dynamic registration "registers as a public client with no client secret" (its desktop app registers http://localhost:8787/callback and https://www.cursor.com/agents/mcp/oauth/callback, both of which this server accepts). Its documentation does not mention client metadata documents: UNVERIFIED. Not run here. With a key: "headers": {"Authorization": "Bearer ${env:STATEJAR_API_KEY}"}.

OpenCode

opencode.json:

{
  "mcp": {
    "statejar": { "type": "remote", "url": "https://statejar.com/mcp", "enabled": true }
  }
}

Then opencode mcp auth statejar opens the browser; OpenCode detects the 401 and registers dynamically (RFC 7591). With a key, add "oauth": false and "headers": {"Authorization": "Bearer {env:STATEJAR_API_KEY}"} to the entry. opencode mcp list, opencode mcp logout, opencode mcp debug show and reset the state.

Tested on 27 Oct with OpenCode 1.19.4: the key entry ("oauth": false, {env:STATEJAR_API_KEY}): opencode mcp list connected, its tools/list answered with the 10 tools. OAuth: opencode mcp auth registered dynamically ("OpenCode"), signed in through the consent page, then connected with 10 tools. Tool calls go through its model and were not run.

VS Code (Copilot agent mode)

MCP: Add Server → HTTP → https://statejar.com/mcp, or .vscode/mcp.json:

{ "servers": { "statejar": { "type": "http", "url": "https://statejar.com/mcp" } } }

Since v1.106 VS Code uses its Client ID Metadata Document "when connecting to an MCP server that uses an authorization server that supports CIMD", which this one does; its document (https://vscode.dev/oauth/client-metadata.json) is a public client with the redirects http://127.0.0.1:33418/ and https://vscode.dev/redirect, and this server accepts it (tested against the document as published). Otherwise it registers dynamically. Not run here. With a key: "headers": {"Authorization": "Bearer ${input:api-token}"} and an inputs entry of type promptString with "password": true. VS Code is also the one client in this list whose documentation lists MCP sampling; StateJar does not use sampling (deprecated in the 2026-07-28 revision) and takes your model's facts through remember's facts instead.

Windsurf (now Devin Desktop, Cascade)

Windsurf's MCP documentation redirects to Devin Desktop's. Its default agent, Devin Local, takes its MCP servers from the Devin CLI:

devin mcp add -s user statejar https://statejar.com/mcp
devin mcp login statejar

or in ~/.config/devin/mcp_config.json (%APPDATA%\devin\mcp_config.json): { "mcpServers": { "statejar": { "url": "https://statejar.com/mcp" } } }. devin mcp login uses dynamic registration unless you set oauthClientId. With a key: "headers": {"Authorization": "Bearer sj_live_…"}, kept in the gitignored .devin/mcp_config.local.json for a project. The legacy Cascade agent reads the same file with serverUrl (or url) and accepts "Bearer ${env:STATEJAR_API_KEY}" in headers. Not run here.

Your own code (the official MCP Python SDK)

The MCP Python SDK at the version this server is built with, and a developer key from STATEJAR_API_KEY as the bearer token. STATEJAR_MCP_URL points the script at another server.

pip install mcp==2.3.0
import asyncio, os

import httpx2                         # comes with the MCP SDK (pip install mcp==2.3.0)
from mcp.client import Client
from mcp.client.streamable_http import streamable_http_client

URL = os.environ.get("STATEJAR_MCP_URL", "https://statejar.com/mcp")
KEY = os.environ["STATEJAR_API_KEY"]  # a developer key, sent as the bearer token


async def main():
    http = httpx2.AsyncClient(headers={"Authorization": f"Bearer {KEY}"}, timeout=60)
    async with http, Client(streamable_http_client(URL, http_client=http)) as mcp:
        tools = await mcp.list_tools()
        print("tools:", ", ".join(t.name for t in tools.tools))

        said = (await mcp.call_tool("remember", {  # waits up to 30 s to read it
            "text": "I live in Bengaluru now, and my laptop budget is 80000 rupees.",
            "wait_seconds": 30,
        })).structured_content
        print("remember:", said["status"], said.get("handle"))

        # a new chat: search reads your newest memory, and only what the question needs
        found = (await mcp.call_tool("search", {
            "query": "What is my laptop budget?", "session": "new-chat",
        })).structured_content
        print(found["memory_context"])


asyncio.run(main())

Run against a local StateJar server, it lists the ten tools, stores a message with remember, and finds the budget from a new chat with search. The run used the account of getting started, after the terminal and the SDKs had stored Meera's facts there, so the new chat gets all of them, with the city and the budget this message changed:

The script run with python: the ten tools listed, remember storing the new city and budget, and search from a new chat returning the memory with the new city and budget and their handle
The MCP Python SDK against StateJar's MCP server. The official MCP Python SDK (mcp 2.3.0) with the key statejar login stored as the bearer token: the ten tools listed, remember storing a new city and budget, and search from a new chat returning the account's memory with them. Recorded 27 Oct 2026 against a local StateJar server; the output is real, with pauses over 3 s cut to 3 s. Full sizeThe recording (.cast)

Any other client

A remote (HTTP) MCP server at https://statejar.com/mcp. If the client does OAuth, it will find everything it needs from the 401 (WWW-Authenticate with resource_metadata and scope) and the two documents https://statejar.com/.well-known/oauth-protected-resource/mcp and https://statejar.com/.well-known/oauth-authorization-server. If it does not, give it your developer key in the header Authorization: Bearer sj_live_….

For memory that is recalled and captured on its own, not only through tools, use the plugin for your client: Claude Code, Codex, OpenCode, OpenClaw or Hermes Agent.

Set it up

Check it works

  1. Your client lists statejar as connected (claude mcp list, gemini mcp list, opencode mcp list, or /mcp inside Codex: codex mcp list only reads its configuration); with OAuth, the app shows under Connected apps on the API keys page.
  2. Ask the assistant to remember this: "I'm Kavya, I live in Bengaluru and my laptop budget is 80000 rupees." The remember reply lists the facts stored.
  3. In a new chat, ask "what is my laptop budget?". The assistant's search returns the budget and the handle (shm_…) it came from.
  4. The audit log lists that disclosure.

What it sends

Troubleshooting

This page as Markdown: /docs/mcp.md