Skip to main content

mci-py

MCI Python Adapter - A lightweight, Python adapter for the Model Context Interface (MCI), enabling AI agents to execute tools defined in JSON or YAML schemas.

The Model Context Interface (MCI) is an open-source, platform-agnostic system for defining and executing AI agent tools through standardized schemas.

Using the basic features that are supported in every programming language, MCI makes it easier to define collections of AI Tools, filter, execute and maintain. Making it a strong alternative or supplement of MCP, which lives right in your project repo and fits in single JSON or YAML file. (Check example.mci.json or example.mci.yaml & example.py)

The mci-py Python adapter allows you to load tool definitions from JSON or YAML files and execute them with full control over authentication, templating, and error handling.


Features

  • 🚀 Simple API - Load and execute tools with just a few lines of Python code
  • 📝 Schema-Based - Define tools declaratively and statically in JSON or YAML files
  • 🔄 Multiple Execution Types - Support for HTTP, CLI, File, and Text execution
  • ✔️ Easy to build - Share MCI Schema reference and documentation of any REST API or CLI application to LLM to build your favorite tools in minute
  • 🔐 Built-in Authentication - API Key, Bearer Token, Basic Auth, and OAuth2 support
  • 🔁 Easy to share - All you need to move your toolset to another project, or share it to the world is a single JSON or YAML file.
  • 🎯 Template Engine - Dynamic value substitution for environment variables and properties, as well as advanced templating directives like "@if", "@foreach", etc. to support complex prompting.
  • 🔒 Secure by design - All you need is adapter and schema file, which is easy to review, even by an LLM, compared to the whole servers. No more third-party code or servers accessing your data.
  • 💔 Flexible separation - You can have one ".mci.json" file for whole project and filter tools out, or you can have 1 file per agent to include whole toolset of agent, or you can have 1 file per API wrapped, you can even have 10 files from different authors and use only 1 tool from each - you can do anything: it doesn't matter, it's not 10 MCP servers to initialize, it's just 10 files in your repo 🤷
  • 🎨 Type Safe - Full type hints and Pydantic validation
  • 🧪 Well Tested - 92%+ test coverage with comprehensive test suite
  • ✅ Schema Validation Mode - Validate schemas without loading toolsets or MCP servers, perfect for CI/CD and development tools

Planned

  • Switch template engine - Now mci-py have built-in basic template engine supporting variables, @if, @for & @foreach blocks. We are planning to add implement Jinja for more robust templating options and update JSON schema to define template engine
  • Include - Add @include("path/to/file.md") directive to simplify reusing the prompt parts

Usage example

from mcipy import MCIClient

# Initialize with your JSON schema file
client = MCIClient(
    schema_file_path="my-tools.mci.json",
    env_vars={
        "API_KEY": "your-secret-key",
    }
)

# Or with YAML schema file
client = MCIClient(
    schema_file_path="my-tools.mci.yaml",
    env_vars={
        "API_KEY": "your-secret-key",
    }
)

# Get all tool objects
tools = client.tools()

# Execute the tool with properties
result = client.execute(
    tool_name="greet_user",
    properties={"username": "Alice"}
)

# Validating mode: Validate schema without env vars or side effects
# Perfect for CI/CD pipelines and development tools
validator = MCIClient(
    schema_file_path="my-tools.mci.json",
    validating=True  # No env vars needed!
)
print(f"Schema is valid with {len(validator.list_tools())} tools")

Documentation


Examples

Explore the examples directory for comprehensive demonstrations:


Support

Need help or have questions?


Contribution

We welcome contributions! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes following our coding standards
  4. Run tests and linting (make test && make lint)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Development Setup

To quickly set up your development environment, run:

./setup_env.sh

This will install uv, Python, and all project dependencies automatically.

Test Coverage

Run make coverage for coverage report

Project Docs

For how to install uv and Python, see installation.md.

For development workflows, see development.md.

For instructions on publishing to PyPI, see publishing.md.


Donation

This project is not backed or funded in any way. It was started by an individual developer and is maintained by the community. If you find this project useful, you can help in several ways:

  • ⭐ Star the repository to show your support
  • 🐛 Report bugs and suggest features
  • 💻 Contribute code, documentation, or examples
  • 📢 Spread the word and share the project
  • 💝 Consider a donation to support ongoing development

Any kind of help is greatly appreciated! 🙏


Credits

Metadata

Release files for mci-py 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mci-py 1.2
File Size Uploaded Provenance Actions
mci_py-1.2.tar.gz 272.3 kB Without provenance Details for mci_py-1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mci-py 1.2
File Interpreter ABI Platform Actions
mci_py-1.2-py3-none-any.whl Python 3 none any Details for mci_py-1.2-py3-none-any.whl

Total release size: 320.9 kB

Release files / mci_py-1.2.tar.gz

Download URL mci_py-1.2.tar.gz
Size 272.3 kB
Tags Source
SHA-256 checksum
How to use checksums
23e655db7febd6ab77dcd2e9141aaa60fbfaba32de2b0b4a6515619da91b5b6d
BLAKE2b-256 checksum
How to use checksums
6c2eb839d6718785e4e872fdb97661544dde14925e75895372b0e459366f6ace
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.13

Release files / mci_py-1.2-py3-none-any.whl

Download URL mci_py-1.2-py3-none-any.whl
Size 48.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
851643d9ae306bb938044b057b44d7b6063381b901ad8c18bb84bb09f2dfc518
BLAKE2b-256 checksum
How to use checksums
6d44f1f9266750038c5a5ee1218fb0df41cc75dd8dd049ff6e4fa00e5de0c625
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.13

Security for mci-py 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page