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:
| Tool | Needs | What it does |
|---|---|---|
remember | write | Stores 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). |
search | read | The memory a question needs, as memory_context, with the handle it came from and the audit id of the disclosure. |
get | read | The current state, one fact of it, or the state a handle names. The handle is re-derived first. |
list | read | Every fact of the current state, as path and value. |
update | write | A correction in your own words, stored as a new version; facts as in remember. |
delete | write | Removes one fact from the current state as a new version. History keeps it. |
history | read | The 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. |
audit | read | What was disclosed, newest first. |
verify | read | Re-derives a handle from the stored state. |
export | read | Every 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:
- OAuth (recommended where the client supports it). Add the server URL; the client finds StateJar's authorization server from the
401and the discovery documents, identifies itself (its published identity, or a registration it makes on the spot), and opens a page on statejar.com where you see the app's name, where it sends you back, and what it may do:memory:read(the read tools),memory:write(the write tools). Allow, and the client gets an access token (one hour) and a refresh token (30 days, rotated on every use). Disconnect the app any time under Connected apps on the API keys page. This is StateJar's own authorization server (OAuth 2.1: PKCE S256 only, exact redirect URIs, RFC 8707 resource binding, RFC 9207iss), on your StateJar account. - A developer key. Make one on the API keys page, put it in
STATEJAR_API_KEY, and give it to the client as the headerAuthorization: Bearer sj_live_…. It is the account's full memory credential.
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:
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
- Scope. Every tool takes an optional
session, the scope inside your account (a project, an agent, a chat). The default ismcp. A new scope's first message builds on your newest memory in any scope. - What an app may do. On the consent page you allow
memory:read,memory:write, or both (the default a client asks for). A read-only token gets a403 insufficient_scopetool error fromremember,updateanddelete, and nothing else changes.offline_access, which some clients add, is accepted; every grant comes with a refresh token regardless. - Facts from your client's model. If the client already extracts facts, let it pass them as
factsonremember:[{"attribute": "city", "value": "Pune", "evidence": "I live in Pune"}]. Anattributeis a StateJar attribute (name,city,budget, …), a path (facts.city) or a short English name for an open fact. Each is accepted only when its evidence is in the text word for word, the value is in the evidence, it is about you and stated (not a question, a hypothetical, a past state or someone else's), and it passes the type check; accepted facts are stored with sourcehostand the audit row names the client. At most 32 per call. The text is still read by StateJar's own pipeline, so a client that proposes nothing loses nothing. - Limits.
- A message for
remembercan be at most 20,000 characters, and one request at most 256 KB. - Each credential has a limit on MCP requests a minute; past it the server answers
429. - Each tool's own calls count against your plan's limits, as REST calls do (pricing and payments).
- A message for
- Credentials. A key or a token belongs to one account and sees only that account's memory. Revoke a key on the API keys page, disconnect an app under Connected apps there; the next request is refused. Access tokens live an hour and refresh tokens 30 days, each refresh token working once: a refresh token used twice disconnects the app, since someone else holds a copy.
Check it works
- Your client lists
statejaras connected (claude mcp list,gemini mcp list,opencode mcp list, or/mcpinside Codex:codex mcp listonly reads its configuration); with OAuth, the app shows under Connected apps on the API keys page. - Ask the assistant to remember this: "I'm Kavya, I live in Bengaluru and my laptop budget is 80000 rupees." The
rememberreply lists the facts stored. - In a new chat, ask "what is my laptop budget?". The assistant's
searchreturns the budget and the handle (shm_…) it came from. - The audit log lists that disclosure.
What it sends
- To StateJar: what you ask a tool to remember, with secrets removed first, and the questions you search with; with
facts, also the facts your client's model read and the words they rest on. Secrets here are API keys and tokens, private keys, passwords written after their name, and card numbers.rememberreports how many were removed, never what they were. - What StateJar keeps: typed facts, never the message. The server logs no message, value, key or token. Of an OAuth sign-in it keeps the app's name and redirect addresses, hashed codes and tokens, and a log of connections and revocations, all removed with your account.
- What you can see: every
searchis a disclosure in your audit log, with the fields it sent; a fact stored from your client's proposal showshostas its source and the client's name on the extraction row. - Your credential: a key goes to StateJar over HTTPS on every request and StateJar keeps only its SHA-256 hash; an OAuth token likewise, and the app you connected sees the token, never your password.
Troubleshooting
401: no credential, or the key is wrong, revoked or expired, or the token expired, was revoked or belonged to a disconnected app. The answer carries aWWW-Authenticateheader that points to/.well-known/oauth-protected-resource/mcpand names the scopes; an OAuth client refreshes or signs in again, a key client needs a new key.403 insufficient_scopefrom a tool: the app was allowedmemory:readonly. Disconnect it on the API keys page and connect again, allowing both.- The client asks you to sign in and you wanted to use a key: it is trying OAuth. In OpenCode, set
"oauth": falseon thestatejarentry; in any client, send the key as a bearer token. - The consent page says the request has expired: it is valid for ten minutes. Start again from the client.
- The client says the server does not support PKCE or dynamic registration: check that it read
https://statejar.com/.well-known/oauth-authorization-server; it listsS256, the registration endpoint andclient_id_metadata_document_supported. 421 Misdirected Request: the request was addressed to a host other thanstatejar.com, for example through a proxy that rewrites theHostheader.403on the MCP endpoint itself: the request carried anOriginheader that is not statejar.com's (a browser extension or a proxy).429: too many requests a minute from one credential, or your plan's limit (what each limit counts). Wait a minute and try again.deleteanswersstored: falseand the fact is still there: a removal is read by the cloud model provider that reads messages for StateJar, and StateJar's own rules decide ("Forget the budget." as withdrawn). When no provider can read the message at that moment, nothing is removed yet; ask again, or say the new value withupdate.- A message is refused as too long:
remembertakes at most 20,000 characters. Send it in parts. - A proposed fact comes back refused: the reason says why,
evidence_not_in_message(the evidence is not word for word in the text),about_someone_else,question,hypothetical,past, a value check such asamount_not_in_evidence,use_text(people, money lent or borrowed, reminders and events are read from the text itself), orpipeline_declined:…(StateJar's own reading refused the same fact).
This page as Markdown: /docs/mcp.md