Skip to content

search_context

Search contexts using semantic vector similarity or keyword matching across summaries and tags.

Overview

The search_context tool finds relevant contexts by searching through AI-generated summaries and tags. Unlike load_context which returns recent contexts chronologically, search_context returns the best matches for your query.

Layer: Core functionality

Purpose: Discover contexts by semantic or keyword matching

Search Routing

search_context automatically routes to the best available search method:

MethodWhen UsedHow It Works
Vectorize (semantic)Cloudflare Vectorize index is populatedConverts query to embedding, finds nearest contexts by meaning
LIKE (keyword fallback)Vectorize unavailable or index emptySQL LIKE '%query%' substring match on summary + tags

Semantic search finds conceptually similar contexts even when exact words don't match. Keyword fallback is exact substring matching — useful for specific IDs, names, or jargon.

If your project was created before v3.2.0 or Vectorize wasn't available when contexts were saved, run reindex_project to backfill embeddings.


Parameters

ParameterTypeRequiredDescription
querystringYesSearch keywords or phrase
projectstringNoLimit search to specific project
personality_modestringNoTemporal posture: historian (default), prophet, archaeologist, minimalist

Parameter Details

query

Keywords or phrases to search for. The search is case-insensitive and matches against:

  • AI-generated summaries
  • AI-generated tags
  • Project names

Examples:

  • "authentication OAuth"
  • "database performance"
  • "bug login"

project

Optional project filter. If provided, only searches within that project.

When to use:

  • Leave empty: Search across all projects
  • Specify project: Narrow results to one project

personality_mode (Layer 5)

Shapes how matching contexts are ranked and presented after the initial search:

ModePost-Search RankingOutput Format
historianBy recency (default)Timestamp + tier + causality
prophetBy prediction scoreScore + propagation reasons
archaeologistBy dormancyLast-accessed + tier
minimalistBy recencySummaries only

Example — minimalist mode for programmatic use:

typescript
search_context({
  query: "authentication",
  project: "mobile-app",
  personality_mode: "minimalist"
})

Result:

Decision to use OAuth2 with PKCE for mobile app authentication

Research findings on mobile authentication best practices

Returns

Formatted text with matching contexts, ordered by relevance:

Found 2 context(s) for "authentication":

**mobile-app-auth** (2025-10-17T15:30:00Z)
Decision to use OAuth2 with PKCE for mobile app authentication
Tags: oauth, security, mobile, authentication, pkce

**api-gateway** (2025-10-17T14:20:00Z)
Implemented JWT token validation in API gateway middleware
Tags: jwt, authentication, api-gateway, middleware, security

Examples

typescript
search_context({
  query: "OAuth authentication"
})

Searches across all projects for OAuth-related contexts.


typescript
search_context({
  query: "performance optimization",
  project: "api-service"
})

Only searches within the "api-service" project.


Multi-Word Queries

typescript
search_context({
  query: "database connection pool"
})

Finds contexts mentioning databases, connections, and pooling.


Use Cases

typescript
// Working on authentication
search_context({ query: "authentication" });

// Returns all auth-related contexts across projects

2. Knowledge Discovery

typescript
// "How did we handle this before?"
search_context({ query: "rate limiting" });

// Find previous implementations

3. Bug Investigation

typescript
// Similar bug happened before
search_context({ query: "timeout error database" });

// Find related incidents

Best Practices

Use Specific Terms

typescript
// ✅ Good: Specific
search_context({ query: "OAuth2 PKCE mobile" });

// ❌ Bad: Too vague
search_context({ query: "auth" });

Combine with Project Filter

typescript
// ✅ Good: Narrow scope
search_context({
  query: "performance",
  project: "api-service"
});

// ❌ Less efficient: Too broad
search_context({ query: "performance" });

See Also