完善 MCP 工具

This commit is contained in:
2026-06-11 08:21:09 +08:00
parent c0f15050d0
commit 1415d3b43b
20 changed files with 3722 additions and 61 deletions
+2
View File
@@ -22,6 +22,7 @@ type AuthSession struct {
TokenID string // 用于审计 metadata 写入
UserID string // user_id 字符串形式(避免反复 uuid.UUID -> string 转换)
Scope Scope
Issuer Issuer // system token(agent 会话持有)受额外限制,见 create_acp_session
}
// FromContext 从 ctx 取出 AuthSession,未鉴权时返 (nil, false)。
@@ -53,6 +54,7 @@ func NewAuthMiddleware(svc TokenService) func(http.Handler) http.Handler {
TokenID: tok.ID.String(),
UserID: tok.UserID.String(),
Scope: tok.Scope,
Issuer: tok.Issuer,
}
ctx := context.WithValue(r.Context(), AuthContextKey, sess)
next.ServeHTTP(w, r.WithContext(ctx))