Help agents on the GitLab MCP server pick Orbit tools
### Problem to Solve
Agents connected to the GitLab MCP server (`/api/v4/mcp`) with the `orbit` toolset rarely pick `query_graph`. With the shipped descriptions, Sonnet used it in 16 of 56 runs and Haiku in 15 of 56. For counts, rankings and joins they loop over REST list and get tools instead.
### Proposed Solution
- Give the `query_graph` description a when-to-use lead, and add a short alias note to `get_graph_schema` (issues are `WorkItem`, functions are `Definition`). Both shipped in gitlab-org/orbit/knowledge-graph!3453, with the description cap raised to 1150 bytes. The alias note is still untested.
- Ship `grep` and `context` in the `orbit` toolset. No MR yet for these. gitlab-org/gitlab!272178 adds `get_orbit_context`, a different tool that reads one issue or MR by token.
Routing text plus `grep` and `context` raised Sonnet from 16 to 38 of 56 runs with `query_graph`. The numbers are in the Agent context block.
<details>
<summary><b>Agent context</b>: extended analysis, alternatives considered, related-code dumps</summary>
##### Problem to Solve
Agents connected to the GitLab MCP server (`/api/v4/mcp`) with the `orbit` toolset rarely pick `query_graph`. With the shipped descriptions, Claude Sonnet used it in 16 of 56 runs and Haiku in 15 of 56. For counts, rankings and joins across work items and MRs, they loop over REST list and get tools instead.
We measured two changes on a local GitLab with Orbit:
| Variant | Sonnet runs with `query_graph` | Haiku runs with `query_graph` |
|---|---|---|
| Shipped descriptions | 16 / 56 | 15 / 56 |
| Routing text added to `query_graph` | 28 / 56 (p=0.033) | 22 / 56 (p=0.23, directional) |
| Routing text plus `grep` and `context` tools | 38 / 56 (p=6e-5) | 29 / 56 (p=0.012) |
Adding only `grep` and `context` raised runs that used any Orbit tool from 16 to 31 of 56 for Sonnet (p=0.007) and from 15 to 32 for Haiku (p=0.002). On a join question (open issues closed by an open MR, with the MR author), Sonnet needed 8 calls with the shipped text and 2 with routing plus grep/context. Lookups of one known object still go to `get_work_item` in every variant, which is the right choice.
##### Proposed Solution
- Give the GQL `query_graph` description a when-to-use lead (the text we tested is in the Agent context block). The shared server never shows `list_commands`, so its routing text never reaches these agents.
- The test `descriptions_are_bounded_and_carry_no_schema` caps that description at 680 bytes, and the shipped one is already 661. The tested text was about 1,111 bytes. Either raise the cap or rewrite the whole description, then measure the final text again. A shorter lead is untested.
- Ship `grep` and `context` in the `orbit` toolset (this epic).
- Add a short alias note to `get_graph_schema` (issues, epics and tasks are `WorkItem`; functions, classes and methods are `Definition`). Guessing `Issue` or `Function` in `expand_nodes` was the most common remaining error. This fix is untested.
Related: the standalone Orbit MCP has its own issue (commands exposed as real tools), and the code graph gap behind the "who calls X" question is #1219.
**Method, numbers, caveats**
**Setup.** GitLab 19.5.6-ee on a local Caproni cluster, GKG 1.5.0, a seeded project (4 users, 10 issues, 6 MRs) plus a clone of gitlab-org/cli for code questions. Claude Code 2.1.327 in Docker (`claude -p --bare --strict-mcp-config`), models claude-sonnet-5-5 and claude-haiku-5-5. One container and one proxy per run; the proxy rewrote tool descriptions per variant and served prototype `grep` and `context` tools backed by `GET /api/v4/orbit/grep` and `POST /api/v4/orbit/context`. Write tools were disallowed. Toolsets: `core,merge_requests,work_items,repository,ci,duo_agent_platform,orbit`.
**Sample.** 7 prompts (assignee with most open bugs, issues closed by open MRs, top reviewer, where a function is defined, who calls a function, one issue's title and state, count of open bugs) x 4 runs x 2 models per variant. A second agent reran the whole batch from scratch; numbers above are pooled over both batches (n=56 per variant and model), with Fisher's exact test against the shipped variant.
**Routing text tested:**
> Use for questions that span many GitLab objects or follow relationships: counts, rankings, group-bys, and joins across work items, merge requests, users, labels, pipelines, and projects, and code structure (where a symbol is defined, who calls it, what imports it). One query replaces many list or search calls made in a loop. To fetch one known object by ID or IID, use its get_ tool instead. Use it even when the user does not mention Orbit or the graph.
**Caveats.**
- The fixture is small: every variant answered the data questions correctly, because 10 issues fit in one REST page. The measured gain is fewer calls. At real scale REST loops hit pagination, so we expect correctness gains too, but did not measure them.
- The Sonnet baseline moved between batches (5 and 11 of 28), which is why we report pooled counts.
- `grep` and `context` were prototypes on the existing REST endpoints. The real tools in this epic may do better or worse.
- Better routing made the "who calls X" answer incomplete more often: the graph misses Go cross-package qualified calls (#1219), so an agent that trusts `query_graph` alone misses callers. The gain grep showed on that question came from text search, not the graph.
- One client only (Claude Code), which loaded every tool up front. A client that defers tools behind search would hide descriptions.
</details>
issue
GitLab AI Context
Project: gitlab-org/orbit/knowledge-graph
Instance: https://gitlab.com
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://gitlab.com/gitlab-org/orbit/knowledge-graph/-/raw/main/CONTRIBUTING.md — contribution guidelines
- https://gitlab.com/gitlab-org/orbit/knowledge-graph/-/raw/main/README.md — project overview and setup
- https://gitlab.com/gitlab-org/orbit/knowledge-graph/-/raw/main/AGENTS.md — AI agent instructions
Repository: https://gitlab.com/gitlab-org/orbit/knowledge-graph
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD