Percept Context โ a Redis-native context graph + GraphRAG engine for video-ad generation, exposed over MCP.
Project description
Percept Context ๐ง โ a Redis-native Context Graph + GraphRAG engine (MCP)
A queryable context graph for video-ad generation that lives entirely inside Redis โ and learns from outcomes.
pip install percept-context-plugin gives any agent (Claude Code, Claude Desktop, your own)
direct access to a reward-weighted property graph on Redis, exposed over the
Model Context Protocol (MCP). Store creative knowledge, run GraphRAG retrieval, and
close the loop by reinforcing what actually performed. Ships with a curated video-ad
knowledge graph; the engine itself is domain-agnostic.
Why this exists
Redis is the obvious substrate for AI memory โ but two things are missing from the stack today:
- No graph. Redis retired RedisGraph (end-of-support Jan 31, 2025) and shipped no replacement; the official AI recipes are all flat vector RAG. There's no first-class way to model entities + relationships and do GraphRAG on Redis.
- No learning loop.
SemanticCachereturns a prior answer, never the best-performing one โ there's no notion of a reward signal feeding back into retrieval.
Percept Context fills both, natively on Redis primitives:
| Concern | How it's done |
|---|---|
| Nodes + embeddings | Redis hashes indexed by RedisVL (SearchIndex, cosine vector field) |
| Edges + weights | Redis sorted sets (member=neighbor, score=weight) โ O(log n) "best neighbors first" |
| Semantic retrieval | RedisVL VectorQuery finds entry nodes |
| GraphRAG | vector entry โ beam traversal of highest-weight edges โ connected subgraph |
| Learning | record_outcome(path, reward) โ ZINCRBY edge weights + bump node scores |
| Multi-tenant | every key namespaced by a graph id โ a shared graph and per-user personal graphs |
Architecture
add_node / link_nodes record_outcome(path, reward)
โ โฒ
โผ โ (e.g. a TRIBE engagement score)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ R E D I S โ
โ โ
โ Nodes (hash + vector, RedisVL SearchIndex) Edges (sorted sets) โ
โ percept:node:{graph}:{uuid} percept:adj:{graph}:โฆ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ โ
โ 1. VectorQuery โ entry nodes โ 2. ZREVRANGE โ top-weight
โ โผ neighbors (beam traversal)
graph_rag_query(brief) โโโโโโโโโโโโโโโโบ grounded subgraph + context
Retrieval is semantic + structural: vectors find where to enter the graph; weighted edges decide what proven context to pull in. Outcomes reinforce the edges, so the graph gets better at retrieval over time.
Install
Requires Python โฅ 3.10 and a Redis with the Search/Query module (Redis Cloud, Redis Stack, or Redis 8). First run downloads a small local embedding model (MiniLM, 384-dim) โ no API key needed.
pip install percept-context-plugin
Configure your connection (or pass env vars at registration):
export REDIS_URL=redis://localhost:6379
export REDIS_PROTOCOL=2
Torch-free install:
pip install percept-context-plugin[openai]and setPERCEPT_VECTORIZER=openai+OPENAI_API_KEYto skip the local model.
Register with Claude Code
claude mcp add percept-context --scope local \
--env REDIS_URL=redis://localhost:6379 \
--env REDIS_PROTOCOL=2 \
-- percept-context
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"percept-context": {
"command": "percept-context",
"env": {
"REDIS_URL": "redis://localhost:6379",
"REDIS_PROTOCOL": "2"
}
}
}
}
๐ Never commit your real
REDIS_URL..envis git-ignored; use.env.exampleas the template.
Tools
| Tool | What it does |
|---|---|
graph_rag_query(query, graph?, types?, k?, hops?) |
The core. Vector-entry + weighted traversal โ grounded subgraph + context. |
search_nodes(query, graph?, types?, k?) |
Pure semantic vector search (no traversal). |
add_node(type, label, content?, props?, graph?) |
Add + embed + index a node. |
link_nodes(src_id, dst_id, type, weight?, props?, graph?) |
Create a weighted directed edge. |
neighbors(node_id, edge_type?, direction?, graph?, limit?) |
Highest-weight neighbors of a node. |
record_outcome(path, reward, graph?) |
Close the loop: reinforce a winning path. |
top_performers(graph?, types?, limit?) |
Most-reinforced nodes. |
graph_stats(graph?) |
Ping, index, node count, endpoint. |
seed_demo_graph(graph?) |
Load the bundled video-ad knowledge graph. |
compose_brief(brief, graph?, k?, hops?) |
Full RAG: retrieve context, then (optional LLM) compose an optimized ad prompt. |
Shared vs. personal graphs
Every tool takes an optional graph namespace:
graphomitted โ the shared graph (PERCEPT_DEFAULT_GRAPH, default"shared").graph="user:dean"โ that user's personal graph, isolated by key prefix.
Query the shared graph for curated, proven knowledge; query a personal graph for what that user's own outcomes have taught the system. They live side-by-side in one Redis.
Quickstart (from source)
git clone <this-repo> && cd percept-context
python -m venv .venv && source .venv/bin/activate
pip install -e .
cp .env.example .env # set REDIS_URL
python examples/quickstart.py # seeds, queries, reinforces, prints top performers
Example agent session:
seed_demo_graph()
graph_rag_query("energy drink ad that stops the scroll", k=3, hops=1)
โ entry: [technique] Pattern interrupt, [principle] Hook in the first second โฆ
โ edges: Hook in the first second โ[ENABLES w=2.00]โ Pattern interrupt โฆ
record_outcome(path=[<hook_id>, <pattern_interrupt_id>], reward=8.5) # a TRIBE score
graph_rag_query("energy drink ad that stops the scroll") # now biased to the winner
Configuration reference
| Env var | Default | Purpose |
|---|---|---|
REDIS_URL |
โ (required) | Redis connection string. |
REDIS_PROTOCOL |
2 |
Use 3 for Redis Cloud / RESP3. |
PERCEPT_INDEX |
percept_nodes |
RediSearch index name. |
PERCEPT_PREFIX |
percept:node |
Node key prefix. |
PERCEPT_DEFAULT_GRAPH |
shared |
Default namespace. |
PERCEPT_VECTORIZER |
hf |
hf (local) or openai. |
PERCEPT_EMBED_MODEL |
โฆall-MiniLM-L6-v2 |
Embedding model. |
ANTHROPIC_API_KEY |
โ | Enables LLM composition in compose_brief. |
PERCEPT_LLM_MODEL |
claude-opus-4-8 |
Model for compose_brief. |
Roadmap
- Plugin 2 โ multimodal video nodes: store videos in Redis, run computer vision to understand their content, and query them semantically โ folding video understanding into this same graph as first-class nodes.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file percept_context_plugin-0.1.0.tar.gz.
File metadata
- Download URL: percept_context_plugin-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef218988d8b287346b4fe0d8f93d54457356b9c546227d7ac68379a08349fd5b
|
|
| MD5 |
c1b1f29b38de333db7e6d0c14903ff97
|
|
| BLAKE2b-256 |
1d47cd92bd17290ec4e39372f70c6b60ff597ac323016253a5c6c692819d0ee2
|
File details
Details for the file percept_context_plugin-0.1.0-py3-none-any.whl.
File metadata
- Download URL: percept_context_plugin-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15ff7fbd179a72cd55e2a126993673424970e535b4de636906778572d4d117b6
|
|
| MD5 |
db39a5986664e159d79576d45a791d06
|
|
| BLAKE2b-256 |
9d7a0cdbebf87de38caf434ab5740aeda40a6b2703eccffe34e562b6fd321528
|