mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
# v0.4.30 (2026-05-11)
## Features - MCP stdio→SSE bridge: expose local stdio MCP plugins over SSE (api/mcp/[plugin]/sse, /message) - Dynamic Linux cert resolution + NSS DB injection (Debian/Arch/Fedora/openSUSE, Chrome/Chromium/Firefox incl. snap) (#1010) - Cowork tool: expanded settings UI & API - GitBook docs (DocsContent, DocsLayout) ## Fixes - OAuth callback postMessage scoped to expected origins (CWE-1385) (#998) - Re-enable TLS verification on DNS-bypass fetch (CWE-295) (#998) - Normalize `developer` role → `system` for OpenAI-format providers (Deepseek, Groq, …) (#1011, closes #773) - Respect `PORT` env in internal model-test fetch (#1014) - Dropdown text readability in dark theme on usage page (#997) ## Improvements - Refactor Claude CLI spoof headers into shared constant - Tool deduper utility in open-sse handlers
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Strip built-in/duplicate tools when equivalent MCP tools are present.
|
||||
* Goal: reduce tool definitions token bloat for Claude clients.
|
||||
*/
|
||||
|
||||
const DEDUP_RULES = [
|
||||
{
|
||||
// Exa MCP present → drop built-in web tools (Exa is preferred).
|
||||
triggers: ["mcp__exa__web_search_exa", "mcp__exa__web_fetch_exa"],
|
||||
strip: ["WebSearch", "WebFetch", "mcp__workspace__web_fetch"],
|
||||
},
|
||||
{
|
||||
// Tavily MCP present → drop built-in web tools.
|
||||
triggers: ["mcp__tavily__tavily_search", "mcp__tavily__tavily_extract"],
|
||||
strip: ["WebSearch", "WebFetch", "mcp__workspace__web_fetch"],
|
||||
},
|
||||
{
|
||||
// Browser MCP present → drop Cowork's duplicate Claude_in_Chrome connector.
|
||||
triggers: [/^mcp__browsermcp__/],
|
||||
strip: [/^mcp__Claude_in_Chrome__/],
|
||||
},
|
||||
];
|
||||
|
||||
function getToolName(t) {
|
||||
return t?.name || t?.function?.name || "";
|
||||
}
|
||||
|
||||
function matches(name, pattern) {
|
||||
if (typeof pattern === "string") return name === pattern;
|
||||
return pattern instanceof RegExp ? pattern.test(name) : false;
|
||||
}
|
||||
|
||||
function dedupeTools(tools) {
|
||||
if (!Array.isArray(tools) || tools.length === 0) return { tools, stripped: [] };
|
||||
const names = tools.map(getToolName);
|
||||
const toStrip = new Set();
|
||||
for (const rule of DEDUP_RULES) {
|
||||
const hasTrigger = names.some((n) => rule.triggers.some((p) => matches(n, p)));
|
||||
if (!hasTrigger) continue;
|
||||
for (const n of names) {
|
||||
if (rule.strip.some((p) => matches(n, p))) toStrip.add(n);
|
||||
}
|
||||
}
|
||||
if (toStrip.size === 0) return { tools, stripped: [] };
|
||||
const out = tools.filter((t) => !toStrip.has(getToolName(t)));
|
||||
return { tools: out, stripped: Array.from(toStrip) };
|
||||
}
|
||||
|
||||
export { dedupeTools };
|
||||
Reference in New Issue
Block a user