Python client for the MindGraph Cloud API
Project description
mindgraph
Python client for the MindGraph Cloud API — a structured semantic memory graph for AI agents.
Install
pip install mindgraph-sdk
Quick Start
from mindgraph import MindGraph
with MindGraph("https://api.mindgraph.cloud", api_key="mg_...") as graph:
# Add a node
node = graph.add_node(
label="User prefers dark mode",
node_type="Preference",
)
# Search
results = graph.search("what does the user prefer?")
# Connect knowledge
graph.add_link(
from_uid=node["uid"],
to_uid="user_abc",
edge_type="BelongsTo",
)
API Reference
Constructor
MindGraph(base_url, *, api_key=None, jwt=None, timeout=30.0)
Supports context manager protocol (with statement) for automatic cleanup.
Reality Layer
| Method | Description |
|---|---|
capture(**kwargs) |
Capture a source, snippet, or observation |
entity(**kwargs) |
Create, alias, resolve, or merge entities |
find_or_create_entity(label, entity_type?, agent_id?) |
Convenience: create or find an entity by label (generic fallback) |
find_or_create_person(label, props?, agent_id?) |
Find or create a Person entity |
find_or_create_organization(label, props?, agent_id?) |
Find or create an Organization entity |
find_or_create_nation(label, props?, agent_id?) |
Find or create a Nation entity |
find_or_create_event(label, props?, agent_id?) |
Find or create an Event entity |
find_or_create_place(label, props?, agent_id?) |
Find or create a Place entity |
find_or_create_concept(label, props?, agent_id?) |
Find or create a Concept entity |
add_claim(label, props?, agent_id?) |
Add a Claim node |
add_evidence(label, props?, agent_id?) |
Add an Evidence node |
add_observation(label, props?, agent_id?) |
Add an Observation node |
Typed entity example:
person = graph.find_or_create_person("Marie Curie", props={"nationality": "Polish"})
org = graph.find_or_create_organization("CERN", props={"org_type": "intergovernmental"})
concept = graph.find_or_create_concept("Nuclear Physics")
# find_or_create_entity() still works as a generic fallback for any entity type
entity = graph.find_or_create_entity("Some Entity")
Epistemic Layer
| Method | Description |
|---|---|
argue(**kwargs) |
Construct a full argument: claim + evidence + warrant + edges |
inquire(**kwargs) |
Add hypothesis, theory, paradigm, anomaly, assumption, or question |
structure(**kwargs) |
Add concept, pattern, mechanism, model, analogy, theorem, etc. |
Intent Layer
| Method | Description |
|---|---|
commit(**kwargs) |
Create a goal, project, or milestone |
deliberate(**kwargs) |
Open decisions, add options/constraints, resolve decisions |
Action Layer
| Method | Description |
|---|---|
procedure(**kwargs) |
Build flows, add steps, affordances, and controls |
risk(**kwargs) |
Assess risk or retrieve existing assessments |
Memory Layer
| Method | Description |
|---|---|
session(**kwargs) |
Open a session, record traces, or close a session |
journal(label, props?, *, summary?, session_uid?, ...) |
Record a journal entry linked to an optional session |
distill(**kwargs) |
Create a summary that distills multiple source nodes |
memory_config(**kwargs) |
Set/get preferences and memory policies |
Agent Layer
| Method | Description |
|---|---|
plan(**kwargs) |
Create tasks, plans, plan steps, update status |
governance(**kwargs) |
Create policies, set safety budgets, request/resolve approvals |
execution(**kwargs) |
Track execution lifecycle and register agents |
CRUD
| Method | Description |
|---|---|
get_node(uid) |
Get a node by UID |
add_node(label, node_type?, props?, agent_id?) |
Add a generic node |
update_node(uid, **kwargs) |
Update node fields |
delete_node(uid) |
Tombstone a node and all connected edges |
add_link(from_uid, to_uid, edge_type, agent_id?) |
Add a typed edge |
get_edges(from_uid?, to_uid?) |
Get edges by source or target |
Search
| Method | Description |
|---|---|
search(query, node_type?, layer?, limit?) |
Full-text search |
hybrid_search(query, k?, node_types?, layer?) |
BM25 + vector search with rank fusion |
Traversal
| Method | Description |
|---|---|
reasoning_chain(uid, max_depth=5) |
Follow epistemic edges from a node |
neighborhood(uid, max_depth=1) |
Get all nodes within N hops |
Ingestion & Retrieval
| Method | Description |
|---|---|
ingest_chunk(content, *, chunk_type?, ...) |
Ingest a single text chunk (sync): stores, embeds, and runs LLM extraction |
ingest_document(content, *, title?, ...) |
Ingest a full document (async): chunks text, returns job ID |
ingest_session(content, *, session_uid?, ...) |
Ingest a session transcript (async): links to session, returns job ID |
retrieve_context(query, *, k?, depth?, ...) |
Retrieve semantically matched chunks + connected graph nodes/edges |
get_job(job_id) |
Get async job status and progress |
clear_graph() |
Clear all graph data |
Lifecycle Shortcuts
| Method | Description |
|---|---|
tombstone(uid, reason?, agent_id?) |
Soft-delete a node |
restore(uid, agent_id?) |
Restore a tombstoned node |
Cross-cutting
| Method | Description |
|---|---|
retrieve(**kwargs) |
Unified retrieval: text search, active goals, open questions, weak claims |
traverse(**kwargs) |
Graph traversal: chain, neighborhood, path, or subgraph |
evolve(**kwargs) |
Lifecycle mutations: update, tombstone, restore, decay, history |
Health & Stats
| Method | Description |
|---|---|
health() |
Health check |
stats() |
Graph-wide statistics |
Management (Cloud only)
| Method | Description |
|---|---|
signup(email, password) |
Create a new account |
login(email, password) |
Login and receive JWT |
create_api_key(name?) |
Create an API key |
list_api_keys() |
List all API keys |
revoke_api_key(key_id) |
Revoke an API key |
get_usage() |
Get usage statistics |
Examples
See examples/ for runnable demos, including a research continuity scenario showing cross-session memory retrieval.
Error Handling
All methods raise MindGraphError on HTTP errors:
from mindgraph import MindGraphError
try:
graph.get_node("nonexistent")
except MindGraphError as e:
print(e.status, e.body)
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 mindgraph_sdk-0.2.0.tar.gz.
File metadata
- Download URL: mindgraph_sdk-0.2.0.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f348059771c02637983b9fe22095ebe0660f46d9fd6ec157e4853ed0530b4c8
|
|
| MD5 |
cbf8d6dd464ac82abf1c9598c97cb792
|
|
| BLAKE2b-256 |
df1653dc3ad65f9a94fff1e8b6a33fd2f876c60d5983ecf5df2472983619ff75
|
Provenance
The following attestation bundles were made for mindgraph_sdk-0.2.0.tar.gz:
Publisher:
publish.yml on shuruheel/mindgraph-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mindgraph_sdk-0.2.0.tar.gz -
Subject digest:
2f348059771c02637983b9fe22095ebe0660f46d9fd6ec157e4853ed0530b4c8 - Sigstore transparency entry: 1201886442
- Sigstore integration time:
-
Permalink:
shuruheel/mindgraph-py@417e14d12921af5bb9d89e8d48e064b017c9703c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/shuruheel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@417e14d12921af5bb9d89e8d48e064b017c9703c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mindgraph_sdk-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mindgraph_sdk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4a3e45f9e63a194ade86b96a3ade91f89e73a02451280fcdcf552a24975473a
|
|
| MD5 |
888bdb3ceba46ab309981146807e89a6
|
|
| BLAKE2b-256 |
936a60046223d0d53339896e1597d11e9313999901107f8ed15daab76167df65
|
Provenance
The following attestation bundles were made for mindgraph_sdk-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on shuruheel/mindgraph-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mindgraph_sdk-0.2.0-py3-none-any.whl -
Subject digest:
a4a3e45f9e63a194ade86b96a3ade91f89e73a02451280fcdcf552a24975473a - Sigstore transparency entry: 1201886445
- Sigstore integration time:
-
Permalink:
shuruheel/mindgraph-py@417e14d12921af5bb9d89e8d48e064b017c9703c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/shuruheel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@417e14d12921af5bb9d89e8d48e064b017c9703c -
Trigger Event:
push
-
Statement type: