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 isgeonemo.packs.mypack.
Steps#
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
Write
part.py. Core callsregister(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)
Declare the distribution in
pyproject.toml. Copypacks/nemotron/pyproject.toml: depend ongeonemo-server, map the folder withpackage-dir = { "geonemo.packs.mypack" = "." }, and list every package.ci/server_packages.pyprints the expected list, and the roottests/test_packaging.pyfails when they differ.Add the pack to the workspace
membersin the rootpyproject.toml, to the[[scan]]and[[rule]]tables ofci/boundaries/tiers.toml(tierpack:mypack), and totestpathsin the rootpyproject.toml. Runuv lockto refreshuv.lock.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
skillsis optional.serviceslimits the part to some API processes. Everydeploy/*/parts.yamlis checked byci/check_parts.py.Run the checks.
python3 ci/import_rules.py python3 ci/check_parts.py python -m pytest packs/mypack/tests
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 namedchangesandinternalare not published.
What register can add#
All methods are on PartRegistry in core/parts.py.
Method |
Adds |
|---|---|
|
An API router. |
|
Fields on the composed |
|
A hook run while the runtime is built. Stages are |
|
Runtime attributes the part owns, closed at shutdown |
|
Commands on the |
|
An entry in API discovery |
|
Readiness probes |
|
GKB extension schemas. See Add a GKB extension schema |
|
Checks beyond the JSON schema |
|
A request adapter for embedding profiles |
|
A model in shared retrieval. See Add an embedding model |
|
An encoder input type, such as |
|
A required scope for changing requests |
|
Tools that let an agent credential call the part’s routes |
|
How durable agent tasks wait on and publish the part’s work |
|
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 |
Compose services |
|
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.