Agent skill

API Mirror

by cyanheads in cyanheads/pubmed-mcp-server

Stand up a persistent, self-refreshing local mirror of a bulk upstream dataset with the MirrorService (@cyanheads/mcp-ts-core/mirror).

Apache-2.0Auto-check passedDatabases

Install API Mirror

skills CLI
$ npx skills add cyanheads/pubmed-mcp-server --skill api-mirror -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install cyanheads/pubmed-mcp-server api-mirror --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/cyanheads/pubmed-mcp-server.git skills-src && mkdir -p .claude/skills && cp -r skills-src/framework-skills/api-mirror .claude/skills/api-mirror && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
api-mirror
GitHub stars
155
Token cost
~2.5k tokens
SKILL.md length
989 words
Files
1
Skills in repo
30
Repo updated
First seen
Licence
Apache-2.0

At a glance

Stand up a persistent, self-refreshing local mirror of a bulk upstream dataset with the MirrorService (@cyanheads/mcp-ts-core/mirror).

  • A server wraps a large
  • SKILL.md covers Context, The shape, cursor vs. checkpoint — the… and What you own vs. what the…, plus 4 more sections
  • Calls docker and bun
  • Slow API and should query a synced local index (embedded SQLite + FTS

What it does

API Mirror is an agent skill from cyanheads/pubmed-mcp-server. Stand up a persistent, self-refreshing local mirror of a bulk upstream dataset with the MirrorService (@cyanheads/mcp-ts-core/mirror). Use when a server wraps a large or slow API and should query a synced local index (embedded SQLite + FTS5) instead of paginating the live API per request.

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Meeting notes and agendas and MCP servers. It works with SQLite and Model Context Protocol. The repository describes itself as: Search PubMed/Europe PMC, fetch articles and full text (PMC/EPMC/Unpaywall), citations, MeSH terms via MCP. STDIO or Streamable HTTP. The licence is Apache-2.0.

When your agent uses it

  • A server wraps a large
  • Slow API and should query a synced local index (embedded SQLite + FTS
  • Instead of paginating the live API per request

Example prompts

  • “/api-mirror”

Requirements

  • Node.js
  • Docker

What it can do on your machine

Read from SKILL.md and the folder at commit 5a417fb. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • docker
    • bun

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use docker, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

API Mirror loads about 2.5k tokens when it runs. Until then it costs about 75 tokens; SKILL.md has 989 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~75
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from cyanheads/pubmed-mcp-server at commit 5a417fb, republished under its Apache-2.0 licence (© cyanheads). 989 words, ~2,514 tokens.

Download SKILL.mdSave it as .claude/skills/api-mirror/SKILL.md (or your agent's skills folder).
name
api-mirror
description
Stand up a persistent, self-refreshing local mirror of a bulk upstream dataset with the MirrorService (@cyanheads/mcp-ts-core/mirror). Use when a server wraps a large or slow API and should query a synced local index (embedded SQLite + FTS5) instead of paginating the live API per request.
metadata.author
cyanheads
metadata.version
1.4
metadata.audience
external
metadata.type
reference

Context

The MirrorService owns the source-agnostic half of a local mirror — the embedded store, the sync-state machine, the runner — so a server supplies only the two parts that are irreducibly per-source: the ingester (a sync generator) and the schema. It targets the embedded-SQLite tier (~10⁴–10⁷ rows). Node/Bun only: bun:sqlite is built-in on Bun, better-sqlite3 is an optional peer dependency on Node; the store is unavailable on Workers (no SQLite, no persistent filesystem).

Import from @cyanheads/mcp-ts-core/mirror.

The shape

ts
import { defineMirror, sqliteMirrorStore } from '@cyanheads/mcp-ts-core/mirror';

const papers = defineMirror({
  name: 'arxiv-papers',
  store: sqliteMirrorStore({
    path: config.mirrorPath,
    table: 'papers',                                 // primary table; FTS index is `papers_fts`
    primaryKey: 'id',
    columns: { id: 'TEXT', title: 'TEXT', authors: 'TEXT', abstract: 'TEXT', updated: 'TEXT' },
    fts: ['title', 'authors', 'abstract'],          // opt-in FTS5 external-content index
    indexes: [{ columns: ['updated'] }],
  }),
  // The ingester — the one part that is always server-specific.
  async *sync({ mode, cursor, checkpoint, signal }) {
    for await (const page of harvestPages({ resumeFrom: cursor, since: checkpoint, signal })) {
      yield {
        records: page.rows,             // objects keyed by declared column
        tombstones: page.deletedIds,    // primary-key values to delete
        cursor: page.token,             // volatile resume position (see below)
        checkpoint: page.maxStamp,      // durable high-water mark (see below)
      };
    }
  },
});

await papers.runSync({ mode: 'init', signal: AbortSignal.timeout(3_600_000) }); // full; resumes on interrupt
await papers.runSync({ mode: 'refresh' });                                       // incremental
const { rows, total } = await papers.query({ match: 'transformers', limit: 10, offset: 0 });
const status = await papers.status();   // { status, ready, checkpoint, total, ... }

cursor vs. checkpoint — the core distinction

Two resume dimensions, deliberately separate. Conflating them silently corrupts resume for token-paged sources.

cursorcheckpoint
MeaningVolatile intra-run resume position (e.g. an OAI-PMH resumption token, a page token)Durable incremental high-water mark (e.g. the max record datestamp)
LifetimeOne run; may expire; cleared on completionPersists; advances monotonically, only on success
Used forResuming an interrupted initSeeding the next refresh

Why they can't merge: during a from-scratch init the records aren't ordered by the high-water field, so the max-so-far is not a valid resume position — only the cursor is. After a completed init the cursor is meaningless, but the high-water mark is the correct refresh seed. The framework persists both per page and threads the right one back into sync() per mode. The checkpoint must be lexicographically monotonic (ISO 8601 works); the runner advances the stored checkpoint only when a page's value compares greater.

What you own vs. what the framework owns

FrameworkServer
Cross-runtime SQLite handle, WAL + busy_timeout; an open waits out another connection's lock for busyTimeoutMsThe sync generator (the ingester)
mirror_sync_state + cursor/checkpoint state machineTranslating your query syntax → FTS5 match
runSync({ init | refresh }), per-page persist, resumeMapping upstream records → row objects
Schema gen (columns + FTS + tokenizer + triggers)Migration content (the up functions)
schema_version + migration runnerScheduling + init/refresh bootstrap (see below)
Generic query() + the raw-handle escape hatchServer-specific access paths via the raw handle

Querying

query({ match?, filters?, sort?, limit, offset }) covers the common case:

  • match — an FTS5 MATCH expression (only when the store declares fts columns). Translate your own query grammar to FTS5 before calling.
  • filters — [{ column, op, value }], AND-combined, over declared columns. op ∈ eq|ne|gt|gte|lt|lte|in (in takes an array).
  • sort — { column, direction } or 'relevance' (FTS bm25; requires match). Defaults to insertion order.

For access paths the generic query can't express — junction tables for index-backed multi-value filtering, denormalized counters, bespoke bm25 weighting — use the raw handle: const db = await mirror.raw(); then run prepared statements against your own auxiliary tables (declare them via a migration). Add the auxiliary DDL in a migrations step; maintain it from your sync mapping or SQL triggers.

A migration runs identically on first creation and on upgrade: a fresh database runs every migration up to version right after the declarative DDL, an existing one runs only those above its stored version. So up() must tolerate a database that already has the current declarative shape — CREATE TABLE IF NOT EXISTS for auxiliary objects, never an ALTER that assumes an older layout of a declared column.

Readiness — key off the completion marker, not live status

status().ready is true once a full sync has ever completed (completedAt != null), not when status === 'complete'. The dataset stays transactionally queryable during a refresh, so a mirror mid-refresh — or one whose last refresh failed — is still ready and should keep serving. Gate the mirror read path on await mirror.ready(); fall back to the live API only when it is false (cold, never-completed init).

Show full SKILL.md (423 more words)Show less

Scheduling and bootstrap (server-owned)

The service owns runSync + state; it does not schedule. Wire "self-refreshing" yourself:

  • Refresh — register runSync({ mode: 'refresh' }) on a cron via schedulerService from @cyanheads/mcp-ts-core/utils, inside setup(). Gate on transport (HTTP) when stdio operators run it out-of-band.
  • Off the serving thread — SQLite calls are synchronous, so each write transaction a sync runs blocks the event loop until it commits. A refresh whose pages or post-sync recomputes take seconds stalls every request, /healthz included, for that long. Run such a scheduled sync in a child process instead: spawn process.execPath with process.execArgv and a compiled job entry in dist/, relay its log lines, and in teardown stop it with SIGTERM, then SIGKILL after a grace period. In-process scheduling suits mirrors whose transactions stay short.
  • Init — run out-of-band (a CLI script / one-shot), never on startup: a full init can take hours and must not block the server. It is idempotent and resumable — re-running after an interrupt continues from the persisted cursor.
Shipping the mirror CLI in a production Docker image

The scaffold Dockerfile copies only dist/ to the runtime stage. A mirror lifecycle script (mirror:init, mirror:refresh, mirror:verify) that imports through the @/ path alias fails under docker exec — @/ resolves to src/ via the source tsconfig.json, and src/ never reaches the image.

On the Bun runtime image (oven/bun), two stanzas fix it — no build change, no rootDir surgery, and the mirror:* package scripts stay identical between a dev checkout and the image.

Add the following to the runtime stage of Dockerfile, after the COPY --from=build .../dist ./dist line:

dockerfile
# Copy mirror lifecycle scripts. The shared context shim (_mirror-context.ts)
# is imported by the three named scripts, so it must travel with them.
COPY --from=build /usr/src/app/scripts/<your>-mirror-init.ts \
                  /usr/src/app/scripts/<your>-mirror-refresh.ts \
                  /usr/src/app/scripts/<your>-mirror-verify.ts \
                  /usr/src/app/scripts/_mirror-context.ts \
                  ./scripts/

# Bun honors tsconfig `paths` at runtime — map `@/` to the compiled `./dist/`
# so the .ts scripts resolve their alias imports against the build output.
# In a dev checkout the source tsconfig.json maps @/* → ./src/*; in the image
# this emitted one maps @/* → ./dist/*. Same `bun run mirror:*` command, both
# environments — the only lever is which tsconfig.json is on disk.
RUN echo '{"compilerOptions":{"baseUrl":".","paths":{"@/*":["./dist/*"]}}}' > tsconfig.json

Caveat: this relies on Bun's runtime paths resolution. A Node runtime image (no native .ts execution) needs the scripts compiled into dist/ instead — a separate tsconfig pass with a different rootDir is required in that case.

package.json files[]: add scripts/_mirror-context.ts and the three named lifecycle scripts so the npm tarball and .mcpb bundle carry them. They resolve @/ only where a tsconfig.json maps it (a dev checkout, or the image above). An npm install ships no such mapping, so an npm-installed server cannot run them: document building the mirror from a checkout or the image.

Checklist

  • defineMirror({ name, store, sync }); the server holds the instance (one per mirror)
  • sqliteMirrorStore spec declares primaryKey, columns, and (if searching) fts
  • sync yields { records, tombstones?, cursor?, checkpoint? } per page; checkpoint is lexicographically monotonic
  • Read path gated on await mirror.ready() with a live fallback when not ready
  • better-sqlite3 added as a peer dependency for Node deployments; mirror disabled on Workers
  • Refresh wired via schedulerService in setup(); init runs out-of-band
  • bun run devcheck passes

© cyanheads, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in framework-skills/api-mirror of cyanheads/pubmed-mcp-server.

Open the folder on GitHubat commit 5a417fb

Compare with similar skills

API Mirror next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

API Mirror compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
API Mirror this skillcyanheads/pubmed-mcp-server155—~2.5kAutomated safety check: PassApache-2.0
Frontmcp Setupagentfront/frontmcp146—~5.8kAutomated safety check: PassApache-2.0
Sap Cap Capiresecondsky/sap-skills462—~4.4kAutomated safety check: PassGPL-3.0
Retinuejklthinking/retinue112—~279Automated safety check: PassMIT
Memmesh CLIThinkfleetAI/memmesh420—~855Automated safety check: PassApache-2.0
Granolawin4r/MuseAI-Skills3321 repos~805Automated safety check: PassNone

Similar skills

  • Frontmcp Setup

    agentfront/frontmcp

    A skill your agent uses when starting, scaffolding, or organizing a FrontMCP project.

    146 GitHub stars~5.8k tokensUpdated yesterday
    DatabasesAuto-check passed
  • Sap Cap Capire

    secondsky/sap-skills

    SAP Cloud Application Programming Model (CAP) development skill using Capire documentation.

    462 GitHub stars~4.4k tokensUpdated 3 days ago
    DatabasesAuto-check passed
  • Retinue

    jklthinking/retinue

    Coordinate work through a local Retinue workspace using its MCP tools.

    112 GitHub stars~279 tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Memmesh CLI

    ThinkfleetAI/memmesh

    MemMesh CLI + local MCP server — the zero-infra, no-API-key path to the same engine as the hosted SDK.

    420 GitHub stars~855 tokensUpdated 1 mo ago
    Agent WorkflowsAuto-check passed
  • Granola

    win4r/MuseAI-Skills

    Search and read Granola meeting notes and transcripts through Granola's OAuth-backed MCP server.

    332 GitHub starsUsed in 1 repo~805 tokens
    Productivity & AutomationAuto-check passed
  • Wrongstack Mailbox MCP

    WrongStack/WrongStack

    Coordinate with WrongStack agents through the project-scoped Mailbox MCP server.

    370 GitHub stars~1.5k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from cyanheads/pubmed-mcp-server

All 30 skills in this repo
  • Add App Tool

    cyanheads/pubmed-mcp-server

    Scaffold an MCP App tool + UI resource pair. An agent skill from cyanheads/pubmed-mcp-server.

    155 GitHub stars~3.2k tokensUpdated 4 days ago
    Auto-check passed
  • Add Prompt

    cyanheads/pubmed-mcp-server

    Scaffold a new MCP prompt template. An agent skill from cyanheads/pubmed-mcp-server.

    155 GitHub stars~1.6k tokensUpdated 4 days ago
    Auto-check passed
  • Add Resource

    cyanheads/pubmed-mcp-server

    Scaffold a new MCP resource definition. An agent skill from cyanheads/pubmed-mcp-server.

    155 GitHub stars~3k tokensUpdated 4 days ago
    Auto-check passed
  • Add Service

    cyanheads/pubmed-mcp-server

    Scaffold a new service integration. An agent skill from cyanheads/pubmed-mcp-server.

    155 GitHub stars~3.6k tokensUpdated 4 days ago
    Auto-check passed
  • Add Test

    cyanheads/pubmed-mcp-server

    Scaffold a test file for an existing tool, resource, or service.

    155 GitHub stars~4.1k tokensUpdated 4 days ago
    Auto-check passed
  • API Auth

    cyanheads/pubmed-mcp-server

    Authentication, authorization, and multi-tenancy patterns for @cyanheads/mcp-ts-core.

    155 GitHub stars~2.7k tokensUpdated 4 days ago
    Auto-check passed

Questions about API Mirror

What does API Mirror do?

Stand up a persistent, self-refreshing local mirror of a bulk upstream dataset with the MirrorService (@cyanheads/mcp-ts-core/mirror). API Mirror is an agent skill from cyanheads/pubmed-mcp-server. Stand up a persistent, self-refreshing local mirror of a bulk upstream dataset with the MirrorService (@cyanheads/mcp-ts-core/mirror).

When should I use API Mirror?

API Mirror fits situations like: A server wraps a large; slow API and should query a synced local index (embedded SQLite + FTS; instead of paginating the live API per request.

How do I install API Mirror in Claude Code?

Run `npx skills add cyanheads/pubmed-mcp-server --skill api-mirror -a claude-code`. Or copy the skill folder (framework-skills/api-mirror in cyanheads/pubmed-mcp-server) into .claude/skills/api-mirror in your project. Claude Code loads it when a task matches its description.

How do I install API Mirror in Codex?

Run `npx skills add cyanheads/pubmed-mcp-server --skill api-mirror -a codex`. Or copy the skill folder (framework-skills/api-mirror in cyanheads/pubmed-mcp-server) into .agents/skills/api-mirror in your project. Codex loads it when a task matches its description.

Can I use API Mirror in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add cyanheads/pubmed-mcp-server --skill api-mirror -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/api-mirror, .gemini/skills/api-mirror, .github/skills/api-mirror and .opencode/skills/api-mirror in your project.

What does API Mirror need to run?

Going by SKILL.md and its folder, API Mirror needs the command-line tools its instructions call (docker and bun). Our summary lists: Node.js; Docker.

Does API Mirror access the network?

SKILL.md contains no URLs. Its commands use docker, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is API Mirror safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does API Mirror use?

API Mirror is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does API Mirror use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to API Mirror?

Skills that share tags, products or a category with API Mirror: Frontmcp Setup (agentfront/frontmcp, 146 stars), Sap Cap Capire (secondsky/sap-skills, 462 stars), Retinue (jklthinking/retinue, 112 stars) and Memmesh CLI (ThinkfleetAI/memmesh, 420 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains API Mirror?

cyanheads (a GitHub user) maintains it in cyanheads/pubmed-mcp-server, which has 155 GitHub stars. The repository holds 30 skills in this directory. The repository was last updated on October 4, 2026.

Source: cyanheads/pubmed-mcp-server on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.