Skip to main content

build_context

Build context from a memory:// URI to continue conversations naturally.
async def build_context(
    url: MemoryUrl,
    project: Optional[str] = None,
    workspace: Optional[str] = None,
    depth: str | int | None = 1,
    timeframe: Optional[TimeFrame] = "7d",
    page: int = 1,
    page_size: int = 10,
    max_related: int = 10,
    output_format: Literal["json", "text"] = "json",
    context: Context | None = None,
) -> dict | str

Parameters

url
string
required
memory:// URI pointing to discussion content. Examples:
  • memory://specs/search
  • memory://projects/basic-memory
  • notes/* (pattern matching)
Valid characters: letters, numbers, hyphens, underscores, forward slashes. Avoid: double slashes (//), angle brackets, quotes, pipes (|)
project
string
Project name to build context from. Optional - server resolves using hierarchy.
workspace
string
Cloud workspace name or tenant_id
depth
integer
default:"1"
How many relation hops to traverse (1-3 recommended for performance)
timeframe
string
default:"7d"
How far back to look. Supports natural language:
  • “2 days ago”, “last week”, “today”
  • Standard formats: “7d”, “24h”
page
integer
default:"1"
Page number of results to return
page_size
integer
default:"10"
Number of results to return per page
Maximum number of related results to return
output_format
string
default:"json"
Response format:
  • json - Structured JSON with internal fields excluded
  • text - Compact markdown text for LLM consumption

Returns

result
dict | string
JSON format - Structured context graph with:
  • results - Array of context results with primary and related entities
  • metadata - Query metadata (URI, depth, counts)
Text format - Compact markdown with:
  • Entity blocks with observations and relations
  • Related entities
  • Metadata footer

Examples

# Continue a specific discussion
build_context("memory://specs/search")

# Get deeper context
build_context(
    "memory://components/memory-service",
    depth=2
)

# Get text output for compact context
build_context(
    "memory://specs/search",
    output_format="text"
)

recent_activity

Get recent activity for a project or across all projects.
async def recent_activity(
    type: Union[str, List[str]] = "",
    depth: int = 1,
    timeframe: TimeFrame = "7d",
    page: int = 1,
    page_size: int = 10,
    project: Optional[str] = None,
    workspace: Optional[str] = None,
    output_format: Literal["text", "json"] = "text",
    context: Context | None = None,
) -> str | list[dict]

Parameters

type
string | list[string]
default:""
Filter by content type(s). Valid options:
  • entity - Knowledge entities
  • relation - Connections between entities
  • observation - Notes and observations
Can be a single string or list: ["entity", "relation"] Default is entity-only.
depth
integer
default:"1"
How many relation hops to traverse (1-3 recommended)
timeframe
string
default:"7d"
Time window to search. Supports natural language:
  • Relative: “2 days ago”, “last week”, “yesterday”
  • Points in time: “2024-01-01”, “January 1st”
  • Standard format: “7d”, “24h”
page
integer
default:"1"
Page number for pagination
page_size
integer
default:"10"
Number of items per page
project
string
Project name to query. Optional - server resolves using hierarchy. If no project can be resolved, returns cross-project discovery information.
output_format
string
default:"text"
“text” returns human-readable summary. “json” returns flat list of recent items.

Returns

result
string | list[dict]
Discovery Mode (no project resolved):
  • Summary of recent activity across all projects
  • Most active project suggestion
  • Guidance for selecting a project
Project-Specific Mode:
  • Detailed activity for the specified project
  • Grouped by type (entities, relations, observations)
  • Pagination info
JSON format:
  • Flat list of recent items with metadata

Examples

# Cross-project discovery
recent_activity()
recent_activity(timeframe="yesterday")

# Project-specific activity
recent_activity(
    project="work-docs",
    type="entity",
    timeframe="yesterday"
)

# Multiple types
recent_activity(
    project="research",
    type=["entity", "relation"],
    timeframe="today"
)

# Deep exploration
recent_activity(
    project="notes",
    type="entity",
    depth=2,
    timeframe="2 weeks ago"
)

list_directory

List directory contents with filtering and depth control.
async def list_directory(
    dir_name: str = "/",
    depth: int = 1,
    file_name_glob: Optional[str] = None,
    project: Optional[str] = None,
    workspace: Optional[str] = None,
    context: Context | None = None,
) -> str

Parameters

dir_name
string
default:"/"
Directory path to list. Examples:
  • / - Root directory
  • /projects - Projects folder
  • /research/ml - Nested path
depth
integer
default:"1"
Recursion depth (1-10). Higher values show subdirectory contents recursively.
  • 1 = immediate children only
  • 2 = children and their children
  • 3+ = deeper exploration
file_name_glob
string
Optional glob pattern for filtering file names. Examples:
  • *.md - All markdown files
  • *meeting* - Files with “meeting” in name
  • project_* - Files starting with “project_”
project
string
Project name to list directory from. Optional - server resolves using hierarchy.

Returns

result
string
Formatted listing of directory contents with:
  • Directories (📁) listed first
  • Files (📄) with metadata (title, date)
  • Summary of total items

Examples

# List root directory
list_directory()

# List specific folder
list_directory(dir_name="/projects")

# Find all markdown files
list_directory(file_name_glob="*.md")

# Deep exploration of research folder
list_directory(dir_name="/research", depth=3)

# Find meeting notes in projects
list_directory(
    dir_name="/projects",
    file_name_glob="*meeting*"
)

Build docs developers (and LLMs) love