一个原生运行在AWS Lambda和Amazon API Gateway上的Peppa MCP服务器,无需任何额外的桥接组件或自定义传输方式。这得益于v2025-03-26引入的可流式传输HTTP传输方式。
架构尽可能简单:

安装依赖项:
cd src
npm install
cd ..
初始化服务器并设置环境变量为MCP服务器端点:
cd terraform
terraform init
terraform plan
terraform apply
export PEPPA_MCP_SERVER_ENDPOINT=$(terraform output --raw endpoint_url)
cd ..
注意:API Gateway端点可能需要几秒钟才能开始运行。
运行客户端:
node src/client.js
观察响应:
> node client.js
listResources 响应: {
resources: [
{
uri: 'peppa://timeslots',
name: 'timeslots',
description: '使用此资源来获取订购小猪佩奇主题公园门票的所有开放时间。',
mimeType: 'text/plain'
}
]
}
readResource 响应: {
contents: [
{
uri: 'peppa://timeslots',
mimeType: 'text/plain',
text: '可用的时间段是:2025年4月19日,2025年4月20日,2025年4月21日'
}
]
}
listTools 响应: {
tools: [
{
name: 'order-tickets',
description: '使用此工具订购小猪佩奇公园的门票。该工具期望两个参数 - 时间段和数量。时间段应该是一个字符串化的日期。数量应该是一个数字。例如:order-tickets(timeslot: "2025年4月19日", quantity: 3)。工具将返回带有订单号的文本消息。',
inputSchema: [Object]
}
]
}
callTool 响应: {
content: [
{
type: 'text',
text: "您已订购了2025年4月19日的3张门票。您的订单号是OINK-1234。"
}
]
}