Metadata-Version: 2.4
Name: jev-memory-mcp
Version: 0.1.0a1
Summary: Public MCP access layer and Python SDK for JEV Memory — Different models. Shared experience. Growing capability.
Author: JEV Memory Maintainers
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/NOyu015/jev-memory-mcp
Project-URL: Documentation, https://github.com/NOyu015/jev-memory-mcp#readme
Project-URL: Issues, https://github.com/NOyu015/jev-memory-mcp/issues
Keywords: mcp,model-context-protocol,ai-memory,jev-memory,agent-memory,llm
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# JEV Memory MCP (`jev-memory-mcp`)

**JEV Memory — Different models. Shared experience. Growing capability.**

`jev-memory-mcp` is the public, zero-dependency [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) access layer and thin Python SDK for **JEV Memory**. It connects MCP-compatible AI coding clients (Claude Desktop, Cursor, Windsurf, Cline, Claude Code) to your JEV Memory service so verified engineering experience is recalled, validated, and inherited across sessions and models.

> **Important Architecture Note:** This package contains **only the public MCP stdio bridge, CLI, and Python client SDK**. Core graph formation, structural evolution, and graph storage live exclusively on your JEV Memory backend service—you must provide a reachable `JEV_MCP_ENDPOINT` and `JEV_MCP_API_KEY`.

## Why JEV Memory?

Stop letting AI agents re-solve the same multi-step engineering problems from scratch. JEV Memory stores execution-verified experience nodes in a lifecycle-governed graph (`CANDIDATE -> VERIFIED -> MATURE -> CORE`), keeps retrieval read-only, and updates trust/maturity only through explicit verification feedback.

### Benchmark Scope (Transparent Disclosure)

In our controlled 100-task evaluation against Basic RAG using the same base model and budget:
- **Overall completion (100 tasks):** JEV V3.3 `75%` vs Basic RAG `77%`
- **Complex multi-step tasks (34 tasks):** JEV V3.3 `67.6%` vs Basic RAG `52.9%`

JEV Memory is **not** a universal replacement for RAG on simple document lookup, and model parameter differences must **not** be treated directly as cost savings. Its strength is reusable, execution-verified engineering workflows on complex recurring tasks.

## Installation

Requires Python 3.9+ (zero third-party runtime dependencies).

### Option A: Run directly with `uvx` (recommended for MCP hosts)

```bash
uvx jev-memory-mcp --version
```

### Option B: Install with `pip`

```bash
pip install jev-memory-mcp
jev-memory-mcp --version
```

## Quick Start & Connection Check

Set your JEV Memory service endpoint and Bearer API key as environment variables (never hardcode keys in committed files):

```bash
export JEV_MCP_ENDPOINT="https://your-jev-service.example.com/mcp"
export JEV_MCP_API_KEY="your-bearer-token"

# Verify /health, Bearer authentication, and tools/list
jev-memory-mcp --check
```

To print a ready-to-paste MCP client configuration snippet:

```bash
jev-memory-mcp --print-config --endpoint "https://your-jev-service.example.com/mcp"
```

## MCP Client Configuration

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "jev-memory": {
      "command": "uvx",
      "args": ["jev-memory-mcp"],
      "env": {
        "JEV_MCP_ENDPOINT": "https://your-jev-service.example.com/mcp",
        "JEV_MCP_API_KEY": "<YOUR_JEV_MCP_API_KEY>"
      }
    }
  }
}
```

### Cursor (`.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "jev-memory": {
      "command": "jev-memory-mcp",
      "args": [],
      "env": {
        "JEV_MCP_ENDPOINT": "https://your-jev-service.example.com/mcp",
        "JEV_MCP_API_KEY": "<YOUR_JEV_MCP_API_KEY>"
      }
    }
  }
}
```

See `examples/` for additional configuration templates and a runnable Python SDK walkthrough.

## Available MCP Tools

| Tool | Mode | Purpose |
|---|---|---|
| `jev_recall` | Read-only | Retrieve verified experience matching a task query (`M0`/`M1`/`M2`/`M3` adaptive routing). Never mutates graph state. |
| `jev_learn` | Write (gated) | Record a newly verified engineering helper/pattern with verification evidence. |
| `jev_record` | Feedback | Submit pass/fail verification feedback for recalled node IDs to update trust, maturity, or quarantine status. |
| `jev_stats` | Read-only | Inspect tenant graph counts, lifecycle distribution, and routing stats. |
| `jev_export_mature` | Export (jailed) | Export verified `MATURE`/`CORE` subgraphs to a server-jailed `.json` filename (no overwrite). |
| `jev_snapshot` | Snapshot (jailed) | Create an atomic server-jailed full snapshot (no overwrite). |

## Feedback Submission & Host Support Matrix

MCP exposes tools to the host LLM, **but the MCP specification itself does not force a host to call tools or submit feedback automatically.**

| MCP Host | Tool Discovery & Manual Call | Automatic Recall / Feedback | Recommended Workflow |
|---|---|---|---|
| Claude Desktop | Supported | No (prompt-driven) | Instruct Claude to call `jev_recall` before coding and `jev_record`/`jev_learn` after tests pass. |
| Cursor / Windsurf / Cline | Supported | Configurable via project rules | Add a short rule in `.cursorrules` / system instructions requiring `jev_recall` at task start and `jev_record` after test verification. |
| Claude Code / Custom Agents | Supported | Configurable via hooks/agent loop | Call `jev_recall` before task execution and `jev_record`/`jev_learn` automatically from your test verifier hook. |
| Python SDK (`JevMemoryClient`) | Direct programmatic control | Full control | Call `client.recall(...)`, run your verifier, then call `client.record(...)` / `client.learn(...)`. |

## Python SDK Example

```python
import os
from jev_memory_mcp import JevMemoryClient

