Claude Code¶
Connect OpenTrace to Claude Code to give your AI assistant deep knowledge about your system architecture.
What is Claude Code?¶
Claude Code is Anthropic's official command-line interface for Claude. It enables Claude to understand your codebase, execute commands, and assist with software engineering tasks directly from your terminal.
By connecting OpenTrace to Claude Code, you give Claude access to your system's architecture, service dependencies, and runtime relationships - enabling it to answer questions about your infrastructure and help debug issues.
Prerequisites¶
- Claude Code installed and configured
- An OpenTrace account
Authentication Methods¶
OpenTrace supports two authentication methods for Claude Code:
| Method | Best For | How It Works |
|---|---|---|
| OAuth (Recommended) | Interactive use by developers | Browser opens for authorization, tokens managed automatically |
| API Token | Automation, CI/CD, headless environments | Service account token configured manually |
Option A: OAuth Authentication (Recommended)¶
OAuth is the recommended method for developers using Claude Code interactively. When you connect, Claude Code opens your browser to authorize access, and handles token management automatically.
Quick Setup¶
Run the following command to add OpenTrace with OAuth:
When you first use the integration, Claude Code will:
- Open your browser to the OpenTrace authorization page
- Prompt you to sign in (if not already signed in)
- Ask you to select an organization and confirm permissions
- Automatically receive and store the authentication token
Note
Claude Code runs a temporary local server to receive the OAuth callback. Your browser will be redirected to 127.0.0.1 to complete the authorization.
By default, this adds the server to your user configuration (available in all sessions). To add it to a specific project only, use the --scope flag:
Manual Configuration (OAuth)¶
You can also configure OAuth manually by creating or editing configuration files.
Project-Level Configuration
Create a .mcp.json file in your project root:
Global Configuration
Edit ~/.claude/settings.json (macOS/Linux) or %USERPROFILE%\.claude\settings.json (Windows):
Option B: API Token Authentication¶
API tokens are recommended for automated environments such as CI/CD pipelines, scripts, or headless servers where browser-based OAuth isn't possible.
1. Get Your API Token¶
- Log in to the OpenTrace dashboard
- Click on the Organization Switcher in the sidebar
- Select Manage organization to open your organization profile
- Navigate to Service Accounts
- Click Create Service Account and give it a name (e.g., "Claude Code CI")
- Click Generate Token on the service account you created
- Copy the token - you'll need it in the next step
Warning
The token is only displayed once. Make sure to copy it before closing the dialog.
2. Configure MCP with API Token¶
Command-Line Configuration¶
claude mcp add opentrace \
--transport http \
https://api.opentrace.ai/mcp/v1 \
--header "Authorization: Bearer YOUR_API_TOKEN"
Replace YOUR_API_TOKEN with your OpenTrace API token.
Tip
Use an environment variable to avoid exposing your token in shell history:
Project-Level Configuration¶
Create a .mcp.json file in your project root:
{
"mcpServers": {
"opentrace": {
"type": "http",
"url": "https://api.opentrace.ai/mcp/v1",
"headers": {
"Authorization": "Bearer ${OPENTRACE_API_TOKEN}"
}
}
}
}
Then set the environment variable:
Global Configuration¶
Edit ~/.claude/settings.json (macOS/Linux) or %USERPROFILE%\.claude\settings.json (Windows):
{
"mcpServers": {
"opentrace": {
"type": "http",
"url": "https://api.opentrace.ai/mcp/v1",
"headers": {
"Authorization": "Bearer ${OPENTRACE_API_TOKEN}"
}
}
}
}
Verify the Connection¶
Start Claude Code in your terminal:
Ask Claude to verify the connection:
"What services are available in OpenTrace?"
If configured correctly, Claude will be able to query your system architecture.
What You Can Do¶
Once connected, Claude can:
- Explore your architecture - Discover services, their relationships, and how they connect
- Analyze dependencies - Understand what each service depends on and what depends on it
- Investigate issues - Trace request paths, find connection points, and debug problems
- Plan changes - Assess the impact of modifications before making them
Example Queries¶
Try asking Claude:
Discovery:
Dependencies:
Investigation:
How do requests flow from the API gateway to the database?
Find the path between the frontend and the order service.
Architecture:
Show me services that connect to the PostgreSQL database.
What are the most critical services in terms of dependencies?
Troubleshooting¶
"MCP server not found" Error¶
- Verify the
.mcp.jsonfile is in your project root or the global settings file exists - Check that the JSON syntax is valid
- Restart Claude Code after making configuration changes
- Run
claude mcp listto see all configured MCP servers
OAuth Authorization Failed¶
- Ensure your browser can open URLs from the terminal
- Check that pop-ups are not blocked
- Verify you have access to the OpenTrace organization
- Try removing the server with
claude mcp remove opentraceand adding it again
"Unauthorized" Error (API Token)¶
- Verify your API token is correct
- Check that the token hasn't expired
- Ensure the environment variable is set if using
${OPENTRACE_API_TOKEN}
No Data Returned¶
- Confirm you have integrations configured in OpenTrace (GitHub, GitLab, AWS EKS)
- Verify data has been synced from your integrations
- Check the OpenTrace dashboard to ensure your services are visible
Next Steps¶
- What You Can Do - Full list of capabilities
- Example Workflows - Common scenarios and approaches
- GitHub Integration - Connect your repositories