Welcome to the MCI Python Adapter! This guide will help you get started quickly with installing and using the MCI (Model Context Interface) adapter to define and execute tools in your Python applications.
- Python 3.11 or higher
uvpackage manager (recommended) orpip
First, install uv if you haven't already:
# macOS or Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or using Homebrew on macOS
brew install uvThen install the MCI Python adapter:
# Install from PyPI
uv pip install mci-py
# Or install with uv add (if using uv project)
uv add mci-pypip install mci-pyimport mcipy
print("MCI Python Adapter installed successfully!")Here's a complete example to get you started in under 5 minutes:
Create a file named my-tools.mci.json:
{
"schemaVersion": "1.0",
"metadata": {
"name": "My First Tools",
"description": "A simple collection of tools"
},
"tools": [
{
"name": "greet_user",
"description": "Generate a personalized greeting",
"inputSchema": {
"type": "object",
"properties": {
"username": {
"type": "string",
"description": "The user's name"
}
},
"required": ["username"]
},
"execution": {
"type": "text",
"text": "Hello, {{props.username}}! Welcome to MCI."
}
},
{
"name": "get_weather",
"description": "Fetch weather information",
"inputSchema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name"
}
},
"required": ["location"]
},
"execution": {
"type": "http",
"method": "GET",
"url": "https://api.example.com/weather",
"params": {
"location": "{{props.location}}"
}
}
}
]
}Create a file named example.py:
from mcipy import MCIClient
# Initialize the client
client = MCIClient(
schema_file_path="my-tools.mci.json",
env_vars={
"API_KEY": "your-secret-key"
}
)
# List available tools
print("Available tools:")
for tool_name in client.list_tools():
print(f" - {tool_name}")
# Execute a tool
result = client.execute(
tool_name="greet_user",
properties={"username": "Alice"}
)
# Check the result
if result.result.isError:
print(f"Error: {result.result.content[0].text}")
else:
print(f"Success: {result.result.content[0].text}")python example.pyOutput:
Available tools:
- greet_user
- get_weather
Success: Hello, Alice! Welcome to MCI.
Now that you've seen the basics, explore these resources to learn more:
- Basic Usage Guide - Detailed usage patterns and examples
- Concepts - Understand MCI core concepts:
- Structure - Project structure and organization
- Tools - Different tool execution types
- Toolsets - Organizing and sharing tools
- MCP Servers - Integrating MCP servers
- Templates - Advanced templating features
- Schema Reference - Complete schema documentation
- API Reference - Detailed API documentation
MCI supports four execution types:
- Text: Return templated text directly
- File: Read file contents with template substitution
- CLI: Execute command-line tools
- HTTP: Make HTTP API requests
Use placeholders in your configurations:
{{props.fieldName}}- Access input properties{{env.VARIABLE_NAME}}- Access environment variables
- Tools: Individual actions defined in your schema
- Toolsets: Reusable collections of tools in separate files
- MCP Servers: Integration with external MCP servers
- API Integration: Use HTTP execution to integrate REST APIs
- DevOps Automation: Use CLI execution for system tasks
- Configuration Management: Use File execution for config templates
- Reporting: Use Text execution for formatted reports
- Data Processing: Combine multiple execution types
If you encounter issues or have questions:
- Check the GitHub Issues
- Review the PRD.md for design decisions
- Examine the example.py for working code
Happy building with MCI! 🚀