client = JevMemoryClient(
    endpoint=os.environ["JEV_MCP_ENDPOINT"],
    api_key=os.environ["JEV_MCP_API_KEY"],
)

# 1. Read-only recall before solving a task
recalled = client.recall("parse iso8601 timestamp safely into YYYY-MM-DD", model_id="claude-sonnet")

# 2. Submit a verified helper after your tests pass
learned = client.learn(
    task_text="parse iso8601 timestamp safely into YYYY-MM-DD",
    helper_code=(
        "from datetime import datetime\n"
        "def parse_iso_date(s: str) -> str:\n"
        "    return datetime.fromisoformat(s.replace('Z', '+00:00')).strftime('%Y-%m-%d')\n"
    ),
    evidence="pytest: 12/12 passed",
    task_id="PROJ-101",
    model_id="claude-sonnet",
)

# 3. Record verification feedback in a later session or different model
client.record(
    [learned["node_id"]],
    passed=True,
    mode="M1",
    model_id="cursor-agent",
    task_id="PROJ-102",
)
```

## Authentication, Security & Data Privacy

- **HTTPS enforced by default:** Plain `http://` is permitted only for loopback hosts (`127.0.0.1`, `localhost`, `::1`). Non-loopback plain HTTP is rejected unless `--allow-insecure-http` is explicitly passed for a private network.
- **Bearer token isolation:** Every request sends `Authorization: Bearer <JEV_MCP_API_KEY>`. API keys are never embedded in URLs, never printed in `repr()`, and never included in error messages.
- **Frame size cap:** Both stdio and HTTP requests enforce a strict `65,536`-byte JSON-RPC frame limit.
- **Tenant isolation & server-side gates:** On the JEV Memory backend, each API key maps to an isolated tenant database, with server-side rate limiting, AST code-poisoning checks, prompt-injection filtering, and jailed no-overwrite exports.
- **Data privacy:** Only the queries, code snippets, and feedback you explicitly send via MCP tool calls are transmitted to your configured `JEV_MCP_ENDPOINT`. No telemetry is collected by `jev-memory-mcp`.

## Troubleshooting

- **`JEV_MCP_ENDPOINT is required` / `JEV_MCP_API_KEY is required`:** Set both environment variables in your shell or MCP host `env` block, then re-run `jev-memory-mcp --check`.
- **`Refusing plain http:// for a non-loopback host`:** Use an `https://` endpoint behind TLS (Cloudflare/Nginx/Caddy), or pass `--allow-insecure-http` only inside a trusted private network.
- **`Authentication failed (HTTP 401)`:** Verify your Bearer token matches an active key configured on the JEV Memory service.
- **`Rate limit exceeded (HTTP 429)`:** Reduce burst frequency or increase the tenant rate limit on your JEV Memory service.

## Known Limitations

- Requires a running JEV Memory MCP HTTP(S) service; this package does not ship a local graph engine.
- Automatic recall and post-verification feedback depend on your MCP host's rules/hooks or explicit prompting.
- Cross-platform verification status is documented per release in the release audit report.

## JEV Ecosystem

`jev-memory-mcp` is part of the **JEV** product family alongside the JEV auditor (`jev-guard`). Both products share the JEV brand and verification-first philosophy while maintaining completely independent architectures and release lifecycles.

## License

Apache-2.0. See `LICENSE`.
