mem-brain-mcp 1.0.9__tar.gz → 1.1.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mem-brain-mcp
3
- Version: 1.0.9
3
+ Version: 1.1.1
4
4
  Summary: MCP Server for Mem-Brain API - Exposes memory operations as MCP tools
5
5
  Keywords: ai,claude,cursor,llm,mcp,memory,model-context-protocol
6
6
  Classifier: Development Status :: 4 - Beta
@@ -194,15 +194,40 @@ For detailed instructions, see [aws/DEPLOYMENT.md](./aws/DEPLOYMENT.md).
194
194
  pytest
195
195
  ```
196
196
 
197
- ### Build and Publish
197
+ ### Build and Publish to PyPI
198
+
199
+ **Prerequisites:** Ensure you have a PyPI account and your credentials are configured in `~/.pypirc`.
200
+
201
+ **Step-by-step deployment:**
202
+
198
203
  ```bash
199
- # Build the wheel
200
- python3 -m build
204
+ # 1. Activate the virtual environment
205
+ cd mem-brain-mcp
206
+ source .venv/bin/activate
207
+
208
+ # 2. Update version in pyproject.toml
209
+ # Edit pyproject.toml and increment the version number (e.g., 1.0.8 -> 1.0.9)
210
+
211
+ # 3. Clean old builds
212
+ rm -rf dist/*
213
+
214
+ # 4. Build the package
215
+ python -m build
201
216
 
202
- # Upload to PyPI
217
+ # 5. Upload to PyPI using twine
203
218
  twine upload dist/*
204
219
  ```
205
220
 
221
+ **Quick deployment (one-liner after version bump):**
222
+ ```bash
223
+ source .venv/bin/activate && rm -rf dist/* && python -m build && twine upload dist/*
224
+ ```
225
+
226
+ **Verify deployment:**
227
+ ```bash
228
+ pip3 index versions mem-brain-mcp
229
+ ```
230
+
206
231
  ## License
207
232
 
208
233
  Same as Mem-Brain API project.
@@ -168,15 +168,40 @@ For detailed instructions, see [aws/DEPLOYMENT.md](./aws/DEPLOYMENT.md).
168
168
  pytest
169
169
  ```
170
170
 
171
- ### Build and Publish
171
+ ### Build and Publish to PyPI
172
+
173
+ **Prerequisites:** Ensure you have a PyPI account and your credentials are configured in `~/.pypirc`.
174
+
175
+ **Step-by-step deployment:**
176
+
172
177
  ```bash
173
- # Build the wheel
174
- python3 -m build
178
+ # 1. Activate the virtual environment
179
+ cd mem-brain-mcp
180
+ source .venv/bin/activate
181
+
182
+ # 2. Update version in pyproject.toml
183
+ # Edit pyproject.toml and increment the version number (e.g., 1.0.8 -> 1.0.9)
184
+
185
+ # 3. Clean old builds
186
+ rm -rf dist/*
187
+
188
+ # 4. Build the package
189
+ python -m build
175
190
 
176
- # Upload to PyPI
191
+ # 5. Upload to PyPI using twine
177
192
  twine upload dist/*
178
193
  ```
179
194
 
195
+ **Quick deployment (one-liner after version bump):**
196
+ ```bash
197
+ source .venv/bin/activate && rm -rf dist/* && python -m build && twine upload dist/*
198
+ ```
199
+
200
+ **Verify deployment:**
201
+ ```bash
202
+ pip3 index versions mem-brain-mcp
203
+ ```
204
+
180
205
  ## License
181
206
 
182
207
  Same as Mem-Brain API project.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mem-brain-mcp"
3
- version = "1.0.9"
3
+ version = "1.1.1"
4
4
  description = "MCP Server for Mem-Brain API - Exposes memory operations as MCP tools"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10,<3.14"
@@ -1,4 +1,3 @@
1
1
  """Mem-Brain MCP Server - Exposes Mem-Brain API as MCP tools."""
2
2
 
3
- __version__ = "1.0.8"
4
-
3
+ __version__ = "1.1.1"
@@ -48,6 +48,7 @@ AGENT_INSTRUCTIONS = """You are an intelligent assistant with a persistent, evol
48
48
  | `search_memories(query, k=5)` | Before answering ANY personal question |
49
49
  | `get_memories(memory_ids)` | Need full details for specific IDs |
50
50
  | `add_memory(content, tags=[], category="")` | User reveals preference/goal/fact |
51
+ | `get_stats()` | Check memory coverage and system health |
51
52
  | `delete_memories(memory_id)` | Memory is wrong or user requests deletion |
52
53
 
53
54
  ---
@@ -741,6 +742,80 @@ async def delete_memories(
741
742
  raise ToolError(f"Error deleting memories: {str(e)}")
742
743
 
743
744
 
745
+ @mcp.tool()
746
+ async def get_stats() -> str:
747
+ """Get comprehensive statistics about the memory system.
748
+
749
+ **Use this tool to:**
750
+ - Check how many memories you have stored
751
+ - See total link count and link density
752
+ - View top tags and memory distribution
753
+ - Understand your knowledge graph structure
754
+
755
+ **Why this matters:**
756
+ - Provides context about memory coverage
757
+ - Shows if the system is actively used
758
+ - Reveals patterns in what you store
759
+ - Helps identify gaps or over-representation
760
+
761
+ Returns formatted statistics including:
762
+ - Total memories count
763
+ - Total links count
764
+ - Average links per memory
765
+ - Top tags by frequency
766
+ - Memory categories/tags distribution
767
+
768
+ **Example:**
769
+ get_stats()
770
+ """
771
+ try:
772
+ logger.info("get_stats called - retrieving memory system statistics")
773
+ client = await _get_api_client()
774
+ result = await client.get_stats()
775
+
776
+ # Extract statistics
777
+ total_memories = result.get("total_memories", 0)
778
+ total_links = result.get("total_links", 0)
779
+ avg_links = result.get("avg_links_per_memory", 0)
780
+ top_tags = result.get("top_tags", [])
781
+
782
+ # Format response
783
+ lines = [
784
+ "📊 Memory System Statistics",
785
+ "",
786
+ f"Total Memories: {total_memories}",
787
+ f"Total Links: {total_links}",
788
+ f"Average Links per Memory: {avg_links:.2f}",
789
+ ]
790
+
791
+ # Add top tags if available
792
+ if top_tags:
793
+ lines.append("")
794
+ lines.append("Top Tags:")
795
+ for tag_data in top_tags[:10]: # Show top 10
796
+ if isinstance(tag_data, dict):
797
+ tag_name = tag_data.get("tag", "unknown")
798
+ count = tag_data.get("count", 0)
799
+ lines.append(f" - {tag_name}: {count} memories")
800
+ else:
801
+ lines.append(f" - {tag_data}")
802
+
803
+ return "\n".join(lines)
804
+ except httpx.HTTPStatusError as e:
805
+ error_detail = e.response.text if e.response else "Unknown error"
806
+ logger.error(f"API error: {e.response.status_code} - {error_detail}")
807
+ if e.response.status_code == 401:
808
+ raise ToolError(
809
+ "Authentication failed. Please login using the 'login' tool or configure your JWT token in the MCP client headers."
810
+ )
811
+ raise ToolError(f"Failed to get statistics: HTTP {e.response.status_code} - {error_detail}")
812
+ except ToolError:
813
+ raise
814
+ except Exception as e:
815
+ logger.error(f"Unexpected error in get_stats: {e}", exc_info=True)
816
+ raise ToolError(f"Error getting statistics: {str(e)}")
817
+
818
+
744
819
  # ============================================================================
745
820
  # HELPER FUNCTIONS
746
821
  # ============================================================================
File without changes
File without changes
File without changes