Loading Jira metadata at runtime
When you build an MCP server (or any tool surface) around the
devboy-jira crate, the JiraSchemaEnricher needs a
JiraMetadata cache to turn customFields / priority /
components / linkType from raw customfield_* ids and free
strings into typed parameters the LLM can pick from.
For downstream consumers who don't already have metadata loaded
out-of-band, JiraClient::load_default_metadata handles project
discovery and per-project metadata fetches in one call. You pick a
strategy, the method does the round-trips, and you feed the result
straight into the enricher.
Strategies
MAX_ENRICHMENT_PROJECTS is currently 30. Beyond that the schema
gets fat enough to cost real tokens at every tools/list, and
agent budgets erode. The cap is enforced at two layers:
load_default_metadatahonours it per the table above.- The schema enricher walks the first 30 projects (sorted by
project key for determinism across reloads) when building both
the flat customfield union and the per-name conflict groups.
Both code paths emit a
tracing::warn!when the cache carries more than 30 projects. Selecting the right 30 is the caller's responsibility — see the strategies above.
Example
After this, tools/list responses for create_issue /
update_issue will surface:
epicKey,sprintId,epicNametyped aliases for the well-known agile customfields (when present on the instance).cf_<sanitized_name>slots for every other customfield in the union.- An
anyOfschema when the same display name resolves to different shapes across projects (see Consuming tool schemas for the wire shape).
Caching the metadata
load_default_metadata doesn't memoise the result — calling it
twice fetches twice. If your runtime hydrates metadata on a
schedule (e.g. once per session, or every few minutes), wrap the
call in your own cache. The output of load_default_metadata is
Clone + Serialize, so storing it in an Arc<JiraMetadata> or
serialising it to disk is straightforward.
See also
- Consuming tool schemas — how
downstream consumers read the enricher's output via
base_tool_definitions()and JSON Schema. - Tool reference — the static catalogue, unenriched.