这是一个基于 MCP (Model Context Protocol) 的 Confluence API 服务实现。该服务提供了与 Confluence 进行交互的能力,支持获取空间信息、页面内容、搜索等功能。
# 安装依赖
npm install
# 清理并构建项目
npm run build:clean
# 启动服务
npm start
在项目根目录创建 .env
文件:
# Confluence 配置
CONFLUENCE_URL=https://your-confluence-url
CONFLUENCE_USERNAME=your-username
CONFLUENCE_PASSWORD=your-password
# 服务器配置
PORT=3000
NODE_ENV=development
TIMEOUT=10000
REJECT_UNAUTHORIZED=true
%USERPROFILE%\.cursor\mcp.json
中添加:{
"mcpServers": {
"mcp-server-confluence-ts": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"@smithery/cli@latest",
"run",
"@enjoyzl/mcp-server-confluence-ts",
"--config",
"{\"confluenceUrl\":\"your-confluence-url\",\"confluenceUsername\":\"your-username\",\"confluencePassword\":\"your-password\"}"
]
}
}
}
%USERPROFILE%\.cursor\mcp.json
中添加:{
"mcpServers": {
"mcp-server-confluence-ts": {
"command": "cmd",
"args": [
"/k",
"cd",
"/d",
"D:\\workspace\\code\\mcp\\mcp-server-confluence-ts",
"&",
"node",
"dist/index.js"
]
}
}
}
Windows 配置说明:
/k
: 执行命令后保持命令窗口,便于查看日志/d
: 切换到指定驱动器- 使用
&
连接多个命令- 路径使用双反斜杠
\\
转义- 环境变量可以在项目的
.env
文件中配置
~/.cursor/mcp.json
中添加:{
"mcpServers": {
"mcp-server-confluence-ts": {
"command": "bash",
"args": [
"-c",
"npx -y @smithery/cli@latest run @enjoyzl/mcp-server-confluence-ts --config '{\"confluenceUrl\":\"your-confluence-url\",\"confluenceUsername\":\"your-username\",\"confluencePassword\":\"your-password\"}'"
]
}
}
}
~/.cursor/mcp.json
中添加:{
"mcpServers": {
"mcp-server-confluence-ts": {
"command": "node",
"args": ["/Users/your-username/workspace/code/mcp/mcp-server-confluence-ts/dist/index.js"],
"env": {
"CONFLUENCE_URL": "your-confluence-url",
"CONFLUENCE_USERNAME": "youraccount",
"CONFLUENCE_PASSWORD": "yourpwd",
}
}
}
}
Mac/Linux 配置说明:
-c
: 执行命令字符串- 使用
&&
连接多个命令- 路径使用正斜杠
/
- 环境变量可以在项目的
.env
文件中配置- Mac 用户主目录通常在
/Users/your-username/
- Linux 用户主目录通常在
/home/your-username/
# 监听文件变化并自动编译
npm run dev
# 监听文件变化并自动重启服务
npm run dev:start
# 仅构建项目
npm run build
# 清理构建目录
npm run clean
# 清理并重新构建
npm run build:clean
# 基本调试模式
npm run inspector
# 开发调试模式(带详细日志)
npm run inspector:dev
const space = await confluenceService.getSpace('SPACE_KEY');
const page = await confluenceService.getPage('PAGE_ID');
const results = await confluenceService.searchContent('search query');
const content = await confluenceService.getPageContent('PAGE_ID');
const confluenceService = new ConfluenceService({
baseUrl: 'https://your-confluence-url',
username: 'your-username',
password: 'your-password',
timeout: 10000,
maxRedirects: 5,
keepAlive: true,
maxContentLength: 10 * 1024 * 1024 // 10MB
});
连接优化
请求优化
错误处理
服务使用结构化日志输出,包含以下信息:
{
"jsonrpc": "2.0",
"method": "log",
"params": {
"level": "info",
"message": "请求信息",
"timestamp": "2024-04-16T12:00:44.000Z"
}
}
错误响应格式:
interface ErrorResponse {
message: string;
statusCode?: number;
error?: any;
config?: {
url?: string;
method?: string;
params?: any;
};
}
欢迎提交 Issue 和 Pull Request。
{
"mcpServers": {
"mcp-server-confluence-ts": {
"env": {},
"args": [
"-y",
"@smithery/cli@latest",
"run",
"@enjoyzl/mcp-server-confluence-ts",
"--config",
"{\"confluenceUrl\":\"your-confluence-url\",\"confluenceUsername\":\"your-username\",\"confluencePassword\":\"your-password\"}"
],
"command": "npx"
}
}
}
Seamless access to top MCP servers powering the future of AI integration.