Skip to main content

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​

  1. Open Code Graph under Tools in the left nav, or go to /ui/code-graph.

  2. Pick payments-team under Acting for team.

  3. Click Connect repository, keep the default Source, enter examplecorp/payments, its numeric id, the branch main, 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"}'
  4. Add the Payload URL and Secret from the Repository webhook dialog to the repository's webhooks with the push event, then click Done.

  5. Click Runs on the new row and wait for a succeeded badge.

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.

The header reads Code Graph, "Repositories indexed for coding agents through the spanway_code MCP server."

ControlTypeWhat it does
Acting for teamTeam dropdownTeam 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 credentialButtonOpens 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 repositoryButtonOpens 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​

ColumnMeaning
RepositoryThe repository as owner and name.
StatusA badge, see below.
Indexed commitThe 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.
OwnerThe owner team id, or "Tenant" when the organization owns it.
Mirror permissionsA 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 errorThe last indexing error, in red.
ActionsThe buttons below.
BadgeMeaning
ReadyThe index is current.
IndexingAn index run is pending.
FailedThe last index run failed. The last good index is kept.
Access lostThe gateway lost access to the repository.
DeletedThe repository is marked deleted.
ActionWho sees itWhat it does
RunsEveryoneOpens the index runs dialog.
ReindexCallers the gateway allows to reindexQueues an index run at once. A toast reads "Queued an index run for ...".
New webhookCallers who can manageMakes a new webhook secret for the repository and opens the Repository webhook dialog with it. There is no confirmation.
DisconnectCallers who can manageOpens 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.

ControlTypeWhat it does
SourceDropdown, default GitHubGitHub 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 pathText field, requiredA 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 idText field, requiredThe numeric id the host shows for the repository or project, up to 20 digits. Anything else is refused.
Branch to indexText field, default mainThe branch to index. Required.
Your GitHub MCP server or Your GitLab MCP serverText field, requiredThe id of the MCP server you signed in to. Used to check that you can read the repository.
CredentialDropdown, requiredA 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 fieldShown only when no team is picked under Acting for team. When a team is picked, that team owns the repository.
ConnectButtonConnects 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.
CancelButtonCloses 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.

ControlTypeWhat it does
Credential nameText field, requiredThe name of the stored GitHub or GitLab credential, placeholder repo-indexer. Credentials of any other kind are refused.
Organization (optional)Text fieldLeave empty to bind it to your own organization, or default for users without one. Only proxy admins can name another organization.
Bind credentialButtonBinds it. A toast reads "... can now index repositories in ...".
CancelButtonCloses the dialog.

Index runs dialog​

Runs opens "Index runs of ...", the latest 50 runs, newest first. A failed run keeps the last good index.

ColumnMeaning
Statussucceeded, queued, running or a failure status, as a badge.
CommitThe commit indexed, shortened.
FilesFiles in the index.
ChangedFiles changed since the previous run.
AttemptsHow many attempts the run took.
Started and FinishedUTC times, or "Never".
ErrorThe 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.

AlertCause and fix
Code Graph needs a Spanway Enterprise licenseThe 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 gatewaySPANWAY_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 teamYou 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 yetNo 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 loadedAny 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.

WhoWhat they can do
Proxy admin, or a custom role with code_graph.manageConnect, 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.reindexSee every repository in the organization and click Reindex. Cannot connect, mirror, rotate webhooks or disconnect.
Custom role with code_graph.readSee every repository in the organization.
Team adminPick their team under Acting for team to see and manage the repositories that team owns. Cannot install the App or bind credentials.
Anyone elseSees 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 seeWhat it meansFix
Code Graph needs a Spanway Enterprise licenseThe license lacks code_graph.Add the feature.
Code Graph is not set up on this gatewaySPANWAY_CODE_GRAPH_DATABASE_URL is unset.Set it and restart.
You are not an admin of this teamThe 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_repoYou, 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_identityYou 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: reasonThe 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 tenantIt 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.