Tools¶
agentgrep’s tools are read-only. They return structured Pydantic models and protect private paths before serialization.
Prompt and Conversation Search¶
search¶
Search normalized prompts or conversations across local agent stores.
- Returns:
Use when you need prompt records matching one or more terms. Pass
scope="conversations" for full conversation, assistant, tool, and
event records, or scope="all" for both surfaces.
Returns: request metadata, run status, result stats, page metadata, and normalized records with ref, agent, store, adapter, path, text, title, role, timestamp, model, session ID, conversation ID, and metadata. When page.next_cursor is present, pass it back as cursor to continue the same search without rebuilding the request.
Example:
{
"tool": "search",
"arguments": {
"terms": ["release notes"],
"agent": "all",
"scope": "prompts",
"limit": 20
}
}
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[list[str] | |
no |
— |
— |
|
t.Annotated[AgentSelector, Field(description='Limit search to one agent or search all agents.')] |
no |
|
— |
|
t.Annotated[SearchScopeName, Field(description='Search prompts, conversations, or both.')] |
no |
|
— |
|
t.Annotated[bool, Field(description='Perform case-sensitive matching.')] |
no |
|
— |
|
t.Annotated[int | |
no |
|
— |
|
t.Annotated[str | |
no |
— |
— |
Time-Windowed Activity¶
recent_sessions¶
Return sources modified in the last N hours, newest-first.
- Returns:
RecentSessionsResponse
Use when you want the most-recently modified sources for an agent — newest-first, optionally bounded by a time window.
Returns: the cutoff timestamp plus source records ordered by mtime_ns descending.
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[AgentSelector, Field(description='Limit discovery to one agent or scan every agent.')] |
no |
|
— |
|
t.Annotated[int, Field(default=24, ge=1, le=24 * 30, description=’Look back this many hours (max 30 days).’, examples=[1, 24, 168])] |
no |
|
— |
|
t.Annotated[int | |
no |
|
— |
Store Discovery¶
find¶
Find known agent stores, session files, and SQLite databases.
- Returns:
Use when you need to inspect which stores, session files, and databases agentgrep can read.
Returns: request metadata, run status, result stats, page metadata, and source records with ref, agent, store, adapter, protected path, path kind, and metadata. When page.next_cursor is present, pass it back as cursor to continue the same discovery scan.
Example:
{
"tool": "find",
"arguments": {
"pattern": "sessions",
"agent": "codex",
"limit": 50
}
}
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[str | |
no |
— |
— |
|
t.Annotated[AgentSelector, Field(description='Limit discovery to one agent or search all agents.')] |
no |
|
— |
|
t.Annotated[int | |
no |
|
— |
|
t.Annotated[str | |
no |
— |
— |
Structured Source Listing¶
list_sources¶
List discovered sources with structured path-kind/source-kind filters.
- Returns:
ListSourcesResponse
Use when you want a structured listing of discovered sources with
optional path-kind, source-kind, and coverage filters. By default this
matches the default-search surface; pass include_non_default=true or
set coverage_filter to inspect inventory-only stores such as Codex
SQLite DBs or Claude session memory. Each returned source includes
searchable, search_by_default, searchable_reason, inspectable,
and version_detection, which records the strategy and evidence
agentgrep used to identify the app/data version for that concrete file
or DB.
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[AgentSelector, Field(description='Limit discovery to one agent or scan every agent.')] |
no |
|
— |
|
t.Annotated['history_file', 'session_file', 'sqlite_db' | |
no |
— |
— |
|
t.Annotated['json', 'jsonl', 'sqlite' | |
no |
— |
— |
|
t.Annotated[int | |
no |
— |
— |
Required-Pattern Filtering¶
filter_sources¶
Filter discovered sources by required substring pattern.
- Returns:
Use when you want to narrow discovered sources by required substring pattern (a stricter find).
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[str | |
no |
— |
— |
|
t.Annotated[AgentSelector, Field(description='Limit discovery to one agent or scan every agent.')] |
no |
|
— |
|
t.Annotated[int | |
no |
|
— |
|
t.Annotated[str | |
no |
— |
— |
Discovery Counts¶
summarize_discovery¶
Aggregate counts of discovered sources by agent, format, and kind.
- Returns:
DiscoverySummaryResponse
Use when you want aggregate counts of discovered sources by agent, format, and path-kind.
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[AgentSelector, Field(description='Limit discovery to one agent or scan every agent.')] |
no |
|
— |
Catalog readonly¶
list_stores¶
List on-disk agent stores from the agentgrep catalog.
- Returns:
ListStoresResponse
Use when you want the canonical catalog of on-disk stores agentgrep knows about — including stores that are not searched by default.
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[str, Field(default='all', description="Filter to one agent or 'all' for every catalog entry.", examples=['all', 'claude', 'cursor'])] |
no |
|
— |
|
t.Annotated[str | |
no |
— |
— |
|
t.Annotated[bool, Field(default=False, description='Return only stores that are searched by default.')] |
no |
|
— |
get_store_descriptor¶
Return the catalog descriptor for a single store by id.
- Returns:
StoreDescriptorModel
Use when you need the full descriptor (role, format, upstream reference, schema notes) for a single store id.
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[str, Field(min_length=1, description="Store id (e.g. 'claude.projects.session').", examples=['claude.projects.session', 'codex.history'])] |
yes |
— |
— |
inspect_record_sample¶
Read the first N records from one adapter+path for schema inspection.
- Returns:
InspectSampleResponse
Use when you want a few raw records from one adapter+path to validate parser output or discover schema variations.
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[str, Field(min_length=1, description="Adapter id (e.g. 'claude.projects_jsonl.v1').", examples=['claude.projects_jsonl.v1', 'codex.history_json.v1'])] |
yes |
— |
— |
|
t.Annotated[str, Field(min_length=1, description='Absolute path to the source file.')] |
yes |
— |
— |
|
t.Annotated[int, Field(default=1, ge=1, le=20, description='Number of records to return (1-20).')] |
no |
|
— |
inspect_result¶
Inspect records behind an opaque search/find result ref.
- Returns:
Use when you have a ref returned by search or find and need to inspect the matching result or sample records from that source without reconstructing local paths.
Parameters
Diagnostics¶
validate_query¶
Dry-run a query against sample text without searching files.
- Returns:
ValidateQueryResponse
Use when you want to dry-run a literal pattern against sample text before issuing a broad cross-agent search.
Parameters
Parameter |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
t.Annotated[list[str], Field(min_length=1, description='One or more literal search terms (AND-matched).', examples=[['alpha'], ['foo', 'bar']])] |
yes |
— |
— |
|
t.Annotated[str, Field(description='Sample text to test the query against.')] |
yes |
— |
— |
|
t.Annotated[bool, Field(description='Perform case-sensitive matching.')] |
no |
|
— |