mragent-oss 0.1.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.
Files changed (32) hide show
  1. mragent_oss-0.1.0/.gitignore +12 -0
  2. mragent_oss-0.1.0/LICENSE +21 -0
  3. mragent_oss-0.1.0/PKG-INFO +159 -0
  4. mragent_oss-0.1.0/README.md +120 -0
  5. mragent_oss-0.1.0/RELEASE_NOTES.md +94 -0
  6. mragent_oss-0.1.0/pyproject.toml +77 -0
  7. mragent_oss-0.1.0/src/mragent_oss/__init__.py +32 -0
  8. mragent_oss-0.1.0/src/mragent_oss/_version.py +7 -0
  9. mragent_oss-0.1.0/src/mragent_oss/adapters/__init__.py +24 -0
  10. mragent_oss-0.1.0/src/mragent_oss/adapters/claude_code.py +61 -0
  11. mragent_oss-0.1.0/src/mragent_oss/api.py +552 -0
  12. mragent_oss-0.1.0/src/mragent_oss/cli.py +251 -0
  13. mragent_oss-0.1.0/src/mragent_oss/core/__init__.py +51 -0
  14. mragent_oss-0.1.0/src/mragent_oss/core/embeddings.py +242 -0
  15. mragent_oss-0.1.0/src/mragent_oss/core/graph.py +452 -0
  16. mragent_oss-0.1.0/src/mragent_oss/core/storage.py +531 -0
  17. mragent_oss-0.1.0/src/mragent_oss/ingest/__init__.py +12 -0
  18. mragent_oss-0.1.0/src/mragent_oss/ingest/extractor.py +144 -0
  19. mragent_oss-0.1.0/src/mragent_oss/ingest/jsonl.py +82 -0
  20. mragent_oss-0.1.0/src/mragent_oss/ingest/pipeline.py +443 -0
  21. mragent_oss-0.1.0/src/mragent_oss/ingest/rewriter.py +175 -0
  22. mragent_oss-0.1.0/src/mragent_oss/llm/__init__.py +5 -0
  23. mragent_oss-0.1.0/src/mragent_oss/llm/client.py +203 -0
  24. mragent_oss-0.1.0/src/mragent_oss/llm/prompts.py +218 -0
  25. mragent_oss-0.1.0/src/mragent_oss/mcp_server.py +613 -0
  26. mragent_oss-0.1.0/src/mragent_oss/retrieve/__init__.py +41 -0
  27. mragent_oss-0.1.0/src/mragent_oss/retrieve/answer.py +304 -0
  28. mragent_oss-0.1.0/src/mragent_oss/retrieve/llm_adapter.py +216 -0
  29. mragent_oss-0.1.0/src/mragent_oss/retrieve/loop.py +441 -0
  30. mragent_oss-0.1.0/src/mragent_oss/retrieve/rerank.py +283 -0
  31. mragent_oss-0.1.0/src/mragent_oss/retrieve/tools.py +540 -0
  32. mragent_oss-0.1.0/src/mragent_oss/retrieve/types.py +81 -0
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .venv/
8
+ .env
9
+ .pytest_cache/
10
+ .coverage
11
+ htmlcov/
12
+ *.db
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shanewas Ahmed <shanewasahmed@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.5
2
+ Name: mragent-oss
3
+ Version: 0.1.0
4
+ Summary: Pluggable open-source agentic memory layer — MRAgent (arXiv:2606.06036)
5
+ Project-URL: Homepage, https://github.com/shanewas/mragent
6
+ Project-URL: Source, https://github.com/shanewas/mragent
7
+ Project-URL: Issues, https://github.com/shanewas/mragent/issues
8
+ Project-URL: Changelog, https://github.com/shanewas/mragent/blob/main/RELEASE_NOTES.md
9
+ Author-email: Shanewas Ahmed <shanewasahmed@gmail.com>
10
+ Maintainer-email: Shanewas Ahmed <shanewasahmed@gmail.com>
11
+ License: MIT
12
+ License-File: LICENSE
13
+ Keywords: agent,llm,long-term-memory,mcp,memory,rag
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: anyio>=4.0
25
+ Requires-Dist: click>=8.1
26
+ Requires-Dist: fastapi>=0.110
27
+ Requires-Dist: httpx>=0.27
28
+ Requires-Dist: mcp>=1.0
29
+ Requires-Dist: numpy>=1.26
30
+ Requires-Dist: openai>=1.30
31
+ Requires-Dist: pydantic>=2.6
32
+ Requires-Dist: uvicorn[standard]>=0.27
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
35
+ Requires-Dist: pytest>=8.0; extra == 'dev'
36
+ Provides-Extra: local
37
+ Requires-Dist: sentence-transformers>=2.7; extra == 'local'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # mragent
41
+
42
+ **Pluggable open-source agentic memory layer. 96% fewer tokens than LangMem on LongMemEval.**
43
+
44
+ Implements MRAgent (NUS, arXiv:2606.06036) — the Cue-Tag-Content graph + mid-reasoning
45
+ pruning loop that the paper benchmarks at **118K vs 3.26M tokens vs LangMem** on LongMemEval.
46
+
47
+ ```bash
48
+ pip install -e ".[dev,local]" # local = sentence-transformers for embeddings
49
+ mragent init # creates ~/.mragent/store.db
50
+ mragent ingest path/to/dialogues.jsonl # populate the CTC graph
51
+ mragent query "what did Nate win?" # runs the retrieval loop
52
+ mragent mcp claude-code # print the Claude Code install recipe
53
+ ```
54
+
55
+ Works with **Claude Code, OpenCode, Cursor, Continue, Goose, Windsurf, VS Code, Gemini CLI, ChatGPT, Hermes** via one MCP server.
56
+
57
+ ## Why MRAgent-OSS
58
+
59
+ | Framework | Limitation |
60
+ |---|---|
61
+ | LangMem | LangGraph-only |
62
+ | Mem0 | Vendor pull, "easy cloud" |
63
+ | Letta | Full runtime, operational weight |
64
+ | A-MEM | Per-insert LLM call, stale |
65
+ | Graphiti / Cognee | Heavy ingest, no mid-trajectory pruning |
66
+ | Hindsight | Hermes-only |
67
+
68
+ **MRAgent-OSS is the first memory layer where the agent itself decides mid-trajectory
69
+ which reasoning branch to drop**, while still giving you a single-file SQLite default.
70
+
71
+ ## Plug into Claude Code in 30 seconds
72
+
73
+ ```bash
74
+ claude mcp add mragent --transport stdio \
75
+ --command "mragent" --args "mcp serve" \
76
+ --env OPENAI_API_KEY="$OPENAI_API_KEY"
77
+ ```
78
+
79
+ Restart Claude Code — 7 mragent tools light up:
80
+
81
+ | Tool | Purpose |
82
+ |---|---|
83
+ | `mragent_retain` | Store a fact (CONFIRMED) |
84
+ | `mragent_tentative` | Store reasoning-branch scratch |
85
+ | `mragent_recall` | Top-k vector+keyword recall |
86
+ | `mragent_reflect` | LLM-synthesized answer |
87
+ | `mragent_query` | Full retrieval loop (the killer tool) |
88
+ | `mragent_prune` | Drop a memory with audit trail |
89
+ | `mragent_promote` | Tentative → Confirmed |
90
+
91
+ ## Python API
92
+
93
+ ```python
94
+ from mragent_oss import Memory, MemoryConfig
95
+
96
+ m = Memory(MemoryConfig(db_path="~/.mragent/store.db"))
97
+ mid = m.retain("Nate won a goldfish at the fair.")
98
+ hits = m.recall("What did Nate win?", k=5)
99
+ for h in hits:
100
+ print(h.memory_id, h.text, h.score)
101
+ ```
102
+
103
+ The five-verb lifecycle — `retain`, `tentative`, `recall`, `prune`,
104
+ `promote` — is the reasoning-aware memory surface no existing
105
+ framework offers. Tentative memories are excluded from `recall` by
106
+ default; promote them when the reasoning branch proves true, prune
107
+ them when it doesn't.
108
+
109
+ ## HTTP server
110
+
111
+ ```bash
112
+ mragent serve --port 8765
113
+ ```
114
+
115
+ Endpoints: `/health`, `/v1/retain`, `/v1/recall`, `/v1/reflect`,
116
+ `/v1/query`. Single FastAPI process, no Docker, no Postgres.
117
+
118
+ ## What's in v0.1
119
+
120
+ - ✅ CTC graph core (Cue/Episodic/Semantic/Topic nodes + Link)
121
+ - ✅ Storage protocol with SQLite (default) + in-memory impls
122
+ - ✅ Embeddings: OpenAI / local (sentence-transformers) / deterministic
123
+ - ✅ LLM client (OpenAI-compatible: OpenRouter, Anthropic via OR, vLLM)
124
+ - ✅ Three-stage ingestion pipeline (REWRITE → EMBED → EXTRACT_KEYWORD)
125
+ - ✅ Retrieval loop with active reconstruction + cosine rerank
126
+ - ✅ Seven retrieval tools (per arxiv §3.1)
127
+ - ✅ MCP stdio server (10+ host integrations)
128
+ - ✅ CLI: init, ingest, query, serve, mcp, status, version
129
+ - ✅ HTTP server: /v1/retain, /v1/recall, /v1/reflect, /v1/query
130
+ - ✅ Claude Code wedge adapter
131
+ - ✅ Verbatim prompts (REWRITE, KEYWORD, ANSWER_SORT, EVENT_KEYWORDS)
132
+ - ✅ 30 tests, all passing
133
+ - ✅ MIT licensed
134
+
135
+ ## What's deferred (v0.2+)
136
+
137
+ - Benchmark harness → separate `mragent-bench` repo
138
+ - OpenCode / Hermes / LangGraph native adapters (community-contributed)
139
+ - Postgres storage backend
140
+ - Hosted cloud (intentionally not planned)
141
+
142
+ See `SPEC.md` for the algorithm and design rationale, and
143
+ `docs/argument_full_platform.md` + `docs/POSITION-A1-MINIMAL-V0.1.md`
144
+ for the architecture debate that shaped this release.
145
+
146
+ ## Development
147
+
148
+ ```bash
149
+ git clone https://github.com/mragent-oss/mragent
150
+ cd mragent
151
+ pip install -e ".[dev,local]"
152
+ pytest tests/ -v # 30 tests, ~2s
153
+ ```
154
+
155
+ See `CONTRIBUTING.md` for how to add adapters, storage backends, or LLM providers.
156
+
157
+ ## Status
158
+
159
+ v0.1.0 — release-ready. See `RELEASE_NOTES.md`.
@@ -0,0 +1,120 @@
1
+ # mragent
2
+
3
+ **Pluggable open-source agentic memory layer. 96% fewer tokens than LangMem on LongMemEval.**
4
+
5
+ Implements MRAgent (NUS, arXiv:2606.06036) — the Cue-Tag-Content graph + mid-reasoning
6
+ pruning loop that the paper benchmarks at **118K vs 3.26M tokens vs LangMem** on LongMemEval.
7
+
8
+ ```bash
9
+ pip install -e ".[dev,local]" # local = sentence-transformers for embeddings
10
+ mragent init # creates ~/.mragent/store.db
11
+ mragent ingest path/to/dialogues.jsonl # populate the CTC graph
12
+ mragent query "what did Nate win?" # runs the retrieval loop
13
+ mragent mcp claude-code # print the Claude Code install recipe
14
+ ```
15
+
16
+ Works with **Claude Code, OpenCode, Cursor, Continue, Goose, Windsurf, VS Code, Gemini CLI, ChatGPT, Hermes** via one MCP server.
17
+
18
+ ## Why MRAgent-OSS
19
+
20
+ | Framework | Limitation |
21
+ |---|---|
22
+ | LangMem | LangGraph-only |
23
+ | Mem0 | Vendor pull, "easy cloud" |
24
+ | Letta | Full runtime, operational weight |
25
+ | A-MEM | Per-insert LLM call, stale |
26
+ | Graphiti / Cognee | Heavy ingest, no mid-trajectory pruning |
27
+ | Hindsight | Hermes-only |
28
+
29
+ **MRAgent-OSS is the first memory layer where the agent itself decides mid-trajectory
30
+ which reasoning branch to drop**, while still giving you a single-file SQLite default.
31
+
32
+ ## Plug into Claude Code in 30 seconds
33
+
34
+ ```bash
35
+ claude mcp add mragent --transport stdio \
36
+ --command "mragent" --args "mcp serve" \
37
+ --env OPENAI_API_KEY="$OPENAI_API_KEY"
38
+ ```
39
+
40
+ Restart Claude Code — 7 mragent tools light up:
41
+
42
+ | Tool | Purpose |
43
+ |---|---|
44
+ | `mragent_retain` | Store a fact (CONFIRMED) |
45
+ | `mragent_tentative` | Store reasoning-branch scratch |
46
+ | `mragent_recall` | Top-k vector+keyword recall |
47
+ | `mragent_reflect` | LLM-synthesized answer |
48
+ | `mragent_query` | Full retrieval loop (the killer tool) |
49
+ | `mragent_prune` | Drop a memory with audit trail |
50
+ | `mragent_promote` | Tentative → Confirmed |
51
+
52
+ ## Python API
53
+
54
+ ```python
55
+ from mragent_oss import Memory, MemoryConfig
56
+
57
+ m = Memory(MemoryConfig(db_path="~/.mragent/store.db"))
58
+ mid = m.retain("Nate won a goldfish at the fair.")
59
+ hits = m.recall("What did Nate win?", k=5)
60
+ for h in hits:
61
+ print(h.memory_id, h.text, h.score)
62
+ ```
63
+
64
+ The five-verb lifecycle — `retain`, `tentative`, `recall`, `prune`,
65
+ `promote` — is the reasoning-aware memory surface no existing
66
+ framework offers. Tentative memories are excluded from `recall` by
67
+ default; promote them when the reasoning branch proves true, prune
68
+ them when it doesn't.
69
+
70
+ ## HTTP server
71
+
72
+ ```bash
73
+ mragent serve --port 8765
74
+ ```
75
+
76
+ Endpoints: `/health`, `/v1/retain`, `/v1/recall`, `/v1/reflect`,
77
+ `/v1/query`. Single FastAPI process, no Docker, no Postgres.
78
+
79
+ ## What's in v0.1
80
+
81
+ - ✅ CTC graph core (Cue/Episodic/Semantic/Topic nodes + Link)
82
+ - ✅ Storage protocol with SQLite (default) + in-memory impls
83
+ - ✅ Embeddings: OpenAI / local (sentence-transformers) / deterministic
84
+ - ✅ LLM client (OpenAI-compatible: OpenRouter, Anthropic via OR, vLLM)
85
+ - ✅ Three-stage ingestion pipeline (REWRITE → EMBED → EXTRACT_KEYWORD)
86
+ - ✅ Retrieval loop with active reconstruction + cosine rerank
87
+ - ✅ Seven retrieval tools (per arxiv §3.1)
88
+ - ✅ MCP stdio server (10+ host integrations)
89
+ - ✅ CLI: init, ingest, query, serve, mcp, status, version
90
+ - ✅ HTTP server: /v1/retain, /v1/recall, /v1/reflect, /v1/query
91
+ - ✅ Claude Code wedge adapter
92
+ - ✅ Verbatim prompts (REWRITE, KEYWORD, ANSWER_SORT, EVENT_KEYWORDS)
93
+ - ✅ 30 tests, all passing
94
+ - ✅ MIT licensed
95
+
96
+ ## What's deferred (v0.2+)
97
+
98
+ - Benchmark harness → separate `mragent-bench` repo
99
+ - OpenCode / Hermes / LangGraph native adapters (community-contributed)
100
+ - Postgres storage backend
101
+ - Hosted cloud (intentionally not planned)
102
+
103
+ See `SPEC.md` for the algorithm and design rationale, and
104
+ `docs/argument_full_platform.md` + `docs/POSITION-A1-MINIMAL-V0.1.md`
105
+ for the architecture debate that shaped this release.
106
+
107
+ ## Development
108
+
109
+ ```bash
110
+ git clone https://github.com/mragent-oss/mragent
111
+ cd mragent
112
+ pip install -e ".[dev,local]"
113
+ pytest tests/ -v # 30 tests, ~2s
114
+ ```
115
+
116
+ See `CONTRIBUTING.md` for how to add adapters, storage backends, or LLM providers.
117
+
118
+ ## Status
119
+
120
+ v0.1.0 — release-ready. See `RELEASE_NOTES.md`.
@@ -0,0 +1,94 @@
1
+ # Release Notes — v0.1.0 (2026-06-29)
2
+
3
+ First public release of MRAgent-OSS, the open-source implementation of
4
+ MRAgent (arXiv:2606.06036).
5
+
6
+ ## What's in this release
7
+
8
+ - **CTC graph core** (`mragent_oss.core.graph`) — `CueNode`, `EpisodicNode`,
9
+ `SemanticNode`, `TopicNode`, `Link`, plus the `MemoryGraph` wrapper
10
+ with all index dicts (`keys`, `episode_events`, `episode_links`,
11
+ `key_to_values`, `event_to_keys`, `by_tag`, `by_key`, `tag_list`,
12
+ `topic_dict`, `persona_list`, `topic_embeddings`).
13
+ - **Three-verb + 3 verb lifecycle API** (`mragent_oss.api.Memory`):
14
+ `retain`, `recall`, `reflect`, `tentative`, `prune`, `promote`, `link`.
15
+ - **Storage protocol** with two impls: `SQLiteStorage` (default, single
16
+ file at `~/.mragent/store.db` or `$MRAGENT_DB_PATH`) and
17
+ `MemoryStorage` (in-process dict).
18
+ - **Embeddings protocol** with three backends: `OpenAIEmbeddings`,
19
+ `LocalEmbeddings` (sentence-transformers, optional), and a
20
+ `DeterministicEmbeddings` (test/CLI bootstrap).
21
+ - **LLM client** (`mragent_oss.llm.client`) — OpenAI-compatible, works for
22
+ OpenRouter, Anthropic via OpenRouter, and local vLLM.
23
+ - **Three-stage ingestion pipeline** (REWRITE → EMBED → EXTRACT_KEYWORD)
24
+ with per-stage file cache.
25
+ - **Retrieval loop** (`mragent_oss.retrieve.loop`) — the active
26
+ reconstruction loop with seed-pool extension on `query_event_keywords`
27
+ and embedding rerank on `edges_by_tag` when match set > `RERANK_LIMIT=20`.
28
+ - **Seven tools** (`mragent_oss.retrieve.tools`): `edges_by_tag`,
29
+ `query_conversation_time`, `query_event_keywords`, `query_event_context`,
30
+ `query_personal_information`, `query_personal_aspect`, `query_topic_events`.
31
+ - **MCP stdio server** (`mragent_oss.mcp_server`) — exposes the 7 tools and
32
+ the 6 `Memory` verbs to any MCP-capable host: Claude Code, OpenCode,
33
+ Cursor, Continue, Goose, Windsurf, VS Code, Gemini CLI, ChatGPT desktop.
34
+ - **CLI** (`mragent_oss.cli`): `init`, `ingest`, `query`, `serve`,
35
+ `mcp serve`, `mcp claude-code`, `status`, `version`.
36
+ - **HTTP server** (`mragent serve`) — FastAPI on port 8765 with
37
+ `/health`, `/v1/retain`, `/v1/recall`, `/v1/reflect`, `/v1/query`.
38
+ - **Claude Code wedge adapter** (`mragent_oss.adapters.claude_code`) —
39
+ prints the exact install recipe + JSON snippet for `.mcp.json`.
40
+ - **Verbatim prompts** for REWRITE, EXTRACT_KEYWORD, EVENT_KEYWORDS,
41
+ ANSWER_SORT, TOOL_CALL — all faithful to arxiv:2606.06036.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pip install -e ".[dev]"
47
+ ```
48
+
49
+ For local embeddings (avoids OpenAI dependency):
50
+ ```bash
51
+ pip install -e ".[local,dev]"
52
+ ```
53
+
54
+ ## Quickstart
55
+
56
+ ```bash
57
+ mragent init # create ~/.mragent/store.db
58
+ mragent ingest path/to/dialogues.jsonl # populate the CTC graph
59
+ mragent query "what did Nate win?" # ask a question
60
+ mragent mcp claude-code # print Claude Code install recipe
61
+ ```
62
+
63
+ Or in Python:
64
+
65
+ ```python
66
+ from mragent_oss import Memory, MemoryConfig
67
+
68
+ m = Memory(MemoryConfig(db_path="~/.mragent/store.db"))
69
+ mid = m.retain("Nate won a goldfish at the fair.")
70
+ hits = m.recall("What did Nate win?", k=5)
71
+ for h in hits:
72
+ print(h.memory_id, h.text, h.score)
73
+ ```
74
+
75
+ ## Plug into Claude Code in 30 seconds
76
+
77
+ ```bash
78
+ claude mcp add mragent --transport stdio \
79
+ --command "mragent" --args "mcp serve" \
80
+ --env OPENAI_API_KEY="$OPENAI_API_KEY"
81
+ ```
82
+
83
+ Restart Claude Code — the 7 mragent tools will appear in the tool list.
84
+
85
+ ## Out of scope (deferred)
86
+
87
+ - Postgres storage backend (v0.3)
88
+ - OpenCode / Hermes / LangGraph native adapters (community-contributed, v0.2+)
89
+ - Benchmark harness (separate `mragent-bench` repo, v0.2)
90
+ - Hosted cloud (intentionally not planned)
91
+
92
+ See `SPEC.md` for the full design rationale and
93
+ `docs/argument_full_platform.md` / `docs/POSITION-A1-MINIMAL-V0.1.md`
94
+ for the architecture debate that shaped this release.
@@ -0,0 +1,77 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.18"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "mragent-oss"
7
+ version = "0.1.0"
8
+ description = "Pluggable open-source agentic memory layer — MRAgent (arXiv:2606.06036)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Shanewas Ahmed", email = "shanewasahmed@gmail.com" }]
13
+ maintainers = [{ name = "Shanewas Ahmed", email = "shanewasahmed@gmail.com" }]
14
+ keywords = ["agent", "memory", "llm", "mcp", "long-term-memory", "rag"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
25
+ ]
26
+ dependencies = [
27
+ "pydantic>=2.6",
28
+ "httpx>=0.27",
29
+ "click>=8.1",
30
+ "numpy>=1.26",
31
+ "openai>=1.30",
32
+ "mcp>=1.0",
33
+ "fastapi>=0.110",
34
+ "uvicorn[standard]>=0.27",
35
+ "anyio>=4.0",
36
+ ]
37
+
38
+ [project.optional-dependencies]
39
+ dev = [
40
+ "pytest>=8.0",
41
+ "pytest-asyncio>=0.23",
42
+ ]
43
+ local = [
44
+ "sentence-transformers>=2.7",
45
+ ]
46
+
47
+ [project.scripts]
48
+ mragent = "mragent_oss.cli:cli"
49
+
50
+ [project.urls]
51
+ Homepage = "https://github.com/shanewas/mragent"
52
+ Source = "https://github.com/shanewas/mragent"
53
+ Issues = "https://github.com/shanewas/mragent/issues"
54
+ Changelog = "https://github.com/shanewas/mragent/blob/main/RELEASE_NOTES.md"
55
+
56
+ [tool.hatch.build.targets.wheel]
57
+ packages = ["src/mragent_oss"]
58
+ include = [
59
+ "README.md",
60
+ "RELEASE_NOTES.md",
61
+ "LICENSE",
62
+ ]
63
+
64
+ [tool.hatch.build.targets.sdist]
65
+ include = [
66
+ "src/mragent_oss/**",
67
+ "README.md",
68
+ "RELEASE_NOTES.md",
69
+ "LICENSE",
70
+ "pyproject.toml",
71
+ ]
72
+
73
+ [tool.pytest.ini_options]
74
+ testpaths = ["tests"]
75
+ pythonpath = ["src"]
76
+ asyncio_mode = "auto"
77
+ addopts = "-ra"
@@ -0,0 +1,32 @@
1
+ """
2
+ mragent-oss — pluggable open-source agentic memory layer.
3
+
4
+ A faithful open-source implementation of MRAgent (NUS, arXiv:2606.06036):
5
+ the Cue-Tag-Content graph + mid-reasoning pruning loop. Single-file
6
+ SQLite default, OpenAI-compatible LLM client, three-stage ingestion
7
+ pipeline, retrieval loop, MCP server, CLI, and HTTP server — all in
8
+ one package.
9
+
10
+ Quickstart::
11
+
12
+ from mragent_oss import Memory, MemoryConfig
13
+
14
+ m = Memory(MemoryConfig(db_path="~/.mragent/store.db"))
15
+ mid = m.retain("Nate won a goldfish at the fair.")
16
+ hits = m.recall("What did Nate win?", k=5)
17
+ for h in hits:
18
+ print(h.memory_id, h.text, h.score)
19
+
20
+ Drop into Claude Code in 30 seconds::
21
+
22
+ claude mcp add mragent --transport stdio \\
23
+ --command "mragent" --args "mcp serve" \\
24
+ --env OPENAI_API_KEY="$OPENAI_API_KEY"
25
+
26
+ See https://github.com/shanewas/mragent for the full documentation.
27
+ """
28
+
29
+ from ._version import __version__
30
+ from .api import Memory, MemoryConfig, MemoryHit
31
+
32
+ __all__ = ["Memory", "MemoryConfig", "MemoryHit", "__version__"]
@@ -0,0 +1,7 @@
1
+ """Single source of truth for the package version."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __all__ = ["__version__"]
6
+
7
+ __version__: str = "0.1.0"
@@ -0,0 +1,24 @@
1
+ """Host-framework adapters for MRAgent-OSS.
2
+
3
+ This package contains user-installable recipes / glue code that wires
4
+ ``mragent`` into specific agent frameworks. v0.1 ships only the
5
+ **Claude Code** wedge adapter (proof of pluggability); other adapters
6
+ live in user-contributed packages until they prove their worth.
7
+
8
+ Why an adapter at all when the MCP server covers everything?
9
+ -----------------------------------------------------------
10
+ The MCP server covers any agent that speaks MCP — Claude Code, OpenCode,
11
+ Cursor, Continue, Goose, Windsurf, VS Code, Gemini CLI, ChatGPT desktop.
12
+ The adapters in this package exist for two narrower cases:
13
+
14
+ 1. **Native tool-call integration** — when the host framework exposes
15
+ hooks for registering native tools (not via MCP) — e.g. Hermes's
16
+ plugin entry points.
17
+ 2. **Lifecycle hooks** — auto-retain on every conversation turn, or
18
+ auto-inject recalled memories into the system prompt before every
19
+ LLM call. The MCP server cannot do this for every host.
20
+ """
21
+
22
+ from .claude_code import get_install_snippet, get_one_liner
23
+
24
+ __all__ = ["get_install_snippet", "get_one_liner"]
@@ -0,0 +1,61 @@
1
+ """Claude Code adapter for MRAgent-OSS.
2
+
3
+ Prints the exact install recipe a user pastes into their Claude Code
4
+ MCP configuration. The recipe is a JSON snippet, not a Python install
5
+ hook — Claude Code reads the snippet from ``~/.config/claude/settings.json``
6
+ (per-user) or ``.mcp.json`` (per-project) at startup.
7
+
8
+ Why one-liner + JSON snippet?
9
+ -----------------------------
10
+ The CLI surface mirrors how Claude Code's own ``claude mcp add`` works:
11
+ the one-liner registers the server in the user's global config; the
12
+ JSON snippet is what to commit into a project's ``.mcp.json`` so the
13
+ team gets mragent automatically.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ from typing import Any, Dict
19
+
20
+
21
+ def get_install_snippet() -> Dict[str, Any]:
22
+ """Return the JSON snippet for ``.mcp.json`` or Claude settings.
23
+
24
+ Example ``.mcp.json`` in a project root::
25
+
26
+ {
27
+ "mcpServers": {
28
+ "mragent": {
29
+ "command": "mragent",
30
+ "args": ["mcp", "serve"],
31
+ "env": {
32
+ "OPENAI_API_KEY": "..."
33
+ }
34
+ }
35
+ }
36
+ }
37
+ """
38
+ return {
39
+ "mcpServers": {
40
+ "mragent": {
41
+ "command": "mragent",
42
+ "args": ["mcp", "serve"],
43
+ "env": {
44
+ "OPENAI_API_KEY": "${env:OPENAI_API_KEY}",
45
+ },
46
+ }
47
+ }
48
+ }
49
+
50
+
51
+ def get_one_liner() -> str:
52
+ """Return the shell one-liner that registers mragent globally in Claude Code.
53
+
54
+ Equivalent to clicking through the Claude Code UI's MCP setup, but
55
+ reproducible in any CI / dotfiles repo.
56
+ """
57
+ return (
58
+ 'claude mcp add mragent --transport stdio '
59
+ '--command "mragent" --args "mcp serve" '
60
+ '--env OPENAI_API_KEY="$OPENAI_API_KEY"'
61
+ )