过去你需要写正则提取参数 → 对接12306非标准API → 处理脏数据 → 手写排版……现在只需一句自然语言AI 自动完成车票查询。先看效果一句话 → 完整车次表执行以下官网 12306-demo 的示例代码import{createSDK}frommcpilotx/intentorch;importdotenvfromdotenv;dotenv.config();asyncfunctionmain(){constsdkcreateSDK();awaitsdk.configureAI({provider:deepseek,apiKey:process.env.DEEPSEEK_API_KEY,model:deepseek-chat});awaitsdk.connectMCPServer({name:12306-mcp,transport:{type:stdio,command:npx,args:[-y,12306-mcp]}});awaitsdk.initCloudIntentEngine();constresultawaitsdk.executeWorkflowWithTracking(查询 2026 年 4 月 15 日北京到上海的所有高铁票);console.log(查询结果:,result.result);}main().catch(console.error);终端直接打印出所有高铁车次、席位、价格和余票整个过程完全由 AI 自动完成意图解析、工具选择、参数映射零规则、零硬编码。本文是 IntentOrch 系列第二篇—— 第一篇介绍见 《【开源】IntentOrch意图驱动的MCP编排引擎》。三步搭建你的“自然语言查票助手”1️⃣ 初始化项目mkdirintentorch-12306cdintentorch-12306npminit-ynpminstallmcpilotx/intentorch dotenv在package.json中添加type: module消除模块警告{name:intentorch-12306,type:module,dependencies:{mcpilotx/intentorch:^latest,dotenv:^16.0.0}}2️⃣ 配置 AI 模型 连接 MCP 服务创建.env文件DEEPSEEK_API_KEYsk-xxxxxxxxxxxx新建index.js完整代码如下import{createSDK}frommcpilotx/intentorch;importdotenvfromdotenv;dotenv.config();asyncfunctionmain(){constsdkcreateSDK();awaitsdk.configureAI({provider:deepseek,apiKey:process.env.DEEPSEEK_API_KEY,model:deepseek-chat});awaitsdk.connectMCPServer({name:12306-mcp,transport:{type:stdio,command:npx,args:[-y,12306-mcp]}});awaitsdk.initCloudIntentEngine();constresultawaitsdk.executeWorkflowWithTracking(查询 2026 年 4 月 15 日北京到上海的所有高铁票);console.log(查询结果:,result.result);}main().catch(console.error);3️⃣ 运行nodeindex.js你已实现了一个生产可用的自然语言查询接口全程未写任何解析逻辑背后发生了什么轻原理IntentOrch 的 Cloud Intent Engine 将整个过程抽象为四个阶段 意图解析LLM 将自然语言转换为结构化意图日期、出发地、目的地、交通工具类型。 工具选择根据 MCP Server 提供的工具列表如get-ticketsAI 自动匹配最合适的工具。⚙️ 工具调用通过 stdio 协议调用 12306 MCP获取原始数据。 结果返回将 MCP 返回的文本或 JSON 直接交还给你无需二次格式化。为什么这对开发者极具价值传统方案需要手写 N 个 if/else、正则、参数校验而 IntentOrch 让 AI 成为“语义路由器”。换一个MCP场景通用范式假如你想查询 GitHub Issues只需把connectMCPServer换成awaitsdk.connectMCPServer({name:github-mcp,transport:{type:stdio,command:npx,args:[-y,modelcontextprotocol/server-github]}});然后输入“列出我仓库下未解决的 bug”AI 就会自动调用list_issues工具。其余代码一行不改。常见踩坑与解决方案 问题1(node:xxxx) Warning: Module type of file...✅ 解决在package.json中添加type: module。 问题2jq: command not found✅ 解决使用JSON.parse或安装jqapt-get install jq/brew install jq。 问题3MCP Server 启动超时或找不到命令✅ 解决手动执行npx -y 12306-mcp测试Node.js 版本建议 v18。进阶玩法多 MCP 协同同时连接天气 MCP 12306 MCP问“这周末北京去上海天气好么顺便查高铁票”。自定义 MCP 工具用 MCP 协议 封装公司内部 API。可观测性集成IntentOrch 内置反馈机制可收集用户行为优化意图解析准确率。立即体验GitHub 仓库MCPilotX/IntentOrch/examples/12306-demogitclone https://github.com/MCPilotX/IntentOrch.gitcdIntentOrch/examples/12306-democp.env.example .env# 填入你的 API Keynpminstallnpmstart互动你想用 IntentOrch MCP 做什么欢迎在评论区留言讨论。上一篇【开源】IntentOrch意图驱动的MCP编排引擎项目主页github.com/MCPilotX/IntentOrch© 2026 IntentOrch · 让自然语言驱动一切工具