recallix 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: recallix
3
+ Version: 0.2.0
4
+ Summary: Python client and MCP server for Recallix, an LLM-free memory layer for AI agents
5
+ License: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/AyishikD/Recallix
7
+ Project-URL: Source, https://github.com/AyishikD/Recallix
8
+ Keywords: memory,ai-agents,llm,mcp,rag
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: requests>=2.31
12
+
13
+ # recallix (Python)
14
+
15
+ Client and MCP server for [Recallix](https://github.com/AyishikD/Recallix): an LLM-free memory
16
+ layer for AI agents. Recallix runs on your own machine, needs no LLM calls, and declines
17
+ instead of guessing.
18
+
19
+ ```bash
20
+ pip install recallix
21
+ ```
22
+
23
+ You need a running Recallix server. The quickest way is
24
+ `docker compose up -d` in the [repository](https://github.com/AyishikD/Recallix); see the quickstart there.
25
+
26
+ ```python
27
+ from recallix import Memory
28
+
29
+ mem = Memory(api_key="rx_...") # base_url defaults to http://localhost:8000
30
+ mem.store("I moved to Pune last month for a job at Infosys.")
31
+ out = mem.recall("Where do I live?")
32
+ print(out["status"], [m["content"] for m in out["memories"]]) # CONSISTENT ['I moved to Pune ...']
33
+ print(mem.recall("What is my brother's name?")["status"]) # ABSTAINED: nothing answers it
34
+ ```
35
+
36
+ ## MCP (Claude Desktop, Cursor, any MCP client)
37
+
38
+ ```json
39
+ "mcpServers": {
40
+ "recallix": {
41
+ "command": "recallix-mcp",
42
+ "env": {"RECALLIX_API_KEY": "rx_...", "RECALLIX_AGENT_ID": "claude-desktop"}
43
+ }
44
+ }
45
+ ```
46
+
47
+ Environment: `RECALLIX_API_KEY` (required), `RECALLIX_URL` (default `http://localhost:8000`),
48
+ `RECALLIX_AGENT_ID` (default `mcp`).
49
+
50
+ License: Apache-2.0.
@@ -0,0 +1,38 @@
1
+ # recallix (Python)
2
+
3
+ Client and MCP server for [Recallix](https://github.com/AyishikD/Recallix): an LLM-free memory
4
+ layer for AI agents. Recallix runs on your own machine, needs no LLM calls, and declines
5
+ instead of guessing.
6
+
7
+ ```bash
8
+ pip install recallix
9
+ ```
10
+
11
+ You need a running Recallix server. The quickest way is
12
+ `docker compose up -d` in the [repository](https://github.com/AyishikD/Recallix); see the quickstart there.
13
+
14
+ ```python
15
+ from recallix import Memory
16
+
17
+ mem = Memory(api_key="rx_...") # base_url defaults to http://localhost:8000
18
+ mem.store("I moved to Pune last month for a job at Infosys.")
19
+ out = mem.recall("Where do I live?")
20
+ print(out["status"], [m["content"] for m in out["memories"]]) # CONSISTENT ['I moved to Pune ...']
21
+ print(mem.recall("What is my brother's name?")["status"]) # ABSTAINED: nothing answers it
22
+ ```
23
+
24
+ ## MCP (Claude Desktop, Cursor, any MCP client)
25
+
26
+ ```json
27
+ "mcpServers": {
28
+ "recallix": {
29
+ "command": "recallix-mcp",
30
+ "env": {"RECALLIX_API_KEY": "rx_...", "RECALLIX_AGENT_ID": "claude-desktop"}
31
+ }
32
+ }
33
+ ```
34
+
35
+ Environment: `RECALLIX_API_KEY` (required), `RECALLIX_URL` (default `http://localhost:8000`),
36
+ `RECALLIX_AGENT_ID` (default `mcp`).
37
+
38
+ License: Apache-2.0.
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "recallix"
7
+ version = "0.2.0"
8
+ description = "Python client and MCP server for Recallix, an LLM-free memory layer for AI agents"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ dependencies = ["requests>=2.31"]
12
+ license = { text = "Apache-2.0" }
13
+ keywords = ["memory", "ai-agents", "llm", "mcp", "rag"]
14
+
15
+ [project.urls]
16
+ Homepage = "https://github.com/AyishikD/Recallix"
17
+ Source = "https://github.com/AyishikD/Recallix"
18
+
19
+ [project.scripts]
20
+ recallix-mcp = "recallix.mcp_server:main"
21
+
22
+ [tool.setuptools]
23
+ packages = ["recallix"]
@@ -0,0 +1,4 @@
1
+ from .client import MemoryClient, RecallixError
2
+ from .memory import Memory
3
+
4
+ __all__ = ["Memory", "MemoryClient", "RecallixError"]
@@ -0,0 +1,33 @@
1
+ from typing import Any, Dict, Optional
2
+
3
+ import requests
4
+
5
+
6
+ class RecallixError(RuntimeError):
7
+ def __init__(self, status: int, detail: str):
8
+ super().__init__(f"HTTP {status}: {detail}")
9
+ self.status = status
10
+ self.detail = detail
11
+
12
+
13
+ class MemoryClient:
14
+ def __init__(self, api_key: str, base_url: str = "http://localhost:8000", timeout: float = 30):
15
+ if not api_key:
16
+ raise ValueError("api_key is required")
17
+ self.base_url = base_url.rstrip("/")
18
+ self.timeout = timeout
19
+ self.session = requests.Session()
20
+ self.session.headers.update({"X-API-Key": api_key, "Content-Type": "application/json"})
21
+
22
+ def request(self, method: str, endpoint: str, data: Optional[Dict] = None,
23
+ params: Optional[Dict] = None) -> Dict[str, Any]:
24
+ """Returns the response's `data`. Raises RecallixError on HTTP errors."""
25
+ body = {k: v for k, v in data.items() if v is not None} if data else None
26
+ res = self.session.request(method, f"{self.base_url}{endpoint}", json=body, params=params, timeout=self.timeout)
27
+ if res.status_code >= 400:
28
+ try:
29
+ detail = res.json().get("detail", res.text)
30
+ except ValueError:
31
+ detail = res.text
32
+ raise RecallixError(res.status_code, str(detail))
33
+ return res.json().get("data")
@@ -0,0 +1,182 @@
1
+ """
2
+ Recallix as an MCP server: give Claude Desktop, Cursor, or any Model Context Protocol
3
+ client a memory that you own and that works with every model.
4
+
5
+ RECALLIX_API_KEY=rx_... python -m recallix.mcp_server
6
+
7
+ Environment:
8
+ RECALLIX_API_KEY your Recallix API key (required)
9
+ RECALLIX_URL API base URL (default http://localhost:8000)
10
+ RECALLIX_AGENT_ID agent name for memories written through this client (default "mcp")
11
+
12
+ Claude Desktop / Cursor configuration (mcpServers):
13
+
14
+ "recallix": {
15
+ "command": "python", "args": ["-m", "recallix.mcp_server"],
16
+ "env": {"RECALLIX_API_KEY": "rx_...", "RECALLIX_AGENT_ID": "claude-desktop"}
17
+ }
18
+
19
+ Memories written by one client with memory_type "shared" are visible to every client and
20
+ agent of the same user; "private" ones only to the agent that wrote them.
21
+
22
+ Implementation: JSON-RPC 2.0 over stdio, one message per line (the MCP stdio transport);
23
+ no dependencies beyond the SDK. Logs go to stderr — stdout carries only protocol messages.
24
+ """
25
+ import json
26
+ import os
27
+ import sys
28
+
29
+ SERVER_INFO = {"name": "recallix", "version": "1.0.0"}
30
+ SUPPORTED_VERSIONS = ("2025-06-18", "2025-03-26", "2024-11-05")
31
+
32
+ INSTRUCTIONS = (
33
+ "Recallix is the user's long-term memory. Call recall_memory before answering questions that may "
34
+ "depend on what the user told you earlier; if its status is ABSTAINED or NO_MATCH, say you don't know "
35
+ "rather than guessing. Call store_memory when the user shares a durable fact, preference or decision. "
36
+ "When a recalled memory was what answered the user, call confirm_answer."
37
+ )
38
+
39
+ TOOLS = [
40
+ {"name": "recall_memory",
41
+ "description": "Search the user's memory. Returns status (CONSISTENT = an answer was found, ABSTAINED = "
42
+ "nothing answers it, NO_MATCH = nothing related), the matching memories with the extracted "
43
+ "answer, and the reason for the decision.",
44
+ "inputSchema": {"type": "object", "properties": {
45
+ "query": {"type": "string", "description": "The question, in natural language."},
46
+ "limit": {"type": "integer", "minimum": 1, "maximum": 20, "default": 5}},
47
+ "required": ["query"]}},
48
+ {"name": "store_memory",
49
+ "description": "Remember something the user said: a fact, preference, plan or decision. Write it as the "
50
+ "user would say it, e.g. \"I'm allergic to peanuts.\"",
51
+ "inputSchema": {"type": "object", "properties": {
52
+ "content": {"type": "string"},
53
+ "memory_type": {"type": "string", "enum": ["shared", "private"], "default": "shared",
54
+ "description": "shared: visible to all of the user's agents; private: only this one."}},
55
+ "required": ["content"]}},
56
+ {"name": "confirm_answer",
57
+ "description": "Tell Recallix which recalled memories actually answered the question (improves ranking and "
58
+ "makes similar future questions find them).",
59
+ "inputSchema": {"type": "object", "properties": {
60
+ "recall_id": {"type": "string"},
61
+ "memory_ids": {"type": "array", "items": {"type": "integer"}}},
62
+ "required": ["recall_id", "memory_ids"]}},
63
+ {"name": "relevant_memories",
64
+ "description": "Given what the user just said, return memories worth keeping in mind even though they did not "
65
+ "ask (e.g. an allergy when they mention a restaurant), each with the reason.",
66
+ "inputSchema": {"type": "object", "properties": {"message": {"type": "string"}}, "required": ["message"]}},
67
+ {"name": "forget_memory",
68
+ "description": "Delete a memory permanently (its vector, long-term copy and timeline entry too).",
69
+ "inputSchema": {"type": "object", "properties": {"memory_id": {"type": "integer"}},
70
+ "required": ["memory_id"]}},
71
+ {"name": "export_memories",
72
+ "description": "Export all of the user's memories in the open recallix-memory format.",
73
+ "inputSchema": {"type": "object", "properties": {}}},
74
+ ]
75
+
76
+
77
+ def _log(*args):
78
+ print(*args, file=sys.stderr, flush=True)
79
+
80
+
81
+ class RecallixMCP:
82
+ def __init__(self, memory, agent_id="mcp"):
83
+ self.memory, self.agent_id = memory, agent_id
84
+
85
+ # -- tools ------------------------------------------------------------
86
+ def _recall(self, query, limit=5):
87
+ out = self.memory.recall(query, limit=int(limit), agent_id=self.agent_id)
88
+ lines = [f"status: {out.get('status')}", f"reason: {(out.get('receipt') or {}).get('reason', '')}",
89
+ f"recall_id: {out.get('recall_id')}"]
90
+ for m in out.get("memories", []):
91
+ answer = f" | answer: {m['answer']}" if m.get("answer") else ""
92
+ lines.append(f"- [memory {m.get('id')}] {m.get('content')}{answer} (relevance {m.get('relevance')})")
93
+ return "\n".join(lines)
94
+
95
+ def _store(self, content, memory_type="shared"):
96
+ out = self.memory.store(content, agent_id=self.agent_id, memory_type=memory_type)
97
+ return f"{out.get('status')}: memory {out.get('memory_id')}"
98
+
99
+ def _confirm(self, recall_id, memory_ids):
100
+ out = self.memory.feedback(recall_id, [int(i) for i in memory_ids])
101
+ return f"confirmed ({out.get('labelled_candidates')} candidates labelled)"
102
+
103
+ def _relevant(self, message):
104
+ rows = self.memory.proactive(message, agent_id=self.agent_id)
105
+ return "\n".join(f"- [memory {r['memory_id']}] {r['content']} ({r['why']})" for r in rows) or "nothing relevant"
106
+
107
+ def _forget(self, memory_id):
108
+ self.memory.delete(int(memory_id))
109
+ return f"memory {memory_id} deleted"
110
+
111
+ def _export(self):
112
+ return json.dumps(self.memory.export(), ensure_ascii=False)
113
+
114
+ def call_tool(self, name, args):
115
+ handlers = {"recall_memory": self._recall, "store_memory": self._store, "confirm_answer": self._confirm,
116
+ "forget_memory": self._forget, "relevant_memories": self._relevant, "export_memories": self._export}
117
+ if name not in handlers:
118
+ raise KeyError(name)
119
+ return handlers[name](**(args or {}))
120
+
121
+ # -- protocol ---------------------------------------------------------
122
+ def handle(self, msg):
123
+ """Response dict for a request, or None for a notification."""
124
+ method, mid, params = msg.get("method"), msg.get("id"), msg.get("params") or {}
125
+ if mid is None: # notification (e.g. notifications/initialized): no reply
126
+ return None
127
+ try:
128
+ if method == "initialize":
129
+ asked = params.get("protocolVersion")
130
+ version = asked if asked in SUPPORTED_VERSIONS else SUPPORTED_VERSIONS[0]
131
+ result = {"protocolVersion": version, "capabilities": {"tools": {"listChanged": False}},
132
+ "serverInfo": SERVER_INFO, "instructions": INSTRUCTIONS}
133
+ elif method == "ping":
134
+ result = {}
135
+ elif method == "tools/list":
136
+ result = {"tools": TOOLS}
137
+ elif method == "tools/call":
138
+ try:
139
+ text = self.call_tool(params.get("name"), params.get("arguments"))
140
+ result = {"content": [{"type": "text", "text": text}], "isError": False}
141
+ except KeyError:
142
+ return {"jsonrpc": "2.0", "id": mid, "error": {"code": -32602, "message": f"unknown tool {params.get('name')!r}"}}
143
+ except Exception as e: # tool failures are reported to the model, not as protocol errors
144
+ result = {"content": [{"type": "text", "text": f"Recallix error: {e}"}], "isError": True}
145
+ else:
146
+ return {"jsonrpc": "2.0", "id": mid, "error": {"code": -32601, "message": f"method not found: {method}"}}
147
+ except Exception as e:
148
+ return {"jsonrpc": "2.0", "id": mid, "error": {"code": -32603, "message": str(e)}}
149
+ return {"jsonrpc": "2.0", "id": mid, "result": result}
150
+
151
+ def serve(self, stdin=sys.stdin, stdout=sys.stdout):
152
+ for line in stdin:
153
+ line = line.strip()
154
+ if not line:
155
+ continue
156
+ try:
157
+ msg = json.loads(line)
158
+ except ValueError:
159
+ stdout.write(json.dumps({"jsonrpc": "2.0", "id": None,
160
+ "error": {"code": -32700, "message": "parse error"}}) + "\n")
161
+ stdout.flush()
162
+ continue
163
+ reply = self.handle(msg)
164
+ if reply is not None:
165
+ stdout.write(json.dumps(reply, ensure_ascii=False) + "\n")
166
+ stdout.flush()
167
+
168
+
169
+ def main():
170
+ from .memory import Memory
171
+ key = os.environ.get("RECALLIX_API_KEY")
172
+ if not key:
173
+ _log("RECALLIX_API_KEY is not set")
174
+ return 1
175
+ memory = Memory(api_key=key, base_url=os.environ.get("RECALLIX_URL", "http://localhost:8000"))
176
+ _log(f"recallix MCP server ready ({os.environ.get('RECALLIX_URL', 'http://localhost:8000')})")
177
+ RecallixMCP(memory, os.environ.get("RECALLIX_AGENT_ID", "mcp")).serve()
178
+ return 0
179
+
180
+
181
+ if __name__ == "__main__":
182
+ sys.exit(main())
@@ -0,0 +1,80 @@
1
+ from typing import Any, Dict, List, Optional
2
+
3
+ from .client import MemoryClient
4
+
5
+
6
+ class Memory:
7
+ """
8
+ Recallix client.
9
+
10
+ mem = Memory(api_key=os.environ["RECALLIX_API_KEY"])
11
+ mem.store("I live in Pune.")
12
+ hits = mem.recall("Where do I live?")
13
+
14
+ `user_id` may only be passed with a service/admin key (multi-user apps);
15
+ a user key always acts as its own user.
16
+ """
17
+
18
+ def __init__(self, api_key: str, base_url: str = "http://localhost:8000", timeout: float = 30):
19
+ self.client = MemoryClient(api_key, base_url, timeout)
20
+
21
+ def store(self, content: str, agent_id: str = "default_agent", memory_type: str = "private",
22
+ user_id: Optional[str] = None, metadata: Optional[Dict] = None) -> Dict[str, Any]:
23
+ """memory_type: "private" (only this agent) or "shared" (all of the user's agents)."""
24
+ return self.client.request("POST", "/memory/store", data={
25
+ "content": content, "agent_id": agent_id, "memory_type": memory_type,
26
+ "user_id": user_id, "metadata": metadata})
27
+
28
+ def recall(self, query: str, limit: int = 10, agent_id: str = "default_agent",
29
+ user_id: Optional[str] = None) -> Dict[str, Any]:
30
+ return self.client.request("POST", "/memory/recall", data={
31
+ "query": query, "limit": limit, "agent_id": agent_id, "user_id": user_id})
32
+
33
+ def feedback(self, recall_id: str, relevant_memory_ids: List[int], user_id: Optional[str] = None) -> Dict[str, Any]:
34
+ """Tell Recallix which recalled memories were useful (trains the ranker)."""
35
+ return self.client.request("POST", "/memory/feedback", data={
36
+ "recall_id": recall_id, "relevant_memory_ids": relevant_memory_ids, "user_id": user_id})
37
+
38
+ def proactive(self, message: str, agent_id: str = "default_agent", limit: int = 5,
39
+ user_id: Optional[str] = None) -> List[Dict[str, Any]]:
40
+ """Memories worth keeping in mind for a new message (no question needed), each with the reason."""
41
+ return self.client.request("POST", "/memory/proactive", data={
42
+ "message": message, "agent_id": agent_id, "limit": limit, "user_id": user_id})
43
+
44
+ def export(self, user_id: Optional[str] = None) -> Dict[str, Any]:
45
+ """All memories in the open "recallix-memory" format (portable to another Recallix)."""
46
+ return self.client.request("GET", "/memory/export", params=_params(user_id=user_id))
47
+
48
+ def import_memories(self, data: Any, format: str = "recallix", agent_id: str = "default_agent",
49
+ memory_type: str = "private", user_id: Optional[str] = None) -> Dict[str, Any]:
50
+ """Import a Recallix export, a Mem0 export (format="mem0") or text, one memory per line (format="text")."""
51
+ return self.client.request("POST", "/memory/import", data={
52
+ "format": format, "data": data, "agent_id": agent_id, "memory_type": memory_type, "user_id": user_id})
53
+
54
+ def delete(self, memory_id: int, user_id: Optional[str] = None) -> Dict[str, Any]:
55
+ return self.client.request("DELETE", f"/memory/{memory_id}", params={"user_id": user_id} if user_id else None)
56
+
57
+ def timeline(self, limit: int = 50, user_id: Optional[str] = None) -> Dict[str, Any]:
58
+ return self.client.request("GET", "/memory/timeline", params=_params(limit=limit, user_id=user_id))
59
+
60
+ def insights(self, user_id: Optional[str] = None) -> Dict[str, Any]:
61
+ return self.client.request("GET", "/memory/insights", params=_params(user_id=user_id))
62
+
63
+ def world_state(self, user_id: Optional[str] = None) -> Dict[str, Any]:
64
+ return self.client.request("GET", "/memory/world-state", params=_params(user_id=user_id))
65
+
66
+ def prediction(self, user_id: Optional[str] = None) -> Dict[str, Any]:
67
+ return self.client.request("GET", "/memory/prediction", params=_params(user_id=user_id))
68
+
69
+ def plan(self, user_id: Optional[str] = None) -> Dict[str, Any]:
70
+ return self.client.request("GET", "/memory/plan", params=_params(user_id=user_id))
71
+
72
+ def profile(self, user_id: Optional[str] = None) -> Dict[str, Any]:
73
+ return self.client.request("GET", "/memory/profile", params=_params(user_id=user_id))
74
+
75
+ def stats(self, user_id: Optional[str] = None) -> Dict[str, Any]:
76
+ return self.client.request("GET", "/memory/stats", params=_params(user_id=user_id))
77
+
78
+
79
+ def _params(**kw):
80
+ return {k: v for k, v in kw.items() if v is not None} or None
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.4
2
+ Name: recallix
3
+ Version: 0.2.0
4
+ Summary: Python client and MCP server for Recallix, an LLM-free memory layer for AI agents
5
+ License: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/AyishikD/Recallix
7
+ Project-URL: Source, https://github.com/AyishikD/Recallix
8
+ Keywords: memory,ai-agents,llm,mcp,rag
9
+ Requires-Python: >=3.9
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: requests>=2.31
12
+
13
+ # recallix (Python)
14
+
15
+ Client and MCP server for [Recallix](https://github.com/AyishikD/Recallix): an LLM-free memory
16
+ layer for AI agents. Recallix runs on your own machine, needs no LLM calls, and declines
17
+ instead of guessing.
18
+
19
+ ```bash
20
+ pip install recallix
21
+ ```
22
+
23
+ You need a running Recallix server. The quickest way is
24
+ `docker compose up -d` in the [repository](https://github.com/AyishikD/Recallix); see the quickstart there.
25
+
26
+ ```python
27
+ from recallix import Memory
28
+
29
+ mem = Memory(api_key="rx_...") # base_url defaults to http://localhost:8000
30
+ mem.store("I moved to Pune last month for a job at Infosys.")
31
+ out = mem.recall("Where do I live?")
32
+ print(out["status"], [m["content"] for m in out["memories"]]) # CONSISTENT ['I moved to Pune ...']
33
+ print(mem.recall("What is my brother's name?")["status"]) # ABSTAINED: nothing answers it
34
+ ```
35
+
36
+ ## MCP (Claude Desktop, Cursor, any MCP client)
37
+
38
+ ```json
39
+ "mcpServers": {
40
+ "recallix": {
41
+ "command": "recallix-mcp",
42
+ "env": {"RECALLIX_API_KEY": "rx_...", "RECALLIX_AGENT_ID": "claude-desktop"}
43
+ }
44
+ }
45
+ ```
46
+
47
+ Environment: `RECALLIX_API_KEY` (required), `RECALLIX_URL` (default `http://localhost:8000`),
48
+ `RECALLIX_AGENT_ID` (default `mcp`).
49
+
50
+ License: Apache-2.0.
@@ -0,0 +1,12 @@
1
+ README.md
2
+ pyproject.toml
3
+ recallix/__init__.py
4
+ recallix/client.py
5
+ recallix/mcp_server.py
6
+ recallix/memory.py
7
+ recallix.egg-info/PKG-INFO
8
+ recallix.egg-info/SOURCES.txt
9
+ recallix.egg-info/dependency_links.txt
10
+ recallix.egg-info/entry_points.txt
11
+ recallix.egg-info/requires.txt
12
+ recallix.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ recallix-mcp = recallix.mcp_server:main
@@ -0,0 +1 @@
1
+ requests>=2.31
@@ -0,0 +1 @@
1
+ recallix
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+