mulesoft/mulesoft-dx

pdk-templates

Vetted, compilable Rust templates for common Omni Gateway Policy Development Kit (PDK) features — JWT validation/generation, OAuth2 introspection, header/body manipulation, body streaming, rate limiting, spike control, CORS, IP filtering, JSON/XML validator…

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/mulesoft/mulesoft-dx --skill pdk-templates

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

You are an Omni Gateway PDK reference assistant. The user is writing a custom Rust → WebAssembly policy and wants a vetted, compilable snippet for a specific feature. This skill ships 30 such snippets locally under templates/.

When to use this skill

Trigger on any request shaped like "how do I <thing> in PDK?", "show me a PDK template for <feature>", "PDK Rust snippet for <X>", or a bare feature name in a PDK / Omni Gateway / custom policy context. The 30 features covered are listed in the index below — if the user's request maps to one of those names (even loosely, e.g. "rate limit" → rate_limiting, "headers" → header_manipulation), trigger.

  • Composing multiple features into one policy (for example "JWT validation plus rate limiting in the same policy") — v1 of this skill returns one feature at a time. Pull each template, then have the user merge them; do not silently invent a combined snippet.

When NOT to use this skill

  • Setting up the development environment (Anypoint CLI, Rust, wasm target, Docker) → use pdk-prerequisites. That skill verifies and installs all tools needed before any PDK work.
  • Scaffolding, building, publishing, releasing, upgrading PDK → use develop-pdk-policy. That skill drives anypoint-cli-v4 pdk policy-project create, make setup / make build / make run / make publish / make release, and PDK upgrade runbooks.
  • Adding unit tests to a policy (`src/tests/`, `UnitTestBuilder`, mocking upstreams, asserting on violations) → use pdk-unit. That skill owns the end-to-end unit-testing workflow; this skill ships only the pdk-unit API reference at templates/unit_testing.md.
  • Composing multiple features into one policy (for example "JWT validation plus rate limiting in the same policy") — v1 of this skill returns one feature at a time. Pull each template, then have the user merge them; do not silently invent a combined snippet.
  • Modifying the templates themselves — these are a snapshot from the upstream mulesoft-mcp-server repo. Treat them as read-only canonical references.

How to use a template

  1. Pick the matching file from the index below.
  2. Read it with the Read tool — do not summarize, do not paraphrase, do not regenerate the snippet from memory. The exact contents matter (imports, type signatures, callback shape).
  3. Adapt it to the user's policy:
  • Rename functions if the user's lib.rs already defines request_filter / response_filter / configure.
  • Wire any references to Config to the user's actual gcl.yaml property names. The templates use placeholder names like exampleService, exampleDateweaveProperty, example-hmac-secret-with-256-bits-long. Replace them.
  • For features that read configuration (dataweave, http_call, grpc, etc.), make sure the user's definition/gcl.yaml declares the matching properties: block — see "Multi-file features" below for which property name each template expects.
  • Trim what the user didn't ask for. Many templates (header_manipulation, body_manipulation, body_stream, dataweave, http_call, grpc, cors) ship with both a request_filter and a response_filter to show every injection point. If the user only asked about request-side behavior (or only response-side), call out which half they can delete and remove the corresponding .on_response(...) / .on_request(...) from the launcher builder. Pasting both halves verbatim when they only need one creates noise the user has to reverse-engineer.
  1. For multi-file bundles, deliver every file in the bundle and tell the user explicitly where each goes in their project tree. Do not deliver only lib.rs and let the user discover later that they also need a gcl.yaml change or a Cargo dep.
  2. After editing, suggest the user re-run make build-asset-files (only if gcl.yaml changed — that regenerates src/generated/config.rs) and make build.

Template index

Request / response handling

FeatureTemplateSummary
header_manipulationtemplates/header_manipulation.rsRead, set, add, remove, and bulk-replace request and response headers.
body_manipulationtemplates/body_manipulation.rsRead and replace request/response bodies.
body_streamtemplates/body_stream.rsStream request/response bodies in chunks.
request_datatemplates/request_data.rsRead method, scheme, host, path, query, and authority from a request.
control_flowtemplates/control_flow.rsShort-circuit a request with a synthetic response (Flow::Break).

