
🚀 Dev.to MCP Server

2025.05.01
0
Python内容管理API 服务交流协作
Dev.to MCP Server 是一个基于 Model Context Protocol (MCP) 的实现,专门为 Dev.to API 提供服务。它提供了浏览、搜索、阅读和创建 Dev.to 上内容的能力。该服务器支持多种功能,包括获取最新文章、热门文章、按标签浏览文章、阅读特定文章、获取用户信息、搜索文章以及创建和更新文章等。
View on GitHub
Overview
✨ 核心功能
- 浏览最新文章:获取 Dev.to 上的最新文章。
- 浏览热门文章:获取 Dev.to 上的热门文章。
- 按标签浏览文章:获取带有特定标签的文章。
- 阅读文章:获取特定文章的详细信息。
- 用户信息:获取 Dev.to 用户的信息。
- 搜索文章:使用关键词搜索文章。
- 创建文章:创建并发布新文章。
- 更新文章:更新现有文章。
- 列出我的文章:列出用户自己发布的文章。
🚀 使用教程
🐳 使用 Docker 运行
- 克隆仓库:
git clone https://github.com/rawveg/devtomcp.git
cd devtomcp
- 使用 Docker Compose 构建并运行:
docker-compose up --build
服务器将在 http://localhost:8000 上可用,SSE 端点在 http://localhost:8000/sse。
🖥️ 客户端配置
Claude Desktop 配置
在 Claude Desktop 的 config.json
中添加 MCP 服务器:
{
"mcpServers": {
"devto": {
"transport": "sse",
"url": "http://localhost:8000/sse",
"env": {
"DEVTO_API_KEY": "your_dev_to_api_key_here"
}
}
}
}
Cursor 配置
在 Cursor 的配置中添加 MCP 服务器:
{
"mcpServers": {
"devto": {
"transport": "sse",
"url": "http://localhost:8000/sse",
"env": {
"DEVTO_API_KEY": "your_dev_to_api_key_here"
}
}
}
}
使用 Python 进行编程访问
import asyncio
import os
from fastmcp.client import Client
async def main():
# 设置环境变量进行认证
os.environ["DEVTO_API_KEY"] = "your_dev_to_api_key_here"
# 连接到 MCP 服务器
client = Client("http://localhost:8000/sse")
# 使用客户端
async with client:
# 获取热门文章
results = await client.call_tool("browse_popular_articles", {})
print(results)
if __name__ == "__main__":
asyncio.run(main())
⚙️ 服务器配置
服务器可以使用以下环境变量进行配置:
环境变量 | 描述 | 默认值 |
---|---|---|
PORT |
服务器运行的端口 | 8000 |
LOG_LEVEL |
日志级别 (INFO, DEBUG 等) | INFO |
🔐 客户端认证
每个客户端需要提供自己的 Dev.to API 密钥进行认证操作。这通过在客户端的 MCP 服务器配置中提供 API 密钥作为环境变量来实现。
注意: 密钥应作为
DEVTO_API_KEY
在 MCP 客户端配置的环境部分提供。
⚠️ 错误处理
服务器返回标准的 MCP 错误响应:
{
"status": "error",
"message": "Error description",
"code": 401
}
常见错误代码: - 401:认证失败(缺少或无效的 API 密钥) - 404:资源未找到 - 422:无效参数 - 500:服务器错误
🔒 安全考虑
- 服务器使用环境变量进行 API 密钥配置,提供适当的安全隔离
- 每个客户端连接使用其自己配置的 API 密钥
- 所有 API 凭据处理都在服务器端进行
- 在生产环境中使用 HTTPS
- 在云部署中使用安全的密钥管理来管理 API 密钥