mirsad-mcp 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.
- mirsad_mcp-0.2.0/LICENSE +21 -0
- mirsad_mcp-0.2.0/PKG-INFO +154 -0
- mirsad_mcp-0.2.0/README.md +132 -0
- mirsad_mcp-0.2.0/mirsad/__init__.py +8 -0
- mirsad_mcp-0.2.0/mirsad/cli.py +69 -0
- mirsad_mcp-0.2.0/mirsad/core.py +701 -0
- mirsad_mcp-0.2.0/mirsad/mcp_server.py +147 -0
- mirsad_mcp-0.2.0/mirsad/viewer.py +248 -0
- mirsad_mcp-0.2.0/mirsad_mcp.egg-info/PKG-INFO +154 -0
- mirsad_mcp-0.2.0/mirsad_mcp.egg-info/SOURCES.txt +14 -0
- mirsad_mcp-0.2.0/mirsad_mcp.egg-info/dependency_links.txt +1 -0
- mirsad_mcp-0.2.0/mirsad_mcp.egg-info/entry_points.txt +2 -0
- mirsad_mcp-0.2.0/mirsad_mcp.egg-info/requires.txt +1 -0
- mirsad_mcp-0.2.0/mirsad_mcp.egg-info/top_level.txt +1 -0
- mirsad_mcp-0.2.0/pyproject.toml +33 -0
- mirsad_mcp-0.2.0/setup.cfg +4 -0
mirsad_mcp-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Koussay Mehdouani
|
|
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,154 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mirsad-mcp
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A shared, living memory hub for AI agents - bi-temporal facts, first-class decisions, and owner-resolved conflicts, served over MCP. Local-first.
|
|
5
|
+
Author: Koussay Mehdouani
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/amkkoussay/Mersad
|
|
8
|
+
Project-URL: Repository, https://github.com/amkkoussay/Mersad
|
|
9
|
+
Keywords: mcp,model-context-protocol,ai-agents,ai-memory,knowledge-graph,sqlite
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: mcp[cli]<2
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# مِرصاد — MIRSAD
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+

|
|
28
|
+

|
|
29
|
+

