Skip to main content
Glama

Opti-MCP: Optimization MCP Server

A Model Context Protocol (MCP) server that provides tools for solving optimization problems using Google OR-Tools. This server enables AI assistants to solve Linear Programming (LP), Integer Programming (IP), Mixed-Integer Programming (MIP), and classic combinatorial optimization problems.

Features

  • Linear Programming: Solve continuous optimization problems with linear constraints

  • Integer/Mixed-Integer Programming: Solve optimization problems with integer decision variables

  • Knapsack Problem: Solve the classic 0/1 knapsack problem efficiently

  • Built on Google OR-Tools for robust, production-grade optimization

  • Simple JSON-based interface

Related MCP server: MCP Optimizer

Prerequisites

  • Node.js 18 or higher

  • Python 3.8 or higher

  • Google OR-Tools Python library

Installation

  1. Clone this repository:

git clone <your-repo-url>
cd opti-mcp
  1. Install Node.js dependencies:

npm install
  1. Install Python dependencies:

pip install ortools
  1. Build the TypeScript code:

npm run build

Configuration

Add to your MCP settings file (e.g., claude_desktop_config.json):

{
  "mcpServers": {
    "opti-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/opti-mcp/dist/index.js"]
    }
  }
}

Available Tools

1. solve_linear_program

Solves linear programming problems where all variables are continuous.

Example: Production Planning

{
  "objective": {
    "coefficients": [3, 5],
    "maximize": true
  },
  "constraints": [
    {
      "coefficients": [1, 0],
      "upper_bound": 4
    },
    {
      "coefficients": [0, 2],
      "upper_bound": 12
    },
    {
      "coefficients": [3, 2],
      "upper_bound": 18
    }
  ],
  "variable_bounds": [[0, "Infinity"], [0, "Infinity"]]
}

This maximizes 3x₀ + 5x₁ subject to:

  • x₀ ≤ 4

  • 2x₁ ≤ 12

  • 3x₀ + 2x₁ ≤ 18

  • x₀, x₁ ≥ 0

2. solve_integer_program

Solves integer or mixed-integer programming problems.

Example: Assignment Problem

{
  "objective": {
    "coefficients": [1, 2, 3, 4],
    "maximize": false
  },
  "constraints": [
    {
      "coefficients": [1, 1, 0, 0],
      "lower_bound": 1,
      "upper_bound": 1
    },
    {
      "coefficients": [0, 0, 1, 1],
      "lower_bound": 1,
      "upper_bound": 1
    }
  ],
  "variable_bounds": [[0, 1], [0, 1], [0, 1], [0, 1]],
  "integer_variables": [0, 1, 2, 3]
}

This solves an assignment problem where variables must be binary (0 or 1).

3. solve_knapsack

Solves the 0/1 knapsack problem.

Example: Item Selection

{
  "values": [360, 83, 59, 130, 431, 67, 230, 52, 93, 125],
  "weights": [7, 0, 30, 22, 80, 94, 11, 81, 70, 64],
  "capacity": 850
}

Maximizes total value while keeping total weight ≤ capacity.

Example Problems

Diet Problem

Minimize cost while meeting nutritional requirements:

{
  "objective": {
    "coefficients": [2.5, 1.8, 3.0, 0.5],
    "maximize": false
  },
  "constraints": [
    {
      "coefficients": [10, 5, 8, 2],
      "lower_bound": 50
    },
    {
      "coefficients": [3, 8, 1, 6],
      "lower_bound": 30
    },
    {
      "coefficients": [5, 4, 7, 3],
      "lower_bound": 40
    }
  ]
}

Bin Packing

Pack items into minimum number of bins:

{
  "objective": {
    "coefficients": [1, 1, 1],
    "maximize": false
  },
  "constraints": [
    {
      "coefficients": [5, 0, 0],
      "upper_bound": 10
    },
    {
      "coefficients": [0, 7, 0],
      "upper_bound": 10
    },
    {
      "coefficients": [0, 0, 4],
      "upper_bound": 10
    }
  ],
  "integer_variables": [0, 1, 2]
}

Response Format

All solvers return a JSON response with:

{
  "status": "OPTIMAL",
  "objective_value": 34.0,
  "solution": [2.0, 6.0],
  "solve_time_ms": 15
}
  • status: OPTIMAL, INFEASIBLE, UNBOUNDED, or UNKNOWN

  • objective_value: The optimal value found (null if not optimal)

  • solution: Array of variable values (null if not optimal)

  • solve_time_ms: Time taken to solve in milliseconds

For knapsack problems:

{
  "status": "OPTIMAL",
  "total_value": 1030,
  "total_weight": 850,
  "selected_items": [0, 2, 3, 4],
  "capacity": 850
}

Development

# Watch mode for development
npm run dev

# Build for production
npm run build

# Run the server
npm start

How It Works

The MCP server:

  1. Receives optimization problems via MCP tool calls

  2. Translates them into Python scripts using OR-Tools

  3. Executes the Python scripts

  4. Returns formatted results

Limitations

  • Requires Python 3.8+ with OR-Tools installed

  • Currently uses GLOP for LP and SCIP for MIP (requires SCIP installation for best performance)

  • Large problems may take significant time to solve

License

MIT

Contributing

Contributions welcome! Please open an issue or PR.

Available Tools

3 tools
solve_integer_programC

Solve an integer programming (IP) or mixed-integer programming (MIP) problem using Google OR-Tools. Variables can be constrained to integer values.

