MCP `get_efficiency` reports allocated resources as usage, so efficiency is always 100 % and recommendations are always +20 %
Version: OpenCost 1.120.3 (opencost:1.120.3), MCP server enabled (MCP_SERVER_ENABLED=true, MCP_HTTP_PORT=8081), Prometheus-compatible backend (VictoriaMetrics).
Summary
The MCP tool get_efficiency populates its cpuCoresUsed / ramBytesUsed fields with allocated quantities rather than measured usage. Because OpenCost allocates max(request, usage), those values are identical to the request for any workload whose request exceeds its usage — i.e. nearly all of them. The reported efficiency is therefore always exactly 1.0, and the derived recommendation is always request × bufferMultiplier (default 1.2), i.e. a 20 % increase presented as a right-sizing suggestion with costSavingsPercent: -20.
The REST /allocation endpoint on the same process, over the same window, returns the correct usage — so this is not a metrics-pipeline or configuration problem.
Reproduction
Same pod, same 24 h window, namespace apps:
tools/call get_efficiency {"window":"24h","aggregate":"namespace","filter":"namespace:\"apps\""}
{
"name": "apps",
"cpuEfficiency": 1.0000000000000095,
"memoryEfficiency": 1.0000000000000009,
"cpuCoresRequested": 3.0432631495818496,
"cpuCoresUsed": 3.0432631495818785,
"ramBytesRequested": 11074386021.743427,
"ramBytesUsed": 11074386021.743437,
"recommendedCpuRequest": 3.651915779498254,
"costSavingsPercent": -20.00000000000085
}GET /allocation?window=24h&aggregate=namespace&accumulate=true — same namespace, same process:
cpuCoreUsageAverage 0.6722 cpuCoreRequestAverage 3.0426 -> 22.1 %
ramByteUsageAverage 9.43e9 ramByteRequestAverage 1.107e10 -> 85.2 %Cross-check straight against the metrics backend agrees with /allocation: 0.6853 cores used vs 3.1449 requested (21.8 %).
Note ramBytesUsed from the tool (11074386021) equals ramByteRequestAverage from /allocation exactly — the used field carries the request value, it is not a zero/absent fallback.
Cause
pkg/mcp/server.go, computeEfficiencyMetric:
// Get current usage (average over the period)
cpuCoresUsed := alloc.CPUCoreHours / hours
ramBytesUsed := alloc.RAMByteHours / hoursCPUCoreHours / RAMByteHours are allocated resource-hours. Allocation.CPUCores() in core/pkg/opencost/allocation.go is this same expression and is documented as converting CPUCoreHours into average cores — allocation, not usage.
The model already exposes the measured values and the correct ratio:
// Allocation.CPUEfficiency()
return a.CPUCoreUsageAverage / a.CPUCoreRequestAverageSuggested fix
Use the usage fields (or delegate to the existing helpers):
cpuCoresUsed := alloc.CPUCoreUsageAverage
ramBytesUsed := alloc.RAMBytesUsageAveragewhich also makes cpuEfficiency agree with Allocation.CPUEfficiency() and turns the recommendation back into usage × buffer.
Impact
Any agent using this tool for right-sizing is told to increase every request by the buffer percentage, with numbers that look computed. In our estate the correct direction was the opposite: the namespace above runs at ~22 % CPU, so it is a candidate for a cut. We have banned the tool internally and kept right-sizing on measured usage.
get_efficiency also does not appear in the MCP integration docs (which list get_allocation_costs, get_asset_costs, get_cloud_costs) — if it is not considered ready, saying so in the docs would help; it is exposed by default when the MCP server is enabled.
Source: opencost/opencost