feat: add auto-injection flag for tools and filter auto-injected tools in UI

This commit is contained in:
mlogclub
2026-04-10 15:41:02 +08:00
parent 31337fa714
commit e7a600b7d5
8 changed files with 51 additions and 29 deletions
@@ -66,6 +66,7 @@ type DirectToolOption = {
label: string;
meta: DirectToolItem;
sourceType: string;
autoInjected: boolean;
groupLabel: string;
};
@@ -354,23 +355,26 @@ function EditDialogBody({
const catalog = await fetchMCPCatalog();
setToolCatalog(catalog);
setDirectToolOptions(
catalog.map((tool) => ({
value: tool.toolCode,
label: `${tool.title || tool.toolName} · ${tool.toolCode}`,
sourceType: tool.sourceType,
groupLabel:
tool.sourceType === "builtin"
? "内置工具"
: tool.serverCode,
meta: {
toolCode: tool.toolCode,
serverCode: tool.serverCode,
toolName: tool.toolName,
title: tool.title || tool.toolName,
description: tool.description || "",
arguments: undefined,
},
})),
catalog
.filter((tool) => !tool.autoInjected)
.map((tool) => ({
value: tool.toolCode,
label: `${tool.title || tool.toolName} · ${tool.toolCode}`,
sourceType: tool.sourceType,
autoInjected: tool.autoInjected,
groupLabel:
tool.sourceType === "builtin"
? "内置工具"
: tool.serverCode,
meta: {
toolCode: tool.toolCode,
serverCode: tool.serverCode,
toolName: tool.toolName,
title: tool.title || tool.toolName,
description: tool.description || "",
arguments: undefined,
},
})),
);
} catch (error) {
toast.error(
@@ -869,6 +873,7 @@ function EditDialogBody({
<div className="mb-1 text-sm font-medium">Direct Tools</div>
<div className="mb-4 text-xs text-muted-foreground">
MCP
`tool_search` Runtime
</div>
<Field>
<FieldContent className="space-y-3">
+1
View File
@@ -334,6 +334,7 @@ export type MCPToolCatalogItem = {
serverCode: string
toolName: string
sourceType: string
autoInjected: boolean
title: string
description: string
inputSchema: unknown