ParametersJSON Schema
NameRequiredDescriptionDefault
objectiveYesLinear objective function coefficients
constraintsYesList of linear constraints
variable_boundsNoBounds for each variable [lower, upper]. Defaults to [0, Infinity]
integer_variablesNoIndices of variables that must be integers (0-indexed). If omitted, all variables are integers.

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden. It discloses the engine (OR-Tools) and that variables can be integer-constrained, but says nothing about optimality guarantees, time limits, infeasibility/unbounded handling, or return format — all material for a solver invocation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences, front-loaded with the core action and engine. Minor redundancy in restating 'integer values' after already saying 'integer programming', but no wasted prose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 4-parameter solver with nested objects, no annotations, and no output schema, the description is thin. It omits return shape (solution values, status, objective value) and edge-case behavior, leaving the agent without information it cannot derive from the input schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the nested objective, constraints, variable_bounds, and integer_variables parameters are already well documented in the schema. The description adds no parameter syntax or default details beyond it, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (solve) and resource (integer/mixed-integer programming problem) and names the underlying engine (Google OR-Tools). It is clear what the tool does, though it does not explicitly distinguish itself from the sibling solvers solve_linear_program and solve_knapsack.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No when-to-use guidance is given. The phrase 'integer or mixed-integer' implicitly separates it from solve_linear_program, but the agent is never told to prefer this tool over that sibling, nor when knapsack-style problems should route elsewhere.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

solve_knapsackC

Solve the classic 0/1 knapsack problem: maximize value subject to weight capacity constraint.

ParametersJSON Schema
NameRequiredDescriptionDefault
valuesYesValue of each item
weightsYesWeight of each item
capacityYesMaximum weight capacity of the knapsack

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must carry the full behavioral burden. It states the optimization goal but omits critical traits: whether the solution is exact, expected input size limits, runtime characteristics, and what the return value contains. This is insufficient for a solver tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that front-loads the problem class and the optimization objective. It contains no redundant or wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a solver with no annotations and no output schema, the description is too sparse. It fails to explain the return value (e.g., optimal value and/or selected items) and provides no behavioral context about the solving process, leaving the agent with significant gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all three parameters (values, weights, capacity) with clear meanings. The description adds no additional parameter semantics or formatting details beyond what the schema provides, making the baseline of 3 appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb+resource: 'Solve the classic 0/1 knapsack problem', and specifies the objective (maximize value) and constraint (weight capacity). It does not, however, differentiate itself from sibling solvers like solve_linear_program or solve_integer_program, leaving the agent to infer that this is the specialized tool for knapsack problems.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description offers no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, exclusions, or the sibling solvers, leaving the agent without any explicit routing cues beyond the problem name.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

solve_linear_programC

Solve a linear programming problem using Google OR-Tools. Maximizes or minimizes a linear objective function subject to linear constraints.

ParametersJSON Schema
NameRequiredDescriptionDefault
objectiveYesLinear objective function coefficients
constraintsYesList of linear constraints
variable_boundsNoBounds for each variable [lower, upper]. Defaults to [0, Infinity]

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full behavioral burden. It states the operation is a solve but says nothing about optimality guarantees, solver status on infeasible/unbounded problems, what happens with malformed or empty constraints, or runtime characteristics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tight sentences that front-load the verb and resource, with the maximize/minimize capability summarized immediately after. No filler or restatement of the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description should describe the return value (solution vector, objective value, status) but omits it entirely. For a nested, multi-parameter solver call whose result shape is non-obvious, this is a significant omission.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents objective, constraints, bounds, and default semantics (including the Infinity convention). The description adds no parameter meaning beyond that, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Solve a linear programming problem') and the solver engine plus objective direction, so the purpose is unambiguous. It does not explicitly distinguish itself from solve_integer_program or solve_knapsack, which is the only thing keeping it from a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this versus the sibling solvers (e.g., continuous variables only vs integer/knapsack), nor any mention of model-size limits or infeasibility preconditions. The agent must infer the choice from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv1.0.0
    • First observedsolve_integer_program
    • First observedsolve_knapsack
    • First observedsolve_linear_program

TDQS

B3.2/5.0

Scored across 3 tools

Disambiguation4/5

The three tools target distinct problem classes (LP, IP/MIP, knapsack), and descriptions make the distinct semantics clear. However, knapsack is technically a special case of integer programming, and LP is a relaxation of MIP, so boundaries overlap enough that a user might wonder which solver to pick.

Naming Consistency5/5

All tools follow a clean solve_<problem> verb_noun pattern: solve_linear_program, solve_integer_program, solve_knapsack. The convention is predictable and readable throughout.

Tool Count3/5

Three tools is thin for a general optimization server; it covers only LP, IP/MIP, and a single specialized problem. The count is borderline rather than well-scoped for the apparent breadth of the domain.

Completeness3/5

Core LP and MIP solving are covered, plus one special case, giving basic coverage with no dead ends for those tasks. However, common optimization operations such as constraint programming, quadratic/nonlinear programming, assignment/transportation, and scheduling are absent, leaving notable gaps.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP-ORTools integrates Google's OR-Tools constraint programming solver with Large Language Models through the MCP, enabling AI models to: Submit and validate constraint models Set model parameters Solve constraint satisfaction and optimization problems Retrieve and analyze solution
    21
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables solving linear programming (LP) and mixed-integer linear programming (MILP) optimization problems through natural language, with built-in simplex and branch-and-cut solvers plus infeasibility diagnostics. Includes optional OR-Tools fallback for larger problems and supports parsing optimization problems from natural language descriptions.
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Provides constraint satisfaction and optimization capabilities to LLMs and AI agents for scheduling, resource allocation, routing, budget optimization, and configuration problems using Google OR-Tools CP-SAT solver.
    5
    5
    Apache 2.0
  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides linear programming (LP), mixed-integer programming (MIP), and quadratic programming (QP) optimization capabilities using the HiGHS solver, enabling AI assistants to solve complex optimization problems like production planning, logistics, and portfolio optimization.
    16 npm
    18
    MIT