惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Martin Fowler
Martin Fowler
博客园_首页
量子位
T
Tailwind CSS Blog
博客园 - Franky
G
Google Developers Blog
D
DataBreaches.Net
Vercel News
Vercel News
B
Blog
Recent Announcements
Recent Announcements
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
爱范儿
爱范儿
博客园 - 【当耐特】
The Cloudflare Blog
H
Help Net Security
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
C
Check Point Blog
有赞技术团队
有赞技术团队
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(config): share MCP mutation pipeline · openclaw/...
vincentkoc · 2026-06-22 · via Recent Commits to openclaw:main

@@ -67,9 +67,10 @@ export async function listConfiguredMcpServers(): Promise<ConfigMcpReadResult> {

6767

};

6868

}

696970-

export async function updateConfiguredMcpServerTools(params: {

70+

async function updateConfiguredMcpServerConfig(params: {

7171

name: string;

72-

tools: McpServerToolSelection | null;

72+

update: (server: Record<string, unknown>) => Record<string, unknown>;

73+

errorLabel: string;

7374

}): Promise<ConfigMcpWriteResult> {

7475

const name = params.name.trim();

7576

if (!name) {

@@ -92,22 +93,7 @@ export async function updateConfiguredMcpServerTools(params: {

92939394

const next = structuredClone(loaded.config);

9495

const servers = normalizeConfiguredMcpServers(next.mcp?.servers);

95-

const server = { ...servers[name] };

96-

if (params.tools === null) {

97-

delete server.toolFilter;

98-

} else {

99-

const include = normalizeToolSelectionList(params.tools.include);

100-

const exclude = normalizeToolSelectionList(params.tools.exclude);

101-

if (include || exclude) {

102-

server.toolFilter = {

103-

...(include ? { include } : {}),

104-

...(exclude ? { exclude } : {}),

105-

};

106-

} else {

107-

delete server.toolFilter;

108-

}

109-

}

110-

servers[name] = server;

96+

servers[name] = params.update({ ...servers[name] });

11197

next.mcp = {

11298

...next.mcp,

11399

servers,

@@ -119,7 +105,7 @@ export async function updateConfiguredMcpServerTools(params: {

119105

return {

120106

ok: false,

121107

path: loaded.path,

122-

error: `Config invalid after MCP tool selection update (${issue.path}: ${issue.message}).`,

108+

error: `Config invalid after MCP ${params.errorLabel} (${issue.path}: ${issue.message}).`,

123109

};

124110

}

125111

await replaceConfigFile({

@@ -135,57 +121,42 @@ export async function updateConfiguredMcpServerTools(params: {

135121

};

136122

}

137123124+

export async function updateConfiguredMcpServerTools(params: {

125+

name: string;

126+

tools: McpServerToolSelection | null;

127+

}): Promise<ConfigMcpWriteResult> {

128+

return updateConfiguredMcpServerConfig({

129+

name: params.name,

130+

errorLabel: "tool selection update",

131+

update: (server) => {

132+

if (params.tools === null) {

133+

delete server.toolFilter;

134+

} else {

135+

const include = normalizeToolSelectionList(params.tools.include);

136+

const exclude = normalizeToolSelectionList(params.tools.exclude);

137+

if (include || exclude) {

138+

server.toolFilter = {

139+

...(include ? { include } : {}),

140+

...(exclude ? { exclude } : {}),

141+

};

142+

} else {

143+

delete server.toolFilter;

144+

}

145+

}

146+

return server;

147+

},

148+

});

149+

}

150+138151

export async function updateConfiguredMcpServer(params: {

139152

name: string;

140153

update: (server: Record<string, unknown>) => Record<string, unknown>;

141154

}): Promise<ConfigMcpWriteResult> {

142-

const name = params.name.trim();

143-

if (!name) {

144-

return { ok: false, path: "", error: "MCP server name is required." };

145-

}

146-147-

const loaded = await listConfiguredMcpServers();

148-

if (!loaded.ok) {

149-

return loaded;

150-

}

151-

if (!Object.hasOwn(loaded.mcpServers, name)) {

152-

return {

153-

ok: true,

154-

path: loaded.path,

155-

config: loaded.config,

156-

mcpServers: loaded.mcpServers,

157-

updated: false,

158-

};

159-

}

160-161-

const next = structuredClone(loaded.config);

162-

const servers = normalizeConfiguredMcpServers(next.mcp?.servers);

163-

servers[name] = canonicalizeConfiguredMcpServer(params.update({ ...servers[name] }));

164-

next.mcp = {

165-

...next.mcp,

166-

servers,

167-

};

168-169-

const validated = validateConfigObjectWithPlugins(next);

170-

if (!validated.ok) {

171-

const issue = validated.issues[0];

172-

return {

173-

ok: false,

174-

path: loaded.path,

175-

error: `Config invalid after MCP configure (${issue.path}: ${issue.message}).`,

176-

};

177-

}

178-

await replaceConfigFile({

179-

nextConfig: validated.config,

180-

baseHash: loaded.baseHash,

155+

return updateConfiguredMcpServerConfig({

156+

name: params.name,

157+

errorLabel: "configure",

158+

update: (server) => canonicalizeConfiguredMcpServer(params.update(server)),

181159

});

182-

return {

183-

ok: true,

184-

path: loaded.path,

185-

config: validated.config,

186-

mcpServers: servers,

187-

updated: true,

188-

};

189160

}

190161191162

export async function setConfiguredMcpServer(params: {