Skip to content

feat(knowledgebase): migrate to MCP 2026 and add Viking API Key authentication - #428

Merged
cuericlee merged 7 commits into
volcengine:mainfrom
Hao-Yu-la:main
Aug 31, 2026
Merged

feat(knowledgebase): migrate to MCP 2026 and add Viking API Key authentication#428
cuericlee merged 7 commits into
volcengine:mainfrom
Hao-Yu-la:main

Conversation

@Hao-Yu-la

Copy link
Copy Markdown
Contributor

背景

将 Viking Knowledge Base MCP Server 迁移至最新 MCP 协议实现,并补充 Viking 知识库 API Key 鉴权能力,便于不使用火山引擎账号 AK/SK 的场景接入。

主要变更

MCP 协议迁移

  • 升级至 MCP Python SDK 2.x,支持 MCP 2026-07-28 协议修订版。
  • 支持 stdio 与无状态 Streamable HTTP transport。
  • 增加 Streamable HTTP 的 host、port、path 等部署配置。
  • 使用异步 aiohttp 调用 Viking 接口,避免阻塞 MCP 事件循环。
  • 增加工具 Schema、结构化返回、ToolAnnotations 和输入校验。
  • 增加上游请求超时配置,并兼容 Viking 空检索结果响应。

Viking API Key 鉴权

  • 新增 VIKING_API_KEY 环境变量。
  • 使用 Authorization: Bearer <VIKING_API_KEY> 调用 Viking 接口。
  • 保留 AK/SK SignerV4 鉴权作为回退方式。
  • 支持同时配置 API Key 与 AK/SK,优先使用 API Key;AK/SK 不参与请求。
  • 未配置 API Key 时,AK 和 SK 必须同时提供。
  • 更新中英文 README 的配置说明和示例。

搜索结果增强

  • search_knowledge 返回结果新增 doc_iddoc_name
  • doc_id 可直接用于后续 get_doc 调用。
  • Viking 未返回文档元数据时,两个字段返回 null,不影响搜索结果。

验证

  • 覆盖 API Key、AK/SK、同时配置、部分 AK/SK、缺失凭证等鉴权组合。
  • 验证同时配置 API Key 与 AK/SK 时,MCP Server 使用 Bearer 请求头。
  • 验证搜索结果元数据映射及异常 doc_info 的兼容处理。
  • 编译检查、uv lock --checkgit diff --check 均通过。
  • 使用真实 Viking API Key 完成 MCP E2E 验证:
    • search_knowledge 成功返回 test_xlsx 的真实检索结果。
    • get_doc 成功返回文档状态。
    • MCP 协议协商版本为 2026-07-28

已知限制

Viking 当前暂不支持 API Key 调用以下接口,因此它们会返回 HTTP 403,属于上游已知限制,即将在知识库中进行支持,支持后所有接口均支持 API Key 调用:

  • list_collections
  • get_collection

兼容性

  • 现有 AK/SK-only 配置继续使用 SignerV4,保持兼容。
  • search_knowledge 新增的 doc_iddoc_name 为可选返回字段,不影响已有客户端对 idcontent 的使用。

@cuericlee cuericlee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@cuericlee
cuericlee merged commit 6d776b2 into volcengine:main Aug 31, 2026
3 checks passed
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.

2 participants