Code Graph page
The Code Graph page manages the GitHub repositories and GitLab projects (gitlab.com or self-managed) the gateway indexes for coding agents. It indexes Python, TypeScript, Java, Go and C# files. Agents query those indexes through the spanway_code MCP server. From here you connect a repository, bind the credential that reads it, set up its push webhook, watch its index runs, reindex it, mirror its source permissions, and disconnect it. Open it at /ui/code-graph. It sits in the left nav in the AI Gateway group under Tools, after Search Tools. The nav shows it to proxy admins, proxy admin viewers, internal users and internal viewers. Org admins do not see it in the nav. When an admin limits the pages internal users can see (the enabled_ui_pages_internal_users UI setting), internal users only see it if it is on that list. The page has no role guard of its own. The gateway decides what each caller may read and change, and it needs the code_graph license feature.
A real-world scenario
A team admin of payments-team wants their own repository indexed without waiting on the platform team. The organization already has a bound credential, so they pick their team under Acting for team, connect the repository, paste the webhook into it, and check that the first index run succeeded.
Steps
-
Open Code Graph under Tools in the left nav, or go to
/ui/code-graph. -
Pick
payments-teamunder Acting for team. -
Click Connect repository, keep the default Source, enter
examplecorp/payments, its numeric id, the branchmain, the id of your GitHub MCP server, and pick the bound Credential. Click Connect. The page calls:curl -X POST "$SPANWAY_URL/code_graph/repos/connect" \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"full_name": "examplecorp/payments", "external_repo_id": "123456789", "default_branch": "main","credential_name": "repo-indexer", "owner_team_id": "payments-team", "user_token_server_id": "source-mcp","team_id": "payments-team"}' -
Add the Payload URL and Secret from the Repository webhook dialog to the repository's webhooks with the push event, then click Done.
-
Click Runs on the new row and wait for a
succeededbadge.
Expected result
The repository shows in the table owned by payments-team, its first run succeeds with a commit and a file count, and later pushes start new runs through the webhook.
Page header
The header reads Code Graph, "Repositories indexed for coding agents through the spanway_code MCP server."
| Control | Type | What it does |
|---|---|---|
| Acting for team | Team dropdown | Team admins pick their team to manage the repositories it owns. Leave it empty to act for your organization. Every list and action on the page uses this choice. |
| Bind credential | Button | Opens the Bind a credential dialog. Shown only when the gateway says you can manage repositories for the whole organization, and only while no team is picked. |
| Connect repository | Button | Opens the Connect a repository dialog. Shown only when you may manage repositories in the current scope. |
When you cannot manage repositories, a line reads "Changing repositories needs proxy admin, the code_graph.manage role or admin of the owner team."
GitHub App card
The card describes how the gateway reads repositories.
When a GitHub App is configured on the gateway, the card names the App, says it indexes repositories with short lived tokens limited to each repository, and shows the App's webhook URL on this gateway. Install GitHub App sends you to the App's install page. It is shown only to callers who can manage the whole organization, with no team picked. When the install returns you to this page, the page binds the new installation to your organization and shows "GitHub App installation ... is bound to ..." or the reason it failed, then removes the install parameters from the URL.
When no GitHub App is configured, the card says repositories are indexed with a GitHub token bound with Bind credential, and that the setup guide explains how to add the App.
Repositories table
| Column | Meaning |
|---|---|
| Repository | The repository as owner and name. |
| Status | A badge, see below. |
| Indexed commit | The first 12 characters of the last indexed commit, or "Not indexed yet". |
| Updates | "Webhook, last push" with the time of the last push event, or "Polling every 5 minutes" when no push has arrived. |
| Owner | The owner team id, or "Tenant" when the organization owns it. |
| Mirror permissions | A switch that keeps the code graph from showing code to people the source host would not. On, a caller only sees the repository if their own GitHub or GitLab sign-in can read it too. Off, which is the default, anyone granted the repository through a team or key sees it. Turning it on hides the repository from callers who have not signed in to the named MCP server, and from everyone while the host is unreachable. The question mark next to the column name says the same. Disabled, with the reason in a tooltip, when you cannot manage repositories. |
| Last error | The last indexing error, in red. |
| Actions | The buttons below. |
| Badge | Meaning |
|---|---|
| Ready | The index is current. |
| Indexing | An index run is pending. |
| Failed | The last index run failed. The last good index is kept. |
| Access lost | The gateway lost access to the repository. |
| Deleted | The repository is marked deleted. |
| Action | Who sees it | What it does |
|---|---|---|
| Runs | Everyone | Opens the index runs dialog. |
| Reindex | Callers the gateway allows to reindex | Queues an index run at once. A toast reads "Queued an index run for ...". |
| New webhook | Callers who can manage | Makes a new webhook secret for the repository and opens the Repository webhook dialog with it. There is no confirmation. |
| Disconnect | Callers who can manage | Opens the disconnect confirmation. |
Turning Mirror permissions on opens the Mirror GitHub permissions for ... or Mirror GitLab permissions for ... dialog. For GitHub, callers only see the repository while their own GitHub identity can read it. For GitLab, callers only see the project while their own GitLab account is an active member of it with at least the Reporter role, and any doubt, such as GitLab being unreachable, hides the project. The identity comes from the per user sign-in of the MCP server you name in GitHub MCP server id or GitLab MCP server id, which is required before Turn on is enabled. Turning the switch off saves at once. A toast confirms either change, for example "Mirroring is off for ...".
Search modes card
Below the table, the Search modes card explains the mode an agent passes on each search_code call. Search covers symbol names and identifiers, not function bodies or comments. Hybrid (recommended for agents) runs both searches and merges them, Lexical (the default when mode is left out) matches identifier words in symbol names, and Symbol matches the start of a qualified name such as billing.refunds. Picking a mode shows example search_code arguments. The card is hidden while the page shows one of the alerts below.
Connect a repository dialog
For GitHub, the dialog says you and the chosen credential must both be able to read the repository, and that your own access is checked with the token of a GitHub MCP server you have signed in to. For GitLab, it says you must be an active member of the project with at least the Reporter role, the token must be able to read its repository, and your membership is checked with the token of a GitLab MCP server you have signed in to.
| Control | Type | What it does |
|---|---|---|
| Source | Dropdown, default GitHub | GitHub or GitLab (gitlab.com or self-managed). Changing it clears the credential and MCP server fields, and the fields below take that host's labels. |
| Repository or Project path | Text field, required | A GitHub repository as owner/name, or a GitLab project as its full path such as group/project or group/subgroup/project. Anything else is refused. |
| GitHub repository id or GitLab project id | Text field, required | The numeric id the host shows for the repository or project, up to 20 digits. Anything else is refused. |
| Branch to index | Text field, default main | The branch to index. Required. |
| Your GitHub MCP server or Your GitLab MCP server | Text field, required | The id of the MCP server you signed in to. Used to check that you can read the repository. |
| Credential | Dropdown, required | A credential bound to this organization that fits the source, a stored GitHub token or GitHub App installation for GitHub, or a GitLab token for GitLab. With none, a note says what to bind first. |
| Owner team (optional) | Text field | Shown only when no team is picked under Acting for team. When a team is picked, that team owns the repository. |
| Connect | Button | Connects the repository and queues its first index run. A toast reads "Connected ..., the first index run is queued". If the gateway returns a webhook, the Repository webhook dialog opens. |
| Cancel | Button | Closes the dialog. |
Validation problems and gateway errors appear as toasts.
Repository webhook dialog
For GitHub, the dialog says to add this webhook to the repository with content type application/json and the push event, and shows the Payload URL on this gateway and the Secret. For GitLab, it says to open the project's Settings, then Webhooks, and add the URL with the secret as its Secret token and Push events turned on. The secret is shown only now. To get a new one later, use New webhook. Done closes the dialog.
Bind a credential dialog
The dialog lets one organization index repositories with a fine grained GitHub token or a GitLab access token. Store a GitHub token first on the Models + Endpoints page under LLM Credentials as a GitHub credential, with the token as its API key and read access to contents and metadata. Store a GitLab project, group or personal access token with the read_api scope through the credentials API with gitlab as its provider, and for a self-managed GitLab add its API base, such as https://gitlab.example.com/api/v4.
| Control | Type | What it does |
|---|---|---|
| Credential name | Text field, required | The name of the stored GitHub or GitLab credential, placeholder repo-indexer. Credentials of any other kind are refused. |
| Organization (optional) | Text field | Leave empty to bind it to your own organization, or default for users without one. Only proxy admins can name another organization. |
| Bind credential | Button | Binds it. A toast reads "... can now index repositories in ...". |
| Cancel | Button | Closes the dialog. |
Index runs dialog
Runs opens "Index runs of ...", the latest 50 runs, newest first. A failed run keeps the last good index.
| Column | Meaning |
|---|---|
| Status | succeeded, queued, running or a failure status, as a badge. |
| Commit | The commit indexed, shortened. |
| Files | Files in the index. |
| Changed | Files changed since the previous run. |
| Attempts | How many attempts the run took. |
| Started and Finished | UTC times, or "Never". |
| Error | The error, when the run failed. |
With no runs the dialog reads "No index runs yet."
Disconnect dialog
Disconnect asks "Disconnect ...?". Agents stop seeing the repository at once and everything indexed from it is deleted. The deleted index cannot be brought back, but you can connect the repository again later. Disconnect confirms and Cancel backs out. A toast reads "Disconnected ... and deleted its index".
Empty, error and disabled states
With no repositories the page reads "No repositories are connected yet. Select Connect repository to index the first one." for callers who can manage, or tells others to ask a proxy admin or a holder of code_graph.manage to connect one.
When the gateway cannot serve the page, the table is hidden and an alert explains why, with a link to the Code Graph setup guide.
| Alert | Cause and fix |
|---|---|
| Code Graph needs a Spanway Enterprise license | The license does not include code_graph. Ask sales@spanway.ai to add it. Once the license is in place the gateway turns Code Graph on within a minute, without a restart. |
| Code Graph is not set up on this gateway | SPANWAY_CODE_GRAPH_DATABASE_URL is not set. Set it to a Postgres role for the codegraph schema and restart the gateway. |
| You are not an admin of this team | You picked a team under Acting for team that you do not administer. Pick one you do, or ask a proxy admin for a role with code_graph.read. |
| You cannot see Code Graph repositories yet | No team is picked and you have no read access for the organization. Ask a proxy admin for a role with code_graph.read, or pick a team you administer. |
| The repositories could not be loaded | Any other failure. The gateway's message is shown. |
Action failures appear as toasts, such as "The index run could not be queued", "The webhook could not be rotated", "The setting could not be saved" and "The repository could not be disconnected".
Differences by role and license
The page reads what you may do from the gateway rather than from your session role.
| Who | What they can do |
|---|---|
Proxy admin, or a custom role with code_graph.manage | Connect, reindex, mirror, rotate webhooks and disconnect for the organization. With no team picked, also install the GitHub App and bind credentials. |
Custom role with code_graph.reindex | See every repository in the organization and click Reindex. Cannot connect, mirror, rotate webhooks or disconnect. |
Custom role with code_graph.read | See every repository in the organization. |
| Team admin | Pick their team under Acting for team to see and manage the repositories that team owns. Cannot install the App or bind credentials. |
| Anyone else | Sees the "You cannot see Code Graph repositories yet" alert. |
Everything on the page needs the code_graph license feature, which the gateway checks on every call. Org admins do not get the nav item.
Errors
| What you see | What it means | Fix |
|---|---|---|
| Code Graph needs a Spanway Enterprise license | The license lacks code_graph. | Add the feature. |
| Code Graph is not set up on this gateway | SPANWAY_CODE_GRAPH_DATABASE_URL is unset. | Set it and restart. |
| You are not an admin of this team | The team under Acting for team is not one you administer. | Pick your own team. |
A toast with Repository connection refused: actor_cannot_read_repo or credential_cannot_read_repo | You, or the bound credential, cannot read the repository on GitHub or GitLab. | Get read access for both. |
A toast with Repository connection refused: actor_has_no_upstream_identity | You have not signed in to the MCP server named in the dialog, or its sign-in is for another host. | Sign in to that MCP server and try again. |
A toast with another Repository connection refused: reason | The credential, owner team, host or repository id does not fit. | Each reason and its fix is listed on the code graph page. |
A toast with That repository is already connected in this tenant | It is connected already. | Use the existing row. |
| "The index run could not be queued" | Reindex failed, the toast shows the gateway's reason. | Fix the cause and click Reindex again. |