三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

怎么下载并安装node.js 且 启动 12306-mcp

怎么下载并安装node.js 且 启动 12306-mcp

Node.js — 下载 Node.js®

双击打开

千万不要勾选该选项,保持当前的未勾选状态,直接点击Next完成安装即可。

原因如下:

  • 勾选此项后,安装程序会在结束后自动下载并安装 Python 和 Visual Studio Build Tools 等编译工具,这个过程非常耗时,且会占用大量 C 盘空间。

  • 运行12306-mcp项目完全不需要这些原生编译工具,不勾选可以避免不必要的麻烦和等待。

后续步骤提醒:

  1. 点击Next完成安装后,务必关闭并重新打开命令行工具(CMD 或 PowerShell)。

  2. 输入node -vnpm -v,如果能输出版本号,说明 Node.js 环境配置成功。

  3. C:\Users\jffc>node -v
    v24.19.0

    C:\Users\jffc>npm -v
    11.17.0

    C:\Users\jffc>npm config set registry https://registry.npmmirror.com/

    C:\Users\jffc>npm config get registry
    https://registry.npmmirror.com/

    C:\Users\jffc>npx -y 12306-mcp --port 8088
    npm warn deprecated @modelcontextprotocol/server-legacy@2.0.0: This package is a frozen copy of v1's SSE transport and OAuth Authorization Server helpers for migration purposes only. Use StreamableHTTP from @modelcontextprotocol/server and a dedicated OAuth server in production. Will not receive new features.
    Streamable HTTP MCP Server listening at http://[::]:8088/mcp
    SSE MCP Server listening at http://[::]:8088/sse

  4. 12306-mcp

  5. Microsoft Windows [版本 10.0.19045.6466]
    (c) Microsoft Corporation。保留所有权利。

    C:\Users\jffc>curl -X POST http://localhost:8088/mcp ^
    More? -H "Content-Type: application/json" ^
    More? -H "Accept: application/json, text/event-stream" ^
    More? -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\",\"params\":{}}"
    {"result":{"tools":[{"name":"get-current-date","description":"获取当前日期,以上海时区(Asia/Shanghai, UTC+8)为准,返回格式为 \"yyyy-MM-dd\"。主要用于解析用户提到的相对日期(如“明天”、“下周三”),提供准确的日期输入。","inputSchema":{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","properties":{}},"execution":{"taskSupport":"forbidden"}},{"name":"get-stations-code-in-city","description":"通过中文城市名查询该城市 **所有** 火车站的名称及其对应的 `station_code`,结果是一个包含多个车站信息的列表。","inputSchema":{"type":"object","properties":{"city":{"type":"string","description":"中文城市名称,例如:\"北京\", \"上海\""}},"required":["city"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"},"execution":{"taskSupport":"forbidden"}},{"name":"get-station-code-of-citys","description":"通过中文城市名查询代表该城市的 `station_code`。","inputSchema":{"type":"object","properties":{"citys":{"type":"string","description":"要查询的城市,比如\"北京\"。若要查询多个城市,请用|分割,比如\"北京|上海\"。"}},"required":["citys"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"},"execution":{"taskSupport":"forbidden"}},{"name":"get-station-code-by-names","description":"通过具体的中文车站名查询其 `station_code` 和车站名。","inputSchema":{"type":"object","properties":{"stationNames":{"type":"string","description":"具体的中文车站名称,例如:\"北京南\", \" 上海虹桥\"。若要查询多个站点,请用|分割,比如\"北京南|上海虹桥\"。"}},"required":["stationNames"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"},"execution":{"taskSupport":"forbidden"}},{"name":"get-station-by-telecode","description":"通过车站的 `station_telecode` 查询车站的详细信息,包括名称、拼音、所属城市等。此接口主要用于在已知 `telecode` 的情况下获取更完整的车站数据,或用于特殊查询及调试目的。一般用户对话流程中较少直接触发。","inputSchema":{"type":"object","properties":{"stationTelecode":{"type":"string","description":"车站的 `station_telecode` (3位字母 编码)"}},"required":["stationTelecode"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"},"execution":{"taskSupport":"forbidden"}},{"name":"get-tickets","description":"查询12306余票信息。","inputSchema":{"type":"object","properties":{"date":{"type":"string","minLength":10,"maxLength":10,"description":"查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”),请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"},"fromStation":{"type":"string","description":"出发地的中文名或站点的 `station_code`(可通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到)"},"toStation":{"type":"string","description":"到达地的中文名或站点的 `station_code`(可通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到)"},"trainFilterFlags":{"type":"string","pattern":"^[GDZTKOFS]*$","maxLength":8,"default":"","description":"车次筛选条件,默认为空,即不筛选。支持多个标志同时筛选。例如用户说“高铁票”,则应使用 \"G\"。可选标志:[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"},"earliestStartTime":{"type":"number","minimum":0,"maximum":24,"default":0,"description":"最早出发时间(0-24),默认为0。"},"latestStartTime":{"type":"number","minimum":0,"maximum":24,"default":24,"description":"最迟出发时间(0-24),默认为24。"},"sortFlag":{"type":"string","default":"","description":"排序方式,默认为空,即不排序。 仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"},"sortReverse":{"type":"boolean","default":false,"description":"是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"},"limitedNum":{"type":"number","minimum":0,"default":0,"description":"返回的余票数量限制,默认为0,即不限制。"},"format":{"type":"string","pattern":"^(text|csv|json)$","default":"text","description":"返回结果格式,默认为text,建议使用text与csv。 可选标志:[text, csv, json]"}},"required":["date","fromStation","toStation"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"},"execution":{"taskSupport":"forbidden"}},{"name":"get-interline-tickets","description":"查询12306中转余票信息。尚且只支持查询前十条。","inputSchema":{"type":"object","properties":{"date":{"type":"string","minLength":10,"maxLength":10,"description":"查询日期,格式为 \"yyyy-MM-dd\"。如果用户提供的是相对日期(如“明天”) ,请务必先调用 `get-current-date` 接口获取当前日期,并计算出目标日期。"},"fromStation":{"type":"string","description":" 出发地的中文名或站点的 `station_code`(可通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到)"},"toStation":{"type":"string","description":"到达地的中文名或站点的 `station_code`(可通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到)"},"middleStation":{"type":"string","default":"","description":"中转地的中 文或站点的 `station_code`(可通过 `get-station-code-by-names` 或 `get-station-code-of-citys` 接口查询得到)。该参数可选 。"},"showWZ":{"type":"boolean","default":false,"description":"是否显示无座车,默认不显示无座车。"},"trainFilterFlags":{"type":"string","pattern":"^[GDZTKOFS]*$","maxLength":8,"default":"","description":"车次筛选条件,默认为空。从以下标志中选取多个条件组合[G(高铁/城际),D(动车),Z(直达特快),T(特快),K(快速),O(其他),F(复兴号),S(智能动车组)]"},"earliestStartTime":{"type":"number","minimum":0,"maximum":24,"default":0,"description":"最早出发时间(0-24),默认为0。"},"latestStartTime":{"type":"number","minimum":0,"maximum":24,"default":24,"description":"最迟出发时间(0-24),默认为24。"},"sortFlag":{"type":"string","default":"","description":"排序方式,默认为空,即不排序。仅支持单一标识。可选标志:[startTime(出发时间从早到晚), arriveTime(抵达时间从早到晚), duration(历时从短到长)]"},"sortReverse":{"type":"boolean","default":false,"description":"是否逆向排序结果,默认为false。仅在设置了sortFlag时生效。"},"limitedNum":{"type":"number","minimum":1,"default":10,"description":"返回的中转余票数量限制,默认为10。"},"format":{"type":"string","pattern":"^(text|json)$","default":"text","description":"返回结果格式,默认为text,建议使用text。可选标志:[text, json]"}},"required":["date","fromStation","toStation"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"},"execution":{"taskSupport":"forbidden"}},{"name":"get-train-route-stations","description":"查询特定列车车次在指定区间内的途径车站、到站时间、出发时间及停留时间等详细经停信息。当用户询问某趟具体列车的经停站时使用此接口。","inputSchema":{"type":"object","properties":{"trainCode":{"type":"string","description":"要查询的车次 `train_code`,例如\"G1033\"。"},"departDate":{"type":"string","minLength":10,"maxLength":10,"description":"列车出发的日期 (格式: yyyy-MM-dd)。如果用户提供的是相对日期,请务必先调用 `get-current-date` 解析。"},"format":{"type":"string","pattern":"^(text|json)$","default":"text","description":"返回结果格 式,默认为text,建议使用text。可选标志:[text, json]"}},"required":["trainCode","departDate"],"additionalProperties":false,"$schema":"http://json-schema.org/draft-07/schema#"},"execution":{"taskSupport":"forbidden"}}]},"jsonrpc":"2.0","id":1}
    C:\Users\jffc>

← 返回列表