mem-brain-mcp 1.0.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.
@@ -0,0 +1,52 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+ .venv/
11
+ venv/
12
+ env/
13
+ ENV/
14
+
15
+ # IDE
16
+ .vscode/
17
+ .idea/
18
+ *.swp
19
+ *.swo
20
+ *~
21
+
22
+ # Testing
23
+ .pytest_cache/
24
+ .coverage
25
+ htmlcov/
26
+ .tox/
27
+
28
+ # Documentation
29
+ *.md
30
+ !README.md
31
+ !docker/**
32
+
33
+ # AWS
34
+ aws/
35
+ *.json.bak
36
+
37
+ # Logs
38
+ *.log
39
+
40
+ # OS
41
+ .DS_Store
42
+ Thumbs.db
43
+
44
+ # Git
45
+ .git/
46
+ .gitignore
47
+
48
+ # Other
49
+ *.bak
50
+ tmp/
51
+ temp/
52
+
@@ -0,0 +1,10 @@
1
+ # API Configuration
2
+ API_BASE_URL=http://localhost:8000
3
+ API_KEY=k5Gn9XCKA7qxjzlgBjN9Wiel1H3gQeaeR052Q7kgDPE
4
+
5
+ # MCP Server Configuration (optional)
6
+ MCP_SERVER_HOST=0.0.0.0
7
+ MCP_SERVER_PORT=8100
8
+
9
+ # Logging (optional)
10
+ LOG_LEVEL=INFO
@@ -0,0 +1,53 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ venv/
25
+ env/
26
+ ENV/
27
+ .venv
28
+
29
+ # IDE
30
+ .vscode/
31
+ .idea/
32
+ *.swp
33
+ *.swo
34
+ *~
35
+
36
+ # OS
37
+ .DS_Store
38
+ Thumbs.db
39
+
40
+ # Project specific
41
+ *.db
42
+ *.sqlite
43
+ *.sqlite3
44
+ tmp/
45
+ *.pkl
46
+ *.pickle
47
+
48
+ # Logs
49
+ *.log
50
+
51
+
52
+
53
+
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: mem-brain-mcp
3
+ Version: 1.0.0
4
+ Summary: MCP Server for Mem-Brain API - Exposes memory operations as MCP tools
5
+ Keywords: ai,claude,cursor,llm,mcp,memory,model-context-protocol
6
+ Classifier: Development Status :: 4 - Beta
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Requires-Python: <3.14,>=3.10
15
+ Requires-Dist: fastmcp<3.0.0,>=2.0.0
16
+ Requires-Dist: httpx>=0.25.0
17
+ Requires-Dist: pydantic-settings>=2.0.0
18
+ Requires-Dist: pydantic>=2.0.0
19
+ Requires-Dist: uvicorn[standard]>=0.27.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: black>=23.0.0; extra == 'dev'
22
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
23
+ Requires-Dist: pytest>=7.4.0; extra == 'dev'
24
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Mem-Brain MCP Server
28
+
29
+ MCP (Model Context Protocol) server that exposes Mem-Brain API functionality as standardized tools for AI agents. Built with [FastMCP](https://gofastmcp.com) for production-ready HTTP/SSE transport.
30
+
31
+ ## Features
32
+
33
+ - **Memory Management**: Create, read, update, and delete memories
34
+ - **Semantic Search**: Search memories using vector similarity
35
+ - **Graph Operations**: Find paths and neighborhoods in the memory graph
36
+ - **Statistics**: Get insights about your memory system
37
+ - **Link Management**: Link and unlink memories
38
+ - **HTTP/SSE Transport**: Run independently, accessible remotely
39
+ - **CLI Interface**: Packaged for easy global execution
40
+
41
+ ## Instant Execution (Recommended)
42
+
43
+ You can run the MCP server instantly without manual installation using `uv`:
44
+
45
+ ```bash
46
+ # Run using uvx (loads environment from .env or shell)
47
+ uvx mem-brain-mcp
48
+
49
+ # Run with custom API URL
50
+ export API_BASE_URL=http://your-api-alb-url.com
51
+ uvx mem-brain-mcp
52
+ ```
53
+
54
+ ## Installation
55
+
56
+ ### From Source
57
+
58
+ 1. Install using `uv` (recommended) or `pip`:
59
+
60
+ ```bash
61
+ cd mem-brain-mcp
62
+ uv pip install .
63
+ ```
64
+
65
+ 2. Run globally:
66
+
67
+ ```bash
68
+ mem-brain-mcp
69
+ ```
70
+
71
+ ## Configuration
72
+
73
+ The server reads configuration from environment variables or a `.env` file in the current working directory:
74
+
75
+ ```env
76
+ # API Configuration
77
+ API_BASE_URL=http://localhost:8000
78
+ # NOTE: API_KEY is optional here - per-user API keys are configured in MCP clients
79
+ API_KEY=your_api_key_here # Optional: fallback for single-user scenarios
80
+
81
+ # MCP Server Configuration
82
+ MCP_SERVER_HOST=0.0.0.0
83
+ MCP_SERVER_PORT=8100
84
+
85
+ # Logging
86
+ LOG_LEVEL=INFO
87
+ ```
88
+
89
+ ## Per-User API Key Configuration
90
+
91
+ Each user must configure their own API key in their MCP client for proper user isolation. The server extracts tokens from request headers.
92
+
93
+ ### Cursor IDE (`~/.cursor/mcp.json`)
94
+
95
+ ```json
96
+ {
97
+ "mcpServers": {
98
+ "mem-brain": {
99
+ "url": "http://localhost:8100/mcp",
100
+ "headers": {
101
+ "Authorization": "Bearer your-jwt-token"
102
+ }
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ ### Claude Desktop
109
+
110
+ #### Option 1: Native Remote (Pro/Team plans)
111
+ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json`):
112
+
113
+ ```json
114
+ {
115
+ "mcpServers": {
116
+ "mem-brain": {
117
+ "url": "http://your-deployed-url/mcp",
118
+ "headers": {
119
+ "Authorization": "Bearer your-jwt-token"
120
+ }
121
+ }
122
+ }
123
+ }
124
+ ```
125
+
126
+ #### Option 2: via CLI (Any plan)
127
+ ```json
128
+ {
129
+ "mcpServers": {
130
+ "mem-brain": {
131
+ "command": "uvx",
132
+ "args": ["mem-brain-mcp"],
133
+ "env": {
134
+ "API_BASE_URL": "http://your-deployed-url",
135
+ "JWT_SECRET_KEY": "your-secret"
136
+ }
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
142
+ ## AWS ECS Deployment
143
+
144
+ The MCP server can be deployed to AWS ECS (Fargate) with an Application Load Balancer.
145
+
146
+ ### Quick Start
147
+
148
+ 1. **Set up security groups** (see [aws/security-groups.md](./aws/security-groups.md))
149
+ 2. **Deploy using the script:**
150
+
151
+ ```bash
152
+ cd mem-brain-mcp/aws
153
+ ./deploy.sh ap-south-1 membrain-mcp membrain-cluster membrain-mcp
154
+ ```
155
+
156
+ For detailed instructions, see [aws/DEPLOYMENT.md](./aws/DEPLOYMENT.md).
157
+
158
+ ## Development
159
+
160
+ ### Running Tests
161
+ ```bash
162
+ pytest
163
+ ```
164
+
165
+ ### Build and Publish
166
+ ```bash
167
+ # Build the wheel
168
+ python3 -m build
169
+
170
+ # Upload to PyPI
171
+ twine upload dist/*
172
+ ```
173
+
174
+ ## License
175
+
176
+ Same as Mem-Brain API project.
@@ -0,0 +1,150 @@
1
+ # Mem-Brain MCP Server
2
+
3
+ MCP (Model Context Protocol) server that exposes Mem-Brain API functionality as standardized tools for AI agents. Built with [FastMCP](https://gofastmcp.com) for production-ready HTTP/SSE transport.
4
+
5
+ ## Features
6
+
7
+ - **Memory Management**: Create, read, update, and delete memories
8
+ - **Semantic Search**: Search memories using vector similarity
9
+ - **Graph Operations**: Find paths and neighborhoods in the memory graph
10
+ - **Statistics**: Get insights about your memory system
11
+ - **Link Management**: Link and unlink memories
12
+ - **HTTP/SSE Transport**: Run independently, accessible remotely
13
+ - **CLI Interface**: Packaged for easy global execution
14
+
15
+ ## Instant Execution (Recommended)
16
+
17
+ You can run the MCP server instantly without manual installation using `uv`:
18
+
19
+ ```bash
20
+ # Run using uvx (loads environment from .env or shell)
21
+ uvx mem-brain-mcp
22
+
23
+ # Run with custom API URL
24
+ export API_BASE_URL=http://your-api-alb-url.com
25
+ uvx mem-brain-mcp
26
+ ```
27
+
28
+ ## Installation
29
+
30
+ ### From Source
31
+
32
+ 1. Install using `uv` (recommended) or `pip`:
33
+
34
+ ```bash
35
+ cd mem-brain-mcp
36
+ uv pip install .
37
+ ```
38
+
39
+ 2. Run globally:
40
+
41
+ ```bash
42
+ mem-brain-mcp
43
+ ```
44
+
45
+ ## Configuration
46
+
47
+ The server reads configuration from environment variables or a `.env` file in the current working directory:
48
+
49
+ ```env
50
+ # API Configuration
51
+ API_BASE_URL=http://localhost:8000
52
+ # NOTE: API_KEY is optional here - per-user API keys are configured in MCP clients
53
+ API_KEY=your_api_key_here # Optional: fallback for single-user scenarios
54
+
55
+ # MCP Server Configuration
56
+ MCP_SERVER_HOST=0.0.0.0
57
+ MCP_SERVER_PORT=8100
58
+
59
+ # Logging
60
+ LOG_LEVEL=INFO
61
+ ```
62
+
63
+ ## Per-User API Key Configuration
64
+
65
+ Each user must configure their own API key in their MCP client for proper user isolation. The server extracts tokens from request headers.
66
+
67
+ ### Cursor IDE (`~/.cursor/mcp.json`)
68
+
69
+ ```json
70
+ {
71
+ "mcpServers": {
72
+ "mem-brain": {
73
+ "url": "http://localhost:8100/mcp",
74
+ "headers": {
75
+ "Authorization": "Bearer your-jwt-token"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ ### Claude Desktop
83
+
84
+ #### Option 1: Native Remote (Pro/Team plans)
85
+ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json`):
86
+
87
+ ```json
88
+ {
89
+ "mcpServers": {
90
+ "mem-brain": {
91
+ "url": "http://your-deployed-url/mcp",
92
+ "headers": {
93
+ "Authorization": "Bearer your-jwt-token"
94
+ }
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ #### Option 2: via CLI (Any plan)
101
+ ```json
102
+ {
103
+ "mcpServers": {
104
+ "mem-brain": {
105
+ "command": "uvx",
106
+ "args": ["mem-brain-mcp"],
107
+ "env": {
108
+ "API_BASE_URL": "http://your-deployed-url",
109
+ "JWT_SECRET_KEY": "your-secret"
110
+ }
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ ## AWS ECS Deployment
117
+
118
+ The MCP server can be deployed to AWS ECS (Fargate) with an Application Load Balancer.
119
+
120
+ ### Quick Start
121
+
122
+ 1. **Set up security groups** (see [aws/security-groups.md](./aws/security-groups.md))
123
+ 2. **Deploy using the script:**
124
+
125
+ ```bash
126
+ cd mem-brain-mcp/aws
127
+ ./deploy.sh ap-south-1 membrain-mcp membrain-cluster membrain-mcp
128
+ ```
129
+
130
+ For detailed instructions, see [aws/DEPLOYMENT.md](./aws/DEPLOYMENT.md).
131
+
132
+ ## Development
133
+
134
+ ### Running Tests
135
+ ```bash
136
+ pytest
137
+ ```
138
+
139
+ ### Build and Publish
140
+ ```bash
141
+ # Build the wheel
142
+ python3 -m build
143
+
144
+ # Upload to PyPI
145
+ twine upload dist/*
146
+ ```
147
+
148
+ ## License
149
+
150
+ Same as Mem-Brain API project.
@@ -0,0 +1,140 @@
1
+ # Troubleshooting Mem-Brain MCP Server
2
+
3
+ ## Common Issues
4
+
5
+ ### Issue: `add_memory` fails with "content parameter not being passed correctly"
6
+
7
+ **Symptoms:**
8
+ - Error message suggests parameters aren't formatted properly
9
+ - Tool call fails even with valid content
10
+
11
+ **Solutions:**
12
+
13
+ 1. **Ensure content is a string, not an object:**
14
+ ```python
15
+ # ✅ Correct
16
+ add_memory(content="I love Python programming")
17
+
18
+ # ❌ Wrong - don't pass as object
19
+ add_memory({"content": "I love Python"})
20
+ ```
21
+
22
+ 2. **Use named parameters:**
23
+ ```python
24
+ # ✅ Correct
25
+ add_memory(
26
+ content="User prefers dark mode",
27
+ tags=["preferences", "ui"],
28
+ category="settings"
29
+ )
30
+
31
+ # ⚠️ May work but not recommended
32
+ add_memory("User prefers dark mode", ["preferences"], "settings")
33
+ ```
34
+
35
+ 3. **Check parameter types:**
36
+ - `content`: Must be a **string** (required)
37
+ - `tags`: Must be a **list of strings** or `None` (optional)
38
+ - `category`: Must be a **string** or `None` (optional)
39
+
40
+ 4. **Example correct calls:**
41
+ ```python
42
+ # Minimal call
43
+ add_memory(content="User loves TypeScript")
44
+
45
+ # With tags
46
+ add_memory(
47
+ content="User prefers Python over JavaScript",
48
+ tags=["coding", "preferences"]
49
+ )
50
+
51
+ # Full call
52
+ add_memory(
53
+ content="User works primarily with backend systems",
54
+ tags=["coding", "backend"],
55
+ category="interests"
56
+ )
57
+ ```
58
+
59
+ ### Issue: Authentication errors
60
+
61
+ **Symptoms:**
62
+ - "Authentication failed" errors
63
+ - "No authentication token provided"
64
+
65
+ **Solutions:**
66
+
67
+ 1. **Make sure you've logged in:**
68
+ ```python
69
+ login(email="your@email.com", password="yourpassword")
70
+ ```
71
+
72
+ 2. **Or configure token in MCP client:**
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "mem-brain": {
77
+ "url": "http://localhost:8100/mcp",
78
+ "headers": {
79
+ "Authorization": "Bearer YOUR_JWT_TOKEN"
80
+ }
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ 3. **Token expired?** Tokens expire after 30 minutes. Call `login` again.
87
+
88
+ ### Issue: Search returns no results
89
+
90
+ **Possible causes:**
91
+ - No memories match your query
92
+ - Memories exist but don't match semantically
93
+ - Try broader queries
94
+
95
+ **Solutions:**
96
+ - Try different search terms
97
+ - Check if memories exist: `get_stats()`
98
+ - Use `get_memories()` to see what's stored
99
+
100
+ ### Issue: Connection refused
101
+
102
+ **Check:**
103
+ 1. API server is running: `curl http://localhost:8000/health`
104
+ 2. MCP server is running: `curl http://localhost:8100/health`
105
+ 3. Ports are correct in configuration
106
+
107
+ ## Debug Mode
108
+
109
+ Enable debug logging to see what's happening:
110
+
111
+ ```bash
112
+ export LOG_LEVEL=DEBUG
113
+ uv run python -m mem_brain_mcp
114
+ ```
115
+
116
+ This will show:
117
+ - All tool calls with parameters
118
+ - API requests and responses
119
+ - Authentication details
120
+ - Error stack traces
121
+
122
+ ## Testing Tools Manually
123
+
124
+ You can test the API directly to verify it's working:
125
+
126
+ ```bash
127
+ # Login
128
+ curl -X POST http://localhost:8000/api/v1/auth/login \
129
+ -H "Content-Type: application/json" \
130
+ -d '{"email": "test@example.com", "password": "TestPassword123"}'
131
+
132
+ # Add memory (use token from login)
133
+ curl -X POST http://localhost:8000/api/v1/memories \
134
+ -H "Content-Type: application/json" \
135
+ -H "Authorization: Bearer YOUR_TOKEN" \
136
+ -d '{"content": "Test memory", "tags": ["test"]}'
137
+ ```
138
+
139
+ If this works but MCP doesn't, the issue is in the MCP tool definition or parameter passing.
140
+