一个用于管理创意写作项目中角色知识和关系的Model Context Protocol (MCP)服务器。
# 克隆仓库
git clone <repository-url>
cd writer-mcp
# 创建虚拟环境
python -m venv venv
source venv/bin/activate # 在Windows上:venv\Scripts\activate
# 安装依赖
pip install -e .
复制.env.example到.env并配置您的设置:
cp .env.example .env
编辑.env以包含您的数据库和API凭证:
# 数据库配置
DATABASE_URL=postgresql://username:password@localhost:5432/writer_mcp
TEST_DATABASE_URL=postgresql://username:password@localhost:5432/writer_mcp_test
# OpenAI配置
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_BASE_URL=https://api.openai.com/v1
CHAT_MODEL=gpt-4o-mini
EMBEDDING_MODEL=text-embedding-3-small
# 应用配置
APP_NAME=Writer MCP
DEBUG_MODE=true
# 向量配置
VECTOR_DIMENSION=1536
# 搜索配置
DEFAULT_SEARCH_LIMIT=10
MAX_SEARCH_LIMIT=100
# MCP服务器配置
MCP_SERVER_NAME=writer-m
MCP_SERVER_VERSION=1.0.0
# 初始化数据库(首次运行)
python scripts/init_db.py
# 启动MCP服务器
python run_server.py
# 安装开发依赖
pip install -e ".[dev]"
# 运行测试
pytest
# 启动开发服务器
python scripts/dev_server.py
writer-mcp/
├── src/writer_mcp/ # 主要源代码
│ ├── config.py # 配置管理
│ ├── server.py # MCP服务器
│ ├── database/ # 数据库相关
│ ├── schemas/ # 数据模型
│ ├── services/ # 业务逻辑
│ ├── tools/ # MCP工具定义
│ └── utils/ # 工具函数
├── scripts/ # 脚本文件
├── tests/ # 测试文件
├── run_server.py # 服务器启动脚本
└── main.py # 主入口文件
MIT许可证 - 详情见LICENSE文件。 </中文翻译>