mem-brain-mcp 1.0.9__py3-none-any.whl → 1.1.0__py3-none-any.whl

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.
mem_brain_mcp/server.py CHANGED
@@ -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
  # ============================================================================
@@ -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.0
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.
@@ -2,8 +2,8 @@ mem_brain_mcp/__init__.py,sha256=4gTKntJjg7JiV6dGhDNy1yFh3TW2tCdME_GR-pnSXwk,89
2
2
  mem_brain_mcp/__main__.py,sha256=H_mwoKm1FBmu4KzAcQcq-TXZqeNvlrAekAxB1s4F4hA,712
3
3
  mem_brain_mcp/client.py,sha256=jpf0fCupoRI8xZnPF4OntAQYxDAiVetIfL3S5GUOwUo,8009
4
4
  mem_brain_mcp/config.py,sha256=xx2lBkCIeT85t0HxtORwZHSU3hZT_EdsThpfjwPJhbQ,1261
5
- mem_brain_mcp/server.py,sha256=PwVh9I6UuuiowPuXPaEIuq87EmsipuytwaPWVq5cqfs,39544
6
- mem_brain_mcp-1.0.9.dist-info/METADATA,sha256=B0t1Hcu1nBOetQdqS26O3pubrYblkN67h999pfigW98,5228
7
- mem_brain_mcp-1.0.9.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
8
- mem_brain_mcp-1.0.9.dist-info/entry_points.txt,sha256=NH6QYQ-Sd8eJn5crpe_DL1PvGeUlL3y65968xPhmwG8,62
9
- mem_brain_mcp-1.0.9.dist-info/RECORD,,
5
+ mem_brain_mcp/server.py,sha256=MZHMahLvpmq9h7j8ipsOfF2j7X_d965vBk_QQBk6Cxw,42272
6
+ mem_brain_mcp-1.1.0.dist-info/METADATA,sha256=hahjVHRKHO1g18XJlP5Whmu6x3L_5iK9sjzJ21kB27A,5846
7
+ mem_brain_mcp-1.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
8
+ mem_brain_mcp-1.1.0.dist-info/entry_points.txt,sha256=NH6QYQ-Sd8eJn5crpe_DL1PvGeUlL3y65968xPhmwG8,62
9
+ mem_brain_mcp-1.1.0.dist-info/RECORD,,