SemiLayerDocs

Examples

Copy these into Claude Desktop / Cursor / Claude Code with the SemiLayer MCP connected. Each example calls real tools in sequence — no special "SemiLayer mode" needed from the agent.

1. Discovery — "What do I have?"

What SemiLayer orgs do I have, and which lenses are live?

What the agent does: whoamiget_map → renders the hierarchy as a tree. Expect org → project → env → lens with status + facet badges.

Cheap, fast, no writes. Perfect first call in a conversation to set context.

2. Focused read — "Search my recipes"

Using my semilayer account, set my context to the recipes lens in the production environment of my food-demo project, then find me the top 5 Thai dishes.

What the agent does:

  1. get_map({ scope: 'envs' }) to find the right scope slugs
  2. set_context({ orgSlug: 'dave-org', projectSlug: 'food-demo', envSlug: 'production', lensSlug: 'recipes' })
  3. search({ query: 'Thai dishes', limit: 5 }) — scope defaults from context
  4. Renders a table from structuredContent.results

The set_context step is the payoff: every subsequent question about that lens skips scope args.

3. Observe — "What's indexing right now?"

Show me ingest status across my dev environment. Flag anything in error or running more than 5 minutes.

What the agent does: status({ envSlug: 'development' }) → renders ingest_status with filtering. The structuredContent.lenses[] array has per-lens status + lastIngestAt + errorCount for a quick triage.

4. Build — "Add a feed to my recipes lens"

Add a discover feed to the recipes lens in dev. Rank 60% on similarity to liked_titles from context, 10% on recency with a 7-day half life, 30% on engagement via the recipe_likes lens. 20 items per page, dedup on sourceRowId.

What the agent does:

  1. describe_lens({ lens: 'recipes' }) to read current config
  2. Drafts the FeedFacetConfig block from your description
  3. add_facet({ lens: 'recipes', facet: 'feed', config: { discover: {...} }, dry_run: true })
  4. Server replies with a diff + confirm_token. Agent shows you the diff.
  5. You: "ship it". Agent calls add_facet({ confirm_token: '...' }).
  6. describe_lens to confirm the new facet is live.

Two confirmations from you (the prompt itself, then "ship it"). Zero copy-paste to Console. Config hashing and drift detection happen server-side in the push pipeline — same as if you'd run semilayer push locally.

5. Create from scratch — "Turn this table into a lens"

I have a Postgres table public.products in my main-db source. Create a lens over it, with semantic search on name + description, similar on both, and a weight of 2 on name. Call it products.

What the agent does:

  1. get_map({ scope: 'envs' }) to confirm the target env
  2. create_lens({ lens: 'products', source: 'main-db', table: 'public.products', config: {...}, dry_run: true })
  3. Dry-run returns the projected config + a confirm_token.
  4. You approve.
  5. create_lens({ confirm_token }) commits — lens exists, paused.
  6. resume_ingest({ lens: 'products' }) — two-call, same pattern — kicks off first full ingest.

Five tool calls from a single sentence. Same checks your CLI would do. Same rollback story — if step 6 fails, the lens just sits paused; you can fix config and retry.

What you get for free

Every example above inherits:

  • RBAC: your role gates every call. Viewer can do #1, #2, #3. Developer+ can do #4 and #5.
  • Quotas: your org's API quota covers every tool call. One bill, one rate limit, visible in Console like any other traffic.
  • Audit: every write tool's commit shows up in the org's audit log with source: 'mcp' + the user sub. Full forensics if someone asks.
  • Short-lived tokens: 1-hour access tokens, 30-day refresh. No static credentials in your agent config.

Next