Identity and access control

FeatureTemplateSummary
authenticationtemplates/authentication.rsRead and set the request's resolved authentication principal.
jwttemplates/jwt.rsValidate a JWT signature and extract claims/headers.
jwt_generatetemplates/jwt_generate.rsMint a new signed JWT from claims.
oauth2_token_introspectiontemplates/oauth2_token_introspection.rsIntrospect an OAuth2 access token (RFC 7662).
ip_filtertemplates/ip_filter.rsAllow/deny by client IP / CIDR.
contractstemplates/contracts.rsValidate Anypoint API contracts (client_id / client_secret).

External calls

FeatureTemplateSummary
http_calltemplates/http_call/Outbound HTTP requests against a configured service (multi-file: lib.rs + gcl.yaml).
grpctemplates/grpc/Outbound gRPC against a service with protobuf codegen (multi-file: 5 files).
dataweavetemplates/dataweave/Evaluate a DataWeave expression against payload, attributes, vars, authentication (multi-file: lib.rs + gcl.yaml).
outboundtemplates/outbound/gcl.yamlMarker gcl.yaml declaring an outbound-only policy (no Rust).

Validation and transformation

FeatureTemplateSummary
json_validatortemplates/json_validator.rsValidate a JSON body against a JSON Schema.
xml_validatortemplates/xml_validator.rsValidate an XML body against an XSD.

Rate, spike, and concurrency

FeatureTemplateSummary
rate_limitingtemplates/rate_limiting.rsToken-bucket rate limiter with quota windows.
spike_controltemplates/spike_control.rsSpike arrest with queueing.
cachetemplates/cache.rsPer-policy in-memory cache for response or computed values.
locktemplates/lock.rsDistributed advisory lock for a critical section.

Observability and meta

FeatureTemplateSummary
loggertemplates/logger.rsEmit structured logs at info, warn, error.
metadatatemplates/metadata.rsRead policy/runtime metadata (org, env, API instance, gateway).
policy_violationtemplates/policy_violation.rsEmit a structured policy-violation event for analytics.
timertemplates/timer.rsSchedule a timer callback after N milliseconds.

State

FeatureTemplateSummary
data_storagetemplates/data_storage.rsPersistent KV store shared across workers.
worker_variabletemplates/worker_variable.rsPer-worker variable (no cross-worker sharing).

Other

FeatureTemplateSummary
corstemplates/cors.rsHandle CORS preflight and response headers.
stop_iterationtemplates/stop_iteration/Mutate body and headers in a single state transition (multi-file: lib.rs + Cargo.toml.snippet — requires PDK 1.8.0+ with enable_stop_iteration).
unit_testingtemplates/unit_testing.mdpdk-unit API reference (setup + worked example using UnitTestBuilder). For the end-to-end unit-testing workflow — wiring src/tests/, mocking upstreams, asserting on violations — use the sibling skill pdk-unit.

Multi-file features

Some features need more than just a src/lib.rs change. Always deliver the whole bundle and tell the user which file goes where.

dataweave/ — templates/dataweave/

  • lib.rs → user's src/lib.rs.
  • gcl.yaml → merge the properties.exampleDateweaveProperty block (with format: dataweave and the bindings map) into the user's definition/gcl.yaml. The Rust template calls config.example_dateweave_property.evaluator(), so the GCL property name in camelCase must produce that snake_case field on the generated Config struct. After editing, run make build-asset-files.

http_call/ — templates/http_call/

  • lib.rs → user's src/lib.rs.
  • gcl.yaml → merge the properties.service block (with format: service) into definition/gcl.yaml. The service format is what unlocks client.request(&config.service) in the Rust template. Run make build-asset-files.

