pmcp-server-toolkit
Runtime library for config-driven MCP servers — auth, secrets, static resources/prompts, [[tools]] synthesizer, code-mode wiring.
Status: 0.1.0 — early access. Public API may evolve as DX matures across Phases 84–89.
What this crate is
pmcp-server-toolkit lifts the operational glue that pmcp-run servers share into the public SDK, so a main.rs can wire a config-driven MCP server in ~15 lines. The crate is organised as a flat module set (Phase 83 decision D-15):
auth—AuthProviderimplementations (StaticAuthProvider,BearerAuthProvider).secrets—SecretsProvidertrait + env/AWS implementations and theSecretValuenewtype that never leaks viaDebug/Display/Serialize.config—ServerConfigtypes with#[serde(deny_unknown_fields)]strictness.prompts—StaticPromptHandleradapter for static prompt templates.resources—StaticResourceHandleradapter for shipped resources.tools—synthesize_from_configbuilder turning[[tools]]config rows intoToolInfo+Arc<dyn ToolHandler>pairs.sql—SqlConnectortrait + dialect enum for backend-agnostic SQL toolkits.builder_ext—ServerBuilderExttrait addingtools_from_config/code_mode_from_configtopmcp::ServerBuilder.code_mode(featurecode-mode, default-on) — re-exports frompmcp-code-modeplus toolkit-side wiring (executor_from_config,assemble_code_mode_prompt).http(featurehttp) — OpenAPI/REST backend connector + outgoing[backend.auth]providers (HttpAuthProvider), including theoauth_passthroughrelay.error—ToolkitErrorenum and the crate-levelResult<T>alias.
oauth_passthrough trust boundary (WR-04)
The http module's oauth_passthrough [backend.auth] variant relays a client-controlled credential into an operator-controlled destination, and the trust posture must be explicit:
- The MCP client controls the forwarded token VALUE — it is the raw inbound
Authorizationheader the client sent, captured by the binary's token-capture provider and forwarded verbatim (a bare token is prefixed withBearer). - The operator controls the destination header NAME —
target_headeris fixed in the committed config; the client cannot redirect the token elsewhere.
Forwarding the client's own credential to the backend is the intended SSO-passthrough behavior — use it only when the backend should receive the MCP client's own identity. The HeaderValue::try_from control-character rejection is the protection against header injection. For a server-side service credential, use a static variant (bearer / oauth2_client_credentials) instead.
What this crate is NOT
- Not a DynamoDB toolkit. Phase 83 dropped
ddb/dynamo-configfrom the feature matrix (D-14). Usepmcp-tasksfor DynamoDB-backed task storage. - Not a generic OpenAPI / JavaScript runtime. The
openapi-code-mode,js-runtime, andmcp-code-modefeatures stay inpmcp-code-modeand are not re-exported via the toolkit (D-14). - Not WASM-ready in 0.1.0. No
wasm32-*target support yet — Phase 83 RESEARCH §"Open Questions" #3 defers WASM until Phase 84+.
Quickstart
The eventual Shape C target is a ~15-line main.rs that loads a config TOML and ships a working MCP server with synthesized tools, static prompts/resources, and code-mode wiring. Phase 86 owns the runnable example; until then the API sketch is:
use ServerBuilder;
use ;
async
Design context
For the architectural responsibility map, review notes, and locked decisions, see .claude/skills/spike-findings-rust-mcp-sdk/SKILL.md and the .planning/phases/83-toolkit-core-lift-pmcp-server-toolkit/ design log.