> ## Documentation Index
> Fetch the complete documentation index at: https://glasser.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> 将 Glasser 添加到 OpenCode，并连接账号。

通过远程 MCP 连接在 OpenCode 中启用 Glasser。如需使用 Skill 和 CLI，请阅读 [OpenCode Skill 指南](https://glasser.ai/docs/zh/setup-skill/opencode.md)。

**1. 添加服务器配置**

打开或创建 `~/.config/opencode/opencode.json`，以便在本机各项目中使用 Glasser。在 `mcp` 下添加 `glasser`，保留已有服务器：

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "glasser": {
      "type": "remote",
      "url": "https://api.glasser.ai/mcp"
    }
  }
}
```

如仅在一个项目中使用，改用项目根目录中的 `opencode.json`。

**2. 登录**

在终端中运行：

```bash theme={null}
opencode mcp auth glasser
```

在浏览器中登录 Glasser，选择工作空间，然后点击 **Allow**。如有需要，先创建账号和工作空间。然后运行 `opencode mcp list`，确认 `glasser` 已连接。

**3. 检查连接**

在新会话中发送：

```text wrap theme={null}
Suggest one small task I can try with Glasser. Check my available balance and mention any first-run reward returned. Explain what the task will do, then wait for me to choose it before a paid Run.
```

Agent 应调用 Glasser 的 `balance` 工具并返回余额。此检查免费；余额为零也表示连接正常。如需执行付费 Run，请在 [Glasser 控制台](https://app.glasser.ai?locale=zh-CN)充值。

Agent 应推荐一个小任务，并说明余额响应中返回的奖励。奖励金额和截止时间取决于账号；如果响应未返回奖励，Agent 只报告余额。详见[首次任务与奖励](https://glasser.ai/docs/zh/mcp-server.md#first-task-and-rewards)。

## 尝试首次请求

```text wrap theme={null}
Use Glasser to find recent news about Stripe. Show me the data you can retrieve and the price, then wait for my approval before any paid Run.
```

批准后，Agent 即可获取数据，并报告结果和费用。

配置选项和认证帮助见 [OpenCode MCP 文档](https://opencode.ai/docs/mcp-servers/)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.