# Opencode AI

[Opencode AI](https://opencode.ai/) is an AI-powered coding assistant with MCP support.

## Prerequisites

- Opencode AI installed
- Scoped Probo OAuth token (see [Authentication](/docs/developers/api/mcp/authentication))
- Your Probo instance URL

## Endpoint

Choose the endpoint for your Probo environment:

| Environment | MCP URL                                      |
| ----------- | -------------------------------------------- |
| Probo US    | `https://us.probo.com/api/mcp/v1`            |
| Probo EU    | `https://eu.probo.com/api/mcp/v1`            |
| Custom      | `https://your-probo-instance.com/api/mcp/v1` |

The `/v1` segment is required.

## Configuration

### 1. Open Opencode Settings

Open Opencode settings or configuration file.

### 2. Add MCP Server

Add the Probo MCP Server configuration:

```json
{
  "mcpServers": {
    "probo": {
      "url": "https://your-probo-instance.com/api/mcp/v1",
      "headers": {
        "Authorization": "Bearer your_api_token_here"
      }
    }
  }
}
```

### 3. Replace Placeholders

Update these values:

- `your-probo-instance.com` → Your Probo instance URL
- `your_api_token_here` → Your OAuth token from Probo

### 4. Restart Opencode

Restart Opencode to apply the configuration.

## Usage

Once configured, you can use Probo tools through Opencode's AI assistant:

**Example queries:**

```
"List all pending obligations in my organization"
"Add a new risk for data breach with high impact"
"Show me all third parties that need review"
```

Opencode will automatically invoke the appropriate Probo MCP tools.

## Environment Variables

For security, use an environment variable for your OAuth token:

```json
{
  "mcpServers": {
    "probo": {
      "url": "https://your-probo-instance.com/api/mcp/v1",
      "headers": {
        "Authorization": "Bearer ${PROBO_API_TOKEN}"
      }
    }
  }
}
```

Set the environment variable:

**macOS/Linux:**

```bash
export PROBO_API_TOKEN="your_api_token_here"
```

**Windows:**

```powershell
$env:PROBO_API_TOKEN = "your_api_token_here"
```

## Multiple Environments

Configure different Probo instances:

```json
{
  "mcpServers": {
    "probo-dev": {
      "url": "http://localhost:8080/api/mcp/v1",
      "headers": {
        "Authorization": "Bearer ${PROBO_DEV_TOKEN}"
      }
    },
    "probo-prod": {
      "url": "https://probo.company.com/api/mcp/v1",
      "headers": {
        "Authorization": "Bearer ${PROBO_PROD_TOKEN}"
      }
    }
  }
}
```

## Troubleshooting

### Tools Not Available

**Problem:** Probo tools aren't showing up in Opencode

**Solutions:**

1. Verify the MCP configuration is correct
2. Restart Opencode completely
3. Check Opencode logs for connection errors
4. Test the endpoint with the MCP Inspector:
   ```bash
   npx @modelcontextprotocol/inspector --cli \
     https://your-probo-instance.com/api/mcp/v1 \
     --transport http \
     --header "Authorization: Bearer $PROBO_API_TOKEN" \
     --method tools/list
   ```

### Authentication Errors

**Problem:** 401 Unauthorized errors

**Solutions:**

1. Create a replacement OAuth token in Probo
2. Verify the token format: `Bearer your_token`
3. Check for extra spaces or newlines
4. Ensure the token hasn't expired or been revoked

### Connection Issues

**Problem:** Cannot connect to Probo instance

**Solutions:**

1. Verify the Probo URL is correct
2. Check network connectivity
3. Use HTTPS for production instances
4. Verify firewall settings

## Best Practices

- Store OAuth tokens in environment variables
- Use separate tokens for different environments
- Rotate tokens regularly (every 90 days)
- Use HTTPS for production connections
- Monitor token usage in Probo settings
- Avoid committing tokens to version control

## Features

Opencode AI with Probo MCP provides:

- AI-powered coding with compliance context
- Real-time access to compliance data
- Automated compliance checks
- Code generation with risk awareness
- Natural language compliance queries

## Learn More

- [Opencode AI Documentation](https://opencode.ai/docs)
- [Available Tools](/docs/developers/api/mcp/tools)
- [Authentication](/docs/developers/api/mcp/authentication)
- [Pagination](/docs/developers/api/mcp/pagination)
