MCP 博客 API
一个使用 FastMCP 和 httpx 构建的简单博客 API 服务。该项目支持 uv,可实现快速、可靠的 Python 包管理和环境设置。
描述
该项目提供了一组 API 工具,用于与模拟博客 API 服务进行交互。它允许用户获取所有博客、按标题搜索博客以及添加新博文。该项目包含一个 uv.lock 文件,用于可复现的依赖项管理。
Related MCP server: Elasticsearch Semantic Search MCP Server
特征
从模拟 API 获取所有博客
按标题搜索博客
添加新博客文章
要求
Python 3.13 或更高版本
httpx 0.28.1 或更高版本
mcp 1.9.0 或更高版本
安装
使用 uv(推荐)
# Clone the repository
git clone https://github.com/yourusername/mcp-blog.git
cd mcp-blog
# Install dependencies with uv
uv pip install -e .
使用 pip
# Clone the repository
git clone https://github.com/yourusername/mcp-blog.git
cd mcp-blog
# Install dependencies
pip install -e .
用法
# Import the MCP server
from main import mcp
# Get all blogs
blogs = mcp.tools.get_blogs()
# Search for blogs by title
search_results = mcp.tools.search_blogs(query="Python")
# Add a new blog
new_blog = mcp.tools.add_blog(title="My New Blog", body="This is the content of my new blog post.")
运行服务器
使用 uv(推荐)
uv python main.py
使用标准 Python
python main.py
环境管理
使用 uv(推荐)
uv 为 Python 项目提供快速的环境管理。以下是为该项目创建和管理虚拟环境的方法:
# Create a new virtual environment
uv venv
# Activate the virtual environment
# On Unix/macOS
source .venv/bin/activate
# On Windows
.venv\Scripts\activate
# Install dependencies in the virtual environment
uv pip install -e .
# Update dependencies
uv pip sync
API 参考
获取博客()
从模拟 API 获取所有博客。
搜索博客(查询:str)
使用模拟 API 按标题搜索博客。
添加博客(标题:str,正文:str)
向模拟 API 添加新博客。
执照
[在此添加您的许可证信息]
贡献
[在此处添加贡献指南]