本项目是模型上下文协议(MCP)生态系统的一部分,提供了与外部 API 和特定领域模型交互的工具。旨在展示如何构建一个具备外部 API 集成和数据验证功能的 MCP 服务器。借助 Investidor10 API,该集成能让 MCP 工具查询股票市场数据,如股票价格和指标。
git clone git@github.com:newerton/mcp-investidor10.git
cd mcp-investidor10
npm install
npm run build
Ctrl+Shift+P 并选择“MCP: 列出服务器”Ctrl+Shift+P 并选择“MCP: 启动服务器”get-acoes示例链接:https://glama.ai/mcp/servers/@newerton/mcp-investidor10
fetch 集成 Investidor10 API(基础设施层)。该项目采用分层架构,灵感来自 领域驱动设计(DDD)模式:
src/domain):定义表示数据结构的接口和类型(例如,Investidor10)。src/infrastructure):实现外部服务,如 Investidor10ApiService,负责向 Investidor10 API 发出 HTTP 请求。src/application):包含业务逻辑的 Investidor10Service,处理和格式化来自基础设施的数据。src/interface):包括控制器(Investidor10ToolsController),负责在 MCP 服务器中注册工具、定义验证方案并返回结果。src/main.ts):初始化 McpServer,配置传输(StdioServerTransport),实例化服务和控制器,并开始侦听 stdio。文件夹结构如下所示:
src/
├── domain/
│ └── models/ # 领域接口
├── infrastructure/
│ └── services/ # 外部 API 实现(Investidor10)
├── application/
│ └── services/ # 业务逻辑和数据格式化
├── interface/
│ └── controllers/ # MCP 工具注册和验证
└── main.ts # 服务器入口点
build/ # 编译后的 JavaScript 代码
.vscode/ # 包含 mcp.json 文件,MCP 服务器配置
贡献可以通过以下方式提交:
请 fork 该项目并按照标准的 GitHub 流程提交您的贡献。
该项目受 LICENSE 许可证保护。