memanto-mcp 0.1.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,36 @@
1
+ # ============================================================================
2
+ # Memanto MCP Server - environment configuration
3
+ # ============================================================================
4
+ # Copy this file to `.env` (or set these vars in your MCP client config).
5
+
6
+ # REQUIRED: Moorcheh API key (https://console.moorcheh.ai/api-keys)
7
+ MOORCHEH_API_KEY=your_key_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
8
+
9
+ # OPTIONAL: Default agent for memory operations.
10
+ # When set, the `agent_id` argument becomes optional on every tool call.
11
+ # Recommended: set this to a stable per-project or per-user identifier.
12
+ MEMANTO_DEFAULT_AGENT_ID=my-mcp-agent
13
+
14
+ # OPTIONAL: Agent pattern used when auto-creating the default agent.
15
+ # One of: support | project | tool (default: tool)
16
+ MEMANTO_AGENT_PATTERN=tool
17
+
18
+ # OPTIONAL: Auto-create the default agent if it does not exist (default: true).
19
+ MEMANTO_AGENT_AUTO_CREATE=true
20
+
21
+ # OPTIONAL: Session lifetime in hours (default: server config / 6).
22
+ # MEMANTO_SESSION_DURATION_HOURS=6
23
+
24
+ # OPTIONAL: Expose agent-management tools (create/list/get/delete).
25
+ # Off by default to keep the MCP tool surface focused on memory operations.
26
+ # MEMANTO_EXPOSE_ADMIN=false
27
+
28
+ # OPTIONAL: Transport. One of: stdio (default) | sse | streamable-http
29
+ # MEMANTO_MCP_TRANSPORT=stdio
30
+
31
+ # OPTIONAL: Host/port when using sse or streamable-http transports
32
+ # MEMANTO_MCP_HOST=127.0.0.1
33
+ # MEMANTO_MCP_PORT=8765
34
+
35
+ # OPTIONAL: Log level (DEBUG | INFO | WARNING | ERROR)
36
+ # MEMANTO_MCP_LOG_LEVEL=INFO
@@ -0,0 +1,106 @@
1
+ # Environment variables and secrets
2
+ .env
3
+ .env.local
4
+ .env.*.local
5
+ *.key
6
+ *.pem
7
+ *.crt
8
+ secrets/
9
+ .secrets
10
+
11
+ # Python
12
+ __pycache__/
13
+ *.py[cod]
14
+ *$py.class
15
+ *.so
16
+ .Python
17
+ uv.lock
18
+ build/
19
+ develop-eggs/
20
+ dist/
21
+ downloads/
22
+ eggs/
23
+ .eggs/
24
+ lib/
25
+ lib64/
26
+ parts/
27
+ sdist/
28
+ var/
29
+ wheels/
30
+ share/python-wheels/
31
+ *.egg-info/
32
+ .installed.cfg
33
+ *.egg
34
+ MANIFEST
35
+
36
+ # Virtual environments
37
+ venv/
38
+ .venv/
39
+ ENV/
40
+ env/
41
+ .env/
42
+
43
+ # IDEs
44
+ .vscode/
45
+ .idea/
46
+ .claude/
47
+ *.swp
48
+ *.swo
49
+ *~
50
+ .DS_Store
51
+
52
+ # Testing
53
+ .tox/
54
+ .nox/
55
+ .coverage
56
+ .coverage.*
57
+ .cache
58
+ nosetests.xml
59
+ coverage.xml
60
+ *.cover
61
+ *.log
62
+ .pytest_cache/
63
+
64
+ # Jupyter Notebook
65
+ .ipynb_checkpoints
66
+
67
+ # mypy
68
+ .mypy_cache/
69
+ .dmypy.json
70
+ dmypy.json
71
+
72
+ # Pyre type checker
73
+ .pyre/
74
+
75
+ # pytype static type analyzer
76
+ .pytype/
77
+
78
+ # Cython debug symbols
79
+ cython_debug/
80
+
81
+ # Database
82
+ *.db
83
+ *.sqlite
84
+ *.sqlite3
85
+
86
+ # Logs
87
+ logs/
88
+ *.log
89
+ pip-log.txt
90
+ pip-delete-this-directory.txt
91
+
92
+ # OS
93
+ .DS_Store
94
+ Thumbs.db
95
+ Desktop.ini
96
+
97
+ # Temporary files
98
+ tmp/
99
+ temp/
100
+ *.tmp
101
+ *.bak
102
+ *.swp
103
+ *.swo
104
+
105
+ # Generated version file
106
+ **/_version.py
@@ -0,0 +1,18 @@
1
+ Copyright 2026 EdgeAI Innovations Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,249 @@
1
+ Metadata-Version: 2.4
2
+ Name: memanto-mcp
3
+ Version: 0.1.0
4
+ Summary: Model Context Protocol (MCP) server for Memanto - persistent semantic memory for any MCP-compatible agent
5
+ Project-URL: Homepage, https://www.memanto.ai
6
+ Project-URL: Documentation, https://docs.memanto.ai
7
+ Project-URL: Repository, https://github.com/moorcheh-ai/memanto
8
+ Project-URL: Bug Tracker, https://github.com/moorcheh-ai/memanto/issues
9
+ Author-email: Memanto <info@memanto.ai>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: agent memory,anthropic,claude,cursor,mcp,memanto,model-context-protocol,moorcheh,semantic memory
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: <4,>=3.10
25
+ Requires-Dist: mcp[cli]>=1.2.0
26
+ Requires-Dist: memanto>=0.1.0
27
+ Requires-Dist: pydantic-settings>=2.0.0
28
+ Requires-Dist: pydantic>=2.0.0
29
+ Requires-Dist: python-dotenv>=1.0.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: mypy<2,>=1.10.0; extra == 'dev'
32
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
33
+ Requires-Dist: pytest-mock<4,>=3.12.0; extra == 'dev'
34
+ Requires-Dist: pytest<9,>=8.2.0; extra == 'dev'
35
+ Requires-Dist: ruff<0.15,>=0.14.6; extra == 'dev'
36
+ Description-Content-Type: text/markdown
37
+
38
+ # Memanto MCP Server
39
+
40
+ **Persistent semantic memory for any MCP-compatible agent.**
41
+
42
+ This package exposes [Memanto's](https://memanto.ai) memory primitives —
43
+ `remember`, `recall`, `answer`, and friends — as
44
+ [Model Context Protocol (MCP)](https://modelcontextprotocol.io) tools so any
45
+ MCP client (Claude Desktop, Cursor, Windsurf, Cline, Continue, Goose,
46
+ custom agents, …) can plug into long-term memory in a single config line.
47
+
48
+ > One Moorcheh API key → typed semantic memory across every agent that
49
+ > shares the namespace, with sub-90 ms retrieval, conflict detection, and
50
+ > zero ingestion latency.
51
+
52
+ ---
53
+
54
+ ## Install
55
+
56
+ ```bash
57
+ pip install memanto-mcp
58
+ ```
59
+
60
+ Requires Python 3.10+ and a [Moorcheh API key](https://console.moorcheh.ai/api-keys)
61
+ (free tier: 100K ops/month).
62
+
63
+ ## Quick start (Claude Desktop)
64
+
65
+ 1. Get a Moorcheh API key from the [console](https://console.moorcheh.ai/api-keys).
66
+ 2. Edit `claude_desktop_config.json` (Settings → Developer → Edit Config):
67
+
68
+ ```json
69
+ {
70
+ "mcpServers": {
71
+ "memanto": {
72
+ "command": "memanto-mcp",
73
+ "env": {
74
+ "MOORCHEH_API_KEY": "mch_xxxxxxxxxxxxxxxxxx",
75
+ "MEMANTO_DEFAULT_AGENT_ID": "my-assistant"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ 3. Restart Claude Desktop. Ask it to *"remember that I prefer concise
83
+ answers"* — then in a brand-new chat tomorrow ask *"what do I prefer?"*.
84
+
85
+ The first call auto-creates the `my-assistant` agent and namespace; every
86
+ subsequent call reuses the same persistent memory.
87
+
88
+ ## Quick start (Cursor / Windsurf / Cline / Continue / Goose)
89
+
90
+ Most clients consume a config file in the
91
+ [standard MCP shape](https://modelcontextprotocol.io/docs/clients).
92
+ The same JSON snippet works almost verbatim:
93
+
94
+ ```json
95
+ {
96
+ "mcpServers": {
97
+ "memanto": {
98
+ "command": "memanto-mcp",
99
+ "env": {
100
+ "MOORCHEH_API_KEY": "mch_xxxxxxxxxxxxxxxxxx",
101
+ "MEMANTO_DEFAULT_AGENT_ID": "cursor-workspace"
102
+ }
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ | Client | Config path |
109
+ |---|---|
110
+ | Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) / `%APPDATA%\Claude\claude_desktop_config.json` (Windows) |
111
+ | Cursor | `~/.cursor/mcp.json` (or per-project `.cursor/mcp.json`) |
112
+ | Windsurf | `~/.codeium/windsurf/mcp_config.json` |
113
+ | Cline (VS Code) | `~/.config/Code/User/globalStorage/cline.cline/settings/cline_mcp_settings.json` |
114
+ | Continue | `~/.continue/config.json` → `experimental.modelContextProtocolServers` |
115
+ | Goose | `~/.config/goose/config.yaml` |
116
+
117
+ ## Available tools
118
+
119
+ The server registers **7 memory tools by default**. Set
120
+ `MEMANTO_EXPOSE_ADMIN=true` to also expose **4 agent-management tools**.
121
+
122
+ ### Memory tools (always on)
123
+
124
+ | Tool | When the agent should call it |
125
+ |---|---|
126
+ | `remember` | Persist a single new fact/preference/decision/goal/instruction. |
127
+ | `batch_remember` | Persist up to 100 memories in one call (e.g. extracted from a document). |
128
+ | `recall` | Semantic search — *always* check here before asking the user to repeat stable info. |
129
+ | `recall_recent` | "What did we just decide?" — newest-first, no query needed. |
130
+ | `recall_as_of` | Point-in-time recall — "what did we know on 2025-11-01?" |
131
+ | `recall_changed_since` | Differential — "what's new since I last checked?" |
132
+ | `answer` | RAG: grounded LLM answer synthesized over the agent's memories. |
133
+
134
+ ### Agent admin tools (opt-in)
135
+
136
+ Enabled when `MEMANTO_EXPOSE_ADMIN=true`:
137
+
138
+ | Tool | Purpose |
139
+ |---|---|
140
+ | `create_agent` | Create a new memory namespace. |
141
+ | `list_agents` | List every agent the API key can see. |
142
+ | `get_agent` | Look up an agent's metadata. |
143
+ | `delete_agent` | Remove an agent's local metadata. |
144
+
145
+ Memory types accepted by `remember` / `batch_remember`:
146
+ `fact`, `preference`, `goal`, `decision`, `artifact`, `learning`, `event`,
147
+ `instruction`, `relationship`, `context`, `observation`, `commitment`,
148
+ `error`.
149
+
150
+ Provenance values: `explicit_statement`, `inferred`, `corrected`,
151
+ `validated`, `observed`, `imported`.
152
+
153
+ ## Configuration
154
+
155
+ All config is via environment variables (load order: process env →
156
+ `.env` file in the working directory).
157
+
158
+ | Variable | Required | Default | Description |
159
+ |---|---|---|---|
160
+ | `MOORCHEH_API_KEY` | **yes** | — | Moorcheh API key. |
161
+ | `MEMANTO_DEFAULT_AGENT_ID` | recommended | _none_ | Default agent. When set, tool calls may omit `agent_id`. |
162
+ | `MEMANTO_AGENT_PATTERN` | no | `tool` | Pattern (`support`/`project`/`tool`) used when auto-creating the default agent. |
163
+ | `MEMANTO_AGENT_AUTO_CREATE` | no | `true` | Create the default agent on first use if missing. |
164
+ | `MEMANTO_SESSION_DURATION_HOURS` | no | server default (6) | Session lifetime in hours. |
165
+ | `MEMANTO_EXPOSE_ADMIN` | no | `false` | Register the 4 agent-management tools. |
166
+ | `MEMANTO_MCP_TRANSPORT` | no | `stdio` | `stdio`, `sse`, or `streamable-http`. |
167
+ | `MEMANTO_MCP_HOST` | no | `127.0.0.1` | Bind host for sse/http transports. |
168
+ | `MEMANTO_MCP_PORT` | no | `8765` | Bind port for sse/http transports. |
169
+ | `MEMANTO_MCP_LOG_LEVEL` | no | `INFO` | Log level (logs are always sent to stderr). |
170
+
171
+ CLI flags (`memanto-mcp --transport sse --port 9000`) override env vars.
172
+
173
+ ## Running over HTTP / SSE
174
+
175
+ For remote clients or multi-process setups, run the server over a network
176
+ transport:
177
+
178
+ ```bash
179
+ # Streamable HTTP (recommended modern transport)
180
+ memanto-mcp --transport streamable-http --host 0.0.0.0 --port 8765
181
+
182
+ # Server-Sent Events (older, still widely supported)
183
+ memanto-mcp --transport sse --host 0.0.0.0 --port 8765
184
+ ```
185
+
186
+ Then point your client at `http://your-host:8765/mcp` (or whatever path the
187
+ chosen transport advertises). Pair with a reverse proxy + auth for
188
+ production deployments — the server itself authenticates upstream to
189
+ Moorcheh using your API key but does **not** authenticate inbound MCP
190
+ clients.
191
+
192
+ ## How it works
193
+
194
+ ```
195
+ ┌──────────────┐ MCP/stdio ┌──────────────────┐ Moorcheh API ┌─────────────┐
196
+ │ Claude / IDE │ ──────────────► │ memanto-mcp │ ────────────────► │ Moorcheh │
197
+ │ (client) │ ◄────────────── │ (this package) │ ◄──────────────── │ Service │
198
+ └──────────────┘ tool calls └──────────────────┘ HTTPS+API key └─────────────┘
199
+ │
200
+ └─ uses memanto.cli.client.SdkClient
201
+ (same client the Memanto CLI uses)
202
+ ```
203
+
204
+ - On startup, settings are validated; the API key is verified lazily on
205
+ first tool call.
206
+ - On the first memory tool invocation for a given agent, the server
207
+ ensures the agent exists (auto-creates if needed) and activates a JWT
208
+ session. Sessions auto-renew before expiry, so long-running MCP
209
+ connections never hit a session-expired error mid-conversation.
210
+ - The server intentionally keeps the session alive on shutdown: JWT
211
+ sessions are TTL-bound and other Memanto clients (CLI, REST) may want
212
+ to share them.
213
+
214
+ ## Programmatic embedding
215
+
216
+ If you're building a custom MCP host or wiring this server into a larger
217
+ process, you can construct the FastMCP instance yourself:
218
+
219
+ ```python
220
+ from memanto_mcp import MCPServerSettings, build_server
221
+
222
+ settings = MCPServerSettings() # reads env / .env
223
+ mcp = build_server(settings)
224
+
225
+ # Add your own tools alongside Memanto's, then run.
226
+ mcp.run(transport="stdio")
227
+ ```
228
+
229
+ ## Troubleshooting
230
+
231
+ | Symptom | Fix |
232
+ |---|---|
233
+ | `configuration error: MOORCHEH_API_KEY is required` | Set the env var in your MCP client config's `env` block. |
234
+ | `Agent '…' does not exist and MEMANTO_AGENT_AUTO_CREATE is disabled` | Either re-enable auto-create or call `create_agent` (admin tools) / `memanto agent create <id>` once. |
235
+ | Tools never appear in the client | Confirm the client supports MCP and the config path matches. Look at the client's MCP log: the server's stderr lines (prefixed `memanto_mcp`) will appear there on startup. |
236
+ | Garbled output in stdio mode | Something on your side is writing to **stdout** — that channel is reserved for JSON-RPC. Move logs to stderr. The server itself only writes to stderr. |
237
+ | Slow first call | Cold-start cost: SDK import + first session activation. Subsequent calls reuse the live session. |
238
+
239
+ ## License
240
+
241
+ MIT — same as the [Memanto](https://github.com/moorcheh-ai/memanto)
242
+ project. See [LICENSE](../../LICENSE).
243
+
244
+ ## Links
245
+
246
+ - [Memanto](https://memanto.ai) — the memory agent itself
247
+ - [Moorcheh](https://moorcheh.ai) — the no-indexing semantic DB underneath
248
+ - [Model Context Protocol spec](https://modelcontextprotocol.io)
249
+ - [Anthropic MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)
@@ -0,0 +1,212 @@
1
+ # Memanto MCP Server
2
+
3
+ **Persistent semantic memory for any MCP-compatible agent.**
4
+
5
+ This package exposes [Memanto's](https://memanto.ai) memory primitives —
6
+ `remember`, `recall`, `answer`, and friends — as
7
+ [Model Context Protocol (MCP)](https://modelcontextprotocol.io) tools so any
8
+ MCP client (Claude Desktop, Cursor, Windsurf, Cline, Continue, Goose,
9
+ custom agents, …) can plug into long-term memory in a single config line.
10
+
11
+ > One Moorcheh API key → typed semantic memory across every agent that
12
+ > shares the namespace, with sub-90 ms retrieval, conflict detection, and
13
+ > zero ingestion latency.
14
+
15
+ ---
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pip install memanto-mcp
21
+ ```
22
+
23
+ Requires Python 3.10+ and a [Moorcheh API key](https://console.moorcheh.ai/api-keys)
24
+ (free tier: 100K ops/month).
25
+
26
+ ## Quick start (Claude Desktop)
27
+
28
+ 1. Get a Moorcheh API key from the [console](https://console.moorcheh.ai/api-keys).
29
+ 2. Edit `claude_desktop_config.json` (Settings → Developer → Edit Config):
30
+
31
+ ```json
32
+ {
33
+ "mcpServers": {
34
+ "memanto": {
35
+ "command": "memanto-mcp",
36
+ "env": {
37
+ "MOORCHEH_API_KEY": "mch_xxxxxxxxxxxxxxxxxx",
38
+ "MEMANTO_DEFAULT_AGENT_ID": "my-assistant"
39
+ }
40
+ }
41
+ }
42
+ }
43
+ ```
44
+
45
+ 3. Restart Claude Desktop. Ask it to *"remember that I prefer concise
46
+ answers"* — then in a brand-new chat tomorrow ask *"what do I prefer?"*.
47
+
48
+ The first call auto-creates the `my-assistant` agent and namespace; every
49
+ subsequent call reuses the same persistent memory.
50
+
51
+ ## Quick start (Cursor / Windsurf / Cline / Continue / Goose)
52
+
53
+ Most clients consume a config file in the
54
+ [standard MCP shape](https://modelcontextprotocol.io/docs/clients).
55
+ The same JSON snippet works almost verbatim:
56
+
57
+ ```json
58
+ {
59
+ "mcpServers": {
60
+ "memanto": {
61
+ "command": "memanto-mcp",
62
+ "env": {
63
+ "MOORCHEH_API_KEY": "mch_xxxxxxxxxxxxxxxxxx",
64
+ "MEMANTO_DEFAULT_AGENT_ID": "cursor-workspace"
65
+ }
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ | Client | Config path |
72
+ |---|---|
73
+ | Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) / `%APPDATA%\Claude\claude_desktop_config.json` (Windows) |
74
+ | Cursor | `~/.cursor/mcp.json` (or per-project `.cursor/mcp.json`) |
75
+ | Windsurf | `~/.codeium/windsurf/mcp_config.json` |
76
+ | Cline (VS Code) | `~/.config/Code/User/globalStorage/cline.cline/settings/cline_mcp_settings.json` |
77
+ | Continue | `~/.continue/config.json` → `experimental.modelContextProtocolServers` |
78
+ | Goose | `~/.config/goose/config.yaml` |
79
+
80
+ ## Available tools
81
+
82
+ The server registers **7 memory tools by default**. Set
83
+ `MEMANTO_EXPOSE_ADMIN=true` to also expose **4 agent-management tools**.
84
+
85
+ ### Memory tools (always on)
86
+
87
+ | Tool | When the agent should call it |
88
+ |---|---|
89
+ | `remember` | Persist a single new fact/preference/decision/goal/instruction. |
90
+ | `batch_remember` | Persist up to 100 memories in one call (e.g. extracted from a document). |
91
+ | `recall` | Semantic search — *always* check here before asking the user to repeat stable info. |
92
+ | `recall_recent` | "What did we just decide?" — newest-first, no query needed. |
93
+ | `recall_as_of` | Point-in-time recall — "what did we know on 2025-11-01?" |
94
+ | `recall_changed_since` | Differential — "what's new since I last checked?" |
95
+ | `answer` | RAG: grounded LLM answer synthesized over the agent's memories. |
96
+
97
+ ### Agent admin tools (opt-in)
98
+
99
+ Enabled when `MEMANTO_EXPOSE_ADMIN=true`:
100
+
101
+ | Tool | Purpose |
102
+ |---|---|
103
+ | `create_agent` | Create a new memory namespace. |
104
+ | `list_agents` | List every agent the API key can see. |
105
+ | `get_agent` | Look up an agent's metadata. |
106
+ | `delete_agent` | Remove an agent's local metadata. |
107
+
108
+ Memory types accepted by `remember` / `batch_remember`:
109
+ `fact`, `preference`, `goal`, `decision`, `artifact`, `learning`, `event`,
110
+ `instruction`, `relationship`, `context`, `observation`, `commitment`,
111
+ `error`.
112
+
113
+ Provenance values: `explicit_statement`, `inferred`, `corrected`,
114
+ `validated`, `observed`, `imported`.
115
+
116
+ ## Configuration
117
+
118
+ All config is via environment variables (load order: process env →
119
+ `.env` file in the working directory).
120
+
121
+ | Variable | Required | Default | Description |
122
+ |---|---|---|---|
123
+ | `MOORCHEH_API_KEY` | **yes** | — | Moorcheh API key. |
124
+ | `MEMANTO_DEFAULT_AGENT_ID` | recommended | _none_ | Default agent. When set, tool calls may omit `agent_id`. |
125
+ | `MEMANTO_AGENT_PATTERN` | no | `tool` | Pattern (`support`/`project`/`tool`) used when auto-creating the default agent. |
126
+ | `MEMANTO_AGENT_AUTO_CREATE` | no | `true` | Create the default agent on first use if missing. |
127
+ | `MEMANTO_SESSION_DURATION_HOURS` | no | server default (6) | Session lifetime in hours. |
128
+ | `MEMANTO_EXPOSE_ADMIN` | no | `false` | Register the 4 agent-management tools. |
129
+ | `MEMANTO_MCP_TRANSPORT` | no | `stdio` | `stdio`, `sse`, or `streamable-http`. |
130
+ | `MEMANTO_MCP_HOST` | no | `127.0.0.1` | Bind host for sse/http transports. |
131
+ | `MEMANTO_MCP_PORT` | no | `8765` | Bind port for sse/http transports. |
132
+ | `MEMANTO_MCP_LOG_LEVEL` | no | `INFO` | Log level (logs are always sent to stderr). |
133
+
134
+ CLI flags (`memanto-mcp --transport sse --port 9000`) override env vars.
135
+
136
+ ## Running over HTTP / SSE
137
+
138
+ For remote clients or multi-process setups, run the server over a network
139
+ transport:
140
+
141
+ ```bash
142
+ # Streamable HTTP (recommended modern transport)
143
+ memanto-mcp --transport streamable-http --host 0.0.0.0 --port 8765
144
+
145
+ # Server-Sent Events (older, still widely supported)
146
+ memanto-mcp --transport sse --host 0.0.0.0 --port 8765
147
+ ```
148
+
149
+ Then point your client at `http://your-host:8765/mcp` (or whatever path the
150
+ chosen transport advertises). Pair with a reverse proxy + auth for
151
+ production deployments — the server itself authenticates upstream to
152
+ Moorcheh using your API key but does **not** authenticate inbound MCP
153
+ clients.
154
+
155
+ ## How it works
156
+
157
+ ```
158
+ ┌──────────────┐ MCP/stdio ┌──────────────────┐ Moorcheh API ┌─────────────┐
159
+ │ Claude / IDE │ ──────────────► │ memanto-mcp │ ────────────────► │ Moorcheh │
160
+ │ (client) │ ◄────────────── │ (this package) │ ◄──────────────── │ Service │
161
+ └──────────────┘ tool calls └──────────────────┘ HTTPS+API key └─────────────┘
162
+ │
163
+ └─ uses memanto.cli.client.SdkClient
164
+ (same client the Memanto CLI uses)
165
+ ```
166
+
167
+ - On startup, settings are validated; the API key is verified lazily on
168
+ first tool call.
169
+ - On the first memory tool invocation for a given agent, the server
170
+ ensures the agent exists (auto-creates if needed) and activates a JWT
171
+ session. Sessions auto-renew before expiry, so long-running MCP
172
+ connections never hit a session-expired error mid-conversation.
173
+ - The server intentionally keeps the session alive on shutdown: JWT
174
+ sessions are TTL-bound and other Memanto clients (CLI, REST) may want
175
+ to share them.
176
+
177
+ ## Programmatic embedding
178
+
179
+ If you're building a custom MCP host or wiring this server into a larger
180
+ process, you can construct the FastMCP instance yourself:
181
+
182
+ ```python
183
+ from memanto_mcp import MCPServerSettings, build_server
184
+
185
+ settings = MCPServerSettings() # reads env / .env
186
+ mcp = build_server(settings)
187
+
188
+ # Add your own tools alongside Memanto's, then run.
189
+ mcp.run(transport="stdio")
190
+ ```
191
+
192
+ ## Troubleshooting
193
+
194
+ | Symptom | Fix |
195
+ |---|---|
196
+ | `configuration error: MOORCHEH_API_KEY is required` | Set the env var in your MCP client config's `env` block. |
197
+ | `Agent '…' does not exist and MEMANTO_AGENT_AUTO_CREATE is disabled` | Either re-enable auto-create or call `create_agent` (admin tools) / `memanto agent create <id>` once. |
198
+ | Tools never appear in the client | Confirm the client supports MCP and the config path matches. Look at the client's MCP log: the server's stderr lines (prefixed `memanto_mcp`) will appear there on startup. |
199
+ | Garbled output in stdio mode | Something on your side is writing to **stdout** — that channel is reserved for JSON-RPC. Move logs to stderr. The server itself only writes to stderr. |
200
+ | Slow first call | Cold-start cost: SDK import + first session activation. Subsequent calls reuse the live session. |
201
+
202
+ ## License
203
+
204
+ MIT — same as the [Memanto](https://github.com/moorcheh-ai/memanto)
205
+ project. See [LICENSE](../../LICENSE).
206
+
207
+ ## Links
208
+
209
+ - [Memanto](https://memanto.ai) — the memory agent itself
210
+ - [Moorcheh](https://moorcheh.ai) — the no-indexing semantic DB underneath
211
+ - [Model Context Protocol spec](https://modelcontextprotocol.io)
212
+ - [Anthropic MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)
@@ -0,0 +1,14 @@
1
+ """Memanto MCP Server.
2
+
3
+ Exposes Memanto's persistent semantic memory as Model Context Protocol tools
4
+ so any MCP-compatible agent (Claude Desktop, Cursor, Windsurf, Cline, etc.)
5
+ can store and retrieve long-term memory.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from memanto_mcp.config import MCPServerSettings
11
+ from memanto_mcp.server import build_server, run_server
12
+
13
+ __all__ = ["MCPServerSettings", "build_server", "run_server", "__version__"]
14
+ __version__ = "0.1.0"