Write a pack#

Add an optional part to the server: its own routes, settings, models or commands, loaded only where a deployment lists it.

The smallest real example is the Nemotron pack (packs/nemotron/). The Clay pack (packs/clay/) adds settings and a runtime hook, and the maritime pack (packs/maritime/) uses most of the registry.

Prerequisites#

  • A source checkout and the workspace environment from Development environment.

  • A pack name, here mypack. The import package is geonemo.packs.mypack.

Steps#

  1. Create the folder. Each pack folder is its own import package.

    packs/mypack/
      __init__.py
      part.py
      pyproject.toml
      LICENSE
      NOTICE
      tests/
      docs/index.md
    
  2. Write part.py. Core calls register(registry) once. Import heavy modules inside the factory functions, so loading the part stays cheap.

    def _router():
        from .api import router
        return router
    
    def _settings():
        from .settings import MyPackSettings
        return MyPackSettings
    
    def register(registry) -> None:
        registry.add_settings(_settings)
        registry.add_router(80, _router)
    
  3. Declare the distribution in pyproject.toml. Copy packs/nemotron/pyproject.toml: depend on geonemo-server, map the folder with package-dir = { "geonemo.packs.mypack" = "." }, and list every package. ci/server_packages.py prints the expected list, and the root tests/test_packaging.py fails when they differ.

  4. Add the pack to the workspace members in the root pyproject.toml, to the [[scan]] and [[rule]] tables of ci/boundaries/tiers.toml (tier pack:mypack), and to testpaths in the root pyproject.toml. Run uv lock to refresh uv.lock.

  5. List the part in a parts list, for example deploy/development/parts.yaml:

    parts:
      - name: mypack
        module: geonemo.packs.mypack.part
        skills: packs/mypack/skills
    

    skills is optional. services limits the part to some API processes. Every deploy/*/parts.yaml is checked by ci/check_parts.py.

  6. Run the checks.

    python3 ci/import_rules.py
    python3 ci/check_parts.py
    python -m pytest packs/mypack/tests
    
  7. Publish the pack’s documentation: create packs/mypack/docs/index.md. The site copies the folder to /_parts/ and lists it on the optional parts page. Folders named changes and internal are not published.

What register can add#

All methods are on PartRegistry in core/parts.py.

Method

Adds

add_router(order, factory, service=)

An API router. service is toolkit, agent-service or monitoring

add_settings(factory)

Fields on the composed Settings, with YAML_KEYS for the config file

on_runtime(stage, hook)

A hook run while the runtime is built. Stages are RUNTIME_STAGES

add_runtime_slots(*names, close=)

Runtime attributes the part owns, closed at shutdown

add_cli(hook)

Commands on the geonemo-services admin CLI

add_capability(order, factory)

An entry in API discovery

add_service_probes(order, provider)

Readiness probes

add_gkb_extensions(directory)

GKB extension schemas. See Add a GKB extension schema

add_extension_validator(namespaces, validate)

Checks beyond the JSON schema

add_embedding_adapter(name, factory)

A request adapter for embedding profiles

add_retrieval_model(name, module, settings=)

A model in shared retrieval. See Add an embedding model

add_input_type(name, factory)

An encoder input type, such as sentinel2 chips

add_route_scope(prefixes, scope)

A required scope for changing requests

add_workload_routes, add_workload_check

Tools that let an agent credential call the part’s routes

add_operation_states, add_publication_check

How durable agent tasks wait on and publish the part’s work

add_middleware(factory, **options)

ASGI middleware

The remaining methods (add_gkb_operations, add_media_headers, add_run_store, add_product_resolver, add_annotation_reader, add_control_check) are described in their docstrings.

Parts also reach the server through files, not methods:

Addition

How

MCP tools

A family module. See Add an MCP tool family

Skills

The skills: folder in the parts list

Compose services

packs/mypack/compose/compose.yml, added by deploy/compose_files.py for each listed part

Providers

Bound in the parts list, not by a part

Result#

geonemo-services lists the pack’s commands, /v1/discovery lists its capability, and the generated reference pages (Parts and providers, Server settings) include it once it is in a parts list. After adding routes, regenerate the OpenAPI contract. See Regenerate contracts.