mcpField
P
python-notebook

python-notebook

github.com/valdesrosierData & databases8107 installsUpdated 4w ago
Repository

About python-notebook

A skill for developing ArcGIS API for Python notebooks across hosted and local environments. It emphasizes runtime-aware dependencies, environment-matched authentication, and safeguards for destructive data operations.

Key features

  1. 01Hosted and local runtime guidance
  2. 02Library and Python version checks
  3. 03Environment-specific authentication
  4. 04Destructive operation approval checks

Use cases

  1. 01Check ArcGIS library availability before importing
  2. 02Choose Python versions for local installs
  3. 03Prepare code that modifies or deletes GIS data

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/valdesrosier/skills --skill python-notebook

After installing, type/python-notebookin Claude Code to confirm it loaded.

Bundled filesagents/openai.yaml

Details

From the project README

ArcGIS API for Python & ArcGIS Notebooks

Determine the runtime target first

The runtime pins the library versions — you do not choose them independently. Establish which target applies before importing anything, because the rules diverge from here:

  • Hosted ArcGIS Notebooks (Enterprise or Online)
  • Local / conda / pip environment

Hosted notebooks: check the runtime manifest

Hosted runtimes are versioned to match the Notebook Server version (e.g. "ArcGIS Notebook Server Standard 12.0"). Two runtimes ship as container images:

  • Standard
  • Advanced — everything in Standard plus ArcPy.

ArcPy is Advanced-only: a notebook switched to Standard errors on any ArcPy cell. Authoring with each runtime is gated by a separate portal privilege. Check the runtime manifest for the target version before importing — do not assume a library is present, and do not pip-install around the runtime.

Changing the runtime can break working code

Precedent: arcgis 2.4.0 introduced a new map widget for Jupyter Notebook 7 / JupyterLab 4, and code written against the old widget requires migration; staying on arcgis 2.3.1 keeps Jupyter Notebook 6. Flag this risk before switching a notebook's runtime, and confirm the current behavior against the release notes for the versions in play.

Local installs: pin Python to the library

arcgis 2.4.2+ requires Python 3.10.x–3.13.x. Verify the exact range against the system-requirements page for the version in use rather than assuming.

Watch deprecated modules

GeoAnalytics Server's final release was Enterprise 11.3; arcgis.geoanalytics is supported via the built-in Python API only through 11.3 and earlier. Do not target it on newer releases.

Auth: match the environment, never inline credentials

  • Inside a hosted notebook, authenticate with GIS("home").
  • Elsewhere, use explicit credential auth — but never write credentials inline; source them from the environment or a prompt.

Guard destructive operations

Before generating any code that calls truncate, delete, delete_features, overwrite, or removes an item or layer, stop and satisfy every point in order. This covers irreversible data operations only, not credentials or org hygiene.

  1. Name the target. State the org and the exact item or layer id the call targets. An unnamed target is a stop.
  2. Show what it is. Display the target's title, type, and feature count so the user sees what they are about to lose.
  3. Confirm it is not production. Say so explicitly and get the user's confirmation before proceeding.
  4. Prefer the reversible form first. Offer a query-first / count-first or dry-run form so the blast radius is known before the destructive call runs.
  5. Never emit blind. Withhold the destructive call until 1–4 are satisfied and the user confirms — even when the user sounds confident.

Done when

The runtime target is identified; libraries are confirmed present in that runtime (or Python is pinned for a local install); auth matches the environment with no inline credentials; and any destructive call has passed through the guard.

Comments

Markdown supported