@bitget-ai/bitget-agent-skill 3.4.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,266 +0,0 @@
1
- #!/usr/bin/env node
2
- // Generates references/commands.md from @bitget-ai/bitget-agent-sdk by walking
3
- // the SDK's own `discover` surface — the same progressive disclosure an agent
4
- // uses at runtime. Driving discover (not raw catalog reads) guarantees the
5
- // static catalog never drifts from what `bgc` actually exposes.
6
- //
7
- // Output is the v3 intent surface: 16 curated verbs (incl. the hidden to-B
8
- // broker/inst_loan), each action's required/optional contract, plus the meta
9
- // tools. The CLI grammar / global-flags block is the stable `bgc` contract.
10
- import { writeFileSync, mkdirSync } from "node:fs";
11
- import { join, dirname } from "node:path";
12
- import { fileURLToPath } from "node:url";
13
-
14
- const __dirname = dirname(fileURLToPath(import.meta.url));
15
- const refsDir = join(__dirname, "..", "references");
16
- mkdirSync(refsDir, { recursive: true });
17
-
18
- const {
19
- loadConfig,
20
- buildTools,
21
- MODULES,
22
- HIDDEN_MODULES,
23
- HIGH_RISK_OPERATIONS,
24
- DISCOVER_TOOL_NAME,
25
- RAW_TOOL_NAME,
26
- SERVER_VERSION,
27
- CATALOG_SPEC_VERSION,
28
- CATALOG_OPERATION_COUNT,
29
- API_VARIANT,
30
- } = await import("@bitget-ai/bitget-agent-sdk");
31
-
32
- // All modules incl. hidden to-B verbs, intent surface — exactly what `bgc`
33
- // exposes with `--modules all` plus the explicitly-named hidden ones.
34
- const config = loadConfig({ modules: MODULES.join(","), surface: "intent", readOnly: false });
35
- const tools = buildTools(config);
36
- const discover = tools.find((t) => t.name === DISCOVER_TOOL_NAME);
37
- const call = async (args) => (await discover.handler(args, {})).data;
38
-
39
- const hidden = new Set(HIDDEN_MODULES);
40
- const highRisk = new Set(HIGH_RISK_OPERATIONS);
41
- const DESC_CAP = 220;
42
-
43
- // Collapse OpenAPI paragraph descriptions to a single, table-safe line.
44
- function cell(text) {
45
- if (text === undefined || text === null) return "";
46
- let s = String(text).replace(/\s+/g, " ").trim().replace(/\|/g, "\\|");
47
- if (s.length > DESC_CAP) s = s.slice(0, DESC_CAP - 1) + "…";
48
- return s;
49
- }
50
-
51
- function enumCell(param) {
52
- if (!Array.isArray(param.enum) || param.enum.length === 0) return "";
53
- return param.enum.map((v) => `\`${v}\``).join(" \\| ");
54
- }
55
-
56
- function paramTable(params) {
57
- if (!params || params.length === 0) return ["_No parameters._", ""];
58
- const out = ["| Param | Type | Enum | Description |", "|-------|------|------|-------------|"];
59
- for (const p of params) {
60
- out.push(`| \`${p.name}\` | ${p.type ?? "any"} | ${enumCell(p)} | ${cell(p.description)} |`);
61
- }
62
- out.push("");
63
- return out;
64
- }
65
-
66
- function anchor(name) {
67
- return name.toLowerCase().replace(/[^a-z0-9]+/g, "-");
68
- }
69
-
70
- function exampleFor(verb, action, required) {
71
- const parts = [`bgc ${verb}`];
72
- if (action) parts.push(`--action ${action}`);
73
- for (const p of required) {
74
- if (p.name === "action") continue;
75
- parts.push(`--${p.name} <${p.name}>`);
76
- }
77
- return parts.join(" ");
78
- }
79
-
80
- const lines = [];
81
- lines.push("# bgc Command Reference (UTA / v3)");
82
- lines.push("");
83
- lines.push(
84
- `Auto-generated from \`@bitget-ai/bitget-agent-sdk\` v${SERVER_VERSION} ` +
85
- `(OpenAPI spec ${CATALOG_SPEC_VERSION}, ${CATALOG_OPERATION_COUNT} operations, ${API_VARIANT}).`,
86
- );
87
- lines.push("Do not edit by hand — run `npm run gen-references`.");
88
- lines.push("");
89
- lines.push(
90
- "This catalog is the **static** mirror of the live surface. For a verb's exact, " +
91
- "doc-grounded contract at any moment, run `bgc discover --tool <verb> --action <name>`.",
92
- );
93
- lines.push("");
94
-
95
- // ── CLI grammar (the stable `bgc` contract) ─────────────────────────────
96
- lines.push("## Grammar");
97
- lines.push("");
98
- lines.push("```");
99
- lines.push("bgc <tool> [--action <name>] [--<param> <value> ...] [global flags]");
100
- lines.push("bgc discover [--domain <d> | --tool <t> [--action <a>] | --search <q>]");
101
- lines.push("bgc raw --operationId <id> [--args '<json>']");
102
- lines.push("```");
103
- lines.push("");
104
- lines.push(
105
- "One verb per call. `--action` selects the intent for action-routed verbs. " +
106
- "Values coerce by shape: `true`/`false` → boolean, a value starting with `[` or `{` → JSON " +
107
- "(e.g. `--orders '[{...}]'`), everything else stays a string. Output is JSON on stdout " +
108
- "(exit 0); errors are a JSON payload on stderr (exit 1).",
109
- );
110
- lines.push("");
111
-
112
- // ── Global flags ─────────────────────────────────────────────────────────
113
- lines.push("## Global flags");
114
- lines.push("");
115
- lines.push("| Flag | Effect |");
116
- lines.push("|------|--------|");
117
- lines.push("| `--action <name>` | Action for an action-routed verb |");
118
- lines.push("| `--modules <list>` | Modules to enable (CLI default: `all`). Name a hidden to-B module to expose it, e.g. `--modules broker` |");
119
- lines.push("| `--surface <mode>` | `intent` (default) or `full` (also expose the 1:1 generated operations) |");
120
- lines.push("| `--full` | Shorthand for `--surface full` |");
121
- lines.push("| `--read-only` | Block all writes (mutually exclusive with `--paper-trading`) |");
122
- lines.push("| `--paper-trading` | Route writes to the Bitget demo environment (needs demo credentials) |");
123
- lines.push("| `--dry-run` | Preview a write without sending it (maps to `dryRun`) |");
124
- lines.push("| `--confirm` | Required to execute destructive (high-risk) writes |");
125
- lines.push("| `--base-url <url>` | Override API base URL (else `BITGET_API_BASE_URL`) |");
126
- lines.push("| `--timeout <ms>` | Per-request timeout (else `BITGET_TIMEOUT_MS`, default 15000) |");
127
- lines.push("| `--pretty` | Pretty-print JSON output |");
128
- lines.push("| `--help`, `--version` | Help / version |");
129
- lines.push("");
130
-
131
- // ── Write safety ───────────────────────────────────────────────────────
132
- lines.push("## Write safety");
133
- lines.push("");
134
- lines.push(
135
- "Every operation is graded **read** < **write** < **high**. Reads run freely. Writes honor " +
136
- "`--dry-run`, `--read-only`, and `--paper-trading`. **High-risk** operations refuse to run " +
137
- "without `--confirm` — without it the call returns `{ confirmationRequired: true }` (a normal " +
138
- "result on stdout, not an error).",
139
- );
140
- lines.push("");
141
- lines.push(`High-risk operations (require \`--confirm\`): ${[...highRisk].map((o) => `\`${o}\``).join(", ")}.`);
142
- lines.push("");
143
- lines.push(
144
- "Common params available on most verbs (not repeated in the tables below): `dryRun`, `confirm` " +
145
- "(writes); `view` (`summary`|`full`) and `fields` (read normalization / token economy); " +
146
- "`fetchAll`, `cursor`, `limit` (paginated reads).",
147
- );
148
- lines.push("");
149
-
150
- // ── Walk the surface ─────────────────────────────────────────────────────
151
- const overview = await call({});
152
- const verbsByDomain = new Map();
153
- for (const d of overview.domains) {
154
- const list = await call({ domain: d.domain });
155
- verbsByDomain.set(d.domain, list.tools);
156
- }
157
-
158
- // Table of contents
159
- lines.push("## Domains");
160
- lines.push("");
161
- for (const d of overview.domains) {
162
- const verbs = verbsByDomain.get(d.domain);
163
- const names = verbs.map((v) => `[\`${v.name}\`](#${anchor(v.name)})`).join(", ");
164
- lines.push(`- **${d.domain}** — ${names}`);
165
- }
166
- lines.push(`- **meta** — [\`${RAW_TOOL_NAME}\`](#raw), [\`${DISCOVER_TOOL_NAME}\`](#discover)`);
167
- lines.push("");
168
-
169
- // Per domain → per verb
170
- for (const d of overview.domains) {
171
- lines.push(`## Domain: ${d.domain}`);
172
- lines.push("");
173
- for (const v of verbsByDomain.get(d.domain)) {
174
- const tool = await call({ tool: v.name });
175
- lines.push(`### \`${v.name}\``);
176
- lines.push("");
177
- const badges = [`risk: **${v.riskLevel}**`, `write: ${v.isWrite ? "yes" : "no"}`, `auth: ${tool.auth}`];
178
- lines.push(badges.join(" · "));
179
- lines.push("");
180
- // Hidden to-B modules have domain === module id (broker, instloan); name the
181
- // module id in the opt-in hint, not the verb name (inst_loan ≠ instloan).
182
- if (hidden.has(d.domain)) {
183
- lines.push(`> Hidden to-B verb — opt in with \`--modules ${d.domain}\` (not in \`--modules all\`).`);
184
- lines.push("");
185
- }
186
- lines.push(cell(tool.description));
187
- lines.push("");
188
-
189
- if (tool.actions) {
190
- lines.push(`**Actions:** ${tool.actions.map((a) => `\`${a}\``).join(", ")}`);
191
- lines.push("");
192
- for (const action of tool.actions) {
193
- const c = await call({ tool: v.name, action });
194
- const danger = highRisk.has(c.operationId) ? " — **[DANGER] requires `--confirm`**" : "";
195
- lines.push(`#### \`bgc ${v.name} --action ${action}\`${danger}`);
196
- lines.push("");
197
- lines.push(`\`${c.method} ${c.path}\` · ${c.auth}${c.isWrite ? " · write" : ""}`);
198
- lines.push("");
199
- if (c.summary) {
200
- lines.push(cell(c.summary));
201
- lines.push("");
202
- }
203
- if (c.required.length > 0) {
204
- lines.push("Required:");
205
- lines.push("");
206
- lines.push(...paramTable(c.required));
207
- }
208
- if (c.optional.length > 0) {
209
- lines.push("Optional:");
210
- lines.push("");
211
- lines.push(...paramTable(c.optional));
212
- }
213
- if (c.required.length === 0 && c.optional.length === 0) {
214
- lines.push("_No business parameters._");
215
- lines.push("");
216
- }
217
- lines.push("```bash");
218
- lines.push(exampleFor(v.name, action, c.required));
219
- lines.push("```");
220
- lines.push("");
221
- }
222
- } else {
223
- // Action-less verb (composite fan-out or 1:1 op): explicit param split.
224
- if (tool.params.required.length > 0) {
225
- lines.push("Required:");
226
- lines.push("");
227
- lines.push(...paramTable(tool.params.required));
228
- }
229
- lines.push("Optional:");
230
- lines.push("");
231
- lines.push(...paramTable(tool.params.optional));
232
- lines.push("```bash");
233
- lines.push(exampleFor(v.name, null, tool.params.required));
234
- lines.push("```");
235
- lines.push("");
236
- }
237
- }
238
- }
239
-
240
- // ── Meta tools ─────────────────────────────────────────────────────────
241
- lines.push("## Meta tools");
242
- lines.push("");
243
- lines.push("### `discover`");
244
- lines.push("");
245
- lines.push(
246
- "Progressive introspection of the live surface. `bgc discover` lists domains; " +
247
- "`--domain <d>` lists a domain's verbs; `--tool <t>` returns one verb's full schema; " +
248
- "`--tool <t> --action <a>` returns one action's exact required/optional contract; " +
249
- "`--search <q>` keyword-searches the whole surface.",
250
- );
251
- lines.push("");
252
- lines.push("### `raw`");
253
- lines.push("");
254
- lines.push(
255
- "Escape hatch to any catalog operation by id, bypassing the intent layer: " +
256
- "`bgc raw --operationId <id> --args '<json>'`. Use when no verb fronts the operation you need.",
257
- );
258
- lines.push("");
259
-
260
- writeFileSync(join(refsDir, "commands.md"), lines.join("\n"), "utf8");
261
-
262
- const verbCount = [...verbsByDomain.values()].reduce((n, v) => n + v.length, 0);
263
- console.log(
264
- `Generated references/commands.md — ${overview.domains.length} domains, ${verbCount} verbs ` +
265
- `(SDK ${SERVER_VERSION}, spec ${CATALOG_SPEC_VERSION}, ${CATALOG_OPERATION_COUNT} ops).`,
266
- );
@@ -1,345 +0,0 @@
1
- ---
2
- name: bitget-agentic
3
- description: >
4
- Use for Bitget Agentic account on the remote MCP https://agent.bitget.com/mcp
5
- (OAuth token, not local API keys). Invoke when the user connects an Agentic
6
- account, re-authorizes, says Connect Agent, reports auth expired, cannot trade,
7
- or trades or queries an account via that remote MCP — even without saying
8
- "Bitget". Chinese triggers: 连接 Agent、重新授权、同意升级到新版MCP、Agentic 账户、
9
- Agent 子账户、Agent 账户、AI 账户、智能交易账户、Key 失效、连不上、
10
- Connect Agent、帮我下单、查 Agentic 余额/持仓. Do NOT use for UTA env API keys,
11
- @bitget-ai/bitget-signal (including its market-data MCP), bgc, a local MCP filled
12
- with BITGET_API_KEY / BITGET_SECRET_KEY / BITGET_PASSPHRASE, or the old
13
- local stdio package @bitget-ai/bitget-agent-mcp. npm and npx are
14
- install channels, not the old edition.
15
- After install, this file covers later chats (prefer this over
16
- bitget-agentic-connect once MCP is already connected). The online connect
17
- guide is only for first-time setup. Server tools are guide, do_query, and
18
- do_request_open_api only — mcp_auth is a client-side OAuth entry (Cursor),
19
- not a server tool. If those three tools are missing, reconnect the remote
20
- MCP before OAuth. Do not invent an auth link.
21
- metadata:
22
- version: 2.2.6
23
- author: Bitget
24
- updated: 2026-11-10
25
- requires:
26
- bins: ["node", "npx"]
27
- node: ">=20"
28
- packages:
29
- mcp: "https://agent.bitget.com/mcp"
30
- license: MIT
31
- ---
32
-
33
- # Bitget Agentic · Local Skill
34
-
35
- Cloud MCP: `https://agent.bitget.com/mcp` (formerly called Agent sub-account). The login state is an OAuth token kept on this cloud MCP connection. Do not copy the token into this file or save a separate copy.
36
-
37
- **The server has only three tools:** `guide`, `do_query`, `do_request_open_api`.
38
- **`mcp_auth` is not a server tool** — it is the client-side entry (Connect / Authenticate) that Cursor and similar clients use to start OAuth against this MCP. Do not `tools/call` a tool named `mcp_auth` on the remote. On Claude Code and other clients without that entry, use an unauthorized / HTTP 401 response from a private `do_request_open_api` call to trigger client OAuth, or follow that client's MCP login flow.
39
-
40
- The online connect guide (`bitget-agentic-connect`) only covers first-time install, connecting the cloud MCP, and the first authorization. This file stays in effect after install; for re-authorization, trading, and disconnect after MCP is already connected, follow this file — do not hand off to the connect guide again.
41
-
42
- If this chat was just told to read this file after install: read the whole file first, not only the opening. Do not send the user to another chat before you finish reading.
43
-
44
- Only skip OAuth when the user explicitly says not to authorize. Saying “just check the market first” is not a refusal. Market data can be queried without login.
45
-
46
- ---
47
-
48
- ## Rules
49
-
50
- - Market data can be queried without login. Trading, account, Reality / rToken require login. Check with `guide` before calling; if an interface is not available, say so.
51
- - Do not: withdraw, transfer from main account to sub-account, change main-account email / phone / 2FA. US stock direct, CFD, tax, staking/lending, and institutional lending are not connected.
52
- - Do not issue or paste API Keys, and do not configure `BITGET_API_*`. One Agentic account can authorize only one Agent, and one Agent can connect only one Agentic account — rebinding (the same Agent to a new account, or another Agent to an already-authorized account) replaces the previous authorization (existing monitored orders may stop working — you must warn the user).
53
- - Agentic accounts created by the old SDK / npm cannot use the new OAuth: selecting an existing sub-account on the auth page will fail. The first time the user uses the new OAuth, guide them to create a new account — do not pick an old one. If the account was already created or connected via the new OAuth, it can be reused on re-authorization.
54
- - Multiple Agents can run at once, each bound to its own sub-account, to manage multiple Agent sub-accounts; if the user wants one Agent to manage multiple sub-accounts, tell them to [join the group and feedback to the product team](https://telegram.me/+o1tYqQ_lXxllYjgy).
55
- - Disconnect on the web at “Sub-account management” → “Disconnect Agent”, not the API Key list.
56
- - Authorization is opened by the **client** against this MCP (Cursor uses `mcp_auth` / Connect). Do not invent an authorization link. When opening OAuth, match the current client against the “Supported client_id” list below; do not assemble an authorization link yourself, and do not change `redirect_uri`.
57
- - Do not proactively use legacy capabilities, and do not remind about them in every chat. Only when the user is about to use them, tell them to avoid them and clear the related config themselves. Do not edit config for the user, and do not assume a fixed config path. Do not use npm / npx to mean “legacy”. The following are **not** legacy under Section 2 — do not treat them as legacy or block OAuth because of them:
58
-
59
- - Terminal CLI `bgc` (`@bitget-ai/bitget-agent-cli`)
60
- - UTA skill without `--skill agentic`. The package name is still `@bitget-ai/bitget-agent-skill`; it is a skill that uses manual API keys, not MCP
61
- - `@bitget-ai/bitget-signal` and its bundled market-data MCP (not this Agentic cloud MCP)
62
- - `npx @bitget-ai/bitget-agent-installer upgrade-all` (also installs signal and its market-data MCP)
63
- - `--target all` only installs the skill on multiple clients; it is not a legacy capability
64
- - Whether the token is valid is judged by unauthorized errors from the MCP (private call failure / HTTP 401). Do not memorize a TTL, and do not call it an API Key expiry.
65
- - Logged-in check: a successful `do_request_open_api` call with a read-only account `operation_id` is enough — prefer `getAccountAssets`, or use `getDeductInfo`. A wrong Cursor `auth.CLIENT_ID` (not `cursor`) causes auth anomalies: the flow finishes but still shows not logged in or 403.
66
- - If the user shows clear product-level confusion or questions (not operational details this doc can cover), you may suggest they [join the group to feedback to the product team](https://telegram.me/+o1tYqQ_lXxllYjgy).
67
-
68
- Safety first, then state clarity, then response speed.
69
-
70
- ---
71
-
72
- ## Call surface (guide first, then execute)
73
-
74
- ```
75
- Market: guide(surface="market_data") → … → entry_id → do_query(entry_id, params)
76
- Trade/account: guide(surface="open_api") → … → operation_id
77
- → do_request_open_api(operation_id, params)
78
- Writes: dry_run=true first for a confirmation card → user clearly says “yes/confirm” → then confirm=true
79
- ```
80
-
81
- If the id is uncertain, you must `guide` first — do not guess `entry_id` / `operation_id`.
82
-
83
- ---
84
-
85
- ## 1. Authorization
86
-
87
- First check whether this chat can use the three cloud MCP tools (at least `guide`). If none are visible, follow “Tools not in this chat” below and stop here — this is a connection problem, not an authorization failure. Do not invent an auth link, do not install `@bitget-ai/bitget-agent-mcp`, and do not reinstall this skill.
88
-
89
- If the tools are already in this chat: use one read-only account call to check login, for example:
90
-
91
- ```
92
- do_request_open_api(operation_id="getAccountAssets", params={})
93
- ```
94
-
95
- (You may also use `getDeductInfo`.) If it succeeds, the user is logged in — no re-authorization. If not logged in, or a private call returns unauthorized / 401, follow this order:
96
-
97
- 1. Run the Section 2 check. If legacy is found, give the cleanup/upgrade reminder first — you do not need to wait for the user to reply “agree to upgrade” before continuing, unless they explicitly say they do not want to upgrade or deal with legacy, in which case stop.
98
- 2. Tell the user: re-authorizing will replace the old token on this cloud MCP connection; please handle positions and open orders first.
99
- 3. Open client authorization per Section 3. Tell the user a browser will open to finish auth — no need to copy an API Key. Do not fill in passwords for them.
100
- 4. Confirm login again with `getAccountAssets` (or `getDeductInfo`). Finishing the page is not enough. After confirmation, tell the user:
101
-
102
- > Authorization complete. An API Key will not be sent to you. Login state stays on the cloud MCP connection — you do not need to hand me any secret.
103
-
104
- When the user wants to disconnect or remove an old API Key, use the exact wording in Section 6 — do not write a separate version here.
105
-
106
- ### Tools not in this chat
107
-
108
- This chat cannot see `guide` / `do_query` / `do_request_open_api`. The address may not be registered in the current client's MCP config yet, or it is registered but this chat has not picked it up. Register/confirm as below, and try `guide()` in this chat — do not assume a new chat is always required.
109
- **Do not** use “whether `mcp_auth` exists” as the only criterion — if there is no client auth entry but the three server tools are present, MCP is connected and only OAuth is needed.
110
-
111
- There is only one address: `https://agent.bitget.com/mcp`. Do not change this domain, and do not configure `BITGET_API_*`.
112
-
113
- If not registered yet, the Agent registers it directly. Clients that can configure MCP themselves (Claude Code / Cursor / Codex) write the address into MCP config; clients with a native connector (e.g. ChatGPT / Dot, Grok Bot) can start authorization directly without manually adding the address:
114
-
115
- - Claude Code: `claude mcp add -s user bitget-mcp-server --transport http https://agent.bitget.com/mcp`, then quit and reopen `claude` (Claude has no Cursor-style `CLIENT_ID` setting)
116
- - Cursor: the Agent writes the HTTP server config into `~/.cursor/mcp.json` (merge with existing servers — do not overwrite the whole file), URL as above, `auth.CLIENT_ID` set to `cursor` (uppercase CLIENT_ID). After writing, the tool usually appears in the current chat right away
117
- - Codex (CLI / Desktop): in the terminal run `codex mcp add bitget-mcp-server --url https://agent.bitget.com/mcp --oauth-client-id codex` to add the server, then `codex mcp login bitget-mcp-server` to finish OAuth; Codex CLI and the desktop app share the same `~/.codex/config.toml` and login state — after auth, open the Codex/ChatGPT desktop app and it shows connected; no extra “Connect” click in the UI. **Codex has specific pitfalls — read “Codex connection notes” below before proceeding.**
118
- - Other clients: if the client has a custom MCP entry, register the same address its way and try once in this chat; if it has no custom MCP entry but has a native connector or auth entry (e.g. ChatGPT / Dot, Grok Bot), start client-side authorization directly — do not treat “cannot add the URL” as unsupported, and do not ask the user to switch clients
119
-
120
- ```json
121
- {
122
- "mcpServers": {
123
- "bitget-mcp-server": {
124
- "url": "https://agent.bitget.com/mcp",
125
- "auth": { "CLIENT_ID": "cursor" }
126
- }
127
- }
128
- }
129
- ```
130
-
131
- After registration, try `guide()` in this chat first, plus (if the client provides one) the auth entry for this MCP. In most cases the connection becomes available in this chat immediately — no new chat needed. If tools are still missing, the most common cause is that the config still has the old local stdio MCP package `@bitget-ai/bitget-agent-mcp`, or a local MCP with hand-filled API Keys — technically old and new can sit in the same config without error (soft conflict), but product-wise only one set is recognized, and the old one blocks the new connection (hard conflict). Explain clearly and guide cleanup — do not just say “check again”. Only after confirming there is no such legacy residue and tools are still missing should you ask the user to open a new chat and request authorization or trading again. The new chat will read this file and start from Section 1. Do not copy install steps from the online guide.
132
-
133
- ---
134
-
135
- ## 2. Legacy quick check
136
-
137
- Before opening the auth window, glance once — no state file, no need to remember across chats; just look at where the current client stores MCP config. Hitting either of the following counts as legacy:
138
-
139
- - Config starts `@bitget-ai/bitget-agent-mcp` via local stdio
140
- - This MCP config has hand-filled `BITGET_API_KEY` / `BITGET_SECRET_KEY` / `BITGET_PASSPHRASE`
141
-
142
- Legacy and the new cloud MCP can technically coexist in the same config without erroring (soft conflict), but product-wise only one set is recognized — keeping both causes call confusion (hard conflict). If legacy is still present, only use the three tools of the new cloud MCP (and the client's auth entry for this MCP); do not touch tools from the old stdio MCP, and do not use API Keys left by the old setup.
143
-
144
- Not legacy: only the cloud address `https://agent.bitget.com/mcp` is configured; `@bitget-ai/bitget-agent-skill` is a skill. bgc, bitget-signal, its market-data MCP, upgrade-all, and UTA skill without `--skill agentic` from the Rules are also not legacy — do not treat them as legacy or block OAuth because of them.
145
-
146
- Which npm package was installed on this machine, or whether `npm list` / `npm view` was run, cannot be used as evidence — do not look them up online or run those commands; only look at the two config checks above. Do not assume a fixed config path, and do not edit config for the user.
147
-
148
- If you cannot find the config location, do not assume there is no legacy. Tell the user you could not find it, and ask them to confirm whether this machine still has the old local stdio MCP package `@bitget-ai/bitget-agent-mcp` or a local MCP with hand-filled API Keys. If they confirm there is none, continue with the new flow; if they are unsure or say there is still legacy, give the reminder below.
149
-
150
- If legacy is still present, send the user the following and continue to Section 3 — you do not need an explicit “agree to upgrade” reply before opening the auth window; only stop and do not start OAuth if the user explicitly says they do not want to upgrade or deal with legacy.
151
-
152
- > This computer's MCP config still has the old local stdio MCP package (@bitget-ai/bitget-agent-mcp), or a local MCP with hand-filled API Keys. Old and new cannot be used together — please clear the old config soon and upgrade to this cloud version, which uses OAuth login and no longer issues or requires hand-filled API Keys. Clearing old config is on you; I will not edit config files for you.
153
- >
154
- > Agentic accounts created by the old SDK / npm are not compatible with the new OAuth — selecting an existing sub-account on the auth page will fail. After the auth window opens, create a new account the first time you use the new OAuth — do not pick an old account. If you already connected an account with the new OAuth before and this is only a re-authorization, reuse that account. If the account list is full, delete a few unused old accounts first, then create a new one.
155
- >
156
- > Before continuing authorization, please finish handling positions and open orders in the old account, so monitoring and pending orders do not silently fail after the upgrade.
157
-
158
- ---
159
-
160
- ## 3. Open authorization (client)
161
-
162
- Start client OAuth against this MCP — do not only send a link, and do not assemble an authorize URL yourself.
163
-
164
- 1. **Cursor:** call client `mcp_auth` on this MCP (or click Connect / Authenticate). Run only one round for the whole flow; do not keep clicking Authenticate / reconnect. Log in on the browser tab that opened this time. If you see “Authorization session ended” and the callback URL already has `code`, the old session was invalidated — start one fresh round only.
165
- 2. **Codex (CLI / Desktop):** use `codex mcp login bitget-mcp-server` to trigger and finish auth (same role as Connect). The CLI opens the browser OAuth window and handles the local callback; log in on the tab that opened this time. CLI and desktop share the login state — after login the desktop app shows connected. (Pitfalls: see “Codex connection notes” below.)
166
- 3. No window popped but a link was returned: open it with whatever the current environment uses to open a browser.
167
- 4. The command also failed: send the link as returned, and explain that this environment has no permission to open a window.
168
- 5. **Clients without `mcp_auth`:** first make one private read-only call (e.g. `getAccountAssets`); if it returns unauthorized / 401, complete MCP login per that client's docs; if there is still no entry, ask the user to log in to that server in the client's MCP settings. Clients with a native connector or auth entry (e.g. ChatGPT / Dot, Grok Bot) can start authorization directly without manually adding the MCP address — do not treat “cannot add the URL” as unsupported, and do not ask the user to switch clients.
169
-
170
- Use the link exactly as returned by the tool/client — do not rewrite it, and do not change Bitget domains in the user prompt.
171
-
172
- **Supported client_id values:** when opening OAuth, match the current client from the list below. The authorization window is still opened by the cloud MCP / client-side auth. Do not fabricate an authorization link, and do not change `redirect_uri`.
173
-
174
- ```json
175
- [
176
- {
177
- "client_id": "https://claude.ai/oauth/claude-code-client-metadata",
178
- "client_name": "Claude Code",
179
- "redirect_uris": [
180
- "http://localhost/callback"
181
- ],
182
- "loopback_port_agnostic": true,
183
- "fetch_cimd": false
184
- },
185
- {
186
- "client_id": "https://claude.ai/oauth/mcp-oauth-client-metadata",
187
- "client_name": "Claude / Duet",
188
- "redirect_uris": [
189
- "https://claude.ai/api/mcp/auth_callback"
190
- ],
191
- "loopback_port_agnostic": false,
192
- "fetch_cimd": true
193
- },
194
- {
195
- "client_id": "https://chatgpt.com/oauth/client.json",
196
- "client_name": "ChatGPT / Dot",
197
- "redirect_uris": [
198
- "https://chatgpt.com/connector_platform_oauth_redirect"
199
- ],
200
- "redirect_uri_prefixes": [
201
- "https://chatgpt.com/connector/oauth/"
202
- ],
203
- "loopback_port_agnostic": false,
204
- "fetch_cimd": false
205
- },
206
- {
207
- "client_id": "cursor",
208
- "client_name": "Cursor",
209
- "redirect_uris": [
210
- "https://www.cursor.com/agents/mcp/oauth/callback",
211
- "https://www.cursor.com/bot/mcp/oauth/callback",
212
- "https://grok.com/connectors-oauth-exchange-code/"
213
- ],
214
- "loopback_port_agnostic": false,
215
- "fetch_cimd": false
216
- },
217
- {
218
- "client_id": "https://cursor.com/oauth/mcp-client.json",
219
- "client_name": "Cursor CIMD / Grok Bot",
220
- "redirect_uris": [
221
- "https://www.cursor.com/agents/mcp/oauth/callback",
222
- "https://www.cursor.com/bot/mcp/oauth/callback",
223
- "https://grok.com/connectors-oauth-exchange-code/"
224
- ],
225
- "loopback_port_agnostic": false,
226
- "fetch_cimd": true
227
- },
228
- {
229
- "client_id": "codex",
230
- "client_name": "OpenAI Codex",
231
- "redirect_uris": [
232
- "http://localhost/callback"
233
- ],
234
- "loopback_port_agnostic": true,
235
- "fetch_cimd": false
236
- },
237
- {
238
- "client_id": "muse",
239
- "client_name": "Meta Muse",
240
- "redirect_uris": [
241
- "https://agent.meta.ai/api/hatch/oauth/callback"
242
- ],
243
- "loopback_port_agnostic": false,
244
- "fetch_cimd": false
245
- },
246
- {
247
- "client_id": "minimax",
248
- "client_name": "MiniMax Code",
249
- "redirect_uris": [
250
- "http://localhost/callback",
251
- "http://localhost/auth/callback"
252
- ],
253
- "loopback_port_agnostic": true,
254
- "fetch_cimd": false
255
- }
256
- ]
257
- ```
258
-
259
- ### Codex connection notes (Codex only; other clients skip this subsection and go to Section 4)
260
-
261
- This subsection applies only to Codex / Codex App. Other clients (Cursor, Claude Code, etc.) skip it and continue at Section 4 below.
262
-
263
- Version requirement: Codex ≥ 0.147 (`codex --version`; upgrade first if lower).
264
-
265
- Codex callbacks are loopback and must use `localhost` + a fixed port (both places must match): `127.0.0.1` returns 403; `localhost` without a port shows `localhost refused to connect`. `codex mcp add` defaults to `127.0.0.1` — change it to:
266
-
267
- ```toml
268
- [mcp_servers.bitget-mcp-server]
269
- url = "https://agent.bitget.com/mcp"
270
-
271
- [mcp_servers.bitget-mcp-server.oauth]
272
- client_id = "codex"
273
- callback_url = "http://localhost:59999/callback"
274
- callback_port = 59999
275
- ```
276
-
277
- (59999 can be any free port; `callback_url` and `callback_port` must match.)
278
-
279
- Login with a proxy (use the proxy actually found in Section 4):
280
-
281
- `HTTPS_PROXY=<proxy> HTTP_PROXY=<proxy> codex mcp login bitget-mcp-server`
282
-
283
- On the auth page, guide the user to: choose “Create a new Agentic account” → check the agreement boxes → click Authorize. **Do not choose “Use an existing account”** — accounts from the old SDK / npm will fail, and the CLI reports `invalid_request`.
284
-
285
- Afterward verify with `getAccountAssets`; success means connected. If you first get `Authentication required`, wait a few seconds and retry.
286
-
287
- CLI and App share `~/.codex/config.toml` and login state. The App ships with the codex CLI; after one login the App shows connected — no extra click needed.
288
-
289
- > The above is the standard Codex path — follow it first. If the real situation differs (version, proxy port, errors, config path, etc.), the Agent may diagnose and adapt; do not get stuck on this subsection — the goal is to get the user connected, not to replay every step here.
290
-
291
- ---
292
-
293
- ## 4. Network
294
-
295
- The auth page and callback need access to bitget.com. On timeout, ECONNREFUSED, ENOTFOUND, network, fetch failed, or if the user says Bitget will not open: check the proxy first — do not immediately treat it as an auth failure and retry.
296
-
297
- Look at the proxy already active in the current environment — do not assume a specific port or config file. If there is a proxy, route the environment through it and reopen Section 3. If not, ask the user to enable one, wait for confirmation, then authorize. Do not have the user keep clicking Allow without checking the network, do not invent bitget.com links, and do not ask the user to hand-fill an API Key.
298
-
299
- ---
300
-
301
- ## 5. Trading and market data
302
-
303
- After login:
304
-
305
- - **Market data:** `guide(surface="market_data", …)` → `do_query(entry_id, params)`
306
- - **Trading / account / Reality:** `guide(surface="open_api", …)` → `do_request_open_api(operation_id, params)`
307
-
308
- Writes: first `dry_run: true` for a confirmation card. After the user clearly replies “yes” or “confirm”, execute with `confirm: true`. High-risk writes (e.g. cancel all, close all, set leverage, repay) require `confirm: true`. “Just do it for me” is not confirmation.
309
-
310
- Confirmation card: symbol, side, size, price type, account, mainnet, “Confirm execution?”. Check positions before closing. Include liquidation price when available. Do not add size on risk-type errors. If balance is insufficient, the user deposits on the web from the main account.
311
-
312
- Batch place / cancel / modify (`batchOrder` / `batchCancel` / `batchModifyOrders`): `params` as a JSON array of order objects, or `{"orderList"|"orders": [...]}`.
313
-
314
- ---
315
-
316
- ## 6. Disconnect and delete old accounts
317
-
318
- For disconnect, use this wording — do not click for the user:
319
-
320
- > Please go to “Sub-account management” on the web and use “Disconnect Agent”. You must clear open orders before disconnecting. Funds can be transferred back in sub-account management; that step is not a prerequisite for disconnect.
321
-
322
- Deleting an old API Key: the new version has no API Key, and you cannot delete a Key alone on the web. First get the name with `getAccountAssets` (or an equivalent read-only account call). If you cannot find it, say so — do not invent. If not logged in, authorize first — do not have the user delete blindly. After you have the name, use:
323
-
324
- > To remove the old API Key for account “{name}”, you must first clear unfinished orders and transfer assets out, then manually delete this Agentic sub-account on the web. I cannot delete it for you.
325
-
326
- ---
327
-
328
- ## 7. Failures
329
-
330
- | Situation | Action |
331
- |-|-|
332
- | Not logged in but wants to trade or query account | Section 1 |
333
- | User cancelled, callback incomplete, reason unclear | “Authorization was not completed. Should I start again?” |
334
- | Token invalid or disconnected on the web | Section 1 |
335
- | Rate limited | Retry later; do not re-authorize |
336
- | Insufficient balance | Have the user deposit on the web |
337
- | All three server tools missing | Back to Section 1 “Tools not in this chat”. Do not invent a link, do not install `@bitget-ai/bitget-agent-mcp`, do not reinstall this skill |
338
- | Account list full | Delete a few unused old accounts, then create a new one. Do not fall back to accounts created by the old SDK / npm (selecting them will fail) |
339
- | Selecting an existing old account on the auth page fails | Guide the user to create a new account; old SDK / npm accounts cannot use the new OAuth |
340
- | KYC incomplete | Wait for the user to finish |
341
- | Cannot reach bitget.com | Section 4 |
342
- | Device verification failed | Ask the user to confirm it is the same App account, then authorize again. This is not token expiry |
343
- | Auth page returns JSON 422 missing OAuth params such as `response_type` / `client_id` / `redirect_uri` / `state` / `code_challenge` | Frontend login redirect dropped params — not an MCP failure; return to Section 3 for one fresh auth round; do not install the old stdio package or hand-fill an API Key |
344
-
345
- Do not: silently switch login state, delete a sub-account for the user, edit config for the user, keep trading after expiry, start OAuth after the user explicitly said they do not want to upgrade or deal with legacy, only send a link without opening the auth window (except when there is no permission to open a window), invent an auth link when tools are missing, treat “no mcp_auth” and “tools missing” as the same failure, or `tools/call` a fabricated `mcp_auth` on the server.