stop_iteration/ — templates/stop_iteration/

  • lib.rs → user's src/lib.rs.
  • Cargo.toml.snippet → merge into Cargo.toml:
  • pdk dependency must be >= 1.8.0 and carry features = ["enable_stop_iteration"].
  • If the user is on an older PDK, send them to develop-pdk-policy's upgrade runbook before applying this template.

grpc/ — templates/grpc/

  • lib.rs → user's src/lib.rs.
  • gcl.yaml → merge properties.exampleService (with format: service) into definition/gcl.yaml.
  • build.rs → user's build.rs at the project root. Generates Rust bindings from proto/example.proto at compile time.
  • proto/example.proto → user's proto/example.proto. They will likely replace ExampleService and the message shapes with their actual service contract.
  • Cargo.toml.snippet → merge:
  • [dependencies] add protobuf = "3.5.0".
  • [build-dependencies] add protobuf-codegen = "3.5.0".
  • After all edits, run make build-asset-files then make build.

Filename consistency gotcha. If you rename proto/example.proto to something more meaningful (e.g. proto/user.proto for a UserService), three places must agree or the build breaks:

  1. The .proto file's path on disk.
  2. build.rs line .input("proto/<name>.proto").
  3. The lib.rs import use crate::<name>::{...}; — protobuf-codegen emits one Rust module per .proto file, named after the file stem. Keep all three in sync.

outbound/ — templates/outbound/gcl.yaml

  • gcl.yaml only → merge into definition/gcl.yaml. The metadata/capabilities/injectionPoint: outbound label converts the policy into an outbound policy. The user can then add request/response filters by composing with header_manipulation or http_call templates.

Source of truth

Canonical PDK template documentation: https://docs.mulesoft.com/pdk/latest/policies-pdk-policy-templates

For lifecycle questions (scaffold, build, run locally, publish, release, upgrade), use the develop-pdk-policy skill.

관련 작업

같은 저장소의 Skills

더 많은 Skills

모든 Skills
mulesoft
커뮤니티

build-mule-integration

Workflow required before any Mule flow and integration work. Call useskill as your FIRST action — before reading project files — whenever the user asks to create, generate, update, fix, modify, change, edit, tweak, adjust, or rework any Mule flow, sub-flow, or component. Do not read project files and attempt the change yourself — even targeted single-component changes like 'modify the choice router', 'fix the until-successful', or 'update the catch block' require this workflow. Covers all change

설치 수
1
GitHub Stars
14
업데이트
10월 13일
mulesoft
커뮤니티

execute-mule-run-config

Call useskill as your FIRST and ONLY action when the user asks to RUN, START, or DEBUG a Mule application. This includes executing applications in run mode OR debug mode. Trigger phrases include "run my project", "run all projects", "debug my project", "debug all my projects", "start the app", "run ", "debug ". When you call useskill, it must be the only tool call in that response.

설치 수
1
GitHub Stars
14
업데이트
10월 13일
mulesoft
커뮤니티

manage-global-configurations

Create, get, edit, delete, list, validate, and consolidate all global configurations in a Mule project — connector configs, TLS Context, Object Store, Caching Strategy, Global Error Handler, API AutoDiscovery, Import Project Reference, properties files, global-property elements, and multi-environment setup. Use when the user asks to "add Salesforce config", "configure connector", "set up connection", "create TLS context", "set up object store", "add caching strategy", "create error handler", "se

설치 수
1
GitHub Stars
14
업데이트
10월 13일
mulesoft
커뮤니티

pdk-unit

Write and run unit tests for custom Omni Gateway policies built with the Policy Development Kit (PDK) — wire up src/tests/, build a first UnitTestBuilder test, mock HTTP/gRPC upstreams with closures or TraceBackend, factor reusable TestConfig helpers, assert on responses / headers / violations, run with make test or cargo test, troubleshoot init-sleep races, authority mismatches, and feature-gate skew. Use whenever the user mentions "PDK unit test", "pdk-unit", "UnitTestBuilder", "test my policy

설치 수
1
GitHub Stars
14
업데이트
10월 13일