The MLRun MCP (Model Context Protocol) Server provides seamless integration between MLRun and MCP-compatible clients. This server exposes MLRun functionality as MCP tools, allowing you to interact with MLRun projects, runs, model endpoints, and other components through any MCP-enabled client.
- Python 3.11 or higher
- Cursor or any IDE supporting custom local / remote MCP servers
- Valid MLRun credentials (V3IO access key if using Iguazio platform)
Open Settings -> Open MCP Settings -> MCP -> New MCP Server and paste below
"mlrun-local-mcp": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://127.0.0.1:8110/mcp",
"--allow-http"
]
}NOTE: When running against an Iguazio system, replace AUTH_TOKEN value with an access token.
{
"mlrun-local-mcp-auth": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://127.0.0.1:8110/mcp",
"--allow-http",
"--header",
"Authorization: Bearer ${AUTH_TOKEN}"
],
"env": {
"AUTH_TOKEN": "<MY_ACCESS_TOKEN>"
}
}
}- SSL Certificate Errors: Set
API_SSL_VERIFY=falsefor self-signed certificates - Authentication Failures: Verify your
AUTH_TOKENandAPI_AUTH_MODEare configure correctly - Connection Timeouts: Ensure your
API_BASE_URLis accessible within your network
-
Prerequisites
- Python 3.11+
- uv for dependency management
-
Clone and Install
git clone <repository-url> cd mcp-server uv sync
-
Environment Configuration
cp .env.template .env # Edit .env with your MLRun API settings: # API_BASE_URL=https://your-mlrun-api.com # API_SSL_VERIFY=true # API_AUTH_MODE=igz3 # or "none" for no auth # API_ACTIVE_PROJECT=default
Stdio Mode (for testing):
uv run mlrun-mcp-serverHTTP Mode (for MCP clients):
uv run mlrun-mcp-server --httpsrc/mcp_server/
├── __init__.py # Package initialization
├── server.py # Main MCP server and tools
├── cli.py # Command-line interface
├── config.py # Configuration management
├── auth_providers/ # Authentication providers
│ └── iguazio.py # Iguazio auth implementation
└── mlrun_client/ # MLRun API integration
├── __init__.py
└── api_client.py # Async MLRun client wrapper
-
Define the tool in
src/mcp_server/server.py:@mcp.tool(title="Your tool name") async def your_tool_function(param: str) -> str: """Tool description.""" async with get_mlrun_api_client() as client: return await client.your_method(param)
-
Implement the API method in
src/mcp_server/mlrun_client/api_client.py:async def your_method(self, *args, **kwargs) -> str: """Your method implementation.""" return await asyncio.to_thread(self._client.your_mlrun_call, *args, **kwargs)
- Linting: Uses Ruff for code formatting and linting
- Type Hints: Full type annotations required
- Async/Await: Use async patterns for all I/O operations
- Documentation: Docstrings for all public functions
# Run linter
uvx ruff check src/ --select I --fix
uvx ruff format src/The MCP Inspector is a very useful tool for developers working with Model Context Protocol servers as it provides interactive testings, real-time debugging and eases the development workflow.
# Use STDIO transport
npx @modelcontextprotocol/inspector uv run mlrun-mcp-server