alexandrebouchez/XCompanionMCP
If you are the rightful owner of XCompanionMCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
XCompanionMCP is a lightweight Model Context Protocol (MCP) server that integrates with the x-tweet-scanner REST API to provide Twitter content planning and analytics.
create_post_template
Create reusable content templates
get_post_template
Retrieve specific templates
update_post_template
Modify existing templates
list_post_templates
List all templates
delete_post_template
Remove templates
XCompanionMCP
A lightweight Model Context Protocol (MCP) layer that provides Twitter content planning and analytics functionality through the x-tweet-scanner REST API.
Overview
XCompanionMCP is a pure MCP implementation that delegates all business logic to the x-tweet-scanner REST API backend. This architecture provides:
- Lightweight Design: No direct database access or business logic in the MCP layer
- API Integration: All operations performed through HTTP calls to x-tweet-scanner
- Proactive AI Guidance: Enhanced prompting system for strategic content creation
- Complete Tool Set: 25+ MCP tools for comprehensive content management
Architecture
āāāāāāāāāāāāāāāāāāā HTTP/REST āāāāāāāāāāāāāāāāāāā
ā XCompanionMCP ā āāāāāāāāāāāāāāā ā x-tweet-scanner ā
ā (MCP Layer) ā ā (REST API) ā
āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā
ā ā
ā ā
ā¼ ā¼
āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā
ā Claude/AI ā ā Database ā
ā Clients ā ā (Supabase) ā
āāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāāāāā
Features
Template Management
- Create, read, update, delete post templates
- Enhanced template structure with engagement optimization
- Template versioning and performance tracking
Weekly Schedule Management
- Create weekly posting schedules
- Time slot management with timezone support
- Schedule optimization recommendations
Daily Operations
- Today's planned posts based on schedule
- Next scheduled post retrieval
- Date-specific post planning
Post Creation & History
- Save and track created posts
- Post status management (draft, scheduled, published)
- Performance analytics integration
User Preferences & Persona
- User preference management
- Persona coaching system with archetype discovery
- Strategic content alignment
Analytics & Intelligence
- Tweet analysis and pattern recognition
- Trending topic identification
- Content performance optimization
- Creation context and AI guidance
Content Intelligence
- Content idea generation
- Viral pattern analysis
- Engagement optimization
Account Management
- Twitter account linking/unlinking
- Multi-account support
Publishing & Scheduling
- Post scheduling with optimal timing
- Publishing calendar management
- Scheduled post cancellation
Reporting & Planning
- Weekly planning overview
- Performance dashboard
- Content calendar export
Installation
-
Clone the repository:
git clone <repository-url> cd XCompanionMCP
-
Install dependencies:
pip install -e .
-
Configure environment:
cp .env.example .env # Edit .env with your configuration
Configuration
Environment Variables
Create a .env
file with the following configuration:
# x-tweet-scanner API Configuration
X_TWEET_SCANNER_API_URL=http://localhost:8000
X_TWEET_SCANNER_API_TOKEN=your_api_token_here
X_TWEET_SCANNER_TIMEOUT=30
X_TWEET_SCANNER_MAX_RETRIES=3
# User Configuration
XCOMPANION_USER_ID=your_user_id
# Optional: Logging
LOG_LEVEL=INFO
API Configuration
The MCP layer requires a running x-tweet-scanner API backend. Configure the connection in your environment:
- API URL: Base URL of your x-tweet-scanner instance
- API Token: Authentication token for API access
- Timeout: Request timeout in seconds
- Max Retries: Number of retry attempts for failed requests
Usage
Running the MCP Server
python main.py
Using with Claude Desktop
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"xcompanion": {
"command": "python",
"args": ["/path/to/XCompanionMCP/main.py"],
"env": {
"X_TWEET_SCANNER_API_URL": "http://localhost:8000",
"X_TWEET_SCANNER_API_TOKEN": "your_token"
}
}
}
}
Available Tools
The MCP server provides 25+ tools organized by category:
Template Management
create_post_template
- Create reusable content templatesget_post_template
- Retrieve specific templatesupdate_post_template
- Modify existing templateslist_post_templates
- List all templatesdelete_post_template
- Remove templates
Schedule Management
create_weekly_template
- Set up posting schedulesget_weekly_template
- View current schedulesupdate_weekly_template
- Modify schedulesremove_weekly_slot
- Remove schedule entriesget_weekly_planning_markdown
- Get formatted planning view
Content Operations
save_created_post
- Save posts with trackingget_all_previous_posts
- Retrieve post historyget_created_post
- Get specific postsupdate_created_post
- Modify saved postsdelete_created_post
- Remove posts
Analytics & Intelligence
query_tweets
- Analyze high-performing contentget_trending_topics
- Identify trending topicsanalyze_content_performance
- Evaluate content potentialget_creation_context
- Get AI-powered creation guidance
And many more...
Proactive AI Guidance
The system includes enhanced AI prompting that provides:
- Pre-execution guidance: Context before tool execution
- Strategic recommendations: Next-step suggestions
- Workflow awareness: Phase-appropriate guidance
- Performance insights: Data-driven optimization tips
API Integration
All operations are performed through HTTP requests to the x-tweet-scanner API:
# Example: Creating a template
async with XTweetScannerClient() as client:
result = await client.create_post_template(user_id, template_data)
The API client handles:
- Authentication with bearer tokens
- Request retries with exponential backoff
- Error handling and recovery
- Response validation
Error Handling
The MCP layer provides comprehensive error handling:
- Authentication Errors: Clear guidance for auth issues
- API Errors: Detailed error messages with recovery steps
- Network Errors: Retry logic with exponential backoff
- Validation Errors: Input validation and correction guidance
Development
Running Tests
pytest
Code Formatting
black src/
ruff check src/
Type Checking
mypy src/
Dependencies
Core Dependencies
mcp[cli]>=1.0.0
- Model Context Protocol frameworkhttpx>=0.27.0
- Async HTTP clientpydantic>=2.0.0
- Data validationpython-dotenv>=1.0.0
- Environment configuration
Development Dependencies
pytest>=7.0.0
- Testing frameworkpytest-asyncio>=0.21.0
- Async test supportblack>=23.0.0
- Code formattingruff>=0.1.0
- Lintingmypy>=1.0.0
- Type checking
Architecture Benefits
Separation of Concerns
- MCP Layer: Handles protocol and AI guidance
- API Layer: Manages business logic and data
- Database Layer: Handled by x-tweet-scanner backend
Scalability
- Lightweight MCP instances
- Centralized business logic in API
- Easy horizontal scaling
Maintainability
- Clear boundaries between layers
- Simplified testing and debugging
- Independent deployment cycles
Comparison with Original XCompanion
Feature | Original XCompanion | XCompanionMCP |
---|---|---|
Architecture | Monolithic | Layered (MCP + API) |
Database Access | Direct | Via REST API |
Business Logic | In MCP server | In x-tweet-scanner API |
Dependencies | Heavy (Supabase, etc.) | Lightweight (HTTP only) |
Deployment | Single unit | Distributed |
Scalability | Limited | High |
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support and questions:
- Check the documentation
- Review the API integration guide
- Open an issue on GitHub