# SonarQube MCP measure tool drops periods values for New Code metrics on branches

**URL:** <https://community.sonarsource.com/t/sonarqube-mcp-measure-tool-drops-periods-values-for-new-code-metrics-on-branches/186322>\
**Category:** SonarQube MCP Server\
**Tags:** bug, sonarqube-cloud\
**Created:** [July 21, 2026, 1:07pm UTC](https://community.sonarsource.com/t/sonarqube-mcp-measure-tool-drops-periods-values-for-new-code-metrics-on-branches/186322 "2026-07-21T13:07:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yaniv\_Nahoum](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/yaniv_nahoum/32/6014_2.png) [@Yaniv\_Nahoum](https://community.sonarsource.com/u/Yaniv_Nahoum)\
**Post date:** [July 21, 2026, 1:07pm UTC](https://community.sonarsource.com/t/sonarqube-mcp-measure-tool-drops-periods-values-for-new-code-metrics-on-branches/186322/1 "2026-07-21T13:07:40Z")

</div>

### Environment

- SonarQube Cloud US
- VS Code Copilot

### Description

The SonarQube MCP `get_component_measures` tool does not expose values for New Code metrics when the SonarQube API returns those values inside the `periods` array.

This affects branch analysis, where New Code measures are represented using a period object rather than a top-level `value`.

**Project**

```plaintext
Project key: ...
Branch: master
SonarQube URL: https://sonarqube.us

```

**Requested metrics**

```plaintext
new_blocker_violations
new_critical_violations
new_major_violations
new_minor_violations

```

**Reproduction**

The raw SonarQube API returns populated New Code measures:

```bash
curl -sS \
  "https://sonarqube.us/api/measures/component?component=${PROJECT_KEY}&branch=master&metricKeys=new_blocker_violations,new_critical_violations,new_major_violations,new_minor_violations" \
  --user "${TOKEN}:" | jq

```

The response includes:

```json
{
  "component": {
    "key": "...",
    "measures": [
      {
        "metric": "new_major_violations",
        "periods": [
          {
            "index": 1,
            "value": "2",
            "bestValue": false
          }
        ]
      },
      {
        "metric": "new_minor_violations",
        "periods": [
          {
            "index": 1,
            "value": "0",
            "bestValue": true
          }
        ]
      },
      {
        "metric": "new_critical_violations",
        "periods": [
          {
            "index": 1,
            "value": "0",
            "bestValue": true
          }
        ]
      },
      {
        "metric": "new_blocker_violations",
        "periods": [
          {
            "index": 1,
            "value": "0",
            "bestValue": true
          }
        ]
      }
    ]
  }
}

```

However, the MCP tool returns the measures without their values:

```json
{
  "measures": [
    {
      "metric": "new_major_violations"
    },
    {
      "metric": "new_minor_violations"
    },
    {
      "metric": "new_critical_violations"
    },
    {
      "metric": "new_blocker_violations"
    }
  ]
}

```

The `periods` property and its contents are missing from the MCP response.

**Expected behavior**

The MCP tool should preserve the New Code period data, or normalize it into a usable value. For example:

```json
{
  "measures": [
    {
      "metric": "new_major_violations",
      "value": "2",
      "period": 1,
      "bestValue": false
    },
    {
      "metric": "new_minor_violations",
      "value": "0",
      "period": 1,
      "bestValue": true
    },
    {
      "metric": "new_critical_violations",
      "value": "0",
      "period": 1,
      "bestValue": true
    },
    {
      "metric": "new_blocker_violations",
      "value": "0",
      "period": 1,
      "bestValue": true
    }
  ]
}

```

At minimum, the adapter should read the value from the first New Code period:

```plaintext
measure.periods[index=1].value

```

It should also continue supporting metrics that use the top-level form:

```plaintext
measure.value

```

**Actual values for this reproduction**

```plaintext
new_major_violations: 2
new_minor_violations: 0
new_critical_violations: 0
new_blocker_violations: 0

```

The SonarQube UI independently confirms that the `master` branch has 2 New Code issues, both Major severity.

**Impact**

Consumers of the MCP `get_component_measures` tool cannot retrieve branch New Code violation counts. This can result in:

- Missing New Code metrics in generated reports
- Incorrect quality summaries
- False conclusions that the project has no New Code data
- Inability to distinguish branch New Code metrics from PR-specific metrics
- Incorrect downstream processing when the response contains a metric without a value

**Scope**

This issue concerns long-lived branch analysis. For branches, SonarQube returns New Code values under `measures[].periods[]`.

PR analysis may use a different response shape and should be tested separately. The fix should avoid assuming that all SonarQube measures have a top-level `value`.

**Suggested validation**

Test the MCP tool with:

```plaintext
Project: ...
Branch: master
Metrics:
- new_blocker_violations
- new_critical_violations
- new_major_violations
- new_minor_violations

```

The result should expose `new_major_violations=2` and zero for the other three metrics.

---

<div class="post-metadata">

**Author:** ![nicolas.quinquenel](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/nicolas.quinquenel/32/40740_2.png) [@nicolas.quinquenel](https://community.sonarsource.com/u/nicolas.quinquenel)\
**Post date:** [September 2, 2026, 7:31am UTC](https://community.sonarsource.com/t/sonarqube-mcp-measure-tool-drops-periods-values-for-new-code-metrics-on-branches/186322/9 "2026-09-02T07:31:28Z")

</div>

Hey @Yaniv_Nahoum, thanks for reaching out! I think this makes sense, and we will implement this in an upcoming version. Here is the [ticket](https://sonarsource.atlassian.net/browse/MCP-614) for reference.
