# How to connect Sourcegraph to OpenClaw (paste one key, 8 tools)

> Connect Sourcegraph to OpenClaw with ClawLink: paste your Sourcegraph key once and 8 tools work from chat. No MCP server to run, nothing stored on your machine.

Web version: https://claw-link.dev/openclaw/sourcegraph

The usual route to Sourcegraph access for OpenClaw is an MCP server you configure and keep running, plus your own OAuth app or API keys. ClawLink gives OpenClaw a more practical Sourcegraph setup: install one ClawHub skill, connect Sourcegraph in the browser, and OpenClaw can call real Sourcegraph actions from any chat surface with no auth, token refresh, or tool wiring to build yourself.

## Setup

It takes three steps to connect OpenClaw to Sourcegraph.

1. **Install ClawLink** — add the plugin to OpenClaw once.
2. **Connect Sourcegraph** — one-click OAuth in the ClawLink dashboard.
3. **Use it from chat** — ask OpenClaw in plain English.

**Paste this into OpenClaw to set up ClawLink:**

> I want to connect my apps to OpenClaw through ClawLink.
> Please install the ClawLink plugin from ClawHub and enable it: `openclaw plugins install clawhub:clawlink-plugin`
> When it is installed, tell me and stop. After I reply, give me the ClawLink pairing link. Setup notes, if you need them: https://claw-link.dev/skill.md

**Alternative for any agent (no plugin needed):** if the OpenClaw plugin route isn't available or doesn't work, any AI agent with shell access can use the ClawLink CLI instead:

```bash
npx -y @useclawlink/cli login          # sign in via browser — no API key to paste
npx -y @useclawlink/cli connect sourcegraph  # connect Sourcegraph (browser OAuth)
npx -y @useclawlink/cli actions sourcegraph  # list available actions
npx -y @useclawlink/cli run sourcegraph <action> --input '<json>'  # execute (add --confirm for writes)
```

### Install by command

The setup prompt above does all of this in one paste. By hand, it is one install command plus a browser approval:

```bash
openclaw plugins install clawhub:clawlink-plugin
```

