Skip to contents

The server-side half of the deployment split: pulls the index artifact published by CI (see build_index()) to a local cache and verifies schema compatibility from its manifest. Serving needs no natverse toolchain, so this runs the same for a local stdio server or a hosted HTTP endpoint. Once fetched, the cached index is picked up automatically by natmcp_mcp_server() / the tools when index = NULL.

Usage

fetch_index(source = NULL, cache_dir = NULL, force = FALSE)

Arguments

source

Base URL or direct index.rds URL to fetch from (see details).

cache_dir

Local cache directory (default: tools::R_user_dir("natmcp", "cache")).

force

Re-download even when the cached copy is already current.

Value

Invisibly, the path to the local index directory.

Details

source is a base URL (the directory holding index.rds + manifest.json) or a direct index.rds URL. When NULL it is taken from the natmcp.index_url option, then the NATMCP_INDEX_URL environment variable, then the default GitHub Pages location. The manifest is fetched first; if its schema_version does not match the installed package the download is refused with an upgrade hint. A re-fetch is skipped when the cached copy already has the same built_at, unless force = TRUE.

You rarely need to call this yourself: the tools call it on first use when no index is found, and natmcp_mcp_server() calls it at start-up when the cached index was last checked more than getOption("natmcp.refresh_days", 7) days ago. options(natmcp.auto_fetch = FALSE) turns both off. Call it yourself to pick up a newer published index straight away.