mcp-sqlite-memory-bank 1.3.0__py3-none-any.whl → 1.4.1__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.
- mcp_sqlite_memory_bank/database.py +247 -160
- mcp_sqlite_memory_bank/prompts.py +252 -0
- mcp_sqlite_memory_bank/resources.py +164 -0
- mcp_sqlite_memory_bank/semantic.py +107 -95
- mcp_sqlite_memory_bank/server.py +183 -33
- mcp_sqlite_memory_bank/types.py +6 -0
- mcp_sqlite_memory_bank/utils.py +5 -2
- {mcp_sqlite_memory_bank-1.3.0.dist-info → mcp_sqlite_memory_bank-1.4.1.dist-info}/METADATA +168 -4
- mcp_sqlite_memory_bank-1.4.1.dist-info/RECORD +15 -0
- mcp_sqlite_memory_bank-1.3.0.dist-info/RECORD +0 -13
- {mcp_sqlite_memory_bank-1.3.0.dist-info → mcp_sqlite_memory_bank-1.4.1.dist-info}/WHEEL +0 -0
- {mcp_sqlite_memory_bank-1.3.0.dist-info → mcp_sqlite_memory_bank-1.4.1.dist-info}/entry_points.txt +0 -0
- {mcp_sqlite_memory_bank-1.3.0.dist-info → mcp_sqlite_memory_bank-1.4.1.dist-info}/licenses/LICENSE +0 -0
- {mcp_sqlite_memory_bank-1.3.0.dist-info → mcp_sqlite_memory_bank-1.4.1.dist-info}/top_level.txt +0 -0
mcp_sqlite_memory_bank/server.py
CHANGED
@@ -65,6 +65,8 @@ from .types import (
|
|
65
65
|
SelectQueryResponse,
|
66
66
|
)
|
67
67
|
from .utils import catch_errors
|
68
|
+
from .resources import setup_mcp_resources
|
69
|
+
from .prompts import setup_mcp_prompts
|
68
70
|
|
69
71
|
# Initialize FastMCP app with explicit name
|
70
72
|
mcp: FastMCP = FastMCP("SQLite Memory Bank for Copilot/AI Agents")
|
@@ -78,6 +80,12 @@ os.makedirs(os.path.dirname(os.path.abspath(DB_PATH)), exist_ok=True)
|
|
78
80
|
# Initialize database
|
79
81
|
db = get_database(DB_PATH)
|
80
82
|
|
83
|
+
# Set up MCP Resources for enhanced context provision
|
84
|
+
setup_mcp_resources(mcp, DB_PATH)
|
85
|
+
|
86
|
+
# Set up MCP Prompts for enhanced workflow support
|
87
|
+
setup_mcp_prompts(mcp, DB_PATH)
|
88
|
+
|
81
89
|
|
82
90
|
# --- Schema Management Tools for SQLite Memory Bank ---
|
83
91
|
|
@@ -458,9 +466,9 @@ def explore_tables(pattern: Optional[str] = None, include_row_counts: bool = Tru
|
|
458
466
|
|
459
467
|
@mcp.tool
|
460
468
|
@catch_errors
|
461
|
-
def add_embeddings(
|
462
|
-
|
463
|
-
|
469
|
+
def add_embeddings(
|
470
|
+
table_name: str, text_columns: List[str], embedding_column: str = "embedding", model_name: str = "all-MiniLM-L6-v2"
|
471
|
+
) -> ToolResponse:
|
464
472
|
"""
|
465
473
|
Generate and store vector embeddings for semantic search on table content.
|
466
474
|
|
@@ -488,19 +496,23 @@ def add_embeddings(table_name: str, text_columns: List[str],
|
|
488
496
|
- Uses efficient batch processing for large datasets
|
489
497
|
- Supports various sentence-transformer models for different use cases
|
490
498
|
"""
|
491
|
-
return cast(
|
492
|
-
table_name, text_columns, embedding_column, model_name
|
493
|
-
)
|
499
|
+
return cast(
|
500
|
+
ToolResponse, get_database(DB_PATH).generate_embeddings(table_name, text_columns, embedding_column, model_name)
|
501
|
+
)
|
494
502
|
|
495
503
|
|
496
|
-
@mcp.tool
|
504
|
+
@mcp.tool
|
497
505
|
@catch_errors
|
498
|
-
def semantic_search(
|
499
|
-
|
500
|
-
|
506
|
+
def semantic_search(
|
507
|
+
query: str,
|
508
|
+
tables: Optional[List[str]] = None,
|
509
|
+
similarity_threshold: float = 0.5,
|
510
|
+
limit: int = 10,
|
511
|
+
model_name: str = "all-MiniLM-L6-v2",
|
512
|
+
) -> ToolResponse:
|
501
513
|
"""
|
502
514
|
Find content using natural language semantic similarity rather than exact keyword matching.
|
503
|
-
|
515
|
+
|
504
516
|
This enables intelligent knowledge discovery - find related concepts even when
|
505
517
|
they use different terminology or phrasing.
|
506
518
|
|
@@ -532,18 +544,26 @@ def semantic_search(query: str, tables: Optional[List[str]] = None,
|
|
532
544
|
- Supports fuzzy matching and concept discovery
|
533
545
|
- Much more powerful than keyword-based search for knowledge discovery
|
534
546
|
"""
|
535
|
-
return cast(
|
536
|
-
|
537
|
-
|
547
|
+
return cast(
|
548
|
+
ToolResponse,
|
549
|
+
get_database(DB_PATH).semantic_search(
|
550
|
+
query, tables, "embedding", None, similarity_threshold, limit, model_name
|
551
|
+
),
|
552
|
+
)
|
538
553
|
|
539
554
|
|
540
555
|
@mcp.tool
|
541
|
-
@catch_errors
|
542
|
-
def find_related(
|
543
|
-
|
556
|
+
@catch_errors
|
557
|
+
def find_related(
|
558
|
+
table_name: str,
|
559
|
+
row_id: int,
|
560
|
+
similarity_threshold: float = 0.5,
|
561
|
+
limit: int = 5,
|
562
|
+
model_name: str = "all-MiniLM-L6-v2",
|
563
|
+
) -> ToolResponse:
|
544
564
|
"""
|
545
565
|
Find content related to a specific row by semantic similarity.
|
546
|
-
|
566
|
+
|
547
567
|
Discover connections and related information that might not be obvious
|
548
568
|
from direct references or tags.
|
549
569
|
|
@@ -559,7 +579,7 @@ def find_related(table_name: str, row_id: int, similarity_threshold: float = 0.5
|
|
559
579
|
On error: {"success": False, "error": str, "category": str, "details": dict}
|
560
580
|
|
561
581
|
Examples:
|
562
|
-
>>> find_related("technical_decisions", 5)
|
582
|
+
>>> find_related("technical_decisions", 5)
|
563
583
|
{"success": True, "results": [
|
564
584
|
{"id": 12, "similarity_score": 0.84, "decision_name": "Related Architecture Choice", ...},
|
565
585
|
{"id": 3, "similarity_score": 0.71, "decision_name": "Similar Technology Decision", ...}
|
@@ -571,19 +591,27 @@ def find_related(table_name: str, row_id: int, similarity_threshold: float = 0.5
|
|
571
591
|
- Can reveal patterns and themes across your knowledge base
|
572
592
|
- Enables serendipitous discovery of relevant information
|
573
593
|
"""
|
574
|
-
return cast(
|
575
|
-
|
576
|
-
|
594
|
+
return cast(
|
595
|
+
ToolResponse,
|
596
|
+
get_database(DB_PATH).find_related_content(
|
597
|
+
table_name, row_id, "embedding", similarity_threshold, limit, model_name
|
598
|
+
),
|
599
|
+
)
|
577
600
|
|
578
601
|
|
579
602
|
@mcp.tool
|
580
603
|
@catch_errors
|
581
|
-
def smart_search(
|
582
|
-
|
583
|
-
|
604
|
+
def smart_search(
|
605
|
+
query: str,
|
606
|
+
tables: Optional[List[str]] = None,
|
607
|
+
semantic_weight: float = 0.7,
|
608
|
+
text_weight: float = 0.3,
|
609
|
+
limit: int = 10,
|
610
|
+
model_name: str = "all-MiniLM-L6-v2",
|
611
|
+
) -> ToolResponse:
|
584
612
|
"""
|
585
613
|
Intelligent hybrid search combining semantic understanding with keyword matching.
|
586
|
-
|
614
|
+
|
587
615
|
Provides the best of both worlds - semantic similarity for concept discovery
|
588
616
|
plus exact text matching for precise searches.
|
589
617
|
|
@@ -609,13 +637,16 @@ def smart_search(query: str, tables: Optional[List[str]] = None,
|
|
609
637
|
FastMCP Tool Info:
|
610
638
|
- Automatically balances semantic and keyword search
|
611
639
|
- Provides separate scores for transparency
|
612
|
-
- Falls back gracefully if semantic search unavailable
|
640
|
+
- Falls back gracefully if semantic search unavailable
|
613
641
|
- Optimal for both exploratory and precise searches
|
614
642
|
- Recommended for general-purpose knowledge discovery
|
615
643
|
"""
|
616
|
-
return cast(
|
617
|
-
|
618
|
-
|
644
|
+
return cast(
|
645
|
+
ToolResponse,
|
646
|
+
get_database(DB_PATH).hybrid_search(
|
647
|
+
query, tables, None, "embedding", semantic_weight, text_weight, limit, model_name
|
648
|
+
),
|
649
|
+
)
|
619
650
|
|
620
651
|
|
621
652
|
@mcp.tool
|
@@ -623,7 +654,7 @@ def smart_search(query: str, tables: Optional[List[str]] = None,
|
|
623
654
|
def embedding_stats(table_name: str, embedding_column: str = "embedding") -> ToolResponse:
|
624
655
|
"""
|
625
656
|
Get statistics about semantic search readiness for a table.
|
626
|
-
|
657
|
+
|
627
658
|
Check which content has embeddings and can be searched semantically.
|
628
659
|
|
629
660
|
Args:
|
@@ -636,7 +667,7 @@ def embedding_stats(table_name: str, embedding_column: str = "embedding") -> Too
|
|
636
667
|
|
637
668
|
Examples:
|
638
669
|
>>> embedding_stats("technical_decisions")
|
639
|
-
{"success": True, "total_rows": 25, "embedded_rows": 25, "coverage_percent": 100.0,
|
670
|
+
{"success": True, "total_rows": 25, "embedded_rows": 25, "coverage_percent": 100.0,
|
640
671
|
"embedding_dimensions": 384}
|
641
672
|
|
642
673
|
FastMCP Tool Info:
|
@@ -648,6 +679,122 @@ def embedding_stats(table_name: str, embedding_column: str = "embedding") -> Too
|
|
648
679
|
return cast(ToolResponse, get_database(DB_PATH).get_embedding_stats(table_name, embedding_column))
|
649
680
|
|
650
681
|
|
682
|
+
# --- Enhanced Tool Discovery and Categorization ---
|
683
|
+
|
684
|
+
|
685
|
+
@mcp.tool
|
686
|
+
@catch_errors
|
687
|
+
def list_tool_categories() -> ToolResponse:
|
688
|
+
"""
|
689
|
+
List all available tool categories for better organization and discovery.
|
690
|
+
|
691
|
+
Returns organized view of available functionality for LLMs and agents.
|
692
|
+
|
693
|
+
Returns:
|
694
|
+
ToolResponse: {"success": True, "categories": {category: [tool_names]}}
|
695
|
+
"""
|
696
|
+
categories = {
|
697
|
+
"schema_management": [
|
698
|
+
"create_table", "list_tables", "describe_table",
|
699
|
+
"drop_table", "rename_table", "list_all_columns"
|
700
|
+
],
|
701
|
+
"data_operations": [
|
702
|
+
"create_row", "read_rows", "update_rows",
|
703
|
+
"delete_rows", "run_select_query"
|
704
|
+
],
|
705
|
+
"search_discovery": [
|
706
|
+
"search_content", "explore_tables"
|
707
|
+
],
|
708
|
+
"semantic_search": [
|
709
|
+
"add_embeddings", "semantic_search", "find_related",
|
710
|
+
"smart_search", "embedding_stats"
|
711
|
+
],
|
712
|
+
"workflow_shortcuts": [
|
713
|
+
"quick_note", "remember_decision", "store_context"
|
714
|
+
],
|
715
|
+
"analytics_insights": [
|
716
|
+
"memory_usage_stats", "content_analytics"
|
717
|
+
]
|
718
|
+
}
|
719
|
+
|
720
|
+
return cast(ToolResponse, {
|
721
|
+
"success": True,
|
722
|
+
"categories": categories,
|
723
|
+
"total_tools": sum(len(tools) for tools in categories.values()),
|
724
|
+
"description": "Organized view of all available memory bank capabilities"
|
725
|
+
})
|
726
|
+
|
727
|
+
|
728
|
+
@mcp.tool
|
729
|
+
@catch_errors
|
730
|
+
def get_tools_by_category(category: str) -> ToolResponse:
|
731
|
+
"""
|
732
|
+
Get detailed information about tools in a specific category.
|
733
|
+
|
734
|
+
Args:
|
735
|
+
category (str): Category name (schema_management, data_operations,
|
736
|
+
search_discovery, semantic_search, workflow_shortcuts, analytics_insights)
|
737
|
+
|
738
|
+
Returns:
|
739
|
+
ToolResponse: {"success": True, "tools": [{"name": str, "description": str, "usage": str}]}
|
740
|
+
"""
|
741
|
+
tool_details = {
|
742
|
+
"schema_management": [
|
743
|
+
{"name": "create_table", "description": "Create new tables with custom schemas", "usage": "create_table('table_name', [{'name': 'col', 'type': 'TEXT'}])"},
|
744
|
+
{"name": "list_tables", "description": "List all available tables", "usage": "list_tables()"},
|
745
|
+
{"name": "describe_table", "description": "Get detailed schema for a table", "usage": "describe_table('table_name')"},
|
746
|
+
{"name": "drop_table", "description": "Delete a table permanently", "usage": "drop_table('table_name')"},
|
747
|
+
{"name": "rename_table", "description": "Rename an existing table", "usage": "rename_table('old_name', 'new_name')"},
|
748
|
+
{"name": "list_all_columns", "description": "Get all columns across all tables", "usage": "list_all_columns()"},
|
749
|
+
],
|
750
|
+
"data_operations": [
|
751
|
+
{"name": "create_row", "description": "Insert new data into any table", "usage": "create_row('table', {'col': 'value'})"},
|
752
|
+
{"name": "read_rows", "description": "Query data with optional filtering", "usage": "read_rows('table', {'filter_col': 'value'})"},
|
753
|
+
{"name": "update_rows", "description": "Modify existing data", "usage": "update_rows('table', {'new_data': 'value'}, {'where_col': 'value'})"},
|
754
|
+
{"name": "delete_rows", "description": "Remove data from tables", "usage": "delete_rows('table', {'filter_col': 'value'})"},
|
755
|
+
{"name": "run_select_query", "description": "Execute safe SELECT queries", "usage": "run_select_query('table', ['col1', 'col2'], {'filter': 'value'})"},
|
756
|
+
],
|
757
|
+
"search_discovery": [
|
758
|
+
{"name": "search_content", "description": "Full-text search across all content", "usage": "search_content('search query', ['table1', 'table2'])"},
|
759
|
+
{"name": "explore_tables", "description": "Discover table structures and sample data", "usage": "explore_tables('pattern*')"},
|
760
|
+
],
|
761
|
+
"semantic_search": [
|
762
|
+
{"name": "add_embeddings", "description": "Enable semantic search on tables", "usage": "add_embeddings('table', ['text_col1', 'text_col2'])"},
|
763
|
+
{"name": "semantic_search", "description": "Natural language content discovery", "usage": "semantic_search('find ML algorithms')"},
|
764
|
+
{"name": "find_related", "description": "Discover similar content", "usage": "find_related('table', row_id, 0.5)"},
|
765
|
+
{"name": "smart_search", "description": "Hybrid keyword + semantic search", "usage": "smart_search('search query')"},
|
766
|
+
{"name": "embedding_stats", "description": "Check semantic search readiness", "usage": "embedding_stats('table')"},
|
767
|
+
],
|
768
|
+
"workflow_shortcuts": [
|
769
|
+
{"name": "quick_note", "description": "Rapidly store notes and observations", "usage": "quick_note('content', 'category')"},
|
770
|
+
{"name": "remember_decision", "description": "Store technical decisions with context", "usage": "remember_decision('decision', 'approach', 'rationale')"},
|
771
|
+
{"name": "store_context", "description": "Save session context and progress", "usage": "store_context('topic', 'current_state', 'next_steps')"},
|
772
|
+
],
|
773
|
+
"analytics_insights": [
|
774
|
+
{"name": "memory_usage_stats", "description": "Analyze memory bank usage patterns", "usage": "memory_usage_stats()"},
|
775
|
+
{"name": "content_analytics", "description": "Get insights on stored content", "usage": "content_analytics('table_name')"},
|
776
|
+
],
|
777
|
+
}
|
778
|
+
|
779
|
+
if category not in tool_details:
|
780
|
+
return cast(ToolResponse, {
|
781
|
+
"success": False,
|
782
|
+
"error": f"Unknown category '{category}'. Available: {list(tool_details.keys())}",
|
783
|
+
"category": "VALIDATION",
|
784
|
+
"details": {"available_categories": list(tool_details.keys())},
|
785
|
+
})
|
786
|
+
|
787
|
+
return cast(ToolResponse, {
|
788
|
+
"success": True,
|
789
|
+
"category": category,
|
790
|
+
"tools": tool_details[category],
|
791
|
+
"tool_count": len(tool_details[category]),
|
792
|
+
})
|
793
|
+
|
794
|
+
|
795
|
+
# ...existing code...
|
796
|
+
|
797
|
+
|
651
798
|
# Export the FastMCP app for use in other modules and server runners
|
652
799
|
app = mcp
|
653
800
|
|
@@ -689,7 +836,10 @@ def _create_row_impl(table_name: str, data: Dict[str, Any]) -> Dict[str, Any]:
|
|
689
836
|
try:
|
690
837
|
current_db.create_table(
|
691
838
|
"nodes",
|
692
|
-
[
|
839
|
+
[
|
840
|
+
{"name": "id", "type": "INTEGER PRIMARY KEY AUTOINCREMENT"},
|
841
|
+
{"name": "label", "type": "TEXT NOT NULL"},
|
842
|
+
],
|
693
843
|
)
|
694
844
|
except Exception:
|
695
845
|
pass # Table might already exist
|
mcp_sqlite_memory_bank/types.py
CHANGED
@@ -182,6 +182,7 @@ class ExploreTablesResponse(SuccessResponse):
|
|
182
182
|
# Semantic Search Response Types
|
183
183
|
class SemanticSearchResponse(TypedDict):
|
184
184
|
"""Response type for semantic search operations."""
|
185
|
+
|
185
186
|
success: bool
|
186
187
|
results: List[Dict[str, Any]]
|
187
188
|
query: str
|
@@ -193,6 +194,7 @@ class SemanticSearchResponse(TypedDict):
|
|
193
194
|
|
194
195
|
class RelatedContentResponse(TypedDict, total=False):
|
195
196
|
"""Response type for find related content operations."""
|
197
|
+
|
196
198
|
success: bool
|
197
199
|
results: List[Dict[str, Any]]
|
198
200
|
target_row: Dict[str, Any]
|
@@ -204,6 +206,7 @@ class RelatedContentResponse(TypedDict, total=False):
|
|
204
206
|
|
205
207
|
class HybridSearchResponse(TypedDict):
|
206
208
|
"""Response type for hybrid search operations."""
|
209
|
+
|
207
210
|
success: bool
|
208
211
|
results: List[Dict[str, Any]]
|
209
212
|
query: str
|
@@ -216,6 +219,7 @@ class HybridSearchResponse(TypedDict):
|
|
216
219
|
|
217
220
|
class EmbeddingStatsResponse(TypedDict):
|
218
221
|
"""Response type for embedding statistics."""
|
222
|
+
|
219
223
|
success: bool
|
220
224
|
table_name: str
|
221
225
|
total_rows: int
|
@@ -227,6 +231,7 @@ class EmbeddingStatsResponse(TypedDict):
|
|
227
231
|
|
228
232
|
class GenerateEmbeddingsResponse(TypedDict):
|
229
233
|
"""Response type for embedding generation operations."""
|
234
|
+
|
230
235
|
success: bool
|
231
236
|
message: str
|
232
237
|
processed: int
|
@@ -236,6 +241,7 @@ class GenerateEmbeddingsResponse(TypedDict):
|
|
236
241
|
|
237
242
|
class EmbeddingColumnResponse(TypedDict):
|
238
243
|
"""Response type for adding embedding columns."""
|
244
|
+
|
239
245
|
success: bool
|
240
246
|
message: str
|
241
247
|
|
mcp_sqlite_memory_bank/utils.py
CHANGED
@@ -31,7 +31,9 @@ def catch_errors(f: T) -> T:
|
|
31
31
|
return cast(ToolResponse, e.to_dict())
|
32
32
|
except sqlite3.Error as e:
|
33
33
|
logging.error(f"{f.__name__} database error: {e}")
|
34
|
-
return cast(
|
34
|
+
return cast(
|
35
|
+
ToolResponse, DatabaseError(f"Database error in {f.__name__}: {e}", {"sqlite_error": str(e)}).to_dict()
|
36
|
+
)
|
35
37
|
except Exception as e:
|
36
38
|
logging.error(f"Unexpected error in {f.__name__}: {e}")
|
37
39
|
return cast(ToolResponse, DatabaseError(f"Unexpected error in {f.__name__}: {e}").to_dict())
|
@@ -50,7 +52,8 @@ def validate_identifier(name: str, context: str = "identifier") -> None:
|
|
50
52
|
"""
|
51
53
|
if not bool(re.match(r"^[A-Za-z_][A-Za-z0-9_]*$", name)):
|
52
54
|
raise ValidationError(
|
53
|
-
f"Invalid {context}: {name}. Must start with letter/underscore and "
|
55
|
+
f"Invalid {context}: {name}. Must start with letter/underscore and "
|
56
|
+
f"contain only letters, numbers, underscores.",
|
54
57
|
{"invalid_name": name},
|
55
58
|
)
|
56
59
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcp_sqlite_memory_bank
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.4.1
|
4
4
|
Summary: A dynamic, agent/LLM-friendly SQLite memory bank for MCP servers with semantic search capabilities.
|
5
5
|
Author-email: Robert Meisner <robert@catchit.pl>
|
6
6
|
License-Expression: MIT
|
@@ -16,6 +16,10 @@ Requires-Dist: fastapi>=0.100.0
|
|
16
16
|
Requires-Dist: uvicorn>=0.22.0
|
17
17
|
Requires-Dist: pydantic>=1.10.0
|
18
18
|
Requires-Dist: fastmcp
|
19
|
+
Requires-Dist: sqlalchemy>=2.0.0
|
20
|
+
Requires-Dist: sentence-transformers>=2.2.0
|
21
|
+
Requires-Dist: torch>=1.9.0
|
22
|
+
Requires-Dist: numpy>=1.21.0
|
19
23
|
Provides-Extra: test
|
20
24
|
Requires-Dist: pytest; extra == "test"
|
21
25
|
Dynamic: license-file
|
@@ -36,10 +40,14 @@ This project provides a robust, discoverable API for creating, exploring, and ma
|
|
36
40
|
- Build and query knowledge graphs for semantic search and reasoning
|
37
41
|
- Store, retrieve, and organize notes or structured data for LLM agents
|
38
42
|
- Enable natural language workflows for database management and exploration
|
43
|
+
- Intelligent content discovery with semantic search capabilities
|
44
|
+
- Access memory content through standardized MCP Resources and Prompts
|
39
45
|
- Integrate with FastMCP, Claude Desktop, and other agent platforms for seamless tool discovery
|
40
46
|
|
41
47
|
**Why mcp_sqlite_memory_bank?**
|
42
|
-
-
|
48
|
+
- **Full MCP Compliance:** Resources, Prompts, and 20+ organized tools
|
49
|
+
- **Semantic Search:** Natural language content discovery with AI-powered similarity matching
|
50
|
+
- **Explicit, discoverable APIs** for LLMs and agents with enhanced categorization
|
43
51
|
- Safe, parameterized queries and schema management
|
44
52
|
- Designed for extensibility and open source collaboration
|
45
53
|
|
@@ -104,18 +112,59 @@ Restart your IDE and try asking your AI assistant:
|
|
104
112
|
- **Dynamic Table Management:** Create, list, describe, rename, and drop tables at runtime
|
105
113
|
- **CRUD Operations:** Insert, read, update, and delete rows in any table
|
106
114
|
- **Safe SQL:** Run parameterized SELECT queries with input validation
|
115
|
+
- **Semantic Search:** Natural language search using sentence-transformers for intelligent content discovery
|
116
|
+
- **MCP Resources:** Access memory content through standardized MCP resource URIs
|
117
|
+
- **MCP Prompts:** Built-in intelligent prompts for common memory analysis workflows
|
118
|
+
- **Tool Categorization:** Organized tool discovery with detailed usage examples for enhanced LLM integration
|
107
119
|
- **Knowledge Graph Tools:** Built-in support for node/edge schemas and property graphs
|
108
120
|
- **Agent/LLM Integration:** Explicit, tool-based APIs for easy discovery and automation
|
109
121
|
- **Open Source:** MIT licensed, fully tested, and ready for community use
|
110
122
|
|
111
123
|
---
|
112
124
|
|
125
|
+
## MCP Compliance & Enhanced Integration
|
126
|
+
|
127
|
+
SQLite Memory Bank v1.4.0+ provides full Model Context Protocol (MCP) compliance with advanced features for enhanced LLM and agent integration:
|
128
|
+
|
129
|
+
### 🔧 MCP Tools (20 Available)
|
130
|
+
Organized into logical categories for easy discovery:
|
131
|
+
- **Schema Management** (6 tools): Table creation, modification, and inspection
|
132
|
+
- **Data Operations** (5 tools): CRUD operations with validation
|
133
|
+
- **Search & Discovery** (2 tools): Content search and exploration
|
134
|
+
- **Semantic Search** (5 tools): AI-powered natural language content discovery
|
135
|
+
- **Analytics** (2 tools): Memory bank insights and statistics
|
136
|
+
|
137
|
+
### 📄 MCP Resources (5 Available)
|
138
|
+
Real-time access to memory content via standardized URIs:
|
139
|
+
- `memory://tables/list` - List of all available tables
|
140
|
+
- `memory://tables/{table_name}/schema` - Table schema information
|
141
|
+
- `memory://tables/{table_name}/data` - Table data content
|
142
|
+
- `memory://search/{query}` - Search results as resources
|
143
|
+
- `memory://analytics/overview` - Memory bank overview analytics
|
144
|
+
|
145
|
+
### 💡 MCP Prompts (4 Available)
|
146
|
+
Intelligent prompts for common memory analysis workflows:
|
147
|
+
- `analyze-memory-content` - Analyze memory bank content and provide insights
|
148
|
+
- `search-and-summarize` - Search and create summary prompts
|
149
|
+
- `technical-decision-analysis` - Analyze technical decisions from memory
|
150
|
+
- `memory-bank-context` - Provide memory bank context for AI conversations
|
151
|
+
|
152
|
+
### 🎯 Enhanced Discoverability
|
153
|
+
- **Tool Categorization:** `list_tool_categories()` for organized tool discovery
|
154
|
+
- **Usage Examples:** `get_tools_by_category()` with detailed examples for each tool
|
155
|
+
- **Semantic Search:** Natural language queries for intelligent content discovery
|
156
|
+
- **LLM-Friendly APIs:** Explicit, descriptive tool names and comprehensive documentation
|
157
|
+
|
158
|
+
---
|
159
|
+
|
113
160
|
|
114
161
|
## Tools & API Reference
|
115
162
|
|
116
163
|
All tools are designed for explicit, discoverable use by LLMs, agents, and developers. Each function is available as a direct Python import and as an MCP tool.
|
117
164
|
|
118
|
-
|
165
|
+
**🔍 Tool Discovery:** Use `list_tool_categories()` to see all organized tool categories, or `get_tools_by_category(category)` for detailed information about specific tool groups with usage examples.
|
166
|
+
|
167
|
+
### Schema Management Tools (6 tools)
|
119
168
|
|
120
169
|
| Tool | Description | Required Parameters | Optional Parameters |
|
121
170
|
|------|-------------|---------------------|---------------------|
|
@@ -126,7 +175,7 @@ All tools are designed for explicit, discoverable use by LLMs, agents, and devel
|
|
126
175
|
| `describe_table` | Get schema details | `table_name` (str) | None |
|
127
176
|
| `list_all_columns` | List all columns for all tables | None | None |
|
128
177
|
|
129
|
-
### Data
|
178
|
+
### Data Operations Tools (5 tools)
|
130
179
|
|
131
180
|
| Tool | Description | Required Parameters | Optional Parameters |
|
132
181
|
|------|-------------|---------------------|---------------------|
|
@@ -136,6 +185,30 @@ All tools are designed for explicit, discoverable use by LLMs, agents, and devel
|
|
136
185
|
| `delete_rows` | Delete rows from table | `table_name` (str), `where` (dict) | None |
|
137
186
|
| `run_select_query` | Run safe SELECT query | `table_name` (str) | `columns` (list[str]), `where` (dict), `limit` (int) |
|
138
187
|
|
188
|
+
### Search & Discovery Tools (2 tools)
|
189
|
+
|
190
|
+
| Tool | Description | Required Parameters | Optional Parameters |
|
191
|
+
|------|-------------|---------------------|---------------------|
|
192
|
+
| `search_content` | Full-text search across table content | `query` (str) | `tables` (list[str]), `limit` (int) |
|
193
|
+
| `explore_tables` | Explore and discover table structures | None | `pattern` (str), `include_row_counts` (bool) |
|
194
|
+
|
195
|
+
### Semantic Search Tools (5 tools)
|
196
|
+
|
197
|
+
| Tool | Description | Required Parameters | Optional Parameters |
|
198
|
+
|------|-------------|---------------------|---------------------|
|
199
|
+
| `add_embeddings` | Generate vector embeddings for semantic search | `table_name` (str), `text_columns` (list[str]) | `embedding_column` (str), `model_name` (str) |
|
200
|
+
| `semantic_search` | Natural language search using vector similarity | `query` (str) | `tables` (list[str]), `similarity_threshold` (float), `limit` (int) |
|
201
|
+
| `find_related` | Find content related to specific row by similarity | `table_name` (str), `row_id` (int) | `similarity_threshold` (float), `limit` (int) |
|
202
|
+
| `smart_search` | Hybrid keyword + semantic search | `query` (str) | `tables` (list[str]), `semantic_weight` (float), `text_weight` (float) |
|
203
|
+
| `embedding_stats` | Get statistics about semantic search readiness | `table_name` (str) | `embedding_column` (str) |
|
204
|
+
|
205
|
+
### Tool Discovery & Organization (2 tools)
|
206
|
+
|
207
|
+
| Tool | Description | Required Parameters | Optional Parameters |
|
208
|
+
|------|-------------|---------------------|---------------------|
|
209
|
+
| `list_tool_categories` | List all available tool categories | None | None |
|
210
|
+
| `get_tools_by_category` | Get detailed tool information by category | `category` (str) | None |
|
211
|
+
|
139
212
|
Each tool validates inputs and returns consistent response formats with success/error indicators and appropriate data payloads.
|
140
213
|
|
141
214
|
---
|
@@ -464,6 +537,97 @@ For a complete agent memory implementation example, see [examples/agent_memory_e
|
|
464
537
|
|
465
538
|
---
|
466
539
|
|
540
|
+
## MCP Resources and Prompts Usage
|
541
|
+
|
542
|
+
### Using MCP Resources
|
543
|
+
|
544
|
+
MCP Resources provide real-time access to memory content through standardized URIs:
|
545
|
+
|
546
|
+
```python
|
547
|
+
# Access resource via MCP client
|
548
|
+
resource_uri = "memory://tables/list"
|
549
|
+
tables_resource = await client.read_resource(resource_uri)
|
550
|
+
|
551
|
+
# Get table schema
|
552
|
+
schema_uri = "memory://tables/user_preferences/schema"
|
553
|
+
schema_resource = await client.read_resource(schema_uri)
|
554
|
+
|
555
|
+
# Access table data
|
556
|
+
data_uri = "memory://tables/user_preferences/data"
|
557
|
+
data_resource = await client.read_resource(data_uri)
|
558
|
+
|
559
|
+
# Search as resource
|
560
|
+
search_uri = "memory://search/user preferences coding style"
|
561
|
+
search_resource = await client.read_resource(search_uri)
|
562
|
+
|
563
|
+
# Analytics overview
|
564
|
+
analytics_uri = "memory://analytics/overview"
|
565
|
+
analytics_resource = await client.read_resource(analytics_uri)
|
566
|
+
```
|
567
|
+
|
568
|
+
### Using MCP Prompts
|
569
|
+
|
570
|
+
MCP Prompts provide intelligent analysis workflows:
|
571
|
+
|
572
|
+
```python
|
573
|
+
# Analyze memory content
|
574
|
+
analysis_prompt = await client.get_prompt("analyze-memory-content", {
|
575
|
+
"focus_area": "technical_decisions"
|
576
|
+
})
|
577
|
+
|
578
|
+
# Search and summarize
|
579
|
+
summary_prompt = await client.get_prompt("search-and-summarize", {
|
580
|
+
"query": "database performance optimization",
|
581
|
+
"max_results": 10
|
582
|
+
})
|
583
|
+
|
584
|
+
# Technical decision analysis
|
585
|
+
decision_analysis = await client.get_prompt("technical-decision-analysis", {
|
586
|
+
"decision_category": "architecture"
|
587
|
+
})
|
588
|
+
|
589
|
+
# Get memory context for conversations
|
590
|
+
context_prompt = await client.get_prompt("memory-bank-context", {
|
591
|
+
"conversation_topic": "API design patterns"
|
592
|
+
})
|
593
|
+
```
|
594
|
+
|
595
|
+
### Semantic Search Examples
|
596
|
+
|
597
|
+
```python
|
598
|
+
# Enable semantic search on existing table
|
599
|
+
add_embeddings("technical_decisions", ["decision_name", "rationale"])
|
600
|
+
|
601
|
+
# Natural language search
|
602
|
+
results = semantic_search("machine learning algorithms",
|
603
|
+
similarity_threshold=0.4,
|
604
|
+
limit=5)
|
605
|
+
|
606
|
+
# Find related content
|
607
|
+
related = find_related("technical_decisions",
|
608
|
+
row_id=123,
|
609
|
+
similarity_threshold=0.5)
|
610
|
+
|
611
|
+
# Hybrid search (keyword + semantic)
|
612
|
+
hybrid_results = smart_search("API design patterns",
|
613
|
+
semantic_weight=0.7,
|
614
|
+
text_weight=0.3)
|
615
|
+
```
|
616
|
+
|
617
|
+
### Tool Organization Discovery
|
618
|
+
|
619
|
+
```python
|
620
|
+
# Discover tool categories
|
621
|
+
categories = list_tool_categories()
|
622
|
+
# Returns: {"schema_management": 6, "data_operations": 5, ...}
|
623
|
+
|
624
|
+
# Get detailed tool information
|
625
|
+
schema_tools = get_tools_by_category("schema_management")
|
626
|
+
# Returns detailed info with usage examples for each tool
|
627
|
+
```
|
628
|
+
|
629
|
+
---
|
630
|
+
|
467
631
|
## Troubleshooting
|
468
632
|
|
469
633
|
### Common MCP Connection Issues
|
@@ -0,0 +1,15 @@
|
|
1
|
+
mcp_sqlite_memory_bank/__init__.py,sha256=6Y9_iSiQIWOPJYMcMkbrqmaWiM-ymRHdNR6W-8jHj-k,2403
|
2
|
+
mcp_sqlite_memory_bank/database.py,sha256=kBHiibDV2ucm9alaDrNB-txm7v-hGt-uTNHIFKuFlKI,41873
|
3
|
+
mcp_sqlite_memory_bank/prompts.py,sha256=AYTpyxRh_YacQQ4SfFJIXGLLyxWaAVmEnkZ9-fgZv1c,11320
|
4
|
+
mcp_sqlite_memory_bank/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
mcp_sqlite_memory_bank/resources.py,sha256=g1IId2yCDQuv0zC5oEzBGhEZrDgi6z3wKpJZujXsr0Y,6869
|
6
|
+
mcp_sqlite_memory_bank/semantic.py,sha256=XVfM1C95TdZDtXOrwrGxR5JZnmeeO4O45gxniPWa6go,14791
|
7
|
+
mcp_sqlite_memory_bank/server.py,sha256=2isYtWyGFIVE1kOE_HWJR0R610YHHWCduKb6srC5ajM,40222
|
8
|
+
mcp_sqlite_memory_bank/types.py,sha256=2rNhd6dbvEFsey9QGHQ0VPGSB3U0RaXw8fKVfiBuUJw,6535
|
9
|
+
mcp_sqlite_memory_bank/utils.py,sha256=wHbR0cUlV-AWBk8ToI5ZgCrfrMp380ofyEc_GLB0l4g,6185
|
10
|
+
mcp_sqlite_memory_bank-1.4.1.dist-info/licenses/LICENSE,sha256=KPr7eFgCJqQIjeSAcwRafbjcgm-10zkrJ7MFoTOGJQg,1092
|
11
|
+
mcp_sqlite_memory_bank-1.4.1.dist-info/METADATA,sha256=DJa6MX4cN5wxlX-sr0W8MaGuZgeASXkl-XsX7Z9kw7w,33094
|
12
|
+
mcp_sqlite_memory_bank-1.4.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
13
|
+
mcp_sqlite_memory_bank-1.4.1.dist-info/entry_points.txt,sha256=S9yGWiCe8f_rgcGCgbwEAX2FfJ9jXWxcc4K4Jenbcn8,150
|
14
|
+
mcp_sqlite_memory_bank-1.4.1.dist-info/top_level.txt,sha256=xQ8MTGECpWMR-9DV4H8mMqaSoZqE-C8EvpOg9E2U1wM,23
|
15
|
+
mcp_sqlite_memory_bank-1.4.1.dist-info/RECORD,,
|
@@ -1,13 +0,0 @@
|
|
1
|
-
mcp_sqlite_memory_bank/__init__.py,sha256=6Y9_iSiQIWOPJYMcMkbrqmaWiM-ymRHdNR6W-8jHj-k,2403
|
2
|
-
mcp_sqlite_memory_bank/database.py,sha256=OaFHUQdsd9kCdaS1F8f5Z5jdaGmedZUbG-ZvProkvvI,41565
|
3
|
-
mcp_sqlite_memory_bank/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
mcp_sqlite_memory_bank/semantic.py,sha256=-QA1XDMlptIwsEDllBzGZS6si26QIdIaIgAiszVkckY,15609
|
5
|
-
mcp_sqlite_memory_bank/server.py,sha256=U2iX7JbYBiIwtIWMHET2gZ_M97HrMmskfrvAS5fL8Wg,33775
|
6
|
-
mcp_sqlite_memory_bank/types.py,sha256=Uz4CsnIR_MU8LAl2BbAqYWVJTogiYi_8-cr0Gg4foYs,6523
|
7
|
-
mcp_sqlite_memory_bank/utils.py,sha256=oF2VNXvxH_yzuipfYZsG6AMB7K0lWFr9Lupz6Cc7sM0,6140
|
8
|
-
mcp_sqlite_memory_bank-1.3.0.dist-info/licenses/LICENSE,sha256=KPr7eFgCJqQIjeSAcwRafbjcgm-10zkrJ7MFoTOGJQg,1092
|
9
|
-
mcp_sqlite_memory_bank-1.3.0.dist-info/METADATA,sha256=z9MVNNrsnI3So7w72lxoUknyYkM0dFp_jFd85QhdMQg,25864
|
10
|
-
mcp_sqlite_memory_bank-1.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
11
|
-
mcp_sqlite_memory_bank-1.3.0.dist-info/entry_points.txt,sha256=S9yGWiCe8f_rgcGCgbwEAX2FfJ9jXWxcc4K4Jenbcn8,150
|
12
|
-
mcp_sqlite_memory_bank-1.3.0.dist-info/top_level.txt,sha256=xQ8MTGECpWMR-9DV4H8mMqaSoZqE-C8EvpOg9E2U1wM,23
|
13
|
-
mcp_sqlite_memory_bank-1.3.0.dist-info/RECORD,,
|
File without changes
|
{mcp_sqlite_memory_bank-1.3.0.dist-info → mcp_sqlite_memory_bank-1.4.1.dist-info}/entry_points.txt
RENAMED
File without changes
|
{mcp_sqlite_memory_bank-1.3.0.dist-info → mcp_sqlite_memory_bank-1.4.1.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
{mcp_sqlite_memory_bank-1.3.0.dist-info → mcp_sqlite_memory_bank-1.4.1.dist-info}/top_level.txt
RENAMED
File without changes
|