convez.ai
MCP ServerIntegração & APIsAvançado
sednalabs

MCP Toolkit Rust

sednalabs/mcp-toolkit-rs

Blocos de construção reutilizáveis em Rust para servidores MCP

Ver no GitHub
InicialPluginScore · de 0 a 100

Biblioteca 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-rs

1 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

Estrelas
1
Forks
0
Acompanhando
0
Saúde
62%
Último commit
há 3 dias
Versão
—
Issues abertas
11
Contribuidores
1

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

CratePurpose
mcp-toolkitUmbrella crate with optional feature groups.
mcp-toolkit-coreProtocol-facing helpers, notifications, and tool inventory types.
mcp-toolkit-authBearer auth, token validation, replay protection, and auth-surface helpers.
mcp-toolkit-httpOAuth/PRM metadata helpers, device-authorization metadata, and optional streamable HTTP session support.
mcp-toolkit-observabilityRedaction, sanitization, tracing bridge, metrics facade, and optional OTel helpers.
mcp-toolkit-policy-corePure policy decisions, claims helpers, route/scope checks, and SQL read-only classification.
mcp-toolkit-policy-runtimeRuntime policy authority adapters and capability guard helpers.
mcp-toolkit-policy-conformanceReusable conformance harnesses for policy vectors and schemas.
mcp-toolkit-policy-ffiOptional dynamic policy-runtime loader.
mcp-toolkit-policy-kernel-adaptersCompatibility adapters for exact external policy-kernel parity work.
mcp-toolkit-postgresPostgreSQL connection and TLS helpers.
mcp-toolkit-processProcess and signal helpers.
mcp-toolkit-serverOptional stdio and hosted HTTP server composition helpers.
mcp-toolkit-testingTool-schema and auth-surface contract test helpers.
mcp-toolkit-docsDocumentation and tool metadata helpers.
mcp-toolkit-geminiOptional 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:

  1. Use mcp-toolkit-core::tool_inventory to register the tools your server can expose.
  2. Use mcp-toolkit-testing::assert_tool_schema_snapshot to lock the exported tools/list contract.
  3. Use mcp-toolkit-core::openai_tool_search when large OpenAI-facing MCP catalogs should publish a reusable defer_loading plus tool_search request fragment, a richer documentation/resource template, and a local allowed_tools discovery envelope.
  4. Use mcp-toolkit-http::oauth and mcp-toolkit-auth::surface when serving MCP over HTTP with OAuth discovery, Protected Resource Metadata, and device-authorization metadata for headless MCP client login.
  5. Use mcp-toolkit-server when you want the toolkit to assemble stdio startup, local Streamable HTTP runtime pieces, host guarding, auth-surface layers, and the default MCP route bundle.
  6. Use mcp-toolkit-observability helpers for sanitized logs, bounded labels, and optional tracing/metrics integration.
  7. 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 main should 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.md explains the OAuth, Protected Resource Metadata, and bearer-enforcement contract.
  • docs/contract-testing.md covers reusable hard-path test helpers for stdio, auth metadata, bearer challenges, host guards, and snapshots.
  • docs/cargo-package-release.md covers the public Git dependency contract, package release approval gate, and eventual crates.io migration path.
  • docs/deferred-loading-and-tool-search.md covers lightweight tool discovery and deferred loading.
  • docs/dependency-governance.md defines dependency selection and update gates.
  • docs/easy-server-ergonomics.md lists the first-run, auth-status, discovery-tool, and diagnostic patterns that make toolkit-built servers easy to try.
  • docs/ecosystem-map.md explains where toolkit, reference architecture, and service-specific code should live.
  • docs/golden-path.md is the end-to-end path for creating, validating, reviewing, releasing, and adopting toolkit-built MCP servers.
  • docs/instant-server-generation.md records the direction for generating secure MCP server scaffolds from OpenAPI, JSON Schema, docs, and examples.
  • docs/new-server-delivery-lane.md defines the seven-gate lane for rapid, reviewable MCP server creation from toolkit templates through proven promotion.
  • docs/observability-evolution.md and docs/observability-rollout.md cover observability adapters and adoption.
  • docs/public-landing-policy.md defines the public repository landing, hosted-check, and break-glass remediation policy.
  • docs/security-profiles.md describes auth profile selection.
  • docs/server-composition-layer.md describes the optional stdio and HTTP server composition layer.
  • docs/starter-templates.md explains the maintained server starter templates and their validation contracts.
  • docs/sql-policy-kernel-conformance.md documents SQL policy vector conformance.
  • docs/tool-inventory-migration.md and docs/tool-schema-snapshots.md cover exported tool-surface management.
  • docs/toolkit-boundary.md defines 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.

Ver o original no GitHub

Bom para

Relacionados