feat(config): wire serial tool into runtime and dashboard

This commit is contained in:
SiYue-ZO committed 2026-04-28 12:56:27 +08:00
1 parent 0f52076762
commit 2114e1a53f
8 files changed
+93

No files matched your search

+22
View File
@@ -171,6 +171,12 @@ var toolCatalog = []toolCatalogEntry{
Category: "hardware",
ConfigKey: "spi",
},
{
Name: "serial",
Description: "Interact with serial ports exposed on the host.",
Category: "hardware",
ConfigKey: "serial",
},
{
Name: "tool_search_tool_regex",
Description: "Discover hidden MCP tools by regex search when tool discovery is enabled.",
@@ -265,6 +271,8 @@ func buildToolSupport(cfg *config.Config) []toolSupportItem {
status, reasonCode = resolveWebSearchToolSupport(cfg)
case "i2c", "spi":
status, reasonCode = resolveHardwareToolSupport(cfg.Tools.IsToolEnabled(entry.ConfigKey))
case "serial":
status, reasonCode = resolveSerialToolSupport(cfg.Tools.IsToolEnabled(entry.ConfigKey))
default:
if cfg.Tools.IsToolEnabled(entry.ConfigKey) {
status = "enabled"
@@ -293,6 +301,18 @@ func resolveHardwareToolSupport(enabled bool) (string, string) {
return "enabled", ""
}
func resolveSerialToolSupport(enabled bool) (string, string) {
if !enabled {
return "disabled", ""
}
switch runtime.GOOS {
case "linux", "darwin", "windows":
return "enabled", ""
default:
return "blocked", "requires_serial_platform"
}
}
func resolveDiscoveryToolSupport(cfg *config.Config, methodEnabled bool) (string, string) {
if !cfg.Tools.IsToolEnabled("mcp") {
return "disabled", ""
@@ -362,6 +382,8 @@ func applyToolState(cfg *config.Config, toolName string, enabled bool) error {
cfg.Tools.I2C.Enabled = enabled
case "spi":
cfg.Tools.SPI.Enabled = enabled
case "serial":
cfg.Tools.Serial.Enabled = enabled
case "tool_search_tool_regex":
cfg.Tools.MCP.Discovery.UseRegex = enabled
if enabled {