Skip to main content

mcp_execution_core/
lib.rs

1//! Core types, traits, and errors for MCP Code Execution.
2//!
3//! This crate provides the foundational types and abstractions used across
4//! all other crates in the MCP execution workspace.
5//!
6//! # Architecture
7//!
8//! The core consists of:
9//! - Strong domain types (`ServerId`, `ToolName`)
10//! - Error hierarchy with contextual information
11//! - Server configuration with security validation
12//! - Command validation utilities
13//!
14//! # Examples
15//!
16//! ```
17//! use mcp_execution_core::{ServerConfig, ServerId};
18//!
19//! // Create a server configuration
20//! let config = ServerConfig::builder()
21//!     .command("docker".to_string())
22//!     .arg("run".to_string())
23//!     .env("LOG_LEVEL".to_string(), "debug".to_string())
24//!     .build()
25//!     .unwrap();
26//!
27//! // Server ID
28//! let server_id = ServerId::new("github").unwrap();
29//! ```
30
31#![deny(unsafe_code)]
32#![warn(missing_docs, missing_debug_implementations)]
33
34mod command;
35mod confinement;
36mod error;
37mod path;
38mod redact;
39mod server_config;
40mod types;
41
42pub mod cli;
43pub mod metadata;
44pub mod provenance;
45pub mod untrusted;
46
47// Re-export error types
48pub use error::{Error, ResourceKind, Result};
49
50// Re-export domain types
51pub use types::{
52    MAX_SERVER_ID_LENGTH, ServerId, ServerIdError, ServerIdSlugError, ToolName, ToolNameError,
53    validate_server_id_slug,
54};
55
56// Re-export server configuration types
57pub use server_config::{ServerConfig, ServerConfigBuilder, Transport};
58
59// Re-export command validation
60pub use command::{
61    MAX_ARG_COUNT, MAX_ARG_LEN, MAX_ENV_COUNT, MAX_ENV_VALUE_LEN, MAX_HEADER_COUNT,
62    MAX_HEADER_VALUE_LEN, MAX_URL_LEN, env_name_charset_desc, env_name_charset_pattern,
63    forbidden_chars, forbidden_env_names, forbidden_env_prefix, validate_server_config,
64    validate_url_scheme,
65};
66
67// Re-export path helpers shared by confinement checks
68pub use path::{
69    contains_parent_dir, first_disallowed_identifier_char, sanitize_path_for_error,
70    validate_path_segment,
71};
72
73// Re-export the shared path-confinement walk
74pub use confinement::{
75    ConfinementError, ConfinementTarget, open_confined_write, resolve_confined_path,
76    write_confined_file,
77};
78
79// Re-export Debug-redaction helpers shared by secret-shaped fields
80pub use redact::{
81    REDACTED_PLACEHOLDER, RedactedItems, RedactedMapValues, RedactedUrl, redact_urls_in_text,
82};