MCP server by SGSxingchen
NovelAI MCP Server
✨ 特性
- 🎨 最新模型支持 - 完整支持 NAI Diffusion V4.5 Full
- 🚀 双传输模式 - Stdio、HTTP SSE、Streamable HTTP
- 🎭 多角色支持 - V4+ 角色定位和独立提示词系统
- 📝 中文优化 - 工具描述使用中文,AI 更准确识别调用时机
- 🔧 灵活部署 - 支持本地运行或 Docker 容器化
📦 快速开始
安装
# 克隆项目
git clone https://github.com/SGSxingchen/NovelAI_MCP.git
cd NovelAI_MCP
# 安装依赖
npm install
# 编译
npm run build
配置
方式一:Stdio 模式(Claude Desktop)
在 Claude Desktop 配置文件中添加:
{
"mcpServers": {
"novelai": {
"command": "node",
"args": ["项目路径/dist/index.js"],
"env": {
"NOVELAI_API_KEY": "your-api-key-here"
}
}
}
}
方式二:Streamable HTTP 模式(LobeChat/Dify 推荐)
Linux/Mac:
export NOVELAI_API_KEY="your-api-key"
export HTTPS_PROXY="http://127.0.0.1:7890" # 可选:设置代理
npm run start:http
Windows PowerShell:
$env:NOVELAI_API_KEY="your-api-key"
$env:HTTPS_PROXY="http://127.0.0.1:7890" # 可选:设置代理
npm run start:http
Windows CMD:
set NOVELAI_API_KEY=your-api-key
set HTTPS_PROXY=http://127.0.0.1:7890
npm run start:http
在客户端配置中添加:
- URL:
http://localhost:3000/mcp - 传输: Streamable HTTP
方式三:SSE 模式(备选)
Linux/Mac:
export NOVELAI_API_KEY="your-api-key"
export HTTPS_PROXY="http://127.0.0.1:7890" # 可选
npm run start:sse
Windows PowerShell:
$env:NOVELAI_API_KEY="your-api-key"
$env:HTTPS_PROXY="http://127.0.0.1:7890"
npm run start:sse
Windows CMD:
set NOVELAI_API_KEY=your-api-key
set HTTPS_PROXY=http://127.0.0.1:7890
npm run start:sse
在客户端配置中添加:
- URL:
http://localhost:3000/sse - 传输: Server-Sent Events (SSE)
🎯 支持的模型
当前版本专注于最新的 NovelAI V4.5 模型:
| 模型 | 说明 |
|------|------|
| nai-diffusion-4-5-full | NAI Diffusion V4.5 Full(唯一支持的模型) |
🔧 核心参数
| 参数 | 类型 | 说明 |
|------|------|------|
| base_prompt | string | 全局场景和风格描述 |
| base_negative_prompt | string | 全局负面提示词 |
| characters | array | 角色数组(单人/多人都要用) |
| width / height | number | 图片尺寸(必须是 64 的倍数) |
| steps | number | 采样步数(锁定 28,免费限制) |
完整参数列表请查看 快速参考。
📊 传输模式对比
| 特性 | Stdio 模式 | Streamable HTTP | SSE 模式 |
|------|-----------|----------------|----------|
| 适用场景 | Claude Desktop | LobeChat、Dify(推荐) | SSE 客户端 |
| 协议标准 | MCP Stdio | MCP Streamable HTTP | MCP SSE Transport |
| 端点 | - | /mcp | /sse + /message |
| 远程访问 | ❌ | ✅ | ✅ |
| 多客户端 | ❌ | ✅ | ✅ |
| 代理支持 | ❌ | ✅ | ✅ |
| 启动命令 | npm run start:stdio | npm run start:http | npm run start:sse |
🌍 环境变量
| 变量 | 必需 | 默认值 | 说明 |
|------|------|--------|------|
| NOVELAI_API_KEY | ✅ | - | NovelAI API 密钥 |
| PORT | ❌ | 3000 | HTTP 服务器端口(仅 HTTP 模式) |
| HTTPS_PROXY | ❌ | - | HTTPS 代理地址 |
| HTTP_PROXY | ❌ | - | HTTP 代理地址 |
📚 文档
🛠️ 开发
# 克隆仓库
git clone https://github.com/SGSxingchen/NovelAI_MCP.git
cd NovelAI_MCP
# 安装依赖
npm install
# 编译
npm run build
# 开发模式
npm run dev
# 启动 HTTP 服务器
npm run start:http
🐳 Docker 部署(可选)
项目包含 Dockerfile,可以自行构建:
# 构建镜像
docker build -t novelai-mcp-server .
# 运行容器
docker run -d \
-p 3000:3000 \
-e NOVELAI_API_KEY="your-api-key" \
--name novelai-mcp \
novelai-mcp-server
🤝 贡献
欢迎提交 Issue 和 Pull Request!
- Fork 本项目
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 开启 Pull Request
📄 许可证
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。
🙏 致谢
- NovelAI - 提供强大的图像生成 API
- Model Context Protocol - MCP 协议规范
- Anthropic - MCP SDK 和 Claude
🔗 相关链接
如果这个项目对你有帮助,请给个 ⭐️!