SuperAPI AI Directory

codebuddy-ide-mcp-upgrade

Coding & development

View repository

Updated 10-16 09:29

About this skill

codebuddy-ide-mcp-upgrade

When to use

  • Need to push the new version of CloudBase MCP into CodeBuddy IDE's built-in integration
  • Online feedback says "the CloudBase features integrated in the IDE are insufficient" (most likely the allowlist is outdated, not that MCP capabilities are lacking)
  • Need to modify the IDE's built-in toolWhiteList / systemPrompt / attatchPrompt
  • Need to determine "which version of the MCP in the IDE is actually installed, and which tools are available"

Integration structure (read first, don't guess)

CodeBuddy IDE's built-in CloudBase MCP is genie extensioncarried by, changing only one place won't take effect,must change both files:

File Content Equivalent source
Contents/Resources/app/extensions/genie/integration-mcp/tcb/index.cjs MCP Server bundle Repository mcp/dist/cli.cjs renamed
Contents/Resources/app/extensions/genie/out/extension/index.js embedded tcb integration config (webpack module,ir.exports=JSON.parse('{...}')) no repository to match against, must unpack in place

Default IDE path:/Applications/CodeBuddy CN.app. The same directory also contains anydev、eop、lighthouse three integrations, don't change the wrong one.

Loading and startup contract:

// TcbIntegration
mcpServer: {
  path: path.join("integration-mcp", "tcb", "index.cjs"),
  envMapper: (r) => ({ TENCENTCLOUD_SECRETID: r.tmp_secret_id,
                       TENCENTCLOUD_SECRETKEY: r.tmp_secret_key,
                       TENCENTCLOUD_SESSIONTOKEN: r.token }),
  toolWhiteList: config.toolWhiteList,
}
// StdioClientTransport
{ command: process.execPath, args: [mcpPath],
  env: { ...envMapper(), INTEGRATION_IDE: "CodeBuddy",
         ELECTRON_RUN_AS_NODE: "1", WORKSPACE_FOLDER_PATHS } }

Do not pass any command line arguments(--cloud-mode / --integration-ide are useless), credentials all rely on environment variables, MCP side mcp/src/auth.ts directly reads TENCENTCLOUD_SECRETID/SECRETKEY。

Steps

1. Unpack to get the online baseline (first step is mandatory)

The config is embedded in the 21MB out/extension/index.js , wrapped with JSON.parse('...') ,must be eval'd according to JS string semantics to parse:

const i = s.indexOf('"id":"tcb"');
const st = s.lastIndexOf("JSON.parse('", i) + 12;
let cursor = st, cfg;
for (;;) {
  cursor = s.indexOf("')", cursor + 1);
  try { cfg = JSON.parse(eval("'" + s.slice(st, cursor) + "'")); break; } catch {}
}

After obtaining it, first count the allowlist and compare it with the repository scripts/tools.json .Ninety percent of the problems are here: the allowlist is stuck at an old version, and it is full of dead entries that have been renamed by MCP.

2. Build the new bundle

cd <repo>/mcp && npm run build:webpack   # 产物 dist/cli.cjs,约 4.6 MiB

Only run build:webpack, do not run npm run build(it will trigger prebuild 's rm -rf dist, and may be intercepted by the safe-delete hook).

3. Generate the new config

The true source of the allowlist is scripts/tools.json,do not handwrite the list. Config changes go in:

  • toolWhiteList ← tools.json all tool names (full set, do not trim, for the reason see "the premise for allowlist trimming no longer exists")
  • systemPrompt.login / .logout、userPrompt.*、attatchPrompt.* <- prompt words
  • Other fields (id、displayName、description、descriptionMap、types、ruleZipUrl、loginOnlyChinese、loginType、toolTimeout)keep original values

3.1 Two things that must be known before writing prompt words

(1) PG mode = Supabase isomorphism, not "one more kind of database"

After determining it is a PG environment, authentication, storage, permissions, migrationall four are redirected:

Capability layer Supabase CloudBase PG mode Tools
Database Postgres PostgreSQL queryPgDatabase / managePgDatabase
Schema changes Migration applyMigration(must include migrationVersion) managePgDatabase
row-level authorization RLS Policies RLS managePgDatabase + rls-patterns.md
Storage Storage Buckets pgstore (a separate system from legacy COS) queryPgStorage(not queryStorage)
Authentication anon/service key Application authentication (publishable key / API key) queryAppAuth / manageAppAuth

Guiding to the wrong path in a PG environment (using NoSQL/MySQL tools, or using queryStorage instead of queryPgStorage) is the most frequent way of going off track.

(2) Look at the prompt's weight distribution, not the total length

  • Total length is not the problem:systemPrompt.login About 10.6k characters ≈ 3.5k tokens, which under Tool Search + long context does not constitute a burden. Deleting guidance to "look short" = losing the judgment quality at key branching points.
  • Look at the ratio of constants vs variables. Measured proportions from one revision:
    • Static index (list of rule file paths + list of console URLs) accounts for 28.8%, but the model can look it up at any time, and the rule file already contains the complete version (the prompt itself even says "see platform rule for full list");
    • The branch variables that truly determine the direction (such as the PG mainline) account for only 6.6%, and they are scattered across non-adjacent sections, requiring the model to piece them together itself — this is a typical cause of "the prompt wrote it but the model didn't follow it".
  • How to fix:
    1. Move the constant index down (can save ~23%), and use the freed space to surface the variable mainline;
    2. After branch determination,immediately follow with a "reroute table", converging the scattered constraints into one place;
    3. For "choose one of three" style parallel lists, if each branch changes multiple subsequent decisions, rewrite them as two self-contained "mainlines".

After revising the prompt, use this script to quantify the weight distribution; don't rely on feeling:

node -e '
const s=require("fs").readFileSync("config/prompts/systemPrompt.login.md","utf8"),L=s.split("\n");
let c="(开头)",a={[c]:0},o=[c];
for(const l of L){if(/^## /.test(l)){c=l.slice(3);if(!(c in a)){a[c]=0;o.push(c)}continue}
if(/^### /.test(l)){c=l.slice(4);if(!(c in a)){a[c]=0;o.push(c)}continue}a[c]+=l.length+1}
for(const k of o)console.log(String(a[k]).padStart(6),(a[k]/s.length*100).toFixed(1).padStart(5)+"%  ",k.slice(0,50))'

4. Inject into the IDE (dry-run first)

node scripts/apply-to-ide.mjs --dry-run   # 只看差异
node scripts/apply-to-ide.mjs             # 备份到 backup/<时间戳>/ 后写入
node scripts/patch-tool-timeout.mjs --timeout 300000   # 接通 toolTimeout(见 Pitfalls)

The replacement logic for writing the config: generatecompact JSON(JSON.stringify(cfg), no bare line breaks), then escape according to JS single-quoted string rules (first \\ then '), and replace the JSON.parse('...') range. Wrong escaping order will break the JS string.

Boundary semantics (learned the hard way, do not get this wrong):start = raw start point (slice(0, start) inalready includes JSON.parse('),end = ') after. So when replacing,you can only concatenate escaped raw + '), and must never concatenate JSON.parse('。

5. Verification

node scripts/verify-ide-config.mjs   # 从 IDE 回读配置,逐字段比对
node scripts/verify-bundle.mjs       # 按 IDE 方式启动 bundle,拉 tools/list

verify-bundle.mjs Replicate the IDE's startup parameters (stdio + INTEGRATION_IDE=CodeBuddy + ELECTRON_RUN_AS_NODE=1 + temporary key placeholder value), and compare three things: whether all exposed tools are within the whitelist, whether the whitelist has dangling entries, and whether the PG tools are registered.

6. Rollback

node scripts/rollback-ide.mjs --latest

Mandatory synchronization items when releasing MCP (to prevent drift)

Whitelist drift is the sole root cause of "insufficient CloudBase functionality in the IDE", not an MCP capability issue. Online measurement: of the 21 whitelist entries, 12 are dead entries that have been deleted or renamed by MCP, and users can actually only use 9.

Therefore, every time MCP releases a version (tools added/deleted/renamed), the IDE-side whitelist must be regenerated, otherwise no matter how frequently new MCP versions are released, the IDE still has the old one.

Release checklist:

  1. scripts/tools.json whether it has been updated (the true source of the tool list)
  2. Use scripts/build-config.mjs to regenerate the IDE config, producing a new toolWhiteList
  3. Check whethernewly added/renamedtools have corresponding guidance in the prompt — referencing a deleted tool name in the prompt will cause the model to call a nonexistent tool
  4. Sync the new config to the IDE side (or directly execute this skill's Steps to inject it into the local IDE for verification)
  5. Record "which tools were newly added this time" in the delivery document, to help the IDE side understand the changes

It is recommended to attach this checklist to the MCP release process (release workflow or release checklist document), and not rely on human memory. The consequence of relying on humans to remember is this batch of 12 dead entries.

The premise for whitelist trimming no longer exists

  • CodeBuddy now supports Tool Search: MCP tools are retrieved on demand and no longer stuffed into the context in full; the MCP server configuration layer also supports defer_loading。
  • The only reason we originally added toolWhiteList to tcb was to save context, and that premise is now gone.
  • Conclusion: the whitelist returns to the single responsibility of "security boundary", generated in full per tools.json full generation. The only consequence of continuing to trim is drifting into dead entries as MCP releases change.
  • ⚠️ When judging "whether the IDE supports Tool Search"do not grep genie's out/extension/index.js — you won't find the ToolSearch string there (0 hits in testing). Tool Search belongs to the Agent CLI kernel layer; the evidence is in the CLI process arguments (--tools whitelist contains ToolSearch) and in mcp-config's defer_loading .

Pitfalls

  • Whitelist filtering happens on the IDE side, not inside the bundle. Swapping only the bundle without swapping the whitelist = new tools are silently filtered out, with zero change on the user side. This is the easiest pitfall to hit.
  • After writing, you must fully exit and restart the IDE for it to take effect; a running process has already loaded the old bundle into memory.
  • When unpacking, the configuration string may contain ') sequences, so you must use "whether eval + JSON.parse succeeds" to determine the end position, not the first ')。
  • To locate the tcb block, you must use "id":"tcb" as the anchor. The full text has toolWhiteList appearing 13 times; searching with toolWhiteList will catch eop (EdgeOne)'s configuration block — the symptom is that the extracted raw is only 1,015 characters (normally it should be ~16,000).
  • Plugin-type tools (such as msg-push) are not in DEFAULT_PLUGINS , and will not be registered even if written into the whitelist; you need to inject CLOUDBASE_MCP_PLUGINS_ENABLED=msg-push. A whitelist of 40 entries with 38 actually exposed isnormal, not a bug.

⚠️ The number one trap: all-green JSON readback ≠ the file is usable

A past incident: during replacement, the JSON.parse(' prefix was concatenated repeatedly, generating JSON.parse('JSON.parse('{...}'), and the second ' closed the string early, making the whole file SyntaxError。but the verify script's JSON field comparison all showed ✅ — because the locating used lastIndexOf("JSON.parse('"), which happened to hit the second prefix and could still parse out correct JSON.

Iron rule: after modifying this kind of large packaged artifact,you must perform a real compilation of the entire file:

import vm from "node:vm";
try { new vm.Script(source, { filename: "index.js" }); }
catch (e) { /* 立即回滚备份 */ }
  • The write script must have built-in compilation validation + automatic rollback on failure
  • The verify script's structure/syntax check musthard-block exit 1; only printing ❌ without changing the exit code is equivalent to no check at all
  • Before delivery, independently run node --check <file>once more; don't trust only your own script
  • Reverse test: feed a known-corrupted backup to verify and confirm it really reports failure (otherwise the detection is just for show)

Known IDE-side defects:toolTimeout is not wired up; it's actually only 60 seconds

  • TcbIntegration 's configuration objectdoes not have toolTimeout field (EopIntegration was passed)
  • callTool uses this.config.toolTimeout → undefined
  • MCP SDK:const Sn = sn?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC, while DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4
  • ⇒ the "toolTimeout":120000 Never took effect, actually it cuts off PG after 60 seconds applyMigration / CloudRun deployment

Fix (scripts/patch-tool-timeout.mjs):

  • Patch A: for TcbIntegration configuration object add toolTimeout:hn.toolTimeout(anchor attatchPrompt:hn.attatchPrompt,loginOnlyChinese:hn.loginOnlyChinese}, the only 1 occurrence in the whole text)
  • Patch B: raise the configuration value from 120000 to 300000

The whitelist can safely keep extra slots (verified in source code)

((ir?.tools) || []).filter((ir) => this.config.mcpServer.toolWhiteList.includes(ir.name))

What is iterated is what the server actually returns tools/list, the whitelist only performs the includes check. Extra entries are silently skipped, do not error, and do not produce dangling tools. So sending the whitelist in full according to tools.json is safe, and no further configuration changes are needed when plugins are enabled later.

  • mcp/src/server.ts uses ide === "CodeBuddy" to check the logging capability, case-sensitive; what the IDE passes is exactly "CodeBuddy", do not change it to lowercase.
  • Old-version bundles use the old MySQL / cloud function / storage tool names (executeReadOnlySQL、createFunction、uploadFiles、writeSecurityRule , etc.), these names have all disappeared in the new bundle; if the prompt still references them, it will lead the model to call non-existent tools.

Verification

Before delivery, all of the following must be satisfied:

  1. Run independently node --check "<genie>/out/extension/index.js" passes(most critical, can catch syntax errors masked by read-back verification)
  2. apply-to-ide.mjs outputs "syntax valid" + "read-back verification passed"
  3. verify-ide-config.mjs structural integrity three items ✅ + seven fields ✅,echo $? is 0
  4. verify-bundle.mjs shows "all exposed tools are in the whitelist" and the PG trio (queryPgDatabase / managePgDatabase / queryPgStorage) is registered
  5. verify-ide-config.mjs reverse test: feeding a known corrupted file must exit 1
  6. After restarting the IDE, complete the manual end-to-end acceptance below (E1–E10)

Manual end-to-end acceptance test cases (the layer that automation cannot prove)

The script can only prove "the bundle and configuration files themselves are correct",it cannot prove that after the IDE loads it the user can actually use it. After restarting, run each item:

# Case Expected
E1 Fully quit then restart the IDE The integration panel renders normally, no SyntaxError, the genie extension reports no errors
E2 The integration panel connects to CloudBase Login succeeds, environment information is displayed
E3 Have the Agent list the available CloudBase tools The count matches the new whitelist (not the old-version count)
E4 In a PG environment have the Agent create a table Goes through managePgDatabase 's applyMigration, the prompt first guides reading the postgresql-development-cloudbase rules
E5 Execute a read-only SQL query Goes through queryMysqlDatabase(no longer executeReadOnlySQL)
E6 Deploy a Node.js cloud function Goes through manageFunctions(no longer createFunction)
E7 Access storage in PG mode Goes through queryPgStorage rather than queryStorage
E8 View/modify security rules Goes through queryPermissions / managePermissions(no longer writeSecurityRule)
E9 A PG migration taking >1 minute Is not interrupted, the 5-minute timeout takes effect (verify the toolTimeout fix)
E10 Observe context usage during normal conversation No obvious bloat after fully opening up the tools (verify the Tool Search conclusion)

Two pitfalls during verification:

  • tcb temporary credentials expire: the log shows Authorization cache loaded for tcb, tempKey expires at: <过去时间>, and you must log in again in the integration panel before MCP comes up.
  • MCP process starts on demand: tcb's MCP Server is only launched after the integration panel connects, so when the IDE has just started, the absence of tcb's tools/list in the logs is normal,don't use that to conclude the bundle didn't take effect。

Log location:~/Library/Application Support/CodeBuddy CN/logs/<时间戳>/window1/exthost/Tencent-Cloud.coding-copilot/腾讯云代码助手.log(search [Integration] / tcb)。

Qualified baseline for MCP server-side quality (can be tested along the way)

If you want to evaluate the MCP tool layer itself along the way, these items are the baseline that has passed actual testing; failing them indicates a regression:

  • Read-only commitment:queryPgDatabase(action=sql) must intercept DELETE / UPDATE / DROP / multi-statement injection, and return executable suggestions with nextActions executable suggestions for
  • confirm gate:managePgDatabase(execute)、manageFunctions(deleteFunction) when confirm is missing must be rejected
  • Zero crashes on negative paths: nonexistent function names / collections / envId / topic all return structured errors or normal semantics, with no bare stack trace
  • Explicit capability boundaries: in a PG environment, queryPermissions should return "PostgreSQL type environments are not supported" rather than pretending to succeed

The complete deliverable template (docs + config + scripts) for the first hands-on run is in the CloudBase-MCP repository's specs/cb-ide-mcp-upgrade/(worktree chore/cb-ide-mcp-upgrade)。

Pre-delivery consistency self-check (easily missed)

For any two-step process of "change config + then apply a separate patch", the scalars changed by the patch must flow back into the config generation script。

Example: in this task, toolTimeout was first raised from 120000 to 300000 via patch-tool-timeout.mjs a separate patch, while build-config.mjs generated tcb-config.new.json still has 120000. The deliverable carries the old value, so if the IDE side directly uses the config, it will fall back to two minutes.

Self-check items:

  1. Compare "the scalar values in the delivered config JSON" with "the values actually in effect in the IDE", and ensure they are equal item by item
  2. The number of whitelist entries, the length of each prompt, and all scalar fields must all match; don't just rely on the readback script reporting green
  3. The numeric tables in the docs (changed items, suggested items) must stay consistent with the config source

Readability of delivered docs (easily overlooked)

Do not put Markdown deliverables under a hidden directory starting with a dot. git worktree commonly uses .worktrees/<name>/, and previewers often refuse to load hidden-directory resources due to security policies, manifesting as "the file can be read, but clicking it won't open it / errors out".

Do two things before delivery:

  1. Mirror the document artifacts to a non-hidden path (this time use ~/Projects/cb-ide-mcp-upgrade/),present_files to point to that path
  2. Generate a self-contained HTML version,present_files pass it first (HTML will open both the preview panel + list the artifact card, which is the most stable)

The rendering script is in this skill's scripts/render-html.mjs, and depends on marked:

mkdir -p /tmp/mdrender && cd /tmp/mdrender
echo '{"name":"mdrender","private":true}' > package.json
npm install marked
NODE_PATH=/tmp/mdrender/node_modules node <skill>/scripts/render-html.mjs \
  "<交付目录>/README.md" "<交付目录>/README.html" "文档标题"

Note:npm install don't run it in ~/.workbuddy/binaries/node/workspace — when there is no package.json, npm will search upward and find ~/node_modules and fail with ENOTEMPTY. Installing into a temporary directory that has a package.json is the easiest.

The artifact comes with sidebar directory navigation (generated from h2/h3), table and code highlighting styles, and@media print print rules (can be directly exported to PDF and handed to an external team).