一个用于访问秘鲁Emtrafesa公交运输服务的模型上下文协议(MCP)服务器。
MCP Emtrafesa 是一个模型上下文协议服务器,它为AI助手提供了无缝访问秘鲁Emtrafesa公交运输系统的能力。通过标准化的MCP工具查询终端、时刻表、票务和常见问题。
# 克隆仓库
git clone https://github.com/georgegiosue/mcp-emtrafesa.git
cd mcp-emtrafesa
# 安装依赖
bun install
# 启动MCP服务器
bun run index.ts
# 可选:使用Model Context Protocol Inspector启动
bunx @modelcontextprotocol/inspector bun index.ts
配置您的MCP客户端以连接到此服务器:
{
"mcpServers": {
"mcp-emtrafesa": {
"command": "npx",
"args": ["mcp-emtrafesa@latest"]
}
}
}
| 工具 | 描述 | 参数 |
|---|---|---|
get-terminals | 获取秘鲁所有公交终端 | 无 |
get-arrival-terminal | 获取目的地终端 | departureTerminalId |
get-departure-schedules | 获取终端间的时刻表 | departureTerminalId, arrivalTerminalId, date? |
get-latest-purchased-tickets | 按用户信息搜索票务 | DNI, email |
get-frequently-asked-questions | 获取关于服务的常见问题 | 无 |
// 获取所有终端
const terminals = await client.callTool("get-terminals");
// 查找从奇克拉约到特鲁希略的路线
const schedules = await client.callTool("get-departure-schedules", {
departureTerminalId: "002",
arrivalTerminalId: "001",
date: "14/07/2025", // 格式:DD/MM/YYYY
});
// 查询已购票
const tickets = await client.callTool("get-latest-purchased-tickets", {
DNI: "12345678",
email: "user@example.com",
});
mcp-emtrafesa/
├── 📁 config/ # API配置
│ └── api.ts # 头部和基础设置
├── 📁 internal/ # 核心业务逻辑
│ └── emtrafesa/ # Emtrafesa特定代码
│ ├── services.ts # API客户端函数
│ └── types.ts # TypeScript类型定义
├── 📁 sandbox/ # 开发工具
│ └── post-consulta.html # HTML解析参考
├── 📄 index.ts # MCP服务器入口点
├── 📄 package.json # 依赖项和脚本
├── 📄 tsconfig.json # TypeScript配置
└── 📄 biome.json # 代码格式规则
GET /Home/GetSucursalesGET /Home/GetSucursalesDestinoPOST /Home/GetItinerario (JSON)POST /Consulta/PostConsulta (表单编码)GET /Home/GetPreguntasFrecuentes# 使用Biome格式化代码
bun run format
# 不写入检查格式
bunx biome check
noUncheckedIndexedAccess使用参考文件测试更改:
# 查看HTML结构参考
open sanbox/post-consulta.html
git checkout -b feature/amazing-feature)bun run format)git commit -m '添加惊人的特性')git push origin feature/amazing-feature)该项目采用MIT许可证 - 详情参见LICENSE文件。