cortexdb-mcp 0.2.0__tar.gz → 0.2.2__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.
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/Dockerfile +1 -1
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/PKG-INFO +3 -23
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/README.md +2 -22
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/cortexdb_mcp/__init__.py +1 -1
- cortexdb_mcp-0.2.2/cortexdb_mcp/__main__.py +5 -0
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/cortexdb_mcp/api.py +2 -2
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/cortexdb_mcp/config.py +2 -2
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/cortexdb_mcp/insights.py +1 -1
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/cortexdb_mcp/server.py +48 -18
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/pyproject.toml +1 -1
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/tests/test_server.py +2 -2
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/.gitignore +0 -0
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/tests/__init__.py +0 -0
- {cortexdb_mcp-0.2.0 → cortexdb_mcp-0.2.2}/tests/test_insights.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cortexdb-mcp
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: MCP Server for CortexDB — expose memory operations to AI agents
|
|
5
5
|
License-Expression: MIT
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -28,7 +28,7 @@ uvx --from . cortexdb-mcp
|
|
|
28
28
|
Set your environment variables:
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
export CORTEXDB_URL="https://api.cortexdb.ai"
|
|
31
|
+
export CORTEXDB_URL="https://api.cortexdb.ai"
|
|
32
32
|
export CORTEXDB_API_KEY="cx_live_your_key_here"
|
|
33
33
|
```
|
|
34
34
|
|
|
@@ -132,13 +132,6 @@ Add to `.vscode/mcp.json` in your project or `~/.vscode/mcp.json` globally:
|
|
|
132
132
|
}
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
### Docker
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
docker build -t cortexdb-mcp .
|
|
139
|
-
docker run -e CORTEXDB_URL=https://api.cortexdb.ai -e CORTEXDB_API_KEY=cx_live_... cortexdb-mcp
|
|
140
|
-
```
|
|
141
|
-
|
|
142
135
|
## Tools
|
|
143
136
|
|
|
144
137
|
### Memory Operations
|
|
@@ -211,7 +204,7 @@ Pre-built prompt templates:
|
|
|
211
204
|
|
|
212
205
|
| Environment Variable | Default | Description |
|
|
213
206
|
|---|---|---|
|
|
214
|
-
| `CORTEXDB_URL` | `
|
|
207
|
+
| `CORTEXDB_URL` | `https://api.cortexdb.ai` | CortexDB server URL |
|
|
215
208
|
| `CORTEXDB_API_KEY` | (none) | API key for authentication |
|
|
216
209
|
| `CORTEXDB_TIMEOUT` | `30.0` | HTTP request timeout (seconds) |
|
|
217
210
|
|
|
@@ -242,19 +235,6 @@ The assistant calls `entity_get` or `entity_edges` to traverse relationships.
|
|
|
242
235
|
|
|
243
236
|
Uses the `deployment_review` prompt to check for recent incidents, dependencies, and risks.
|
|
244
237
|
|
|
245
|
-
## Development
|
|
246
|
-
|
|
247
|
-
```bash
|
|
248
|
-
# Install in dev mode
|
|
249
|
-
pip install -e ".[dev]"
|
|
250
|
-
|
|
251
|
-
# Run tests
|
|
252
|
-
pytest
|
|
253
|
-
|
|
254
|
-
# Run the server locally
|
|
255
|
-
CORTEXDB_URL=http://localhost:3141 CORTEXDB_API_KEY=test cortexdb-mcp
|
|
256
|
-
```
|
|
257
|
-
|
|
258
238
|
## Architecture
|
|
259
239
|
|
|
260
240
|
```
|
|
@@ -15,7 +15,7 @@ uvx --from . cortexdb-mcp
|
|
|
15
15
|
Set your environment variables:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
export CORTEXDB_URL="https://api.cortexdb.ai"
|
|
18
|
+
export CORTEXDB_URL="https://api.cortexdb.ai"
|
|
19
19
|
export CORTEXDB_API_KEY="cx_live_your_key_here"
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -119,13 +119,6 @@ Add to `.vscode/mcp.json` in your project or `~/.vscode/mcp.json` globally:
|
|
|
119
119
|
}
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
### Docker
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
docker build -t cortexdb-mcp .
|
|
126
|
-
docker run -e CORTEXDB_URL=https://api.cortexdb.ai -e CORTEXDB_API_KEY=cx_live_... cortexdb-mcp
|
|
127
|
-
```
|
|
128
|
-
|
|
129
122
|
## Tools
|
|
130
123
|
|
|
131
124
|
### Memory Operations
|
|
@@ -198,7 +191,7 @@ Pre-built prompt templates:
|
|
|
198
191
|
|
|
199
192
|
| Environment Variable | Default | Description |
|
|
200
193
|
|---|---|---|
|
|
201
|
-
| `CORTEXDB_URL` | `
|
|
194
|
+
| `CORTEXDB_URL` | `https://api.cortexdb.ai` | CortexDB server URL |
|
|
202
195
|
| `CORTEXDB_API_KEY` | (none) | API key for authentication |
|
|
203
196
|
| `CORTEXDB_TIMEOUT` | `30.0` | HTTP request timeout (seconds) |
|
|
204
197
|
|
|
@@ -229,19 +222,6 @@ The assistant calls `entity_get` or `entity_edges` to traverse relationships.
|
|
|
229
222
|
|
|
230
223
|
Uses the `deployment_review` prompt to check for recent incidents, dependencies, and risks.
|
|
231
224
|
|
|
232
|
-
## Development
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
|
-
# Install in dev mode
|
|
236
|
-
pip install -e ".[dev]"
|
|
237
|
-
|
|
238
|
-
# Run tests
|
|
239
|
-
pytest
|
|
240
|
-
|
|
241
|
-
# Run the server locally
|
|
242
|
-
CORTEXDB_URL=http://localhost:3141 CORTEXDB_API_KEY=test cortexdb-mcp
|
|
243
|
-
```
|
|
244
|
-
|
|
245
225
|
## Architecture
|
|
246
226
|
|
|
247
227
|
```
|
|
@@ -6,7 +6,7 @@ display proactive insights. Results are cached with a configurable TTL (default
|
|
|
6
6
|
|
|
7
7
|
Configuration is read from environment variables:
|
|
8
8
|
|
|
9
|
-
- ``CORTEXDB_URL`` -- CortexDB base URL (default ``
|
|
9
|
+
- ``CORTEXDB_URL`` -- CortexDB base URL (default ``https://api.cortexdb.ai``)
|
|
10
10
|
- ``CORTEXDB_API_KEY`` -- Optional bearer token
|
|
11
11
|
- ``CORTEXDB_TENANT_ID``-- Optional tenant scope
|
|
12
12
|
- ``INSIGHTS_CACHE_TTL``-- Cache lifetime in seconds (default ``300``)
|
|
@@ -34,7 +34,7 @@ logger = logging.getLogger("cortexdb_mcp.api")
|
|
|
34
34
|
# Configuration
|
|
35
35
|
# ---------------------------------------------------------------------------
|
|
36
36
|
|
|
37
|
-
CORTEXDB_URL = os.environ.get("CORTEXDB_URL", "
|
|
37
|
+
CORTEXDB_URL = os.environ.get("CORTEXDB_URL", "https://api.cortexdb.ai")
|
|
38
38
|
CORTEXDB_API_KEY = os.environ.get("CORTEXDB_API_KEY")
|
|
39
39
|
CORTEXDB_TENANT_ID = os.environ.get("CORTEXDB_TENANT_ID")
|
|
40
40
|
INSIGHTS_CACHE_TTL = int(os.environ.get("INSIGHTS_CACHE_TTL", "300"))
|
|
@@ -19,7 +19,7 @@ class CortexMCPConfig:
|
|
|
19
19
|
timeout: HTTP request timeout in seconds.
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
-
url: str = "
|
|
22
|
+
url: str = "https://api.cortexdb.ai"
|
|
23
23
|
api_key: str | None = None
|
|
24
24
|
timeout: float = 30.0
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ class CortexMCPConfig:
|
|
|
29
29
|
|
|
30
30
|
Environment variables
|
|
31
31
|
---------------------
|
|
32
|
-
CORTEXDB_URL -- CortexDB base URL (default ``
|
|
32
|
+
CORTEXDB_URL -- CortexDB base URL (default ``https://api.cortexdb.ai``)
|
|
33
33
|
CORTEXDB_API_KEY -- API key (default ``None``)
|
|
34
34
|
CORTEXDB_TIMEOUT -- Request timeout in seconds (default ``30.0``)
|
|
35
35
|
"""
|
|
@@ -123,23 +123,29 @@ async def memory_store(
|
|
|
123
123
|
ttl_seconds:
|
|
124
124
|
Auto-expiry time in seconds. Omit for permanent storage.
|
|
125
125
|
"""
|
|
126
|
+
# Always route to /v1/remember. The /v1/episodes endpoint requires a
|
|
127
|
+
# structured Source object (connector + external_id) and a full Actor,
|
|
128
|
+
# which an MCP caller doesn't have. Carry `source`, `episode_type`, and
|
|
129
|
+
# `tags` through the free-form metadata bag instead — the coordinator
|
|
130
|
+
# and recall pipeline both honour `metadata.source` for filtering.
|
|
131
|
+
metadata: dict[str, str] = {"episode_type": episode_type}
|
|
132
|
+
if source is not None:
|
|
133
|
+
metadata["source"] = source
|
|
134
|
+
if tags:
|
|
135
|
+
metadata["tags"] = ",".join(tags)
|
|
136
|
+
|
|
126
137
|
body: dict[str, Any] = {
|
|
127
138
|
"content": content,
|
|
128
|
-
"
|
|
139
|
+
"metadata": metadata,
|
|
129
140
|
}
|
|
130
|
-
if source is not None:
|
|
131
|
-
body["source"] = source
|
|
132
141
|
if tenant_id is not None:
|
|
133
142
|
body["tenant_id"] = tenant_id
|
|
134
143
|
if namespace is not None:
|
|
135
144
|
body["namespace"] = namespace
|
|
136
|
-
if tags is not None:
|
|
137
|
-
body["tags"] = tags
|
|
138
145
|
if ttl_seconds is not None:
|
|
139
146
|
body["ttl_seconds"] = ttl_seconds
|
|
140
147
|
|
|
141
|
-
|
|
142
|
-
result = await _request("POST", path, json_body=body)
|
|
148
|
+
result = await _request("POST", "/v1/remember", json_body=body)
|
|
143
149
|
|
|
144
150
|
event_id = result.get("event_id") or result.get("episode_id") or "unknown"
|
|
145
151
|
return f"Stored successfully. ID: {event_id}"
|
|
@@ -857,29 +863,35 @@ async def export_data(
|
|
|
857
863
|
|
|
858
864
|
@mcp.tool()
|
|
859
865
|
async def import_data(
|
|
860
|
-
|
|
866
|
+
memories: list[dict[str, Any]],
|
|
861
867
|
tenant_id: str | None = None,
|
|
862
|
-
format: str = "json",
|
|
863
868
|
) -> str:
|
|
864
|
-
"""
|
|
869
|
+
"""Bulk-import memories into CortexDB.
|
|
865
870
|
|
|
866
871
|
Parameters
|
|
867
872
|
----------
|
|
868
|
-
|
|
869
|
-
|
|
873
|
+
memories:
|
|
874
|
+
List of memory objects to import. Each item must have a `content`
|
|
875
|
+
field (string); optional fields: `metadata` (dict of str→str),
|
|
876
|
+
`scope` (str).
|
|
870
877
|
tenant_id:
|
|
871
878
|
Tenant scope for the imported data.
|
|
872
|
-
|
|
873
|
-
|
|
879
|
+
|
|
880
|
+
Requires the Starter tier or higher. Free-tier accounts will receive
|
|
881
|
+
HTTP 402 (feature_not_available).
|
|
874
882
|
"""
|
|
875
|
-
|
|
883
|
+
if not isinstance(memories, list) or not memories:
|
|
884
|
+
raise ValueError("memories must be a non-empty list of objects")
|
|
885
|
+
|
|
886
|
+
body: dict[str, Any] = {"memories": memories}
|
|
876
887
|
if tenant_id:
|
|
877
888
|
body["tenant_id"] = tenant_id
|
|
878
889
|
|
|
879
890
|
result = await _request("POST", "/v1/import", json_body=body)
|
|
880
891
|
|
|
881
|
-
imported = result.get("imported",
|
|
882
|
-
|
|
892
|
+
imported = result.get("imported", 0)
|
|
893
|
+
failed = result.get("failed", 0)
|
|
894
|
+
return f"Import complete. {imported} imported, {failed} failed."
|
|
883
895
|
|
|
884
896
|
|
|
885
897
|
# ===========================================================================
|
|
@@ -1078,7 +1090,25 @@ def weekly_digest(tenant_id: str | None = None) -> str:
|
|
|
1078
1090
|
|
|
1079
1091
|
def main() -> None:
|
|
1080
1092
|
"""Run the CortexDB MCP server over stdio transport."""
|
|
1081
|
-
|
|
1093
|
+
import argparse
|
|
1094
|
+
|
|
1095
|
+
parser = argparse.ArgumentParser(
|
|
1096
|
+
prog="cortexdb-mcp",
|
|
1097
|
+
description="CortexDB MCP Server — expose memory operations to AI agents via the Model Context Protocol.",
|
|
1098
|
+
)
|
|
1099
|
+
parser.add_argument(
|
|
1100
|
+
"--transport",
|
|
1101
|
+
choices=["stdio"],
|
|
1102
|
+
default="stdio",
|
|
1103
|
+
help="Transport mode (default: stdio)",
|
|
1104
|
+
)
|
|
1105
|
+
parser.add_argument(
|
|
1106
|
+
"--version",
|
|
1107
|
+
action="version",
|
|
1108
|
+
version="cortexdb-mcp 0.2.1",
|
|
1109
|
+
)
|
|
1110
|
+
args = parser.parse_args()
|
|
1111
|
+
mcp.run(transport=args.transport)
|
|
1082
1112
|
|
|
1083
1113
|
|
|
1084
1114
|
if __name__ == "__main__":
|
|
@@ -41,7 +41,7 @@ class TestConfig:
|
|
|
41
41
|
|
|
42
42
|
def test_defaults(self):
|
|
43
43
|
cfg = CortexMCPConfig()
|
|
44
|
-
assert cfg.url == "
|
|
44
|
+
assert cfg.url == "https://api.cortexdb.ai"
|
|
45
45
|
assert cfg.api_key is None
|
|
46
46
|
assert cfg.timeout == 30.0
|
|
47
47
|
|
|
@@ -59,7 +59,7 @@ class TestConfig:
|
|
|
59
59
|
monkeypatch.delenv("CORTEXDB_API_KEY", raising=False)
|
|
60
60
|
monkeypatch.delenv("CORTEXDB_TIMEOUT", raising=False)
|
|
61
61
|
cfg = CortexMCPConfig.from_env()
|
|
62
|
-
assert cfg.url == "
|
|
62
|
+
assert cfg.url == "https://api.cortexdb.ai"
|
|
63
63
|
assert cfg.api_key is None
|
|
64
64
|
|
|
65
65
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|