Basic Usage
This guide covers the essential patterns for working with the MCI Python adapter, from client initialization to tool execution and error handling.Importing the Client
Creating Tool Schema Files
MCI supports both JSON and YAML formats for schema files. Choose the format that best suits your preferences.JSON Format
Create a file namedmy-tools.mci.json:
YAML Format
Create a file namedmy-tools.mci.yaml:
Note: MCI supports both JSON (.json) and YAML (.yaml,.yml) formats interchangeably.
Initializing the Client
Basic Initialization
With Environment Variables
Backward Compatibility
Working with Tools
Listing Tools
Get a list of all available tool names:Executing Tools
Execute a tool with properties:Filtering Tools
By Tool Names (Include Only)
By Tool Names (Exclude)
By Tags
By Toolsets
Getting Tool Schemas
Retrieve the input schema for a tool:Execution Types
MCI supports four execution types: Text, File, CLI, and HTTP. Each type is designed for different use cases.Text Execution
Return static or templated text directly. Perfect for simple messages, templates, or computed strings. Schema Example:File Execution
Read and return file contents with optional template substitution. Useful for loading configuration files, templates, or documentation. Schema Example:CLI Execution
Execute command-line programs and capture their output. Great for running system commands, scripts, or CLI tools. Schema Example:command: The command to execute (e.g., “grep”, “python”, “node”)args: Fixed arguments passed to the commandflags: Dynamic flags based on input propertiestype: "boolean": Include flag only if property is truetype: "value": Include flag with property value (e.g.,--file value)
cwd: Working directory for command executiontimeout_ms: Maximum execution time in milliseconds
HTTP Execution
Make HTTP requests to APIs with full support for authentication, headers, query parameters, and request bodies.Basic GET Request
POST Request with JSON Body
Authentication Types
API Key (Header):Python Usage Example
Advanced Features
Toolsets
Toolsets allow you to organize tools into reusable, modular collections. See the Toolsets Concept Guide for detailed information. Quick Example:Error Handling
Always check theisError property of execution results:
Multiple Clients
You can create multiple client instances for different schema files:Environment Variables
Environment variables are the recommended way to handle secrets and configuration:Security: Path Restrictions
Important Security Feature: By default, MCI restricts file and directory access to protect against arbitrary file access vulnerabilities.Default Behavior
When executing file-based tools or CLI tools with a working directory (cwd), MCI validates that all paths are within the directory containing the schema file:
Allowing Specific Directories
You can allow additional directories usingdirectoryAllowList:
Per-Tool Configuration
Override security settings for individual tools:- Tool-level settings override schema-level settings
- Relative paths are resolved relative to the schema directory
enableAnyPathsdisables all path validation - Use with extreme caution- Subdirectories are automatically allowed