Then ask OpenClaw to set up ClawLink. It starts browser pairing and prints an approval link — open it, approve the device, return to the chat, and say `done`. Finally, connect Sourcegraph in the [ClawLink dashboard](https://claw-link.dev/dashboard) — paste your Sourcegraph API key once.

Verify the connection by asking OpenClaw:

> Use Sourcegraph to check site settings edit permission and walk me through the result in plain English.

### Using a different agent?

The OpenClaw plugin is one client of ClawLink's MCP server. Claude Code, Cursor, Codex, or any agent that can run a shell command pairs with the same ClawLink account through the CLI:

```bash
npx -y @useclawlink/cli login
```

`login` opens the same browser approval and stores a credential locally. Once Sourcegraph is connected in the dashboard, that agent calls the same 8 Sourcegraph tools over MCP. Full setup for MCP clients and shell agents: [connect apps to any AI agent](https://claw-link.dev/learn/connect-apps-to-any-ai-agent).

## Sourcegraph MCP for OpenClaw

Looking for a Sourcegraph MCP server for OpenClaw? ClawLink connects Sourcegraph to OpenClaw and exposes 8 Sourcegraph tools your agent can call over [MCP](https://claw-link.dev/learn/what-is-an-mcp-server), with [hosted auth](https://claw-link.dev/learn/oauth-for-ai-agents) and nothing to run or maintain yourself. Using Hermes instead? The [Hermes Sourcegraph integration](https://claw-link.dev/hermes/sourcegraph) works the same way.

## What the OpenClaw Sourcegraph integration can do

8 Sourcegraph tools are ready for OpenClaw once the account is connected.

### All 8 Sourcegraph tools for OpenClaw

| Tool | What it does |
|---|---|
| **Check site settings edit permission** `sourcegraph_check_site_settings_edit_permission` | Check whether site settings can be edited through the API |
| **Compare commits** `sourcegraph_compare_commits` | Compare two commits in a repository and retrieve their file diffs |
| **Get commit details** `sourcegraph_get_commit_details` | Get detailed information about a specific commit in a repository |
| **Get current user** `sourcegraph_get_current_user` | Retrieve information about the currently authenticated user |
| **Get file contents** `sourcegraph_get_file_contents` | Fetch the contents of a specified file on the default branch |
| **List repositories** `sourcegraph_list_repositories` | List repositories on the Sourcegraph instance |
| **List repository files** `sourcegraph_list_repository_files` | List all files and directories in a repository path |
| **List repository languages** `sourcegraph_list_repository_languages` | List languages used in a repository |

## Example prompts

**Check Site Settings Edit Permission**

> Use Sourcegraph to check site settings edit permission and walk me through the result in plain English.

**Compare Commits**

> Use Sourcegraph to compare commits and walk me through the result in plain English.

**Get Commit Details**

> Pull the relevant data from Sourcegraph, summarize it in plain English, and point out anything that needs attention.

**Get Current User**

> Pull the relevant data from Sourcegraph, summarize it in plain English, and point out anything that needs attention.

## ClawLink vs. building it yourself

The alternative to ClawLink is usually manual API key setup plus your own token handling, permission troubleshooting, and tool plumbing for OpenClaw. That is fine if you want to build and maintain the integration yourself. Most teams just want Sourcegraph working from chat.

| | Manual | ClawLink |
|---|---|---|
| **Credential handling** | Collect, validate, store, and rotate the Sourcegraph API key yourself, then make sure every tool call uses the right account. | Users complete the hosted ClawLink setup once and the connected Sourcegraph account becomes available to the agent without you building credential management. |
| **Ongoing maintenance** | You own refresh logic, permission debugging, environment config, and every provider-specific edge case for Sourcegraph. | ClawLink handles the repetitive integration plumbing so your team can focus on the workflow instead of the infrastructure. |
| **Agent usability** | You still need to expose the right Sourcegraph actions to the runtime in a format your agent can reliably use. | 8 tools for Sourcegraph are already exposed through ClawLink, so the agent can read and act from chat immediately. |

## ClawLink vs. Composio

Composio also exposes Sourcegraph to AI agents. It is developer infrastructure: Python and TypeScript SDKs, an MCP server, and a catalog past 1,000 apps, aimed at teams shipping agent products. ClawLink is built for OpenClaw users instead. You install the plugin once, connect Sourcegraph in the browser, and the 8 tools above work from chat. There is no SDK and no config file, and the Sourcegraph key you paste at setup is stored server-side rather than kept in your environment. Choosing between them? Read the full [Composio alternatives](https://claw-link.dev/hub/composio-alternatives) comparison.

### OpenClaw installed the Sourcegraph skill but can't call the tools
The ClawHub skill teaches OpenClaw about Sourcegraph, but the calls run through the ClawLink plugin and your connected account. Make sure Sourcegraph is connected in the dashboard, then start a fresh chat so OpenClaw reloads the tool catalog. If OpenClaw runs as a persistent gateway, restart it so the new tools register.

### Connection succeeds but no tools appear
Reconnect Sourcegraph from the dashboard, then start a fresh chat if the runtime still has the old tool catalog loaded.

### "Tool schema not loaded yet" error when calling Sourcegraph tools
Sourcegraph tool schemas load on demand the first time a tool runs and are cached after that, so this error usually clears on its own: wait a few seconds and retry the same request. If every Sourcegraph call keeps failing with it in a fresh chat, reconnect from the dashboard, and contact support if it still persists — that pattern points to a configuration problem on our side, not something you can fix by reconnecting again.

### Sourcegraph returns 403 or "permission denied" on one action while others work
Two usual causes. The connected account may not have access to the specific workspace, inbox, store, or project in the request — check that first. If access looks right, the agent may have sent a placeholder value (like "YOUR_ID" or an example id from documentation) instead of a real one: ask it to run a list or search tool first, then retry the action with a real id from those results. Most failures at this stage are one of these two, not ClawLink bugs.

### API key setup works but results look incomplete
Double-check that the API key for Sourcegraph has the right scopes or account access. A valid key can still be too limited for some reads or writes.

### Is there a OpenClaw Sourcegraph integration?
Yes. ClawLink is the fastest way to connect OpenClaw to Sourcegraph: link your Sourcegraph account once in the browser and OpenClaw can call the Sourcegraph API through 8 ready-made tools — no custom code or token handling.

### How do I add Sourcegraph to OpenClaw with ClawLink?
Paste the setup prompt from this page into OpenClaw. It installs the ClawLink Sourcegraph skill from ClawHub, then you click Connect in the dashboard to authorize Sourcegraph. OpenClaw calls the tools from the next message — no config files, and the Sourcegraph key you paste is stored server-side instead of in your environment.

### How long does it take to connect Sourcegraph to OpenClaw?
About two minutes. Sign in, click Connect next to Sourcegraph in the dashboard, authenticate, and OpenClaw can use it from the next chat message.

### Why use ClawLink instead of wiring Sourcegraph up myself?
The alternative to ClawLink is usually manual API key setup plus your own token handling, permission troubleshooting, and tool plumbing for OpenClaw. That is fine if you want to build and maintain the integration yourself. Most teams just want Sourcegraph working from chat.

### OpenClaw installed the Sourcegraph skill but can't call the tools
The ClawHub skill teaches OpenClaw about Sourcegraph, but the calls run through the ClawLink plugin and your connected account. Make sure Sourcegraph is connected in the dashboard, then start a fresh chat so OpenClaw reloads the tool catalog. If OpenClaw runs as a persistent gateway, restart it so the new tools register.

## Related

- [OpenClaw GitHub integration](https://claw-link.dev/openclaw/github) — Manage repositories, issues, pull requests, and workflows
- [PagerDuty](https://claw-link.dev/openclaw/pagerduty) — Manage incidents, on-call schedules, and services
- [SafetyCulture tools](https://claw-link.dev/openclaw/safetyculture) — SafetyCulture (formerly iAuditor) is a workplace operations platform that enables teams to conduct digital inspections, manage audits, track issues, schedule tasks, and maintain compliance through mobile and web applications.
