{"id":44762699,"url":"https://github.com/wspringer/highs-mcp","last_synced_at":"2026-02-16T03:18:19.160Z","repository":{"id":297221633,"uuid":"994763108","full_name":"wspringer/highs-mcp","owner":"wspringer","description":"MCP tool to solve optimization problems using HiGHS","archived":false,"fork":false,"pushed_at":"2025-06-18T12:55:42.000Z","size":200,"stargazers_count":12,"open_issues_count":8,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-25T13:16:10.995Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wspringer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-02T12:51:07.000Z","updated_at":"2025-08-13T16:04:57.000Z","dependencies_parsed_at":"2025-06-08T05:45:19.518Z","dependency_job_id":null,"html_url":"https://github.com/wspringer/highs-mcp","commit_stats":null,"previous_names":["wspringer/highs-mcp"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/wspringer/highs-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wspringer%2Fhighs-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wspringer%2Fhighs-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wspringer%2Fhighs-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wspringer%2Fhighs-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wspringer","download_url":"https://codeload.github.com/wspringer/highs-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wspringer%2Fhighs-mcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29499612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T02:07:14.481Z","status":"online","status_checked_at":"2026-02-16T02:03:22.852Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-16T03:18:18.476Z","updated_at":"2026-02-16T03:18:19.155Z","avatar_url":"https://github.com/wspringer.png","language":"TypeScript","funding_links":["https://buymeacoffee.com/up8kgm1"],"categories":[],"sub_categories":[],"readme":"# HiGHS MCP Server\n\nA Model Context Protocol (MCP) server that provides linear programming (LP) and mixed-integer programming (MIP) optimization capabilities using the [HiGHS solver](https://highs.dev/).\n\n\u003ca href=\"https://buymeacoffee.com/up8kgm1\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" width=\"200\" /\u003e\n\u003c/a\u003e\n\n## Overview\n\nThis MCP server exposes the HiGHS optimization solver through a standardized interface, allowing AI assistants and other MCP clients to solve complex optimization problems including:\n\n- Linear Programming (LP) problems\n- Mixed-Integer Programming (MIP) problems\n- Quadratic Programming (QP) problems for convex objectives\n- Binary and integer variable constraints\n- Multi-objective optimization\n\n## Requirements\n\n- Node.js \u003e= 16.0.0\n\n## Installation\n\n```bash\nnpm install highs-mcp\n```\n\nOr clone and build from source:\n\n```bash\ngit clone https://github.com/wspringer/highs-mcp.git\ncd highs-mcp\nnpm install\nnpm run build\n```\n\n## Usage\n\n### As an MCP Server\n\nThe server can be run directly:\n\n```bash\nnpx highs-mcp\n```\n\nOr if built from source:\n\n```bash\nnpm start\n```\n\n### Integration with Claude\n\nTo use this tool with Claude, add it to your Claude configuration file:\n\n**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`\n**Windows**: `%APPDATA%\\Claude\\claude_desktop_config.json`\n**Linux**: `~/.config/Claude/claude_desktop_config.json`\n\n```json\n{\n  \"mcpServers\": {\n    \"highs\": {\n      \"command\": \"npx\",\n      \"args\": [\"highs-mcp\"]\n    }\n  }\n}\n```\n\nAfter adding the configuration, restart Claude to load the HiGHS optimization tool.\n\n### Integration with Other MCP Clients\n\nThe HiGHS MCP server is compatible with any MCP client. Some popular options include:\n\n- **[Claude Desktop](https://claude.ai/desktop)**: Anthropic's AI assistant with native MCP support\n- **[MCP CLI](https://github.com/modelcontextprotocol/cli)**: Command-line interface for testing MCP servers\n- **[MCP Inspector](https://github.com/modelcontextprotocol/inspector)**: Web-based tool for debugging MCP servers\n- **Custom Applications**: Any application using the [MCP SDK](https://github.com/modelcontextprotocol/sdk)\n\n## Tool API\n\nThe server provides a single tool: `optimize-mip-lp-tool`\n\n### Input Schema\n\n```typescript\n{\n  problem: {\n    sense: 'minimize' | 'maximize',\n    objective: {\n      linear?: number[],  // Linear coefficients (optional if quadratic is provided)\n      quadratic?: {       // Quadratic terms for convex QP (optional)\n        // Dense format:\n        dense?: number[][]  // Symmetric positive semidefinite matrix Q\n        \n        // OR Sparse format:\n        sparse?: {\n          rows: number[],     // Row indices (0-indexed)\n          cols: number[],     // Column indices (0-indexed)\n          values: number[],   // Values of Q matrix\n          shape: [number, number]  // [num_variables, num_variables]\n        }\n      }\n    },\n    variables: Array\u003c{\n      name?: string,        // Variable name (optional, defaults to x1, x2, etc.)\n      lb?: number,          // Lower bound (optional, defaults to 0)\n      ub?: number,          // Upper bound (optional, defaults to +∞, except binary gets 1)\n      type?: 'cont' | 'int' | 'bin'  // Variable type (optional, defaults to 'cont')\n    }\u003e,\n    constraints: {\n      // Dense format (for small problems):\n      dense?: number[][],  // 2D array where each row is a constraint\n      \n      // OR Sparse format (for large problems with many zeros):\n      sparse?: {\n        rows: number[],    // Row indices of non-zero coefficients (0-indexed)\n        cols: number[],    // Column indices of non-zero coefficients (0-indexed)\n        values: number[],  // Non-zero coefficient values\n        shape: [number, number]  // [num_constraints, num_variables]\n      },\n      \n      sense: Array\u003c'\u003c=' | '\u003e=' | '='\u003e,  // Constraint directions\n      rhs: number[]  // Right-hand side values\n    }\n  },\n  options?: {\n    // Solver Control\n    time_limit?: number,              // Time limit in seconds\n    presolve?: 'off' | 'choose' | 'on',\n    solver?: 'simplex' | 'choose' | 'ipm' | 'pdlp',\n    parallel?: 'off' | 'choose' | 'on',\n    threads?: number,                 // Number of threads (0=automatic)\n    random_seed?: number,             // Random seed for reproducibility\n    \n    // Tolerances\n    primal_feasibility_tolerance?: number,  // Default: 1e-7\n    dual_feasibility_tolerance?: number,    // Default: 1e-7\n    ipm_optimality_tolerance?: number,      // Default: 1e-8\n    infinite_cost?: number,                 // Default: 1e20\n    infinite_bound?: number,                // Default: 1e20\n    \n    // Simplex Options\n    simplex_strategy?: number,              // 0-4: algorithm strategy\n    simplex_scale_strategy?: number,        // 0-5: scaling strategy\n    simplex_dual_edge_weight_strategy?: number,  // -1 to 2: pricing\n    simplex_iteration_limit?: number,       // Max iterations\n    \n    // MIP Options\n    mip_detect_symmetry?: boolean,          // Detect symmetry\n    mip_max_nodes?: number,                 // Max branch-and-bound nodes\n    mip_rel_gap?: number,                   // Relative gap tolerance\n    mip_abs_gap?: number,                   // Absolute gap tolerance\n    mip_feasibility_tolerance?: number,     // MIP feasibility tolerance\n    \n    // Logging\n    output_flag?: boolean,                  // Enable solver output\n    log_to_console?: boolean,               // Console logging\n    highs_debug_level?: number,             // 0-4: debug verbosity\n    \n    // Algorithm-specific\n    ipm_iteration_limit?: number,           // IPM max iterations\n    pdlp_scaling?: boolean,                 // PDLP scaling\n    pdlp_iteration_limit?: number,          // PDLP max iterations\n    \n    // File I/O\n    write_solution_to_file?: boolean,       // Write solution to file\n    solution_file?: string,                 // Solution file path\n    write_solution_style?: number           // Solution format style\n  }\n}\n```\n\n### Output Schema\n\n```typescript\n{\n  status: 'optimal' | 'infeasible' | 'unbounded' | string,\n  objective_value: number,\n  solution: number[],         // Solution values for each variable\n  dual_solution: number[],    // Dual values for constraints\n  variable_duals: number[]    // Reduced costs for variables\n}\n```\n\n### Notes on Quadratic Programming (QP)\n\n- **Convex QP only**: The quadratic matrix Q must be positive semidefinite\n- **Continuous variables only**: Integer/binary variables are not supported with quadratic objectives (no MIQP)\n- **Format**: Objective function is: minimize c^T x + 0.5 x^T Q x\n- **Matrix specification**: When specifying Q, values should be doubled to account for the 0.5 factor\n\n## Use Cases\n\n### 1. Production Planning\n\nOptimize production schedules to maximize profit while respecting resource constraints:\n\n```javascript\n{\n  problem: {\n    sense: 'maximize',\n    objective: {\n      linear: [25, 40]  // Profit per unit\n    },\n    variables: [\n      { name: 'ProductA' },  // Product A (defaults: cont, [0, +∞))\n      { name: 'ProductB' }   // Product B (defaults: cont, [0, +∞))\n    ],\n    constraints: {\n      dense: [\n        [2, 3],  // Machine hours per unit\n        [1, 2]   // Labor hours per unit\n      ],\n      sense: ['\u003c=', '\u003c='],\n      rhs: [100, 80]  // Available machine/labor hours\n    }\n  }\n}\n```\n\n### 2. Transportation/Logistics\n\nMinimize transportation costs across a supply chain network:\n\n```javascript\n{\n  problem: {\n    sense: 'minimize',\n    objective: {\n      linear: [12.5, 14.2, 13.8, 11.9, 8.4, 9.1, 10.5, 6.2]\n    },\n    variables: [\n      { name: 'S1_W1' }, { name: 'S1_W2' }, { name: 'S2_W1' }, { name: 'S2_W2' },\n      { name: 'W1_C1' }, { name: 'W1_C2' }, { name: 'W2_C1' }, { name: 'W2_C2' }\n      // All default to: cont, [0, +∞)\n    ],\n    constraints: {\n      // Supply, flow conservation, and demand constraints (dense format)\n      dense: [\n        [1, 1, 0, 0, 0, 0, 0, 0],\n        [0, 0, 1, 1, 0, 0, 0, 0],\n        [1, 0, 1, 0, -1, -1, 0, 0],\n        [0, 1, 0, 1, 0, 0, -1, -1],\n        [0, 0, 0, 0, 1, 0, 1, 0],\n        [0, 0, 0, 0, 0, 1, 0, 1]\n      ],\n      sense: ['\u003c=', '\u003c=', '=', '=', '\u003e=', '\u003e='],\n      rhs: [50, 40, 0, 0, 30, 25]  // Supply, conservation, demand\n    }\n  }\n}\n```\n\n### 3. Portfolio Optimization\n\nOptimize investment allocation with risk constraints:\n\n```javascript\n{\n  problem: {\n    sense: 'maximize',\n    objective: {\n      linear: [0.08, 0.12, 0.10, 0.15]  // Expected returns\n    },\n    variables: [\n      { name: 'Bonds', ub: 0.4 },         // Max 40% in bonds\n      { name: 'Stocks', ub: 0.6 },        // Max 60% in stocks\n      { name: 'RealEstate', ub: 0.3 },    // Max 30% in real estate\n      { name: 'Commodities', ub: 0.2 }    // Max 20% in commodities\n      // All default to: cont, lb=0\n    ],\n    constraints: {\n      dense: [\n        [1, 1, 1, 1],           // Total allocation = 100%\n        [0.02, 0.15, 0.08, 0.20]  // Risk constraint\n      ],\n      sense: ['=', '\u003c='],\n      rhs: [1, 0.10]  // Exactly 100% allocated, max 10% risk\n    }\n  }\n}\n```\n\n### 4. Portfolio Optimization with Risk (Quadratic Programming)\n\nMinimize portfolio risk (variance) while achieving target return:\n\n```javascript\n{\n  problem: {\n    sense: 'minimize',\n    objective: {\n      // Quadratic: minimize portfolio variance (risk)\n      quadratic: {\n        dense: [  // Covariance matrix (×2 for 0.5 factor)\n          [0.2, 0.04, 0.02],\n          [0.04, 0.1, 0.04], \n          [0.02, 0.04, 0.16]\n        ]\n      }\n    },\n    variables: [\n      { name: 'Stock_A', lb: 0 },\n      { name: 'Stock_B', lb: 0 },\n      { name: 'Stock_C', lb: 0 }\n    ],\n    constraints: {\n      dense: [\n        [1, 1, 1],              // Sum of weights = 1\n        [0.1, 0.12, 0.08]       // Expected return \u003e= target\n      ],\n      sense: ['=', '\u003e='],\n      rhs: [1, 0.1]  // 100% allocation, min 10% return\n    }\n  }\n}\n```\n\n### 5. Resource Allocation\n\nOptimize resource allocation across projects with integer constraints:\n\n```javascript\n{\n  problem: {\n    sense: 'maximize',\n    objective: {\n      linear: [100, 150, 80]  // Value per project\n    },\n    variables: [\n      { name: 'ProjectA', type: 'bin' },  // Binary: select or not\n      { name: 'ProjectB', type: 'bin' },  // Binary: select or not\n      { name: 'ProjectC', type: 'bin' }   // Binary: select or not\n      // Binary defaults to [0, 1] bounds\n    ],\n    constraints: {\n      dense: [\n        [5, 8, 3],   // Resource requirements\n        [2, 3, 1]    // Time requirements\n      ],\n      sense: ['\u003c=', '\u003c='],\n      rhs: [10, 5]  // Available resources/time\n    }\n  }\n}\n```\n\n### 5. Large Sparse Problems\n\nFor large optimization problems with mostly zero coefficients, use the sparse format for better memory efficiency:\n\n```javascript\n{\n  problem: {\n    sense: 'minimize',\n    objective: {\n      linear: [1, 2, 3, 4]  // Minimize x1 + 2x2 + 3x3 + 4x4\n    },\n    variables: [\n      {}, {}, {}, {}  // All default to: cont, [0, +∞)\n    ],\n    constraints: {\n      // Sparse format: only specify non-zero coefficients\n      sparse: {\n        rows: [0, 0, 1, 1],    // Row indices\n        cols: [0, 2, 1, 3],    // Column indices  \n        values: [1, 1, 1, 1],  // Non-zero values\n        shape: [2, 4]          // 2 constraints, 4 variables\n      },\n      // Represents: x1 + x3 \u003e= 2, x2 + x4 \u003e= 3\n      sense: ['\u003e=', '\u003e='],\n      rhs: [2, 3]\n    }\n  }\n}\n```\n\nUse sparse format when:\n- Problem has \u003e 1000 variables or constraints\n- Matrix has \u003c 10% non-zero coefficients\n- Memory efficiency is important\n\n### 6. Enhanced Solver Options\n\nFine-tune solver behavior with comprehensive HiGHS options:\n\n```javascript\n{\n  problem: {\n    sense: 'minimize',\n    objective: { linear: [1, 1] },\n    variables: [{}, {}],\n    constraints: {\n      dense: [[1, 1]],\n      sense: ['\u003e='],\n      rhs: [1]\n    }\n  },\n  options: {\n    // Algorithm Control\n    solver: 'simplex',\n    simplex_strategy: 1,                    // Dual simplex\n    simplex_dual_edge_weight_strategy: 1,   // Devex pricing\n    simplex_scale_strategy: 2,              // Equilibration scaling\n    \n    // Performance Tuning\n    parallel: 'on',\n    threads: 4,\n    simplex_iteration_limit: 10000,\n    \n    // Tolerances\n    primal_feasibility_tolerance: 1e-8,\n    dual_feasibility_tolerance: 1e-8,\n    \n    // Debugging\n    output_flag: true,\n    log_to_console: true,\n    highs_debug_level: 1,\n    \n    // MIP Control (for integer problems)\n    mip_detect_symmetry: true,\n    mip_max_nodes: 5000,\n    mip_rel_gap: 0.001\n  }\n}\n```\n\n**Key Option Categories:**\n\n- **Solver Control**: Algorithm selection, parallelization, time limits\n- **Tolerances**: Precision control for feasibility and optimality\n- **Simplex Options**: Strategy, scaling, pricing, iteration limits\n- **MIP Options**: Symmetry detection, node limits, gap tolerances\n- **Logging**: Output control, debugging levels, file output\n- **Algorithm-specific**: IPM and PDLP specialized options\n\n## Features\n\n- **High Performance**: Built on the HiGHS solver, one of the fastest open-source optimization solvers\n- **Sparse Matrix Support**: Efficient handling of large-scale problems with sparse constraint matrices\n- **Type Safety**: Full TypeScript support with Zod validation for robust error handling\n- **Compact Variable Format**: Self-contained variable specifications with smart defaults\n- **Flexible Problem Types**: Supports continuous, integer, and binary variables\n- **Multiple Solver Methods**: Choose between simplex, interior point, and other algorithms\n- **Comprehensive Output**: Returns primal solution, dual values, and reduced costs\n\n## Development\n\n### Building\n\n```bash\nnpm run build\n```\n\n### Testing\n\n```bash\nnpm test        # Run tests once\nnpm run test:watch  # Run tests in watch mode\nnpm run test:ui     # Run tests with UI\n```\n\n### Type Checking\n\n```bash\nnpx tsc --noEmit\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nMIT License - Copyright (c) 2024 Wilfred Springer\n\n## Related Projects\n\n- [HiGHS](https://highs.dev/) - The underlying optimization solver\n- [Model Context Protocol](https://modelcontextprotocol.io/) - The protocol specification\n- [MCP SDK](https://github.com/modelcontextprotocol/sdk) - SDK for building MCP servers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwspringer%2Fhighs-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwspringer%2Fhighs-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwspringer%2Fhighs-mcp/lists"}