workshop-27-08-26
workshop-27-08-26
用于 2026 年 8 月 27 日 AWS AI FDE for Commerce 训练营工作坊的 MCP 服务器示例
什么是 MCP?
MCP(Model Context Protocol) 是一种 开源 的系统间通信协议,允许不同应用(主要是 AI 应用)之间交换数据/上下文信息。
使用该协议,AI 系统(如代理应用)可以消费/提供来自/面向其他系统的上下文信息,使模型能够以更高的确定性和相关性运行。
使用 USB-C 类比:
将 MCP 视为 AI 应用的 USB-C 端口。正如 USB-C 提供了一种连接电子设备的标准方式,MCP 也提供了一种将 AI 应用连接到其他系统的标准方式。
Related MCP server: Basic MCP Server
SDK 选项
该协议支持不同的 SDK(软件开发工具包)选项,可用于在不同语言/框架中实现 MCP。
在此处查看完整列表:Available SDKs
传输选项
聚焦于工作坊的上下文,我们将探讨 Node.js 最常用/流行的传输选项:
stdio
让 MCP 服务器作为子进程运行,通过 stdin 和 stdout 发送和接收消息。
HTTP
提供一个服务器,通过 HTTP 请求同时向多个客户端接收和发送消息。
框架
使用 Node.js 的技术/框架来简化 MCP 协议的实现,例如:
工作坊场景
客户 Nordesul
考虑一个大型客户的电子商务项目,有 20 名开发人员组成的团队负责将其遗留的虚拟商店(V0)迁移到更现代的框架(V1)。目标是让 V1 虚拟商店与 V0 完全相同,但使用 V1 的性能改进。
由于多名开发人员将在同一代码库上工作,交付物必须具有最佳的标准化和质量,遵循我们公司的规范和品牌形象。
客户拥有一个包含其所有 API 文档的数据库,这些文档位于与开发团队共享的端点中,供查询使用。
本仓库
本仓库包含一个 MCP 服务器模板,可用于:
了解使用
@modelcontextprotocol/server实现 stdio 和 HTTP 传输;模拟 AI 系统与任何外部服务之间的通信;
作为实现真实 MCP 服务器的灵感来源;
成为使用自定义 tools 的 AI 代理的入门途径。
仓库结构
/servers
使用不同传输和框架的示例 MCP 服务器。
/servers/stdio
通过 stdin 和 stdout 以子进程方式提供 MCP 消息。
/servers/http
仅使用 Node.js 原生 HTTP 模块,通过 HTTP 请求提供 MCP 消息。
/servers/express
使用 Express 框架,通过 HTTP 请求提供 MCP 消息。
/tools
自定义 tools 的示例,AI 代理可使用这些工具与其他系统交互。
/tools/index.js
集中并导出仓库中的所有 tools,以便 MCP 服务器能够统一注册它们。
/tools/nordesul-deploy
返回在 Nordesul 客户处安全部署的基本注意事项和最佳实践。
/tools/nordesul-delivery
模拟项目的实现模式和契约。
/tools/nordesul-reference
模拟在 Nordesul 客户处查询 API 文档。
/tools/nordesul-status
模拟在 Nordesul 客户处查询应用状态。
/utils
集中项目的工具/共享函数。
/.opencode
Opencode 的配置目录,包含一个自定义的 mentor 代理,用于帮助工作坊参与者了解仓库及其功能。
运行项目
前置要求
安装依赖
在项目根目录下,运行命令:
npm install
# ou:
yarn install运行服务器
通过 stdio 运行 MCP 服务器:
npm run start:stdio
# ou:
yarn start:stdio通过 http 运行 MCP 服务器:
npm run start:http
# ou:
yarn start:http通过与 Express 集成运行 MCP 服务器:
npm run start:express
# ou:
yarn start:express运行导师代理(Opencode 示例)
安装 Opencode 后,在仓库目录中打开您喜欢的终端并运行命令:
opencode首次运行将下载 Opencode 的所有依赖项,请等待过程完成。Mentor 代理将默认被选中。
MCP 服务器与 AI 代理的集成
Opencode: MCP servers;
Claude: Connect Claude Code to tools via MCP;
Codex: Model Context Protocol;
Cursor: Model Context Protocol (MCP);
Antigravity: Model Context Protocol (MCP)。
示例提示词
使用您的代理与仓库中的 tools 交互的一些示例:
nordesul-delivery
Quais são os padrões de implementação para a área de checkout do Nordesul?nordesul-deploy
Antes de eu publicar essa mudança no Nordesul, quais cuidados devo tomar?nordesul-reference
Me mostra a documentação da API de pedidos (orders) do Nordesul.nordesul-status
Qual o status atual da aplicação checkout-service no Nordesul?This server cannot be deployed
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA customizable, production-ready template for building Model Context Protocol servers with dual transport support (stdio and HTTP), TypeScript, Docker support, and extensible architecture for tools, resources, and prompts.-
- -licenseNot gradedqualityNot gradedmaintenanceA minimal Model Context Protocol server template demonstrating basic implementation of tools, resources, and prompts built with Smithery SDK.-
- AlicenseBqualityDmaintenanceA template repository for building Model Context Protocol (MCP) servers that enable LLM clients to interact with custom tools and services through standardized JSON-RPC communication.3MIT
- AlicenseAqualityDmaintenanceA Model Context Protocol server template designed for building custom servers using the @intelagent/mcp-shared library. It provides boilerplate code and example tools to streamline the development, testing, and deployment of new MCP servers.330 npmMIT