Metadata-Version: 2.4
Name: plot-vendor-mcp
Version: 0.1.0
Summary: MCP server for generating vendor performance comparison charts
Author: virtTestCLI
License: MIT
Requires-Python: >=3.10
Requires-Dist: fastmcp>=2.0
Requires-Dist: matplotlib>=3.5
Description-Content-Type: text/markdown

# plot-vendor-mcp

A [FastMCP](https://gofastmcp.com) server that wraps the `plot_vendor.py`
rendering script as a standard MCP tool. Agents can call
`generate_vendor_chart` over the MCP protocol with a JSON payload from
`virttest ktf vendor_analysis` and receive a rendered PNG (file path or
base64 data URL).

## Features

- Single tool `generate_vendor_chart` — accepts the vendor_analysis JSON
  string, optional `output_path`, and optional `title`.
- Renders normalized horizontal bar charts (per-vendor color palettes,
  spec-size shading, baseline 1.0× reference line).
- Self-contained: only depends on `fastmcp` and `matplotlib`.
- Compatible with single-instance, single-spec NvN, and multi-spec NvN
  payloads.

## Install / run locally

```bash
# from source
pip install -e .

# verify the server module loads
python -c "from plot_vendor_mcp.server import mcp; print(mcp.name)"

# run the MCP server (stdio transport)
plot-vendor-mcp
# or
python -m plot_vendor_mcp.server
```

## Run via uvx (no install)

```bash
uvx plot-vendor-mcp
```

## MCP client configuration

```json
{
  "mcpServers": {
    "plot-vendor": {
      "command": "uvx",
      "args": ["plot-vendor-mcp"]
    }
  }
}
```

## Tool: `generate_vendor_chart`

| Argument      | Type   | Description                                                                                  |
| ------------- | ------ | -------------------------------------------------------------------------------------------- |
| `data`        | string | JSON string from `virttest ktf vendor_analysis` (case_type / instances / baseline_idx / results). |
| `output_path` | string | Optional. PNG output path. When empty the tool returns a base64 data URL.                    |
| `title`       | string | Optional. Custom chart title. When empty the title is auto-generated.                        |

Returns:

- `"Chart saved to: <output_path>"` when `output_path` is set.
- `"data:image/png;base64,<...>"` otherwise.

## Example payload

```json
{
  "case_type": "cpu",
  "image_version": "CentOS 9 64bit",
  "baseline_idx": 0,
  "instances": [
    {"provider": "aliyun", "instance_type": "ecs.g9i.2xlarge", "label": "阿里云 ecs.g9i.2xlarge"},
    {"provider": "aws", "instance_type": "m8i.2xlarge", "label": "aws m8i.2xlarge"}
  ],
  "results": [
    {"scenario": "unixbench_single_2026", "result_key": "ProcessScore", "desc": "UnixBench单核", "direction": "higher", "values": [1682.5, 1500.0]},
    {"scenario": "crypto_256", "result_key": "Score", "desc": "AES-256加密", "direction": "higher", "values": [4500.0, 4200.0]}
  ]
}
```

Pipe usage (CLI to MCP client wrapper) is not provided here — the server
is intended to be invoked through MCP-aware clients (Claude Desktop,
Codex CLI, Aliyun Bailian, etc.).
