Confluence MCP Server
A Model Context Protocol (MCP) server that provides Confluence search functionality for LexisNexis internal systems.
README
Confluence MCP Server
A Model Context Protocol (MCP) server that provides Confluence search functionality for LexisNexis internal systems:
- Confluence Search - Search and retrieve content from LexisNexis Confluence
Overview
This MCP server is built using the @modelcontextprotocol/sdk and provides seamless integration with LexisNexis Confluence through standardized MCP protocols. It enables AI assistants and other MCP clients to search Confluence documentation.
Features
🔍 Confluence Search Tool
- Search across LexisNexis Confluence spaces, pages, blog posts, and attachments
- Retrieve detailed content from search results
- Support for CQL (Confluence Query Language) queries
- Configurable search result limits
- Bearer token authentication
Prerequisites
- Node.js 18+
- npm or pnpm package manager
- TypeScript 5.3+
- Access to LexisNexis internal networks (for Confluence services)
Installation
-
Clone the repository:
git clone <repository-url> cd confluence_mcp -
Install dependencies:
npm install # or pnpm install -
Build the project:
npm run build
Configuration
Environment Variables
Create a .env file in the project root with the following variables:
# Confluence Configuration
CONFLUENCE_BEARER_TOKEN=your_confluence_bearer_token_here
LIMIT=5 # Optional: Number of search results to return (default: 2)
Bearer Token Setup
To use the Confluence search functionality, you'll need a valid bearer token:
- Log into LexisNexis Confluence
- Generate an API token
- Set the
CONFLUENCE_BEARER_TOKENenvironment variable
Usage
Starting the Server
npm start
The server runs on stdio transport and will output:
Confluence MCP Server running on stdio
Tool Usage
Confluence Search
Tool Name: confluence-search
Description: Search Confluence using a search string. Input must start with 'confluence' (case-insensitive) followed by the search string.
Input Format:
confluence <your search terms>
Examples:
confluence API documentation
confluence deployment guide
confluence troubleshooting
Response: Returns the full content of matching Confluence pages, including HTML markup.
Technical Architecture
MCP Protocol Implementation
This server implements the Model Context Protocol (MCP) specification:
- Transport Layer: Uses stdio transport for communication
- Message Format: JSON-RPC 2.0 protocol
- Tool Registration: Dynamic tool registration with schema validation
- Error Handling: Structured error responses with proper HTTP status codes
Request/Response Flow
- Client Request: MCP client sends tool invocation request
- Validation: Input parameters validated using Zod schemas
- Processing: Tool-specific logic executed (API calls, authentication)
- Response: Structured response returned with content array
Rate Limiting & Performance
- Confluence API: Built-in 1-second delay between content detail requests
- Concurrent Requests: Handles multiple tool invocations safely
- Memory Management: Streaming responses for large content retrieval
API Endpoints
Confluence API
- Base URL:
https://confluence.lexisnexis.dev - Search Endpoint:
/rest/api/search - Content Endpoint:
/rest/api/content/{id}
Project Structure
confluence_mcp/
├── src/
│ └── confluence.ts # Main MCP server implementation
├── build/ # Compiled JavaScript output
│ └── confluence.js # Confluence search functionality
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── jest.config.js # Jest testing configuration
└── manifest.xml # Office add-in manifest (legacy)
Development
Building
npm run build
This compiles TypeScript files from src/ to build/ directory.
Testing
npm test
Note: Tests are currently not implemented (returns "Error: no test specified").
Code Structure
The server uses the MCP SDK to:
- Create an MCP Server instance for Confluence search functionality
- Register tools using
server.tool()method - Handle stdio transport for communication
- Implement async tool handlers with proper error handling
Key Dependencies
@modelcontextprotocol/sdk- Core MCP functionalitynode-fetch- HTTP requests to APIszod- Runtime type validation and schema validation
Advanced Configuration
Confluence Search Customization
You can customize the search behavior by modifying the CQL query in src/confluence.ts:
const cqlQuery = `siteSearch ~ "${searchString}" AND type in ("space","user","page","blogpost")`;
Environment-Specific Settings
Different environments may require different configurations:
# Development
CONFLUENCE_BEARER_TOKEN=dev_token_here
LIMIT=2
# Production
CONFLUENCE_BEARER_TOKEN=prod_token_here
LIMIT=10
Error Handling
The server implements comprehensive error handling:
- Network Errors: Automatic retry logic for transient failures
- Authentication Errors: Clear error messages for invalid credentials
- Rate Limiting: Graceful handling of API rate limits
- Input Validation: Schema-based validation with detailed error messages
Security Considerations
⚠️ Important Security Notes:
- Credentials: Never commit bearer tokens or passwords to version control
- Environment Variables: Use
.envfiles or secure environment variable management - Network Access: This server requires access to internal LexisNexis networks
- Token Handling: Session tokens should be handled securely and not logged
Troubleshooting
Common Issues
-
"Invalid input" errors:
- Ensure Confluence queries start with "confluence"
-
Authentication failures:
- Check bearer token validity for Confluence
- Ensure network connectivity to LexisNexis services
-
No search results:
- Try broader search terms
- Check if you have access to the Confluence spaces
- Verify the LIMIT environment variable is set appropriately
-
Rate limiting errors:
- The server implements 1-second delays between requests
- For high-volume usage, consider implementing exponential backoff
- Monitor API rate limits in your environment
-
Memory issues with large responses:
- Reduce the LIMIT environment variable
- Filter search results more specifically
- Consider implementing response streaming for very large content
Debug Logging
The server outputs debug information to stderr:
- Search queries and bearer tokens
- API response statuses
- Error messages and stack traces
Enable verbose logging by setting:
export DEBUG=confluence-mcp:*
Performance Monitoring
Monitor key metrics:
- Response times for Confluence searches
- Memory usage during large content retrieval
- Error rates for search operations
Integration Examples
Using with MCP Clients
Claude Desktop Configuration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"confluence-mcp": {
"command": "node",
"args": ["c:/dev/confluence_mcp/build/confluence.js"],
"env": {
"CONFLUENCE_BEARER_TOKEN": "your_token_here",
"LIMIT": "5"
}
}
}
}
Custom MCP Client
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
const transport = new StdioClientTransport({
command: 'node',
args: ['./build/confluence.js']
});
const client = new Client({
name: "confluence-client",
version: "1.0.0"
}, {
capabilities: {}
});
await client.connect(transport);
License
ISC License
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests (when test framework is implemented)
- Submit a pull request
Changelog
Version 1.0.0
- Initial release with Confluence search tool
- MCP SDK integration
- TypeScript implementation
- Basic error handling and logging
For more information about the Model Context Protocol, visit: https://modelcontextprotocol.io/
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。