MCP Toolkit Rust
sednalabs/mcp-toolkit-rs
Blocos de construção reutilizáveis em Rust para servidores MCP
Ver no GitHubBiblioteca modular em Rust com componentes reutilizáveis para construir servidores e clientes do Model Context Protocol (MCP). Inclui primitivas para autenticação, HTTP, políticas, observabilidade, PostgreSQL e testes, organizadas em crates especializadas que podem ser compostas conforme necessário.
Instalação
npx convez-ai sednalabs/mcp-toolkit-rs1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
Casos de uso
- Criar servidores MCP com autenticação e políticas de segurança
- Implementar observabilidade, tracing e métricas em servidores MCP
- Validar e testar contratos de ferramentas e superfícies de autenticação
- Integrar PostgreSQL, OAuth e gerenciamento de sessões em servidores MCP
Veredito

Toolkit robusto e bem-estruturado para quem constrói servidores MCP em Rust, ainda em estágio pré-1.0 mas com documentação clara e abordagem composável. Recomendado para desenvolvedores experientes que precisam de infraestrutura sólida para MCP production-ready.
README
A tradução para o português deste README ainda está na fila.
mcp-toolkit-rs
Reusable Rust building blocks for Model Context Protocol (MCP) servers and clients.
mcp-toolkit-rs is an early public workspace for the shared substrate that
keeps Rust MCP services consistent: auth discovery, HTTP/session support,
policy primitives, tool inventory helpers, observability, process utilities,
and test harnesses. It is pre-1.0 and the crates are not published to
crates.io yet, so adopters should consume it from Git for now.
What Is Included
| Crate | Purpose |
|---|---|
mcp-toolkit | Umbrella crate with optional feature groups. |
mcp-toolkit-core | Protocol-facing helpers, notifications, and tool inventory types. |
mcp-toolkit-auth | Bearer auth, token validation, replay protection, and auth-surface helpers. |
mcp-toolkit-http | OAuth/PRM metadata helpers, device-authorization metadata, and optional streamable HTTP session support. |
mcp-toolkit-observability | Redaction, sanitization, tracing bridge, metrics facade, and optional OTel helpers. |
mcp-toolkit-policy-core | Pure policy decisions, claims helpers, route/scope checks, and SQL read-only classification. |
mcp-toolkit-policy-runtime | Runtime policy authority adapters and capability guard helpers. |
mcp-toolkit-policy-conformance | Reusable conformance harnesses for policy vectors and schemas. |
mcp-toolkit-policy-ffi | Optional dynamic policy-runtime loader. |
mcp-toolkit-policy-kernel-adapters | Compatibility adapters for exact external policy-kernel parity work. |
mcp-toolkit-postgres | PostgreSQL connection and TLS helpers. |
mcp-toolkit-process | Process and signal helpers. |
mcp-toolkit-server | Optional stdio and hosted HTTP server composition helpers. |
mcp-toolkit-testing | Tool-schema and auth-surface contract test helpers. |
mcp-toolkit-docs | Documentation and tool metadata helpers. |
mcp-toolkit-gemini | Optional process-backed Gemini CLI integration helpers. |
mcp-toolkit-gemini is intentionally API-key-only. It requires
GEMINI_API_KEY, clears inherited process environment state before launching
the Gemini CLI, and does not support browser, account, or home-directory based
Gemini CLI authentication.
Quick Start
For the complete server creation, validation, review, and release route, start
with docs/golden-path.md. For a copyable checklist that turns that route into
a repeatable implementation lane, use docs/new-server-delivery-lane.md. For
the operator-facing details that make a server easy to try and debug, use
docs/easy-server-ergonomics.md.
Add the specific crates you need from Git:
[dependencies]
mcp-toolkit-core = { git = "https://github.com/sednalabs/mcp-toolkit-rs", branch = "main" }
mcp-toolkit-http = { git = "https://github.com/sednalabs/mcp-toolkit-rs", branch = "main", features = ["session"] }
[dev-dependencies]
mcp-toolkit-testing = { git = "https://github.com/sednalabs/mcp-toolkit-rs", branch = "main" }
Or use the umbrella crate when you want one dependency with explicit feature selection:
[dependencies]
mcp-toolkit = {
git = "https://github.com/sednalabs/mcp-toolkit-rs",
branch = "main",
features = ["auth", "http", "policy", "process", "server"]
}
Commit the consumer Cargo.lock after resolution. The lockfile records the
exact toolkit SHA; manifest rev pins are only needed for special cases where a
consumer intentionally wants a long-lived frozen toolkit ref. See
docs/cargo-package-release.md for the package release and migration path.
Run the baseline checks from the repository root:
cargo fmt --all --check
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo test --workspace --all-targets --all-features
A Minimal Adoption Path
For a new Rust MCP server, start with the smallest slice that gives you a stable public surface:
- Use
mcp-toolkit-core::tool_inventoryto register the tools your server can expose. - Use
mcp-toolkit-testing::assert_tool_schema_snapshotto lock the exportedtools/listcontract. - Use
mcp-toolkit-core::openai_tool_searchwhen large OpenAI-facing MCP catalogs should publish a reusabledefer_loadingplustool_searchrequest fragment, a richer documentation/resource template, and a localallowed_toolsdiscovery envelope. - Use
mcp-toolkit-http::oauthandmcp-toolkit-auth::surfacewhen serving MCP over HTTP with OAuth discovery, Protected Resource Metadata, and device-authorization metadata for headless MCP client login. - Use
mcp-toolkit-serverwhen you want the toolkit to assemble stdio startup, local Streamable HTTP runtime pieces, host guarding, auth-surface layers, and the default MCP route bundle. - Use
mcp-toolkit-observabilityhelpers for sanitized logs, bounded labels, and optional tracing/metrics integration. - Add policy crates only when the service has an authorization, SQL read-only, or capability-guard boundary that needs reusable enforcement.
For a copyable starting point, see templates/curated-stdio-intent-server for
stdio intent tools and templates/hosted-http-auth-server for hosted HTTP with
OAuth Protected Resource Metadata, headless device-auth metadata, bearer
challenges, host guarding, schema snapshots, and contract tests.
For existing service adoption, migrate one runtime seam at a time and prove the
before/after contract through GitHub-hosted validation. The checklist in
docs/golden-path.md defines the expected handoff, review gate, and release
evidence.
Example: Lock A Tool Schema
use mcp_toolkit_testing::assert_tool_schema_snapshot;
use serde_json::json;
#[test]
fn tool_schema_snapshot_matches_exported_tools() {
let tools = vec![
json!({
"name": "example.search",
"description": "Search the configured source index",
"inputSchema": {
"type": "object",
"properties": {
"query": { "type": "string" }
},
"required": ["query"]
}
}),
];
assert_tool_schema_snapshot("spec/tool_schema_snapshot.v1.json", &tools);
}
Run this test in strict mode by default. To intentionally rebaseline snapshots,
set MCP_TOOLKIT_UPDATE_TOOL_SNAPSHOTS=1 for the test run and review the JSON
diff before merging.
Security And Release Posture
This repository is public-facing and uses a conservative GitHub Actions posture:
- workflow tokens are read-only by default;
- external fork pull requests require maintainer approval before workflows run;
- workflows avoid
pull_request_target; - third-party Actions are pinned to immutable commits;
- CodeQL analyzes GitHub Actions workflow policy;
- Cobertura coverage reports upload to GitHub Code Quality for pull requests;
- changes to
mainshould land through pull requests with required hosted checks, except for documented urgent security remediation.
Dependency policy is documented in docs/dependency-governance.md.
Security reporting guidance is documented in SECURITY.md.
Documentation
docs/auth-surface.mdexplains the OAuth, Protected Resource Metadata, and bearer-enforcement contract.docs/contract-testing.mdcovers reusable hard-path test helpers for stdio, auth metadata, bearer challenges, host guards, and snapshots.docs/cargo-package-release.mdcovers the public Git dependency contract, package release approval gate, and eventual crates.io migration path.docs/deferred-loading-and-tool-search.mdcovers lightweight tool discovery and deferred loading.docs/dependency-governance.mddefines dependency selection and update gates.docs/easy-server-ergonomics.mdlists the first-run, auth-status, discovery-tool, and diagnostic patterns that make toolkit-built servers easy to try.docs/ecosystem-map.mdexplains where toolkit, reference architecture, and service-specific code should live.docs/golden-path.mdis the end-to-end path for creating, validating, reviewing, releasing, and adopting toolkit-built MCP servers.docs/instant-server-generation.mdrecords the direction for generating secure MCP server scaffolds from OpenAPI, JSON Schema, docs, and examples.docs/new-server-delivery-lane.mddefines the seven-gate lane for rapid, reviewable MCP server creation from toolkit templates through proven promotion.docs/observability-evolution.mdanddocs/observability-rollout.mdcover observability adapters and adoption.docs/public-landing-policy.mddefines the public repository landing, hosted-check, and break-glass remediation policy.docs/security-profiles.mddescribes auth profile selection.docs/server-composition-layer.mddescribes the optional stdio and HTTP server composition layer.docs/starter-templates.mdexplains the maintained server starter templates and their validation contracts.docs/sql-policy-kernel-conformance.mddocuments SQL policy vector conformance.docs/tool-inventory-migration.mdanddocs/tool-schema-snapshots.mdcover exported tool-surface management.docs/toolkit-boundary.mddefines what belongs in this public toolkit.
Status
The workspace is useful today, but it is still pre-1.0. Expect APIs to tighten
as the public surface settles. Crates are marked publish = false until the
crate-level release process is ready; consumers should use public Git
dependencies plus committed lockfiles until crates are published.
License
Licensed under the Apache License, Version 2.0. See LICENSE.