Skip to content

feat(adapter): add Codex MCP gateway bridge#372

Open
WHUTcjh-2024 wants to merge 2 commits into
TencentCloud:mainfrom
WHUTcjh-2024:codex/issue-235-codex-mcp-adapter
Open

feat(adapter): add Codex MCP gateway bridge#372
WHUTcjh-2024 wants to merge 2 commits into
TencentCloud:mainfrom
WHUTcjh-2024:codex/issue-235-codex-mcp-adapter

Conversation

@WHUTcjh-2024

Copy link
Copy Markdown

Description | 描述

Add a focused STDIO MCP adapter that exposes the existing TDAI Gateway to
Codex and other MCP clients. The adapter remains a transport boundary; storage,
ranking, capture, and pipeline behavior stay in the existing memory engine.

Adapter capabilities

  • Publish an executable memory-tencentdb-mcp npm command.
  • Implement the latest published MCP revision (2025-11-25) and negotiate
    2025-06-18, 2025-03-26, and 2024-11-05 clients.
  • Enforce the MCP initialization lifecycle, integer/string request IDs, closed
    tool schemas, runtime rejection of extra arguments, notifications, parse
    errors, and MCP tool-error semantics.
  • Expose five tools: recall, capture, L1 memory search, L0 conversation search,
    and session flush.
  • Call the Gateway through an authenticated, timeout-bounded HTTP client that
    preserves base paths, validates object responses, and rejects ambiguous or
    credential-bearing URLs.
  • Reserve STDOUT for newline-delimited MCP JSON-RPC frames and send fatal
    startup diagnostics to STDERR.

Recall compatibility

The Gateway now returns prepend_context and append_system_context
separately so MCP hosts do not flatten dynamic and stable prompt content. The
legacy context field keeps its original meaning for existing clients.

Documentation

The adapter guide includes architecture, security boundaries, all five tools,
environment variables, and a Codex config.toml example verified against the
official mcp_servers.<id> configuration reference.

Related Issue | 关联 Issue

Closes #235

Change Type | 修改类型

  • Bug fix | Bug 修复
  • New feature | 新功能
  • Documentation update | 文档更新
  • Code optimization | 代码优化

Self-test Checklist | 自测清单

  • Verified locally | 本地验证通过
  • No existing features affected | 无影响现有功能

Additional Notes | 其他说明

Validation

  • Node.js 24: 7 test files, 95 tests passed.
  • MCP/Gateway coverage includes lifecycle negotiation, all tools, strict input
    validation, parse errors, tool errors, timeout/network failures, real local
    HTTP routing, Bearer authentication, and response-shape validation.
  • npm run build: passed; generated executable MCP bundle is about 14.4 KB.
  • npm pack --dry-run --json: passed and includes the MCP binary and guide.
  • git diff --check: passed.

The current Gateway scopes memory by session_key. This adapter does not claim
user_id as a tenant-isolation boundary because the core storage path does not
yet enforce that scope.

@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Thank you for submitting this PR and participating in Tencent Rhino-bird Open-source Training Program!
We have successfully received your submission. The program is currently in full swing, and we will complete the Code Review for you as soon as possible. Please keep an eye on the status notifications for this PR so you can follow up promptly once the review feedback is provided.
Thanks again for your contribution and open-source spirit! 🚀

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.

Cross-Platform Adapters for the Memory Plugin

2 participants