MCI Structure
This document explains the structural organization of MCI projects, including entry files, toolsets, MCP server caching, and basic templating patterns.Entry Files
MCI projects start with one or more entry files located in the root of your project directory. These are the main schema files that define your tool collections.Single Entry File
The simplest structure uses a single entry file:mci.json
Multiple Entry Files
You can have multiple entry files, each creating a specific set of tools for different purposes:- Each entry file is independent and creates its own set of tools
- Entry files can share toolsets from the
./mcidirectory - Use multiple entry files to organize tools by environment, team, or purpose
- No limit on the number of entry files (1, 3, 10, or more)
- Each entry file must be loaded separately by the client; multiple entry files are not automatically merged and each requires its own MCIClient instance.
Automatic .env File Loading
MCI automatically loads environment variables from.env and .env.mci files when loading your MCI schema. This provides a convenient way to manage environment-specific configuration without manually setting variables.
Automatic Detection:
- When you run any MCI command (
run,list,validate, etc.), MCI looks for environment files in:- The project root directory (same location as your
mci.jsonormci.yaml) - The
./mcidirectory
- The project root directory (same location as your
- MCI prioritizes
.env.mcifiles (MCI-specific configs) over.envfiles (general configs) - Important: When
.env.mcifiles exist,.envfiles are not loaded at all - This allows you to keep MCI-specific environment variables separate from general project variables
- If
.env.mcifiles exist: Only.env.mcifiles are loaded./mci/.env.mci- Library MCI-specific configs- Project root
.env.mci- Project MCI-specific configs (higher priority)
- If no
.env.mcifiles exist:.envfiles are loaded instead./mci/.env- Library general defaults- Project root
.env- Project-level configs (higher priority)
- Then: System environment variables and explicit env_vars override all file-based configs
- File-based configs (
.env.mcifiles if they exist, otherwise.envfiles)- From
./mci/directory first - Then from project root
- From
- System environment variables (set via
exportor shell config) - Environment variables passed via CLI or code (highest priority)
- .env files are completely optional - MCI works fine without them
- No error if .env files are missing
- Use
.env.mcifor MCI-specific configurations to keep them completely separate from general project configs - When
.env.mciexists,.envis ignored (not merged) - You can disable auto-loading by setting
auto_load_dotenv=Falsewhen using the MCI library programmatically - .env files should NOT be committed to version control if they contain secrets
Toolsets Directory
Toolsets are stored in the./mci directory by default. This can be customized using the libraryDir field.
Default Structure
Custom Library Directory
You can use a different directory name:Nested Toolset Organization
Organize toolsets in subdirectories:MCP Tools Cache
When you register MCP servers in your schema, MCI automatically caches the tools in a specialmcp subdirectory within your toolsets directory.
Cache Location
How It Works
- Register MCP Server in your entry file:
-
First Load: MCI connects to the MCP server, fetches all tools, and saves them to
./mci/mcp/filesystem.mci.json - Subsequent Loads: MCI uses the cached file instead of connecting to the server (much faster)
-
Cache File Example (
./mci/mcp/filesystem.mci.json):
Cache Management
Expiration: Caches expire after a configurable number of days (default: 30):.gitignore:
Basic Templating
MCI supports templating in all schema files using the{{}} syntax. This allows dynamic values from environment variables and provides default fallbacks.
Environment Variable Templating
Syntax:{{env.VARIABLE_NAME}}
Default Values with Pipe Operator
Syntax:{{env.VARIABLE_NAME|'default_value'}}
The pipe operator (|) allows you to specify a default value if the environment variable is not set:
{{env.DB_HOST|'localhost'}}→"localhost"{{env.DB_PORT|'5432'}}→"5432"{{env.DB_USER|'postgres'}}→"postgres"
{{env.DB_HOST|'localhost'}}→"production.db.example.com"{{env.DB_PORT|'5432'}}→"3306"
Note: This allows any amount of vars (but keep it under 5, please): {{env.DB_HOST|env.EXTERNAL_DB_HOST|'localhost'}}
MCI File Templating Examples
Example 1: API Configuration with Defaults
Example 2: CLI Tools with Environment Defaults
Example 3: MCP Server with Template Defaults
Example 4: Toolset Reference with Filtering
Template Usage in Different Contexts
1. Entry Files - Use templates in the main schema:libraryDir or top-level config, but can use templates in tool definitions:
Best Practices
1. Use Descriptive Entry File Names
2. Organize Toolsets by Domain
3. Use Environment Variables for Secrets
4. Provide Sensible Defaults
5. Document Your Entry Files
Summary
- Entry Files: Main schema files in your project root that define tool collections
- Multiple Entry Files: Use as many as needed for different environments or purposes
- Toolsets Directory: Default is
./mci, customizable vialibraryDir - MCP Cache: Auto-generated in
./mci/mcp/when MCP servers are registered - Templating: Use
{{env.VAR}}for environment variables,{{env.VAR|default}}for defaults - Organization: Group toolsets by domain, use descriptive names, and document your schemas
