Skip to content

Conversation

@SaladDay
Copy link
Contributor

Ⅰ. Describe what this PR did

此PR为MCP Server的Redis配置添加了Secret引用支持,解决了密码必须明文存储在ConfigMap中的安全问题。

Ⅱ. Does this pull request fix one issue?

fixes #3001

Ⅲ. Why don't you add test cases (unit test/integration test)?

已添加测试

Ⅳ. Describe how to verify it

  1. 创建Secret:

    kubectl create secret generic redis-credentials \
      -n higress-system \
      --from-literal=password='your-secure-password'
  2. 更新 ConfigMap:

    kubectl edit cm higress-config -n higress-system

    添加配置:

    mcpServer:
      enable: true
      redis:
        address: "redis:6379"
        passwordSecret:
          name: redis-credentials
          key: password
  3. 验证:

    • 检查MCP Server能否正常连接 Redis
    • 确认密码不会在ConfigMap中明文显示
    • 测试用户级MCP server 功能是否正常
  4. 运行单元测试:

    go test -v ./pkg/ingress/kube/configmap/... -run TestMcpServer

@lingma-agents
Copy link

lingma-agents bot commented Oct 14, 2025

为 MCP Server 的 Redis 配置添加 Secret 引用支持

变更概述
  • 新功能

    • McpServer.RedisConfig 结构新增 PasswordSecret 字段,支持通过 Kubernetes Secret 引用 Redis 密码,提升配置安全性。
    • 新增 SecretKeyReference 类型用于定义对 Secret 中特定键的引用,支持指定命名空间、名称和键。
    • 在生成 MCP Server 会话配置时,优先使用 PasswordSecret 引用的值,并以 ${secret.namespace/name.key} 格式注入 Envoy 配置。
  • 问题修复

    • 添加对 PasswordSecret 字段的校验逻辑,确保 namekey 不为空,防止配置错误。
  • 测试更新

    • 增加多个单元测试用例,覆盖 PasswordSecret 配置缺失字段、有效配置及深拷贝等场景。
    • 添加 constructMcpSessionStruct 测试用例,验证密码字段在使用 Secret 引用时的正确格式化。
  • 文档

    • 更新架构文档 (docs/architecture.md),说明如何通过 passwordSecret 配置 Redis 密码。
    • 更新插件文档 (plugins/golang-filter/mcp-server/servers/higress/higress-api/README*.md),提供使用 Secret 引用 Redis 密码的示例配置。
变更文件
文件路径 变更说明
docs/architecture.md 新增关于 MCP Server Redis 配置支持通过 Secret 引用密码的说明,并更新了参考链接。
pkg/​ingress/​kube/​configmap/​mcp_​server.​go 新增 `PasswordSecret` 字段和 `SecretKeyReference` 类型,添加校验逻辑,并在生成配置时支持 Secret 引用。
pkg/​ingress/​kube/​configmap/​mcp_​server_​test.​go 增加多个测试用例,验证 `PasswordSecret` 字段的校验、深拷贝和配置生成逻辑。
plugins/​golang-filter/​mcp-server/​servers/​higress/​higress-api/​README.​md 更新配置示例,展示如何通过 `passwordSecret` 字段引用 Redis 密码。
plugins/​golang-filter/​mcp-server/​servers/​higress/​higress-api/​README_​en.​md 更新英文配置示例,展示如何通过 `passwordSecret` 字段引用 Redis 密码。

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

@codecov-commenter
Copy link

codecov-commenter commented Oct 14, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.13%. Comparing base (ef31e09) to head (075f481).
⚠️ Report is 757 commits behind head on main.

Files with missing lines Patch % Lines
pkg/ingress/kube/configmap/mcp_server.go 90.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3006      +/-   ##
==========================================
+ Coverage   35.91%   45.13%   +9.22%     
==========================================
  Files          69       82      +13     
  Lines       11576    10917     -659     
==========================================
+ Hits         4157     4927     +770     
+ Misses       7104     5641    -1463     
- Partials      315      349      +34     
Files with missing lines Coverage Δ
pkg/ingress/kube/configmap/mcp_server.go 74.24% <90.00%> (ø)

... and 96 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@johnlanni johnlanni merged commit 1bcef0c into alibaba:main Oct 27, 2025
12 checks passed
ink-hz pushed a commit to ink-hz/higress-ai-capability-auth that referenced this pull request Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Secret Reference for Redis Password in MCP Server

3 participants