Expose product length calculation through MCP
This commit is contained in:
@@ -32,7 +32,11 @@ from pdf_report import (
|
||||
render_roll_report,
|
||||
safe_report_filename,
|
||||
)
|
||||
from roll_calculation import calculate_roll, modify_calculation
|
||||
from roll_calculation import (
|
||||
calculate_product_length,
|
||||
calculate_roll,
|
||||
modify_calculation,
|
||||
)
|
||||
from transport_calculation import analyze_transport, transport_presets
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -199,6 +203,40 @@ def create_roll_calculation():
|
||||
return jsonify(result), 200
|
||||
|
||||
|
||||
@app.route("/api/calculations/product-length", methods=["POST"])
|
||||
@auth.login_required
|
||||
def create_product_length_calculation():
|
||||
"""Calculate deterministic product length for a target roll diameter."""
|
||||
payload = request.get_json(silent=True)
|
||||
if not isinstance(payload, dict):
|
||||
result = {
|
||||
"status": "invalid_parameter",
|
||||
"invalid": [{"field": "request", "message": "JSON object required"}],
|
||||
}
|
||||
else:
|
||||
allowed = {
|
||||
"target_roll_diameter_mm",
|
||||
"core_diameter_mm",
|
||||
"thickness_mm",
|
||||
"thickness_stddev_mm",
|
||||
"width_m",
|
||||
"area_weight_g_m2",
|
||||
}
|
||||
unknown = sorted(set(payload) - allowed)
|
||||
if unknown:
|
||||
result = {
|
||||
"status": "invalid_parameter",
|
||||
"invalid": [{
|
||||
"field": "request",
|
||||
"message": "unknown request fields: " + ", ".join(unknown),
|
||||
}],
|
||||
}
|
||||
else:
|
||||
result = calculate_product_length(**payload)
|
||||
log_access(auth.current_user(), "/api/calculations/product-length", "POST")
|
||||
return jsonify(result), 200
|
||||
|
||||
|
||||
@app.route("/api/calculations/roll/modify", methods=["POST"])
|
||||
@auth.login_required
|
||||
def modify_roll_calculation():
|
||||
|
||||
Reference in New Issue
Block a user