Skip to main content
Glama

scry

Scry Marker Specification - This project implements a formal, generic scry marker contract defined here

See scryspec.com for an overview.

Marker-indexed SQL cache MCP server. Scry indexes in-file @scry.* markers into a SQLite database that agents query via read-only SQL, providing structured project knowledge without LLM reasoning.

PyPI Python

Install

uv pip install scry-mcp
# or:
pip install scry-mcp

The PyPI distribution is scry-mcp (the bare name scry was already taken on PyPI). The import name and the installed console command are both scry.

Related MCP server: Context Bunker MCP

Quickstart

# In your project root:
scry init                # scaffolds agent/ + driver dirs, updates .gitignore

Then add it to your MCP client config:

{
  "mcpServers": {
    "scry": {
      "command": "scry"
    }
  }
}

The MCP client inherits cwd from wherever it's launched, and scry walks up from there looking for an agent/ directory — so the same config works for any project. Bare scry (no subcommand) starts the MCP server over stdio — that's what Claude calls. Other subcommands:

Command

Purpose

scry

Run the MCP server (default).

scry init [path]

Create .scry/{data,runtime,scripts}/ and a .scry/.gitignore. Idempotent — safe to run inside an ACP project.

scry surface [--force]

One-shot batch reindex without booting the server.

scry version

Print the package version.

The server walks up from cwd until it finds a .scry/ directory; that becomes the project root (falling back to cwd when none is found). The cache lives at .scry/data/project.db and is gitignored.

Marker mode

marker_mode in .scry/config.toml controls how markers are handled:

Mode

Behavior

inline (default)

Markers live embedded in source files.

sidecar

Markers live in agent/scry/ sidecar files, keeping source clean; extras.source points at the described file.

off

No markers read or written. Only scry_grep, scry_surface, and scry_db_health are registered — scry becomes a fast full-text file search. Point it at any project (create .scry/config.toml with marker_mode = "off"); no marker adoption required.

Markers

Scry recognizes three marker kinds per scry-spec v1.2.0: @scry.entry and @scry.anchor are block markers with a YAML body between open/close tokens; @scry.bind is a line or block marker declaring cross-references.

<!-- @scry.entry
id: design.auth-flow~a1b2c3d4
kind: design
summary: >
  JWT auth middleware, token validation, refresh flow
status: active
weight: 0.85
tags: ["scope:auth", "topic:security"]
rationale: >
  Missing this causes auth bypass bugs
applies: modifying auth, adding protected endpoints
seeded_questions:
  - How does token refresh work?
extras:
  owner: auth-team
  jira: AUTH-1247
  reviewed_at: 2026-05-19
@scry.entry.end -->

<!-- @scry.anchor auth-check~f1e2d3c4
description: JWT validation point for protected routes
@scry.anchor.end -->
# @scry.bind validate-jwt~a1b2c3d4 spec.auth~xyz89012#FR3
# @scry.bind jwt-expiry~b2c3d4e5 spec.auth~xyz89012#UT1

Block markers can be embedded in any host-language comment style (HTML, Python, JS, JSDoc, Rust, bare YAML). Comment prefixes are inferred from the YAML body — there is no per-language config.

extras field (scry-spec v1.2.0, FR4.B)

@scry.entry accepts an optional extras field: a single-depth map of arbitrary string keys to scalar values (string | number | boolean | null). Use it to attach structured metadata that isn't part of the core schema — ownership, ticket IDs, cost ledgers, review timestamps, anything you want to query later.

