Skip to content

tonythethompson/olive-model-optimization

v0.1.0MIT

Configure, validate, and troubleshoot Microsoft Olive optimization workflows for ONNX models across CPU, GPU, and NPU targets.

Olive Model Optimization

A Model Context Protocol (MCP) server that helps AI agents query, configure, and troubleshoot Microsoft Olive model optimization workflows.

Overview

This MCP server provides 32 tools for:

  • Pass Catalog & Configuration - List 92+ optimization passes, generate config templates, deep-dive into parameters
  • Strategy & Recommendations - Get quantization strategies, hardware optimization guides, tradeoff analysis
  • Troubleshooting & Diagnostics - Diagnose Olive errors against the knowledge base with actionable workarounds
  • Compatibility & Validation - Check model × pass × hardware compatibility and validate UIState configurations
  • Documentation & Reference - Semantic search across Olive documentation, generate CLI commands, get data configs
  • Job Lifecycle (Studio Integration) - Submit, monitor, cancel optimization jobs through Olive Studio

Installation

Prerequisites

  • Python 3.10+ with pip
  • Node.js and npm (for MCP integration in Kiro)

Setup

This repository uses the Agent Plugins format. Install it through a compatible plugin/Powers workflow from the repository root; plugin.json is the canonical manifest and the root mcp.json contains the MCP server configuration.

For the legacy Kiro Power workflow, POWER.md is retained as optional documentation.

Install the MCP server dependencies:

cd olive-mcp-server
python -m venv .venv
.venv\Scripts\pip install -e ".[dev]" "mcp<2"

Usage

With Kiro (Recommended)

Install this power in Kiro, then use the tools directly:

// Example: Get quantization strategy for LLM on NVIDIA GPU
const result = await get_quantization_strategy({
  model_type: "LLM",
  target_hardware: "NVIDIA RTX 4090",
  latency_budget: "<100ms",
  accuracy_threshold: "<2% drop"
});

Direct CLI Usage

# Run the MCP server
python olive-mcp-server/run.py

# Or using the console script
.venv\Scripts\olive-mcp-server

Tools

ToolDescription
get_olive_passesList available passes, filtered by category
get_pass_config_templateGenerate scaffold Olive workflow JSON for a pass
get_quantization_strategyRecommend a quantization approach for model + hardware
get_hardware_optimization_guideReturn a hardware-specific optimization path
get_pass_chainValidate and explain an ordered pass chain
troubleshoot_olive_errorDiagnose Olive or Studio errors
diagnose_errorDiagnose an error using the Olive and Studio knowledge bases
get_error_frequency_summarySummarize recurring troubleshooting errors
get_model_compatibilityCheck Olive support for a model/framework combo
get_cli_commandGenerate a ready-to-run Olive CLI command
get_data_config_templateGenerate data configuration templates for calibration and evaluation
search_olive_documentationSearch across the local knowledge base and live docs
get_pass_parametersDeep-dive into a pass parameter schema
evaluate_optimization_tradeoffAnalyze quality vs. performance tradeoff
get_integration_recipeReturn full Olive recipe templates
get_context_for_pipelineReturn relevant passive context for a pipeline
validate_ui_state_recipeValidate a Studio UIState via local bridge
get_recipe_for_ui_stateGenerate complete Olive recipe from UIState
get_runtime_ep_hintsRecommend runtime execution-provider settings
record_troubleshoot_feedbackLocal aggregate thumbs feedback for KB entries
get_mcp_capabilitiesCapability state for agents
list_optimization_jobsList Studio jobs
get_optimization_jobGet status for one Studio job
get_optimization_resultsGet results/metrics from a completed job
validate_optimization_jobStudio preflight + fingerprint
submit_optimization_jobSubmit an optimization job via Studio
cancel_optimization_jobCancel a running job
plan_optimizationCreate a staged optimization plan
execute_and_observeExecute and observe an optimization plan
diagnose_and_fixDiagnose failed runs and propose fixes
compare_resultsCompare optimization results
get_model_infoInspect model metadata

Configuration

Environment Variables

VariablePurpose
OLIVE_MCP_RETRIEVAL_MODEauto (default), keyword, or semantic
OLIVE_MCP_SEMANTIC_BUDGET_MSCold semantic budget (default 8000; 0 = unlimited)
OLIVE_MCP_PRELOAD_EMBEDDINGSIf 1, warm model + indexes at startup
OLIVE_STUDIO_API_URLLoopback base URL for Studio (e.g., http://127.0.0.1:3000)

MCP Configuration

The canonical Agent Plugins configuration is the root mcp.json. It uses ${PLUGIN_ROOT} so the installed plugin can locate the unchanged internal olive-mcp-server directory on any machine.

{
  "$schema": "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json",
  "mcpServers": {
    "olive-mcp": {
      "type": "stdio",
      "command": "python",
      "args": ["run.py"],
      "cwd": "${PLUGIN_ROOT}/olive-mcp-server",
      "env": {
        "OLIVE_MCP_RETRIEVAL_MODE": "auto",
        "PYTHONPATH": "${PLUGIN_ROOT}/olive-mcp-server"
      }
    }
  }
}

Schema and Knowledge-Base Provenance

The authoritative recipe reference is the Microsoft Olive 0.13.0 schema. It requires input_model to contain type and config, so model settings are nested (for example, input_model.config.model_path). Generated Hugging Face templates use HfModel; pass entries are arrays of { "type": ..., "config": ... }; and data components use { "type": ..., "params": ... }.

The bundled passes.json, compatibility matrix, and raw integration_recipes.json are intentionally retained as historical 0.13.0 reference snapshots for compatibility guidance and troubleshooting. They are not emitted verbatim: get_integration_recipe normalizes historical handler names and valid pass/data wrappers while preserving the schema-required input_model.config envelope. They are not proof that every listed pass is available in the latest Olive release. Use the schema_source, catalog_status, and evidence fields in tool responses to distinguish current recipe output from historical catalog data.

Knowledge Base

The server includes a local knowledge base with:

  • passes.json - Pass catalog with parameters and gotchas
  • hardware_profiles.json - Hardware target profiles
  • quirks.json - Common behaviors and pitfalls
  • troubleshooting.json - Olive runtime error diagnosis rules
  • studio_troubleshooting.json - Olive Studio / builder / UI diagnosis rules
  • compatibility_matrix.json - Model compatibility matrix (evidence-backed claims)
  • integration_recipes.json - Ready-to-run Olive recipe templates

Development

Running Tests

cd olive-mcp-server
.venv\Scripts\python -m pytest tests -q

Updating the Knowledge Base

.venv\Scripts\python -m scripts.update_kb
.venv\Scripts\python -m scripts.expand_kb

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Run tests: pytest tests -q
  4. Submit a pull request

Support

For bugs, schema mismatches, or MCP connection issues, open a GitHub support issue. Please include the tool name, a minimal sanitized input, your Python version, and the MCP server logs when possible.

Privacy Policy

Read the repository Privacy Policy.

Acknowledgments