|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
> **MIRSAD (مِرصاد)** is a shared, living memory hub for AI agents — one local
|
|
33
|
+
> store that Claude, ChatGPT and any MCP client can all read and write.
|
|
34
|
+
> Bi-temporal facts (nothing is ever silently overwritten), decisions stored
|
|
35
|
+
> as first-class units with their reasons, evidence and outcomes, and
|
|
36
|
+
> cross-agent conflicts that only the owner resolves. It ships with a live
|
|
37
|
+
> graph view: open the local page and watch your agents' memory grow as a
|
|
38
|
+
> network while they work. Local-first · MCP-native · SQLite/D1 · no heavy
|
|
39
|
+
> infrastructure, no LLM needed in the write path.
|
|
40
|
+
>
|
|
41
|
+
> _Keywords: MCP server, AI agent memory, shared memory, temporal knowledge
|
|
42
|
+
> graph, decision log, Claude, ChatGPT, SQLite, local-first._
|
|
43
|
+
|
|
44
|
+
**ذاكرة جماعية واحدة لكل مساعداتك.** خادم ذاكرة مبني على رسم معرفي زمني (Temporal Knowledge Graph) يقرأ منه ويكتب فيه كل مساعداتك وأنت نفسك — عبر بروتوكول MCP نفسه — فلا يضيع قرار اتُّخذ مع مساعدٍ عن بقيّة المساعدين، ولا تُنسى أسبابه وأدلّته ونتائجه.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## What is MIRSAD?
|
|
48
|
+
|
|
49
|
+
MIRSAD is an **open-source shared memory server for AI agents**, built on the
|
|
50
|
+
Model Context Protocol (MCP). Instead of every assistant keeping its own
|
|
51
|
+
private, forgetful memory, MIRSAD gives all of them **one collective memory**
|
|
52
|
+
they can read and write: Claude, ChatGPT, or any MCP client.
|
|
53
|
+
|
|
54
|
+
### Features
|
|
55
|
+
|
|
56
|
+
- **Bi-temporal facts** — facts carry validity time and recording time;
|
|
57
|
+
updates invalidate, never delete, so you can ask "what was true then?"
|
|
58
|
+
- **Decisions as first-class units** — every decision is stored with its
|
|
59
|
+
reasons, evidence, rejected alternatives, effects and outcomes, and can
|
|
60
|
+
be traced with a single `why` query.
|
|
61
|
+
- **Cross-agent conflict queue** — when one agent overwrites another's
|
|
62
|
+
fact, the latest value wins for queries but a conflict is opened for the
|
|
63
|
+
owner's ruling. Nothing is silently lost.
|
|
64
|
+
- **Live graph viewer** — open the local page and watch the memory as a
|
|
65
|
+
living network (entities, decisions, values, edges) while agents write;
|
|
66
|
+
click any node to read its story.
|
|
67
|
+
- **Arabic + English name resolution** — normalization and entity aliases,
|
|
68
|
+
so a fact stored as "MIRSAD" is found when an agent searches «مِرصاد».
|
|
69
|
+
- **Zero LLM in the write path** — deterministic storage on a single
|
|
70
|
+
SQLite file; runs anywhere, even on a phone via Termux.
|
|
71
|
+
|
|
72
|
+
### Quickstart
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/amkkoussay/Mersad.git
|
|
76
|
+
cd Mersad
|
|
77
|
+
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
|
|
78
|
+
MIRSAD_DB=~/mirsad.db .venv/bin/python -m mirsad.mcp_server
|
|
79
|
+
# MCP endpoint: http://127.0.0.1:8765/mcp · Live graph: http://127.0.0.1:8765/
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Then add `http://127.0.0.1:8765/mcp` as a custom MCP connector in your
|
|
83
|
+
assistant of choice, and it shares this memory with every other client.
|
|
84
|
+
|
|
85
|
+
## لماذا وُجد؟ (ما وجدناه في مراجعة الأنظمة الكبرى)
|
|
86
|
+
|
|
87
|
+
راجعنا Graphiti وCognee وMem0 وLetta وgraph-agent-memory وMemori (التقارير في `research/`). الخلاصة: لا واحد منها يخزّن **«القرار وسببه ودليله ونتيجته» كوحدة أولى جاهزة**، وأغلبها يحتاج LLM مدفوعًا وقاعدة رسوم منفصلة لمجرّد الكتابة، وMem0 الحالي لا يحسم التناقضات أصلًا، وLetta يترك الذاكرة لقرار النموذج. مِرصاد يأخذ أفضل أفكارهم ويصلح أضعف نقاطهم:
|
|
88
|
+
|
|
89
|
+
| الفكرة | من أين | كيف في مِرصاد |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| حقائق ثنائية الزمن (valid/recorded) تُبطَل ولا تُحذف | Graphiti | نفس النموذج، لكن **بلا LLM في طريق الكتابة** — الحسم حتمي بالكود |
|
|
92
|
+
| التعارضات سجلّات صريحة لا دمج صامت | Cognee (FactConflict) | أيّ كتابة من وكيل فوق حقيقة نشطة لوكيل آخر تفتح **تعارضًا** ينتظر قرارك |
|
|
93
|
+
| نسبة كل سجلّ لكاتبه | Mem0 | `source_agent` على كل حقيقة وقرار |
|
|
94
|
+
| مرآة Markdown قابلة للمراجعة والنسخ عبر git | Letta / Basic Memory | `export` يولّد سجلًّا مقروءًا كاملًا |
|
|
95
|
+
| ذاكرة الاستدلال طبقة أولى | graph-agent-memory | **القرار وحدة واحدة**: قرار ← أسباب ← أدلّة ← بدائل مرفوضة ← ملفات متأثرة ← نتائج، مع سلسلة استبدال (supersedes) |
|
|
96
|
+
|
|
97
|
+
والفرق العملي الأكبر: **ملف SQLite واحد، صفر خدمات خارجية، صفر مفاتيح API** — يعمل على أيّ جهاز، حتى هاتفك عبر Termux.
|
|
98
|
+
|
|
99
|
+
## نموذج البيانات
|
|
100
|
+
|
|
101
|
+
- **كيانات (Entities):** أشخاص، مشاريع، ملفات، مفاهيم.
|
|
102
|
+
- **حقائق (Facts):** (كيان، علاقة، قيمة) مع أربعة أزمنة: متى صحّت في العالم، متى توقّفت، متى سُجّلت، متى أُبطلت — فيمكن السؤال: «ما الصحيح الآن؟» و«ما الذي كان صحيحًا وقتها؟».
|
|
103
|
+
- **قرارات (Decisions):** الوحدة الكاملة أعلاه، بحالات proposed/accepted/rejected/superseded.
|
|
104
|
+
- **حلقات (Episodes):** النصّ الخام المصدر لكل سجلّ — لا يُحذف أبدًا (الأصل/Provenance).
|
|
105
|
+
- **تعارضات (Conflicts):** خلافات بين الوكلاء تنتظر حكمك، وحكمك نفسه يُحفظ.
|
|
106
|
+
|
|
107
|
+
## التشغيل
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
cd shared-memory-hub
|
|
111
|
+
python3 -m venv .venv && .venv/bin/pip install "mcp[cli]<2"
|
|
112
|
+
|
|
113
|
+
# خادم MCP عبر HTTP (للموصّلات) — المنفذ 8765 افتراضيًا
|
|
114
|
+
MIRSAD_DB=~/mirsad.db .venv/bin/python -m mirsad.mcp_server
|
|
115
|
+
|
|
116
|
+
# أو عبر سطر الأوامر
|
|
117
|
+
.venv/bin/python -m mirsad.cli --db ~/mirsad.db fact "Project" cache_backend Redis --agent agent-a
|
|
118
|
+
.venv/bin/python -m mirsad.cli --db ~/mirsad.db why Redis
|
|
119
|
+
.venv/bin/python -m mirsad.cli --db ~/mirsad.db export
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
الأدوات الإحدى عشرة عبر MCP: `remember_fact`، `current_fact`، `timeline`، `record_decision`، `record_outcome`، `add_alias`، `why`، `recall`، `open_conflicts`، `resolve_conflict`، `memory_stats`.
|
|
123
|
+
|
|
124
|
+
## خريطة الذاكرة الحية (النسخة المحلية)
|
|
125
|
+
|
|
126
|
+
شغّل الخادم المحلي ثم افتح **http://127.0.0.1:8765/** في المتصفح: شبكة حية
|
|
127
|
+
لذاكرتك — الكيانات والقرارات والقيم عقدٌ، والحقائق والروابط روابط. تتحدث
|
|
128
|
+
الخريطة لحظيًا بينما يكتب أي وكيل في الذاكرة (الكتابة الجديدة تنبض وتظهر
|
|
129
|
+
في مكانها)، والضغط على أي عقدة يفتح قصتها: حقائقها الحالية، خطها الزمني،
|
|
130
|
+
القرارات التي شاركت فيها ومَن كتب ماذا ومتى. التعارضات المفتوحة تُعلَّم
|
|
131
|
+
بحلقة حمراء. كل ذلك محلي بالكامل — صفحة واحدة بلا أي اعتماديات خارجية،
|
|
132
|
+
والمحرك يعرّض البيانات عبر `GET /graph`.
|
|
133
|
+
|
|
134
|
+
## الاختبارات (قابلة للفشل فعليًا)
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
.venv/bin/python demo.py # 23 فحصًا على المحرّك: قرارات، زمن، تعارض بين وكيلين، أسماء بديلة، استبدال
|
|
138
|
+
.venv/bin/python test_mcp.py # خادم حقيقي + عميل MCP رسمي: كتابة من وكيل وقراءة من آخر
|
|
139
|
+
.venv/bin/python test_graph.py # 13 فحصًا على خريطة الذاكرة الحية: عقد وروابط وقصص وعدّاد تغييرات
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## توصيل التطبيقات — الحقيقة كما تحققنا منها (نوفمبر 2026)
|
|
143
|
+
|
|
144
|
+
- **Claude (هاتف وويب):** يدعم موصّلات MCP بعيدة على **كل الخطط** (المجانية: موصّل واحد) بأدوات قراءة **وكتابة**. أضف الخادم من claude.ai ← Settings ← Connectors، وسيعمل داخل محادثات الهاتف (الاتصال من سحابة Anthropic).
|
|
145
|
+
- **ChatGPT:** إضافة خادم مخصص من **الويب فقط**، ثم يعمل على الهاتف. لكن على الخطط الفردية (Pro) الصلاحية **قراءة فقط** — يقرأ الذاكرة المشتركة ولا يكتب فيها؛ الكتابة عبر MCP محفوظة لخطط Business/Enterprise/Edu. (Plus: غير مُتحقق منه بدقة من مصدر OpenAI.)
|
|
146
|
+
- **شرط تقني لا مفرّ منه:** الخادم يجب أن يكون على **رابط HTTPS عام** ليصل إليه التطبيقان (localhost لا يكفي). خيارات الاستضافة: نفق آمن (مثل Cloudflare Tunnel) من جهازك، أو خدمة سحابية مجانية، أو VPS رخيص — القرار والخطوة التالية عليك (تحتاج حسابك).
|
|
147
|
+
- **تنبيهان صادقان:** (1) الذاكرة عبر MCP «عند الطلب» — المساعد يستدعي الأدوات أثناء المحادثة حين يقرّر أو حين تطلب منه، ليست مرآة حيّة تلتقط كل شيء تلقائيًا. (2) هوية الكاتب (`agent`) في هذه النسخة يصرّح بها العميل نفسه؛ في نسخة الإنتاج يجب أن تأتي من تسجيل الدخول (OAuth) حتى لا ينتحل وكيلٌ اسم آخر.
|
|
148
|
+
|
|
149
|
+
## خريطة الطريق
|
|
150
|
+
|
|
151
|
+
1. OAuth حقيقي للخادم (هوية موثّقة لكل مساعد/جهاز).
|
|
152
|
+
2. استيراد أرشيف محادثات ChatGPT (conversations.json) وClaude وتحويله لحلقات.
|
|
153
|
+
3. استخراج تلقائي اختياري بالـLLM لمن يريده — كطبقة فوق الكتابة اليدوية، لا بديلًا عنها.
|
|
154
|
+
4. بحث دلالي بالتضمينات بجانب البحث النصي والرسمي الحالي.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# مِرصاد — MIRSAD
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
> **MIRSAD (مِرصاد)** is a shared, living memory hub for AI agents — one local
|
|
11
|
+
> store that Claude, ChatGPT and any MCP client can all read and write.
|
|
12
|
+
> Bi-temporal facts (nothing is ever silently overwritten), decisions stored
|
|
13
|
+
> as first-class units with their reasons, evidence and outcomes, and
|
|
14
|
+
> cross-agent conflicts that only the owner resolves. It ships with a live
|
|
15
|
+
> graph view: open the local page and watch your agents' memory grow as a
|
|
16
|
+
> network while they work. Local-first · MCP-native · SQLite/D1 · no heavy
|
|
17
|
+
> infrastructure, no LLM needed in the write path.
|
|
18
|
+
>
|
|
19
|
+
> _Keywords: MCP server, AI agent memory, shared memory, temporal knowledge
|
|
20
|
+
> graph, decision log, Claude, ChatGPT, SQLite, local-first._
|
|
21
|
+
|
|
22
|
+
**ذاكرة جماعية واحدة لكل مساعداتك.** خادم ذاكرة مبني على رسم معرفي زمني (Temporal Knowledge Graph) يقرأ منه ويكتب فيه كل مساعداتك وأنت نفسك — عبر بروتوكول MCP نفسه — فلا يضيع قرار اتُّخذ مع مساعدٍ عن بقيّة المساعدين، ولا تُنسى أسبابه وأدلّته ونتائجه.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## What is MIRSAD?
|
|
26
|
+
|
|
27
|
+
MIRSAD is an **open-source shared memory server for AI agents**, built on the
|
|
28
|
+
Model Context Protocol (MCP). Instead of every assistant keeping its own
|
|
29
|
+
private, forgetful memory, MIRSAD gives all of them **one collective memory**
|
|
30
|
+
they can read and write: Claude, ChatGPT, or any MCP client.
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
- **Bi-temporal facts** — facts carry validity time and recording time;
|
|
35
|
+
updates invalidate, never delete, so you can ask "what was true then?"
|
|
36
|
+
- **Decisions as first-class units** — every decision is stored with its
|
|
37
|
+
reasons, evidence, rejected alternatives, effects and outcomes, and can
|
|
38
|
+
be traced with a single `why` query.
|
|
39
|
+
- **Cross-agent conflict queue** — when one agent overwrites another's
|
|
40
|
+
fact, the latest value wins for queries but a conflict is opened for the
|
|
41
|
+
owner's ruling. Nothing is silently lost.
|
|
42
|
+
- **Live graph viewer** — open the local page and watch the memory as a
|
|
43
|
+
living network (entities, decisions, values, edges) while agents write;
|
|
44
|
+
click any node to read its story.
|
|
45
|
+
- **Arabic + English name resolution** — normalization and entity aliases,
|
|
46
|
+
so a fact stored as "MIRSAD" is found when an agent searches «مِرصاد».
|
|
47
|
+
- **Zero LLM in the write path** — deterministic storage on a single
|
|
48
|
+
SQLite file; runs anywhere, even on a phone via Termux.
|
|
49
|
+
|
|
50
|
+
### Quickstart
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/amkkoussay/Mersad.git
|
|
54
|
+
cd Mersad
|
|
55
|
+
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
|
|
56
|
+
MIRSAD_DB=~/mirsad.db .venv/bin/python -m mirsad.mcp_server
|
|
57
|
+
# MCP endpoint: http://127.0.0.1:8765/mcp · Live graph: http://127.0.0.1:8765/
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Then add `http://127.0.0.1:8765/mcp` as a custom MCP connector in your
|
|
61
|
+
assistant of choice, and it shares this memory with every other client.
|
|
62
|
+
|
|
63
|
+
## لماذا وُجد؟ (ما وجدناه في مراجعة الأنظمة الكبرى)
|
|
64
|
+
|
|
65
|
+
راجعنا Graphiti وCognee وMem0 وLetta وgraph-agent-memory وMemori (التقارير في `research/`). الخلاصة: لا واحد منها يخزّن **«القرار وسببه ودليله ونتيجته» كوحدة أولى جاهزة**، وأغلبها يحتاج LLM مدفوعًا وقاعدة رسوم منفصلة لمجرّد الكتابة، وMem0 الحالي لا يحسم التناقضات أصلًا، وLetta يترك الذاكرة لقرار النموذج. مِرصاد يأخذ أفضل أفكارهم ويصلح أضعف نقاطهم:
|
|
66
|
+
|
|
67
|
+
| الفكرة | من أين | كيف في مِرصاد |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| حقائق ثنائية الزمن (valid/recorded) تُبطَل ولا تُحذف | Graphiti | نفس النموذج، لكن **بلا LLM في طريق الكتابة** — الحسم حتمي بالكود |
|
|
70
|
+
| التعارضات سجلّات صريحة لا دمج صامت | Cognee (FactConflict) | أيّ كتابة من وكيل فوق حقيقة نشطة لوكيل آخر تفتح **تعارضًا** ينتظر قرارك |
|
|
71
|
+
| نسبة كل سجلّ لكاتبه | Mem0 | `source_agent` على كل حقيقة وقرار |
|
|
72
|
+
| مرآة Markdown قابلة للمراجعة والنسخ عبر git | Letta / Basic Memory | `export` يولّد سجلًّا مقروءًا كاملًا |
|
|
73
|
+
| ذاكرة الاستدلال طبقة أولى | graph-agent-memory | **القرار وحدة واحدة**: قرار ← أسباب ← أدلّة ← بدائل مرفوضة ← ملفات متأثرة ← نتائج، مع سلسلة استبدال (supersedes) |
|
|
74
|
+
|
|
75
|
+
والفرق العملي الأكبر: **ملف SQLite واحد، صفر خدمات خارجية، صفر مفاتيح API** — يعمل على أيّ جهاز، حتى هاتفك عبر Termux.
|
|
76
|
+
|
|
77
|
+
## نموذج البيانات
|
|
78
|
+
|
|
79
|
+
- **كيانات (Entities):** أشخاص، مشاريع، ملفات، مفاهيم.
|
|
80
|
+
- **حقائق (Facts):** (كيان، علاقة، قيمة) مع أربعة أزمنة: متى صحّت في العالم، متى توقّفت، متى سُجّلت، متى أُبطلت — فيمكن السؤال: «ما الصحيح الآن؟» و«ما الذي كان صحيحًا وقتها؟».
|
|
81
|
+
- **قرارات (Decisions):** الوحدة الكاملة أعلاه، بحالات proposed/accepted/rejected/superseded.
|
|
82
|
+
- **حلقات (Episodes):** النصّ الخام المصدر لكل سجلّ — لا يُحذف أبدًا (الأصل/Provenance).
|
|
83
|
+
- **تعارضات (Conflicts):** خلافات بين الوكلاء تنتظر حكمك، وحكمك نفسه يُحفظ.
|
|
84
|
+
|
|
85
|
+
## التشغيل
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
cd shared-memory-hub
|
|
89
|
+
python3 -m venv .venv && .venv/bin/pip install "mcp[cli]<2"
|
|
90
|
+
|
|
91
|
+
# خادم MCP عبر HTTP (للموصّلات) — المنفذ 8765 افتراضيًا
|
|
92
|
+
MIRSAD_DB=~/mirsad.db .venv/bin/python -m mirsad.mcp_server
|
|
93
|
+
|
|
94
|
+
# أو عبر سطر الأوامر
|
|
95
|
+
.venv/bin/python -m mirsad.cli --db ~/mirsad.db fact "Project" cache_backend Redis --agent agent-a
|
|
96
|
+
.venv/bin/python -m mirsad.cli --db ~/mirsad.db why Redis
|
|
97
|
+
.venv/bin/python -m mirsad.cli --db ~/mirsad.db export
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
الأدوات الإحدى عشرة عبر MCP: `remember_fact`، `current_fact`، `timeline`، `record_decision`، `record_outcome`، `add_alias`، `why`، `recall`، `open_conflicts`، `resolve_conflict`، `memory_stats`.
|
|
101
|
+
|
|
102
|
+
## خريطة الذاكرة الحية (النسخة المحلية)
|
|
103
|
+
|
|
104
|
+
شغّل الخادم المحلي ثم افتح **http://127.0.0.1:8765/** في المتصفح: شبكة حية
|
|
105
|
+
لذاكرتك — الكيانات والقرارات والقيم عقدٌ، والحقائق والروابط روابط. تتحدث
|
|
106
|
+
الخريطة لحظيًا بينما يكتب أي وكيل في الذاكرة (الكتابة الجديدة تنبض وتظهر
|
|
107
|
+
في مكانها)، والضغط على أي عقدة يفتح قصتها: حقائقها الحالية، خطها الزمني،
|
|
108
|
+
القرارات التي شاركت فيها ومَن كتب ماذا ومتى. التعارضات المفتوحة تُعلَّم
|
|
109
|
+
بحلقة حمراء. كل ذلك محلي بالكامل — صفحة واحدة بلا أي اعتماديات خارجية،
|
|
110
|
+
والمحرك يعرّض البيانات عبر `GET /graph`.
|
|
111
|
+
|
|
112
|
+
## الاختبارات (قابلة للفشل فعليًا)
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
.venv/bin/python demo.py # 23 فحصًا على المحرّك: قرارات، زمن، تعارض بين وكيلين، أسماء بديلة، استبدال
|
|
116
|
+
.venv/bin/python test_mcp.py # خادم حقيقي + عميل MCP رسمي: كتابة من وكيل وقراءة من آخر
|
|
117
|
+
.venv/bin/python test_graph.py # 13 فحصًا على خريطة الذاكرة الحية: عقد وروابط وقصص وعدّاد تغييرات
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## توصيل التطبيقات — الحقيقة كما تحققنا منها (نوفمبر 2026)
|
|
121
|
+
|
|
122
|
+
- **Claude (هاتف وويب):** يدعم موصّلات MCP بعيدة على **كل الخطط** (المجانية: موصّل واحد) بأدوات قراءة **وكتابة**. أضف الخادم من claude.ai ← Settings ← Connectors، وسيعمل داخل محادثات الهاتف (الاتصال من سحابة Anthropic).
|
|
123
|
+
- **ChatGPT:** إضافة خادم مخصص من **الويب فقط**، ثم يعمل على الهاتف. لكن على الخطط الفردية (Pro) الصلاحية **قراءة فقط** — يقرأ الذاكرة المشتركة ولا يكتب فيها؛ الكتابة عبر MCP محفوظة لخطط Business/Enterprise/Edu. (Plus: غير مُتحقق منه بدقة من مصدر OpenAI.)
|
|
124
|
+
- **شرط تقني لا مفرّ منه:** الخادم يجب أن يكون على **رابط HTTPS عام** ليصل إليه التطبيقان (localhost لا يكفي). خيارات الاستضافة: نفق آمن (مثل Cloudflare Tunnel) من جهازك، أو خدمة سحابية مجانية، أو VPS رخيص — القرار والخطوة التالية عليك (تحتاج حسابك).
|
|
125
|
+
- **تنبيهان صادقان:** (1) الذاكرة عبر MCP «عند الطلب» — المساعد يستدعي الأدوات أثناء المحادثة حين يقرّر أو حين تطلب منه، ليست مرآة حيّة تلتقط كل شيء تلقائيًا. (2) هوية الكاتب (`agent`) في هذه النسخة يصرّح بها العميل نفسه؛ في نسخة الإنتاج يجب أن تأتي من تسجيل الدخول (OAuth) حتى لا ينتحل وكيلٌ اسم آخر.
|
|
126
|
+
|
|
127
|
+
## خريطة الطريق
|
|
128
|
+
|
|
129
|
+
1. OAuth حقيقي للخادم (هوية موثّقة لكل مساعد/جهاز).
|
|
130
|
+
2. استيراد أرشيف محادثات ChatGPT (conversations.json) وClaude وتحويله لحلقات.
|
|
131
|
+
3. استخراج تلقائي اختياري بالـLLM لمن يريده — كطبقة فوق الكتابة اليدوية، لا بديلًا عنها.
|
|
132
|
+
4. بحث دلالي بالتضمينات بجانب البحث النصي والرسمي الحالي.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""MIRSAD (مِرصاد) — a shared temporal knowledge-graph memory for multiple AI agents.
|
|
2
|
+
|
|
3
|
+
One memory hub that every MCP-capable assistant — and the user himself — can read and
|
|
4
|
+
write through the same tools, so a decision made with one assistant is known —
|
|
5
|
+
with its reasons, evidence and outcome — to all the others.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""MIRSAD command line — the same operations the MCP tools expose.
|
|
2
|
+
|
|
3
|
+
Examples:
|
|
4
|
+
python -m mirsad.cli --db ~/mirsad.db fact "Project X" uses_cache Redis --agent agent-a
|
|
5
|
+
python -m mirsad.cli --db ~/mirsad.db why Redis
|
|
6
|
+
python -m mirsad.cli --db ~/mirsad.db export > DECISIONS.md
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import argparse
|
|
12
|
+
import json
|
|
13
|
+
|
|
14
|
+
from .core import Mirsad
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main() -> None:
|
|
18
|
+
p = argparse.ArgumentParser(prog="mirsad")
|
|
19
|
+
p.add_argument("--db", default="mirsad.db")
|
|
20
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
21
|
+
|
|
22
|
+
f = sub.add_parser("fact")
|
|
23
|
+
f.add_argument("subject")
|
|
24
|
+
f.add_argument("predicate")
|
|
25
|
+
f.add_argument("value")
|
|
26
|
+
f.add_argument("--agent", default="user")
|
|
27
|
+
|
|
28
|
+
c = sub.add_parser("current")
|
|
29
|
+
c.add_argument("subject")
|
|
30
|
+
c.add_argument("predicate")
|
|
31
|
+
|
|
32
|
+
t = sub.add_parser("timeline")
|
|
33
|
+
t.add_argument("subject")
|
|
34
|
+
|
|
35
|
+
w = sub.add_parser("why")
|
|
36
|
+
w.add_argument("topic")
|
|
37
|
+
|
|
38
|
+
r = sub.add_parser("recall")
|
|
39
|
+
r.add_argument("query")
|
|
40
|
+
|
|
41
|
+
sub.add_parser("conflicts")
|
|
42
|
+
sub.add_parser("stats")
|
|
43
|
+
sub.add_parser("export")
|
|
44
|
+
|
|
45
|
+
args = p.parse_args()
|
|
46
|
+
m = Mirsad(args.db)
|
|
47
|
+
|
|
48
|
+
if args.cmd == "fact":
|
|
49
|
+
out = m.remember_fact(args.subject, args.predicate, args.value, source_agent=args.agent)
|
|
50
|
+
elif args.cmd == "current":
|
|
51
|
+
out = m.current_fact(args.subject, args.predicate)
|
|
52
|
+
elif args.cmd == "timeline":
|
|
53
|
+
out = m.timeline(args.subject)
|
|
54
|
+
elif args.cmd == "why":
|
|
55
|
+
out = m.why(args.topic)
|
|
56
|
+
elif args.cmd == "recall":
|
|
57
|
+
out = m.recall(args.query)
|
|
58
|
+
elif args.cmd == "conflicts":
|
|
59
|
+
out = m.open_conflicts()
|
|
60
|
+
elif args.cmd == "stats":
|
|
61
|
+
out = m.stats()
|
|
62
|
+
elif args.cmd == "export":
|
|
63
|
+
print(m.export_markdown())
|
|
64
|
+
return
|
|
65
|
+
print(json.dumps(out, ensure_ascii=False, indent=2))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
main()
|