---
title: OpenCode
description: Add the Clics local MCP server to OpenCode so agents can query analytics and manage projects, goals, and funnels.
seo:
  title: Add Clics MCP to OpenCode for analytics access
---

Connect Clics to [OpenCode](https://opencode.ai) so the agent can query stats and manage your workspace from the terminal or IDE.

## When to use this

Use OpenCode when you prefer its agent workflow and want live Clics data (traffic, goals, funnels) available as MCP tools.

## Prerequisites

- Node.js 18 or newer
- OpenCode installed and configured
- A Clics API key from **Settings → API keys**

## Config file

| Scope | File |
| --- | --- |
| **Project or global** | `opencode.json` or `opencode.jsonc` |

OpenCode uses a dedicated `mcp` block (not `mcpServers`), with `type: "local"` and a `command` array.

## Configuration

```json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "clics": {
      "type": "local",
      "command": ["npx", "-y", "@clicsdev/mcp"],
      "enabled": true,
      "environment": {
        "CLICS_API_KEY": "your_api_key"
      }
    }
  }
}
```

## Enable the server

1. Save `opencode.json` (or `opencode.jsonc`)
2. Restart OpenCode or reload MCP servers
3. Confirm `clics` appears as enabled
4. Ask a test question in a new session

## Verify the connection

Ask:

> "List my Clics projects"

OpenCode should call `list_projects` and return your workspace data.

## Example prompts

- "How many visitors did we get in the last 7 days?"
- "List goals for my main project"
- "Create a page goal for `/pricing`"
- "Show conversion rates for my signup funnel"

## Tips

- Prefer `npx -y @clicsdev/mcp` so you always get the latest package
- Keep API keys out of git: use a local config or inject `CLICS_API_KEY` from your shell environment
- Name the project in prompts when you track multiple sites

## Troubleshooting

| Problem | Fix |
| --- | --- |
| Server not listed | Confirm the config uses `mcp.clics` with `type: "local"` and `enabled: true` |
| Auth failures | Check `environment.CLICS_API_KEY` matches a live dashboard key |
| Command fails | Ensure Node.js and `npx` are on the PATH for the OpenCode process |
| Empty stats | Confirm the project has traffic and the date range is correct |
