Use OAuth for interactive IDE sessions. Use an API key for automation or clients that cannot complete a browser sign-in.
OAuth setup
OAuth signs you in through your browser. You do not need to create an API key or register an OAuth client.- Cursor
- Claude Code
- VS Code
- Codex
1
Open MCP settings
Open Customize and select MCPs.
2
Add Greptile
Add this configuration to project-level
.cursor/mcp.json or user-level ~/.cursor/mcp.json:3
Sign in
Ask Cursor:On the first protected tool call, follow the browser prompt to sign in.
4
Verify the connection
Run the same prompt again. A successful
list_custom_context result confirms authentication. Seeing Greptile’s tools in settings confirms discovery, but not authentication.Multiple organizations
Accounts with more than one Greptile organization gettenant_required. The error lists every organization you belong to, by name and id.
Set X-Greptile-Tenant to your organization’s handle or id. The handle is the first path segment of every Greptile URL, for example app.greptile.com/your-handle. The id is the one in the error. Any member can read the handle from the URL. Only an admin can change it. See Change organization handle.
If the handle changes, update the header. The id never changes.
This header routes requests. It does not authenticate them and works with OAuth.
- Cursor
- Claude Code
- VS Code
- Codex
Add the header to the OAuth server entry:
organization argument on any tool call. If you set both, reads follow the argument. Tool calls that write are rejected when the two name different organizations.
API key setup
Create an API key in Settings > Organization > API Keys, then configure your client below.- Cursor
- Claude Code
- VS Code
- Codex
On macOS or Linux, open the Command Palette and run Shell Command: Install ‘cursor’ command in PATH once. Then set the key and launch Cursor from the same terminal so the app inherits it:Then add this configuration to project-level Save the file, then call a Greptile tool to verify authentication.
.cursor/mcp.json or user-level ~/.cursor/mcp.json:Verify API key authentication
Call an authenticated tool directly:result. An invalid or revoked key returns 401 Unauthorized.
Troubleshooting
OAuth is not offered
OAuth is not offered
Remove any static
Authorization header or bearer-token setting from the Greptile server entry, restart the client, then invoke a protected tool such as list_custom_context. The resulting authentication challenge starts OAuth discovery.The OAuth browser does not open
The OAuth browser does not open
Claude Code users can run
claude mcp login greptile --no-browser and open the printed URL manually. In Cursor or VS Code, invoke a protected tool such as list_custom_context to trigger authentication.Tool calls return tenant_required
Tool calls return tenant_required
Your account belongs to multiple Greptile organizations. See Multiple organizations to find your organization’s handle or id and set it as the
X-Greptile-Tenant header. Agents can pass it as the organization argument instead.API key authentication fails
API key authentication fails
Confirm that the key has no extra spaces, has not been revoked, and belongs to an organization that can access the requested repositories. Use the authenticated curl request above to test it.
No tools are available
No tools are available
Restart the client, confirm Greptile is enabled, and check that the server URL is exactly
https://api.greptile.com/mcp.Tools return empty results
Tools return empty results
Confirm that your organization has repositories indexed in Greptile and that your user or API key can access them.
Configuration file locations
Next steps
Auto-Fix Workflow
Resolve Greptile comments from your IDE.
Tools Reference
Read the tools reference.