Constraints:

  • Single depth only — values must be scalars; nested maps and lists are diagnostic violations.

  • Serialized size ≤ 4 KB (the spec's SHOULD-level cap).

  • Oversize payloads MUST round-trip intact — the cap is a diagnostic, not a truncation gate. Empty extras: {} emits a SHOULD-level warning.

Indexed and queryable as of v0.17.0. The extras field is serialized to compact JSON-text in the scry__doc.extras column (NULL when absent), and exposed to scry_sql via SQLite JSON1. A doc with

extras:
  cost_usd: 12.5
  tier: gold
  active: true

answers queries like:

SELECT id,
       json_extract(extras, '$.cost_usd') AS cost,
       json_extract(extras, '$.tier')     AS tier
FROM scry__doc
WHERE kind = 'deliverable'
  AND json_extract(extras, '$.active') = 1
ORDER BY cost DESC;

Round-trip is byte-equivalent for the YAML scalar map: integers, floats, strings, booleans, and null are preserved.

@scry.entry kind values (v1.2.0 baseline)

kind

use for

design

architecture and design docs

pattern

canonical recipes, established patterns

spec

requirements and specifications

lesson

post-mortems, "I tried X and it failed because Y"

internal

service quirks, undocumented behaviors

task

discrete work items

milestone

phase markers, exit criteria

goal

objective satisfied by a deliverable set via the satisfies typed edge (v1.2.0)

report

wake/session reports

audit

security or integrity audits

research

research notes

code

implementation-specific docs

MCP tools

Tool

Purpose

scry_sql(query)

Read-only SQL gateway. Rejects mutator keywords. Returns {results, row_count} JSON.

scry_grep(query, kind?, status?, path_glob?, limit?)

Full-text search over indexed file bodies (scry__file_fts). Complements scry_sql when you want to search prose, not just marker fields.

scry_mint(kind, prefix)

Generate a collision-free ID and the marker schema.

scry_mint_with_check(kind, prefix)

Preferred minter — same as scry_mint plus tier-1/tier-2 collision warnings.

scry_surface(force=false, path?)

Batch reindex from disk. force=true hard-deletes records whose source file no longer exists; path scopes the walk to a single file or subdirectory.

scry_sink(then_surface=false)

Lower the index back to disk-only state — truncates all index tables atomically (schema preserved, disk markers untouched). Requires user confirmation; then_surface=true rebuilds in one call.

scry_scrub()

Create a <branch>--clean git branch with all @scry.* markers stripped from non-agent files.

scry_script(action, script?, params?)

Discover and run validation scripts from src/scry/scripts/ and .scry/scripts/.

scry_db_health()

Probe the project DB and report status ∈ {ok, corrupt, locked}, integrity_check result, and scry__doc row count. For substrate auto-restore loops that need to distinguish corruption from transient WAL write-lock contention.

Database schema

Marker-backed core tables:

Table

Holds

scry__doc

One row per @scry.entry marker — id, kind, status, weight, summary, rationale, applies, current_path, ephemeral, missing_since, content_hash, extras, timestamps.

scry__doc_tag

Tags as a join table — (doc_id, tag).

scry__doc_seeded_question

Seeded questions per doc — (doc_id, ordinal, question).

scry__anchor

One row per @scry.anchor marker — id, doc_id, description, content_hash, timestamps.

scry__anchor_seeded_question

Seeded questions per anchor — (anchor_id, ordinal, question).

scry__bind

One row per @scry.bind marker — source_doc_id, source_local_id, target_id, target_fragment, comment, content_hash, timestamps.

scry__rel

Typed edges between docs — (from_id, to_id, predicate, fragment). Predicates: depends_on, implements, supersedes. Cycle detection enforced on depends_on.

scry__file

Universal file-body index — (path, doc_id, body, content_hash, last_modified). Populated during scry_surface.

scry__warning

Lint-style warnings emitted by the parser/indexer — id, kind, marker_kind, marker_id, file_path, message, detected_at.

migration

Schema migration ledger.

FTS5 virtual tables (trigger-maintained, queryable via FTS MATCH):

FTS table

Searches

scry__doc_fts

Doc summary, rationale, applies, current_path.

scry__doc_tag_fts

Tag strings.

scry__doc_seeded_question_fts

Doc seeded questions.

scry__anchor_fts

Anchor descriptions.

scry__bind_fts

Bind source_local_id, target_id, comment.

scry__file_fts

Full file bodies. Prefer the scry_grep tool over hand-rolled queries.

The cache is fully reconstructable from disk via scry_surface. The DB is gitignored; after git pull, agents call scry_surface to rebuild.

Watcher

A daemon thread runs alongside the MCP server, watching the project tree with a 150 ms debounce window. A lock file at .scry/runtime/lock performs PID-based primary election so multiple sessions don't race writes. The primary instance runs a cold scan on startup; secondaries observe and wait.

On file deletion: docs are soft-deleted (missing_since set); anchors and binds are hard-deleted.

Tests

uv pip install -e ".[dev]"
pytest

159 tests cover the parser, SQL gateway, mint, surface, watcher plumbing, script discovery, relationship cycle detection, FR4.B extras indexing + JSON1 queryability, schema-migration backfill, and concurrent-connection retry behavior.

License

MIT — see LICENSE.

Available Tools

9 tools
scry_db_healthA

Probe the scry project database and report health.

Designed for substrate code (e.g. reflection's wake.py auto-restore loop) that needs to distinguish actual corruption from transient WAL write-lock contention. The same scry-mcp connection primitives are used as for every other tool — long busy_timeout, WAL journal mode, retry semantics — so a healthy-but-busy DB will not be reported as corrupt.

Returns JSON with these fields:

status "ok" | "corrupt" | "locked" integrity result of PRAGMA integrity_check (string), or null when the probe could not run (e.g. status=locked) doc_count integer row count of scry__doc, or null when the table does not exist yet (fresh / unmigrated DB) doc_count_error populated when doc_count is null and the count query failed for a known-benign reason (table missing); null otherwise db_path absolute path to the project.db file probed error string explanation when status != "ok"; null otherwise

Status semantics for substrate decisions:

status="ok" DB is healthy. Do not quarantine. status="locked" DB is healthy but contended. Do NOT quarantine; retry the probe on the next wake. Substrate code that conflates this with corruption causes the Group-C cascade described in the May 2026 diagnostic. status="corrupt" DB failed PRAGMA integrity_check or could not be opened as a SQLite database at all. Safe to initiate auto-restore.

A status="ok" with doc_count=null and doc_count_error="no such table: scry__doc" is a fresh-and-unmigrated DB. Substrate should run migrations (or call scry_surface) rather than quarantine.

Inputs: no named parameters. Returns: result

scry_grepA

Full-text search over all indexed file bodies (scry__file_fts).

Complements scry_sql: use this when you want broad full-text search across file content, not just curated marker fields.

Returns one hit per file (highest BM25-ranked match).

Args: query: FTS5 query string — plain words, phrases ("foo bar"), boolean (foo AND bar, foo OR bar, NOT foo). Accepts standard FTS5 syntax. kind: Optional: filter to files whose associated doc has this kind (e.g. 'design', 'lesson', 'pattern'). Files without a doc marker are excluded when this filter is set. status: Optional: filter by doc status (e.g. 'active', 'draft'). Files without a doc marker are excluded when set. path_glob: Optional: GLOB pattern on file path, e.g. 'agent/design/' or '.py'. Applied before FTS. limit: Max number of results to return (default 20).

Returns JSON: { "hits": [ { "path": "agent/design/...", "doc_id": "design.foo~abcd1234" | null, "snippet": "...text with matches highlighted...", "score": 12.4, "match_count": 3 } ], "total_matches": 47, "query": "...", "filters_applied": { "kind": null, "status": null, "path_glob": null } }

Tips:

  • Combine with scry_sql: get doc IDs from scry_grep, then JOIN to scry__doc_tag or scry__doc for richer metadata.

  • Use path_glob to scope to a subtree: 'agent/design/*'

  • scry__file is populated during scry_surface; call that first if results are empty on a fresh DB.

Inputs: query (required), kind, limit, status, +1 more. Returns: result

scry_mintA

REQUIRED before writing any @scry.* marker. Generates a collision-free ID and returns the marker schema with per-field instructions. Follow the returned instructions exactly when filling fields.

Also performs collision detection and returns warnings alongside the ID:

tier1_collisions — markers with the SAME prefix already in the DB. If any tier-1 hit is the same logical concept, ABANDON the new ID and reference the existing marker instead — stranded IDs pollute scry.

tier2_neighbors — markers in the same kind+first-segment family (informational; may reveal related prior work to link against).

Args: kind: "entry", "anchor", or "bind" prefix: Human-readable prefix. entry: MUST contain a dot (e.g. "design.auth-flow", "task.fix-bug") anchor/bind: MUST NOT contain dots (e.g. "auth-check", "validate-jwt")

Returns JSON with: id, schema (marker_open/close + per-field instructions), and optionally tier1_collisions + tier2_neighbors when they exist.

Field quality matters (FR4.A authoring guidance): summary — prose sentences + 'Also:' keyword cluster at the end. "JWT auth middleware, validates bearer tokens. Also: JWT, bearer-token, auth-guard, refresh-flow" tags — carry both classifier and bare-keyword forms. ["topic:auth", "auth", "scope:runtime", "runtime"] rationale — Why this artifact exists: the problem it solves or the role it fills. Not why you would search for it, not a findability claim, not its importance. Lesson: "prevents re-introducing the auth bypass fixed in PR 412". Design: "centralizes token checks so endpoints do not each re-implement them". Track wake: "owns the reflect-mcp build-to-PyPI path". Bad: "invisible to scry without this", "this is important". applies — verb-shaped triggers (actions, not topics). "modifying auth, adding protected endpoints" not "when working on auth" seeded_questions — include both full questions AND fragment queries. ["What is the JWT refresh flow?", "JWT refresh token implementation"]

Inputs: kind (required), prefix (required). Returns: result

scry_mint_with_checkA

PREFERRED over raw scry_mint. Generates a collision-free scry marker ID (same as scry_mint) and augments the response with existing-marker warnings:

Tier 1 — exact-prefix collision: markers with the same prefix already in scry__doc. If any tier-1 hit is the same logical concept, ABANDON the new ID and reference the existing marker instead — stranded IDs pollute scry.

Tier 2 — family-slug neighbors: related markers in the same slug family (informational; may reveal related prior work to link against).

Args: kind: 'entry', 'anchor', or 'bind' prefix: Human-readable prefix. entry MUST contain a dot (e.g. 'design.auth-flow', 'task.fix-bug'). anchor/bind must NOT contain dots (e.g. 'auth-check', 'validate-jwt').

Returns: id, marker schema (same as scry_mint), plus tier-1/tier-2 collision info.

Inputs: kind (required), prefix (required). Returns: result

scry_scriptA

Run validation or transformation scripts with DB access.

Actions: list — discover available scripts (bundled + project-local) run — execute a named script

Args: action: "list" or "run" script: script name (required for action="run") params: arbitrary params passed to the script (optional)

Scripts have read-write DB access. They return structured JSON.

Inputs: action (required), params, script. Returns: result

scry_scrubA

Create a clean PR branch with all @scry.* markers stripped.

By default, files inside agent/** and any AGENT.md are excluded from scrubbing — their markers are left intact. Only tracked files outside the agent workspace are cleaned. This matches the common workflow: agent/ is gitignored (or excluded via .git/info/exclude), so only the tracked source files need clean markers for PR submission.

Set include_agent=true to restore the prior behavior: scrub everything and remove the agent/ directory entirely.

Creates {branch}--clean from current HEAD. Does not stage or commit — leaves unstaged changes for the user.

Fails if on main/master or if working tree is dirty.

Inputs: include_agent. Returns: result

scry_sinkA

Lower the index back to disk-only state. The DB forgets; the disk remembers.

Truncates all scry index tables (scry__doc, scry__anchor, scry__bind, scry__rel, scry__file, scry__warning, and join tables) in a single atomic transaction. Schema is preserved; FTS tables update via existing triggers. Disk markers are never modified.

Requires protocol-level user confirmation via MCP elicitation before executing — the operation will not proceed if the confirmation is declined, cancelled, or unavailable.

Args: then_surface: If True, immediately runs scry_surface after the sink to rebuild the index from disk markers in a single call. Equivalent to "reset + reindex."

Returns JSON with pre-deletion counts and operation result.

Inputs: then_surface. Returns: result

scry_sqlA

Execute a read-only SQL query against the scry project database. Use this to discover project state, search docs, check coverage, inspect anchors.

Supports SELECT and WITH (CTE) queries only. All mutator keywords (INSERT, UPDATE, DELETE, DROP, etc.) are blocked.

Key tables: scry__doc — knowledge graph entries (@scry.entry markers) columns: id, kind, status, weight, summary, rationale, applies, current_path, ephemeral, missing_since, content_hash, extras (JSON1; NULL when absent), created_at, updated_at extras: single-depth scalar map per scry-spec FR4.B (v1.1.0+). Query with JSON1, e.g. SELECT id, json_extract(extras, '$.cost_usd') AS cost FROM scry__doc WHERE kind = 'deliverable' ORDER BY cost DESC scry__doc_tag — tags as a join table: doc_id, tag scry__doc_seeded_question — seeded questions: doc_id, ordinal, question scry__anchor — named code location bookmarks: id, doc_id, description, content_hash, created_at, updated_at scry__anchor_seeded_question — anchor seeded questions: anchor_id, ordinal, question scry__bind — binding markers (@scry.bind): id, source_doc_id, source_local_id, target_id, target_fragment, comment, content_hash, created_at, updated_at scry__rel — typed edges between docs: from_id, to_id, predicate (depends_on|implements|supersedes|satisfies), fragment scry__file — universal file body index: path, doc_id, body, content_hash, last_modified scry__bind_fts — full-text search over bindings (source_local_id, target_id, comment) scry__warning — lint-style warnings: id, kind, marker_kind, marker_id, file_path, message, detected_at (kinds: misplaced_doc, depends_on_cycle) scry__doc_fts — full-text search over docs (id, summary, rationale, applies, current_path) scry__doc_tag_fts — full-text search over tags (tag, doc_id UNINDEXED) scry__doc_seeded_question_fts — full-text search over seeded questions (question, doc_id UNINDEXED) scry__anchor_fts — full-text search over anchors (id, description) scry__file_fts — full-text search over file bodies (path, body); prefer scry_grep tool

Returns JSON: {"results": [...], "row_count": N}

Inputs: query (required). Returns: result

scry_surfaceA

Rebuild the DB from disk markers. Use after git pull, bulk file moves, or if query results seem stale. The file watcher handles live indexing — only call this for full re-scans.

Walks all project files, parses @scry.* markers, upserts to DB. Idempotent. Uses content-hash dedup.

Args: force: If true, hard-deletes records whose files no longer exist. If false (default), sets missing_since and warns. path: Optional scope, relative to project root. None (default) — full corpus walk. Current behavior, unchanged. — re-index exactly that one file. — re-index every file under that directory, recursively. If path does not exist on disk, returns a clear error. Scoped reconciliation: flagged_missing, misplaced_doc warnings, and force-deletes are all scoped to the path — docs outside the scope are never flagged as missing.

Returns JSON with counts per marker type, any warnings, and a scope field echoing the path argument (null for a full walk).

Inputs: path, force. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 9 tools

    Disambiguation3/5

    The tools are mostly distinct, but scry_mint and scry_mint_with_check have overlapping functionality—both generate IDs and report collisions, with the latter described as 'preferred'. This could confuse an agent about which to use. Other tools like scry_grep and scry_sql are complementary and well-differentiated.

    Naming Consistency4/5

    All tools consistently use the 'scry_' prefix, and most follow a verb or verb_noun pattern (e.g., scry_grep, scry_scrub). However, scry_mint_with_check breaks the pattern with a prepositional suffix, and scry_db_health is a noun_noun form. Overall, naming is readable and predictable with minor inconsistencies.

    Tool Count5/5

    With 9 tools, the server provides a well-scoped interface for managing scry markers and the database. Each tool serves a clear purpose without unnecessary overlap or excessive granularity. The count is appropriate for the domain.

    Completeness4/5

    The tool surface covers core workflows: marker creation (scry_mint, scry_mint_with_check), search (scry_grep, scry_sql), database rebuild (scry_surface), reset (scry_sink), cleanup (scry_scrub), health checks (scry_db_health), and scripting (scry_script). Minor gaps exist, such as no dedicated tool for updating or deleting markers directly, but these are manageable via scry_sql and file operations.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that indexes your codebase using tree-sitter AST parsing and gives AI tools instant access to structural intelligence like dependency graphs, call trees, and dead code detection from a local SQLite database.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Local MCP server for persistent, searchable agent memory using SQLite FTS5, replacing flat MEMORY.md files with efficient full-text search and workspace context caching.
      GPL 3.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      A local MCP server that parses codebases into semantic chunks, indexes them in SQLite with vector embeddings, and exposes MCP tools for LLM agents to query.
      MIT