Skip to main content

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 the mcp_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 optional config object with the following fields:
  • expDays (default: 30): Number of days until the cached MCP toolset expires and needs to be re-fetched
  • filter (optional): Filter type - one of "only", "except", "tags", or "withoutTags"
  • filterValue (optional): Comma-separated list of tool names or tags to filter (required if filter is set)

How Caching Works

When you load an MCI schema with MCP servers:
  1. 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
  2. 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
  3. Expiration: When a cached toolset expires (based on expiresAt date):
    • 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:
This filters tools at registration time, so only the specified tools are loaded from the cache.

MCP Execution Type

Cached MCP tools use the "mcp" execution type in their toolset files:
When executing MCP tools:
  • 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:
With default libraryDir being "./mci", caches are at:

Manual Cache Refresh

To force a refresh of MCP toolsets:
  1. Delete the cache files in {libraryDir}/mcp/
  2. 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:
They contain:
  • schemaVersion: Matches your main schema version
  • metadata: Server name and description
  • tools: 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 SchemaParserError with 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 expiresAt date in the cache file
  • Delete cache files to force a refresh
  • Reduce expDays for 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

  1. Set Appropriate Expiration: Use shorter expDays for frequently changing APIs, longer for stable ones
  2. Use Filtering: Filter MCP tools to only include what you need for performance
  3. Environment Variables: Keep credentials in environment variables, not in schema files
  4. Cache in .gitignore: Add mci/mcp/ to .gitignore to avoid committing cache files
  5. Error Handling: Always check result.result.isError when executing MCP tools

See Also