劳氏船级社MCP服务器
一种模型上下文协议(MCP)服务器,使LLM能够访问劳氏船级社的海事情报数据。提供用于CursorIDE集成的MCP工具和用于web应用程序的可选HTTP API。
特性
公共访问(无身份验证)
- 按关键字搜索所有劳埃德船级社RSS提要中的文章
- 按行业(集装箱、干散货等)或主题(脱碳、红海风险等)浏览最新文章
- 自动从RSS源中提取图像
- 按类别列出可用提要
智能支付墙检测
- 自动检测免费与付费文章
- 仅在需要时请求身份验证
- 基于会话的身份验证,以避免重复登录
双接口
- MCP协议: 通过stdio与Cursor IDE直接集成
- HTTP API: 用于web应用程序的可选基于FastAPI的REST端点
- OpenAPI文档位于
/docs - 部署到托管平台(Render、Railway、Fly.io、Google Cloud Run)
快速开始
先决条件
- Python 3.10+
- (可选)Redis用于生产会话存储
安装
- 克隆存储库:
git clone https://github.com/yourusername/lloyds-list-mcp.git
cd lloyds-list-mcp- 创建虚拟环境:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- 安装依赖项:
pip install -r requirements.txt- 安装Playwright浏览器:
playwright install chromium- 配置环境(可选):
cp config/.env.example .env
# Edit .env to customize settings本地运行
选项1:用uvicorn跑步
uvicorn src.lloyds_list_mcp.api:app --host 0.0.0.0 --port 8000 --reload选项2:使用Docker Compose(包括Redis)运行
docker-compose up服务器将在 http://localhost:8000
API文件,网址: http://localhost:8000/docs
API终点
公共端点(无身份验证)
搜索文章
POST /api/search
Content-Type: application/json
{
"query": "container shipping rates",
"sector": "Containers",
"limit": 10
}答复:
{
"status": "success",
"count": 5,
"results": [
{
"title": "Container rates surge in Q1 2026",
"url": "https://lloydslist.com/...",
"date": "2026-01-20",
"summary": "Container shipping rates increased 15%...",
"image_url": "https://lloydslist.com/images/article.jpg",
"tags": ["Containers", "Markets"],
"author": "John Doe"
}
]
}获取最新文章
POST /api/latest
Content-Type: application/json
{
"feed_type": "sectors",
"feed_name": "Containers",
"limit": 10
}列出可用源
GET /api/feeds答复:
{
"status": "success",
"feeds": {
"sectors": ["Containers", "Dry Bulk", "Tankers & Gas", ...],
"topics": ["Decarbonisation", "Red Sea Risk", "Sanctions", ...],
"regulars": ["Daily Briefing", "The View", "Podcasts & Video", ...]
}
}经过身份验证的端点(用于付费内容)
获取文章内容(通过付费墙检测)
POST /api/article
Content-Type: application/json
{
"article_url": "https://lloydslist.com/LL1156104/...",
"user_session": null // Optional - only needed if paywalled
}如果可以阅读,请回复:
{
"status": "success",
"paywall": false,
"content": {
"title": "Article title",
"full_text": "Complete article text...",
"images": [...],
"author": "Author name",
"date": "2026-01-20",
"tags": ["Containers"]
}
}如果付费墙+无会话,则响应:
{
"status": "authentication_required",
"paywall": true,
"message": "This article requires a Lloyd's List subscription",
"url": "https://lloydslist.com/..."
}认证用户
POST /api/auth/login
Content-Type: application/json
{
"username": "your.email@example.com",
"password": "your-password"
}答复:
{
"status": "success",
"message": "Authentication successful",
"session_token": "abc123...",
"expires_in": 86400
}总结文章
POST /api/summarize
Content-Type: application/json
{
"article_urls": ["https://lloydslist.com/LL1156104/..."],
"summary_length": "brief", // "brief", "detailed", or "full"
"user_session": null // Optional - required for detailed/full if paywalled
}建筑
flowchart TD
WebApp[AI Web App] -->|HTTP/REST API| MCPServer[MCP Server - Hosted]
MCPServer -->|Public RSS Parsing| feedparser[feedparser]
MCPServer -->|Staged Auth Check| AuthManager[Auth Manager]
subgraph PublicTier[Tier 1: Public - No Auth]
feedparser -->|Titles/Summaries| MCPServer
end
subgraph AuthTier[Tier 2: Authenticated - On Demand]
AuthManager -->|Valid Session?| SessionStore[Session Store]
SessionStore -->|No| WebApp
WebApp -->|User Login UI| User[End User]
User -->|Credentials| LloydsAuth[Lloyd's List Auth]
LloydsAuth -->|Session Token| SessionStore
SessionStore -->|Yes| ContentFetcher[Article Fetcher]
ContentFetcher -->|Full Text| MCPServer
end
MCPServer -->|Results| WebApp部署
部署以渲染(免费层)
- 在以下位置创建渲染帐户https://render.com
- 创建新的Web服务:
- 连接您的GitHub存储库 - 环境:Docker - 在根目录下使用Dockerfile
- 添加环境变量:
SESSION_STORE=memory
SESSION_SECRET_KEY=your-random-secret-key
LOG_LEVEL=INFO- 部署
您的API将在 https://your-app.onrender.com
替代平台
- 铁路: 从GitHub一键部署
- Fly.io:
flyctl deploy命令行界面 - 谷歌云运行: 通过gcloud部署容器
配置
环境变量(可选-提供默认值):
# Server
HOST=0.0.0.0
PORT=8000
LOG_LEVEL=INFO
# Cache
CACHE_DIR=.cache
FEED_CACHE_TTL=300
# Session Management
SESSION_STORE=memory # or 'redis'
REDIS_URL=redis://localhost:6379/0
SESSION_TTL=86400 # 24 hours
SESSION_SECRET_KEY=your-secret-key
# Deployment
ENVIRONMENT=production发展
运行测试
pytest代码质量
# Format code
black src/
# Lint
ruff src/
# Type check
mypy src/安全
- 服务器上未存储凭据
- 静态加密会话
- 从未记录密码
- 会话自动过期
- 分阶段身份验证(仅在需要时)
MCP工具(用于直接MCP使用)
如果直接通过MCP协议使用服务器:
search_articles(query, sector?, category?, limit?)-搜索公共RSS源get_latest_articles(feed_type, feed_name, limit?)-获取最新文章list_available_feeds()-列出所有订阅源get_article_content(article_url, user_session?)-获取完整文章(支持付费墙)authenticate_user(username, password)-创建经过身份验证的会话summarize_articles(article_urls, summary_length, user_session?)-生成摘要
技术栈
- MCP-SDK: mcp使用(Python)
- Web框架: 快速API
- RSS解析: 馈送分析器
- 身份验证: 剧作家(浏览器自动化)
- HTML解析: 美丽的Soup4
- HTTP客户端: httpx
- 会话存储: Redis(生产)或内存(开发)
许可证
Apache许可证2.0-请参阅 许可证 了解详情。
贡献
欢迎投稿!请看 代理商.md 发展指南。
支持
对于问题或疑问:
- 打开GitHub问题
- 查看API文档,网址:
/docs - 审查 代理商.md 了解实施细节
