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: whoami → get_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:
get_map({ scope: 'envs' })to find the right scope slugsset_context({ orgSlug: 'dave-org', projectSlug: 'food-demo', envSlug: 'production', lensSlug: 'recipes' })search({ query: 'Thai dishes', limit: 5 })— scope defaults from context- 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
discoverfeed to the recipes lens in dev. Rank 60% on similarity toliked_titlesfrom 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:
describe_lens({ lens: 'recipes' })to read current config- Drafts the
FeedFacetConfigblock from your description add_facet({ lens: 'recipes', facet: 'feed', config: { discover: {...} }, dry_run: true })- Server replies with a diff +
confirm_token. Agent shows you the diff. - You: "ship it". Agent calls
add_facet({ confirm_token: '...' }). describe_lensto 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.productsin 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 itproducts.
What the agent does:
get_map({ scope: 'envs' })to confirm the target envcreate_lens({ lens: 'products', source: 'main-db', table: 'public.products', config: {...}, dry_run: true })- Dry-run returns the projected config + a confirm_token.
- You approve.
create_lens({ confirm_token })commits — lens exists, paused.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
- Setup → — add the MCP server to your agent if you haven't
- Tool catalog → — every arg shape + return shape