远征MCP服务器
MCP服务器,将Expedition API(游轮、酒店、旅游)作为n8n AI代理的工具公开。
设置
npm install
cp .env.example .env
# Edit .env with your API token跑
# Development (auto-reload)
npm run dev
# Production
npm run build
npm start服务器启动于 http://localhost:3001/mcp
可用工具
| 工具 | 说明 |
|---|---|
list_cruises | 按出发地列出游轮(加拉帕戈斯/南极洲/所有) |
get_cruise_availability | 可用性+游轮价格 |
list_hotels | 列出酒店 |
get_hotel_availability | 按日期和夜晚列出的酒店可用性 |
list_tours | 按出发地和可选巡航过滤器列出旅行 |
get_itinerary | 全天行程 |
generate_brochure | 生成PDF宣传册→ 返回base64 |
n8n配置
1.添加MCP客户端节点
- 网址:
http://localhost:3001/mcp - 传输:流式HTTP
2.从工具响应中提取PDF(AI Agent后的代码节点)
// Add this Code node after your AI Agent node
const steps = $('AI Agent').item.json.intermediateSteps ?? [];
let attachment = null;
for (const step of steps) {
const obs = step?.observation ?? step?.output ?? '';
try {
const parsed = JSON.parse(obs);
if (parsed.type === 'EXPEDITION_PDF_ATTACHMENT') {
attachment = {
type: 'pdf',
filename: parsed.filename,
base64: parsed.base64,
title: parsed.title,
};
break;
}
} catch {
// not JSON, skip
}
}
return {
message: $('AI Agent').item.json.output,
attachment,
};3.Webhook响应
webhook节点应返回上述Code节点的输出:
{
"message": "Here is the brochure for the Seaman Journey 8D tour!",
"attachment": {
"type": "pdf",
"filename": "seaman-journey-8d-brochure.pdf",
"base64": "JVBERi0x...",
"title": "Seaman Journey 8 Days / 7 Nights"
}
}当没有PDF时, attachment 将是 null.
在n8n服务器(Linux)上部署
# Clone / copy the project to the server
git clone ... && cd expedition-mcp
npm install --production
npm run build
# Run with PM2 (recommended)
pm2 start dist/index.js --name expedition-mcp
pm2 save旅行者前端
添加 ChatbotVoyagers.vue 组件和配置 nuxt.config.ts:
runtimeConfig: {
public: {
n8nChatWebhook: 'https://your-n8n.com/webhook/voyagers-chat'
}
}