Expand description
Core types, traits, and errors for MCP Code Execution.
This crate provides the foundational types and abstractions used across all other crates in the MCP execution workspace.
§Architecture
The core consists of:
- Strong domain types (
ServerId,ToolName) - Error hierarchy with contextual information
- Server configuration with security validation
- Command validation utilities
§Examples
use mcp_execution_core::{ServerConfig, ServerId};
// Create a server configuration
let config = ServerConfig::builder()
.command("docker".to_string())
.arg("run".to_string())
.env("LOG_LEVEL".to_string(), "debug".to_string())
.build()
.unwrap();
// Server ID
let server_id = ServerId::new("github").unwrap();Modules§
- cli
- CLI-specific types and utilities.
- metadata
- Structured sidecar metadata describing a server’s generated tools.
- untrusted
- Helpers for safely embedding untrusted MCP-server-supplied metadata into Markdown documents and LLM-facing prompts.
Structs§
- Redacted
Items - Debug-formats a list of strings, replacing every entry wholesale with
REDACTED_PLACEHOLDER. - Redacted
MapValues - Debug-formats a
String-valued map with keys visible and every value replaced byREDACTED_PLACEHOLDER. - Redacted
Url - Debug-formats a URL with userinfo credentials and query string hidden, keeping the scheme, host, and path readable.
- Server
Config - MCP server configuration with command, arguments, and environment.
- Server
Config Builder - Builder for constructing
ServerConfiginstances. - Server
Id - Server identifier (newtype over String).
- Tool
Name - Tool name identifier (newtype over String).
Enums§
- Error
- Main error type for MCP Code Execution.
- Resource
Kind - Identifies which bounded resource a
Error::ResourceLimitExceededrejection concerns. - Server
IdError - Error returned when a candidate string fails the invariant
ServerId::newenforces. - Tool
Name Error - Error returned when a candidate string fails the invariant
ToolName::newenforces. - Transport
- Transport-specific configuration for connecting to an MCP server.
Constants§
- MAX_
ARG_ COUNT - Maximum number of positional arguments accepted in a
ServerConfig(denial-of-service protection, CWE-400). - MAX_
ARG_ LEN - Maximum byte length for a single command string, argument, or environment variable name.
- MAX_
ENV_ COUNT - Maximum number of environment variables accepted in a
ServerConfig. - MAX_
ENV_ VALUE_ LEN - Maximum byte length for a single environment variable value.
- MAX_
HEADER_ COUNT - Maximum number of HTTP headers accepted for Http/Sse transport.
- MAX_
HEADER_ VALUE_ LEN - Maximum byte length for a single HTTP header value.
- MAX_
URL_ LEN - Maximum byte length for the HTTP/Sse transport
url. - REDACTED_
PLACEHOLDER - Fixed placeholder substituted for every redacted value.
Functions§
- contains_
parent_ dir - Returns
trueifpathcontains a..(parent-directory) component. - forbidden_
chars - Returns the shell metacharacters considered forbidden in a command or argument string.
- forbidden_
env_ names - Returns the exact-match forbidden environment variable names.
- forbidden_
env_ prefix - Returns the environment-variable-name prefix rejected regardless of exact match
(currently
DYLD_, macOS’s dynamic-linker variable family). - redact_
urls_ in_ text - Finds every URL-shaped token in
textand redacts each one. - sanitize_
path_ for_ error - Sanitizes a file path for inclusion in an error message, to prevent information disclosure.
- validate_
path_ segment - Validates that
segmentis a single plain path component: non-empty, and with no.., path separator, or root/prefix component. - validate_
server_ config - Validates a
ServerConfigfor safe execution, dispatching on transport type. - validate_
url_ scheme - Validates that a URL uses the
http://orhttps://scheme.
Type Aliases§
- Result
- Result type alias for MCP operations.