mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-10-27 16:00:17 +00:00
* feat(mcp): add 1Panel MCP and enhance MCP credential management * feat(i18n): implement MCP document localization and remove legacy code
34 lines
949 B
Go
34 lines
949 B
Go
package mcpruntime
|
|
|
|
import (
|
|
"regexp"
|
|
|
|
contract "github.com/1Panel-dev/1Panel/core/utils/mcp"
|
|
)
|
|
|
|
const (
|
|
ContractVersion = contract.ContractVersion
|
|
Protocol = "streamable-http"
|
|
DefaultPort = 18081
|
|
maxCatalogBytes = 2 << 20
|
|
)
|
|
|
|
type State struct {
|
|
Installed bool
|
|
Status string
|
|
Ready bool
|
|
Reason string
|
|
AdapterVersion string
|
|
Image string
|
|
ImageID string
|
|
}
|
|
|
|
var catalogSlots = make(chan struct{}, 8)
|
|
var versionPattern = regexp.MustCompile(`^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$`)
|
|
var bearerPattern = regexp.MustCompile(`(?i)bearer\s+[^\s"']+`)
|
|
var sensitivePattern = regexp.MustCompile(`(?i)("?(?:password|token|secret|authorization)"?\s*[:=]\s*)("[^"]*"|[^\s,}]+)`)
|
|
|
|
func redactLog(value string) string {
|
|
return sensitivePattern.ReplaceAllString(bearerPattern.ReplaceAllString(value, "Bearer [REDACTED]"), "${1}[REDACTED]")
|
|
}
|