feat(api): implement API key generation and management functionality

Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
This commit is contained in:
luckfox-eng29
2026-05-15 18:39:08 +08:00
parent 233e6e9cd6
commit 18f7d8425f
5 changed files with 232 additions and 18 deletions

7
mcp.go
View File

@@ -26,9 +26,12 @@ func StartMCP(port int, stdio bool) {
// SSE mode
addr := fmt.Sprintf(":%d", port)
sseServer := server.NewSSEServer(s)
handler := sseServer.SSEHandler()
// Add auth for non-localhost
mux := http.NewServeMux()
mux.Handle("/sse", sseServer.SSEHandler())
mux.Handle("/message", sseServer.MessageHandler())
var handler http.Handler = mux
if config.APIKey != "" {
handler = withAPIKeyAuth(handler, config.APIKey)
}