Overview
MCP (Model Context Protocol) is a protocol for connecting AI models to external tools and data sources. The MCI-MCP integration allows you to:- Register MCP servers in your MCI schema (both STDIO and HTTP types)
- Auto-fetch and cache MCP toolsets to avoid repeated server connections
- Filter MCP tools using the same filtering system as MCI toolsets
- Execute MCP tools directly from the MCI client
- Apply templating to MCP server configurations (e.g., environment variables)
Registering MCP Servers
Add themcp_servers field to your MCI schema file to register MCP servers:
STDIO MCP Server Example
HTTP MCP Server Example
MCP Server Configuration
Each MCP server supports an optionalconfig object with the following fields:
expDays(default: 30): Number of days until the cached MCP toolset expires and needs to be re-fetchedfilter(optional): Filter type - one of"only","except","tags", or"withoutTags"filterValue(optional): Comma-separated list of tool names or tags to filter (required iffilteris set)
How Caching Works
When you load an MCI schema with MCP servers:-
First Load: MCI checks for a cached toolset file in
{libraryDir}/mcp/{serverName}.mci.json- If the file doesn’t exist or is expired, MCI connects to the MCP server
- Fetches all tools and builds a complete MCI-compatible toolset
- Saves the toolset to the cache file with an expiration date
- Applies filtering based on the server’s
config
-
Subsequent Loads: MCI uses the cached toolset file if it exists and hasn’t expired
- No connection to the MCP server is needed
- Much faster initialization
- Tools are ready immediately
-
Expiration: When a cached toolset expires (based on
expiresAtdate):- MCI automatically re-fetches tools from the MCP server
- Updates the cache file with fresh data and a new expiration date
Using MCP Tools
Once registered, MCP tools work just like regular MCI tools:Filtering MCP Tools
MCP tools support the same filtering as regular tools:Filter by Server Name (Toolset)
Filter by Tool Names
Filter by Tags
Schema-Level Filtering
You can also filter at the schema level in the server config:MCP Execution Type
Cached MCP tools use the"mcp" execution type in their toolset files:
- MCI connects to the registered MCP server
- Calls the tool directly using the MCP protocol
- Returns results in MCI’s standard format
Environment Variable Templating
MCP server configurations support templating for environment variables:Cache Management
Cache Location
By default, MCP toolset caches are stored in:libraryDir being "./mci", caches are at:
Manual Cache Refresh
To force a refresh of MCP toolsets:- Delete the cache files in
{libraryDir}/mcp/ - Reload your schema - MCI will re-fetch from the MCP servers
Viewing Cache Contents
Cached toolset files are standard MCI toolset files. You can inspect them:schemaVersion: Matches your main schema versionmetadata: Server name and descriptiontools: All tools from the MCP server (with MCP execution type)expiresAt: ISO 8601 timestamp when cache expires
Example: Complete Integration
Here’s a complete example combining MCP servers with regular MCI tools:Troubleshooting
MCP Server Not Available
If an MCP server is not available during schema loading:- MCI will raise a
SchemaParserErrorwith details - Check that the MCP server command/URL is correct
- Ensure required environment variables are set
- For STDIO servers, verify the command is in PATH
Cache Issues
If you’re seeing stale data:- Check the
expiresAtdate in the cache file - Delete cache files to force a refresh
- Reduce
expDaysfor more frequent updates
Tool Not Found
If an MCP tool isn’t available:- Check if it was filtered out by the server config
- Verify the MCP server actually provides that tool
- Clear cache and reload to get fresh tool list
Best Practices
- Set Appropriate Expiration: Use shorter
expDaysfor frequently changing APIs, longer for stable ones - Use Filtering: Filter MCP tools to only include what you need for performance
- Environment Variables: Keep credentials in environment variables, not in schema files
- Cache in .gitignore: Add
mci/mcp/to.gitignoreto avoid committing cache files - Error Handling: Always check
result.result.isErrorwhen executing MCP tools
