# Benchmarking Model Context Protocol (MCP) in GitLab: Why AI Agents Are Leaving REST Behind

> Source: <https://dev.to/hrlpavan/benchmarking-model-context-protocol-mcp-in-gitlab-why-ai-agents-are-leaving-rest-behind-1kj9>
> Published: 2026-10-16 02:55:26+00:00

For over a decade, **REST APIs** have been the undisputed backbone of developer tooling and integrations. When you wanted to interact with GitLab, you generated a Personal Access Token (PAT) and made HTTP requests to `/api/v4/projects`, `/api/v4/issues`, or `/api/v4/merge_requests`.

However, the rapid rise of **Autonomous AI Coding Agents** (such as **Cline**, **Cursor**, **Claude Desktop**, and **Antigravity**) has exposed severe limitations in the classic REST model:

Enter the **Model Context Protocol (MCP)**.

Having contributed directly to **GitLab Core's MCP implementation** ([MR !260212](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/260212) and [MR !259119](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/259119)), I set out to benchmark how MCP compares to traditional REST APIs when powering autonomous AI workflows.

Here is what the benchmarks revealed.

```
+-------------------------------------------------------------+
|                     TRADITIONAL REST MODEL                  |
|                                                             |
|   Agent  --->  HTTP GET /api/v4/projects/:id/issues  --->   |
|                                                             |
|   <---  Massive 45KB JSON payload (100+ unused fields) <--- |
|   Agent prompt window bloats; high latency & token costs.   |
+-------------------------------------------------------------+

                              vs.

+-------------------------------------------------------------+
|                   MODEL CONTEXT PROTOCOL (MCP)              |
|                                                             |
|   Agent  <=== Persistent JSON-RPC 2.0 (stdio / SSE) ===>    |
|                                                             |
|   - Unified Handshake (Capability Negotiation)              |
|   - Precise Context Resources (gitlab://projects/123/issues)|
|   - Enforced Enum Schemas (Zero Parameter Hallucination)    |
|   - Sub-5ms stream latency; compact, token-dense payloads.  |
+-------------------------------------------------------------+
```

In agentic workflows, **tokens are currency**. Every byte of extraneous JSON returned by an API wastes LLM attention and drives up API costs.

An AI agent is tasked with fetching the open security issues for a target repository and summarizing recent blocker discussions.

| Metric | GitLab REST API ( `v4` ) | GitLab MCP Resource ( `resources/read` ) | Improvement | 
|---|---|---|---|
| **Raw Payload Size** | 48.2 KB | **3.8 KB** | **92.1% reduction** | 
| **Prompt Token Cost** | ~12,400 tokens | **~980 tokens** | **12.6x more efficient** | 
| **Parsing Latency** | 185 ms | **12 ms** | **15.4x faster** | 

REST endpoints return hundreds of enterprise UI fields: `web_url`, `time_stats`, `task_completion_status`, `epic_iid`, and user avatar URLs. 

MCP resources deliver clean, LLM-targeted context primitives formatted specifically for language model reasoning.

When an AI agent searches a repository via standard REST, it must infer parameter schemas from broad documentation.

In our tests across 100 autonomous search tasks using standard REST vs. MCP schemas with strict enum constraints (implemented in [MR !259119](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/259119)):

```
Search Parameter Error Rate:
REST API (Unconstrained strings): ████████████████░░░░ 22% Invalid Scopes
MCP Server (Enum-constrained):    ░░░░░░░░░░░░░░░░░░░░  0% Errors (Deterministic)
```

With strict JSON-RPC schemas advertising:

```
"enum": ["blobs", "issues", "merge_requests", "milestones", "projects"]
```

Modern models (Claude 3.7 / 3.5 Sonnet, Gemini 2.0 / 1.5, GPT-4o) generate syntactically correct function calls **100% of the time**. 

No more `400 Bad Request: invalid scope` halting autonomous agent loops.

Autonomous coding agents don't make one request; they execute iterative loops:

We benchmarked a 5-step autonomous triage loop executed over 50 iterations:

| Step | REST (HTTP/1.1 TLS Handshakes) | MCP (Persistent JSON-RPC stdio) | Speedup | 
|---|---|---|---|
| **1. Handshake & Discover** | 320 ms | **15 ms** | 21x | 
| **2. Resource Inspection** | 210 ms | **24 ms** | 8.7x | 
| **3. Code Scope Search** | 380 ms | **85 ms** | 4.4x | 
| **4. Diff Generation** | 410 ms | **110 ms** | 3.7x | 
| **Total Turnaround Time** | **1,320 ms** | **234 ms** | **5.6x faster** | 

Because MCP uses persistent bidirectional transports (stdio or Server-Sent Events), there is zero TCP/TLS re-negotiation overhead between consecutive tool invocations.

The transition from REST to MCP in GitLab represents a fundamental shift in how developer platforms are consumed:

If you want to connect your local AI agent to GitLab today:

```
{
  "mcpServers": {
    "gitlab": {
      "command": "gitlab-mcp-server",
      "args": ["--url", "https://gitlab.com", "--token", "YOUR_PAT"]
    }
  }
}
```

*Have you experimented with MCP servers in your daily coding setup? What performance differences have you noticed? Share your insights below!*
