ashutosh-rath02/mcp-ai-assistant
If you are the rightful owner of mcp-ai-assistant 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.
LangChain MCP Server is a Model Context Protocol server built with LangChain and Google Gemini, designed to provide specialized AI tools for various tasks while adhering to clean architecture principles.
generate_poem
Create poems in various styles (haiku, sonnet, free verse, limerick).
create_character
Generate detailed fictional characters for storytelling.
design_system
Design software system architectures.
analyze_market
Conduct market analysis and competitive research.
create_workout
Generate personalized workout plans.
generate_recipe
Create recipes based on available ingredients.
plan_trip
Plan travel itineraries.
solve_puzzle
Solve logic puzzles and brain teasers.
LangChain MCP Server - Clean Architecture
A Model Context Protocol (MCP) server built with LangChain and Google Gemini, following clean architecture principles. This server provides specialized AI tools for various tasks like poetry generation, character creation, system design, market analysis, workout planning, recipe generation, trip planning, and puzzle solving.
๐๏ธ Architecture
The project follows Clean Architecture principles with clear separation of concerns:
src/
โโโ domain/ # Core business logic
โ โโโ entities/ # Domain entities (Tool, ToolResult)
โ โโโ services/ # Domain services (ToolService)
โโโ application/ # Application layer
โ โโโ use_cases/ # Use cases (ListTools, ExecuteTool)
โ โโโ services/ # Application services (MCPService)
โโโ infrastructure/ # External dependencies
โ โโโ ai/ # AI service implementations
โ โโโ config/ # Configuration management
โ โโโ repositories/ # Data access implementations
โโโ presentation/ # User interface layer
โโโ api/ # Web API handlers
โโโ cli/ # Command-line interface
โโโ models/ # Presentation models
๐ Features
- Clean Architecture: Proper separation of concerns with domain, application, infrastructure, and presentation layers
- Specialized AI Tools: 8 different AI-powered tools for various tasks
- Smart CLI: AI-powered tool selection based on natural language input
- WebSocket API: Real-time communication via MCP protocol
- REST API: Additional HTTP endpoints for health checks and tool listing
- Comprehensive Testing: Test scripts to verify functionality
๐ ๏ธ Available Tools
- generate_poem - Create poems in various styles (haiku, sonnet, free verse, limerick)
- create_character - Generate detailed fictional characters for storytelling
- design_system - Design software system architectures
- analyze_market - Conduct market analysis and competitive research
- create_workout - Generate personalized workout plans
- generate_recipe - Create recipes based on available ingredients
- plan_trip - Plan travel itineraries
- solve_puzzle - Solve logic puzzles and brain teasers
๐ Prerequisites
- Python 3.8+
- Google Gemini API key
- Required Python packages (see requirements.txt)
๐ Quick Start
1. Setup Environment
# Clone the repository
git clone <repository-url>
cd langchain-mcp
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cp env_example.txt .env
# Edit .env with your Google API key
2. Run the Server
# Start the MCP server
python run_server.py
The server will start on http://localhost:8000
with WebSocket endpoint at ws://localhost:8000/ws
.
3. Use the Smart CLI
# Run the interactive CLI
python run_cli.py
# Or run a single request
python run_cli.py --request "Write a poem about AI"
4. Test the Server
# Run the test script
python run_test.py
๐๏ธ Architecture Details
Domain Layer
- Entities: Core business objects (
Tool
,ToolResult
) - Services: Domain business logic (
ToolService
)
Application Layer
- Use Cases: Application-specific business rules
- Services: Orchestration of domain services
Infrastructure Layer
- AI Service: LLM integration with Google Gemini
- Configuration: Environment and settings management
- Repositories: Data access implementations
Presentation Layer
- API: WebSocket and HTTP handlers
- CLI: Command-line interface with AI tool selection
- Models: Request/response data structures
๐ง Configuration
The application uses environment variables for configuration:
# MCP Server
MCP_HOST=localhost
MCP_PORT=8000
# Google Gemini
GOOGLE_API_KEY=your_api_key_here
DEFAULT_MODEL=gemini-2.0-flash
MAX_TOKENS=4000
TEMPERATURE=0.7
# Logging
LOG_LEVEL=INFO
๐ API Usage
WebSocket MCP Protocol
Connect to ws://localhost:8000/ws
and use the MCP protocol:
// Initialize
{
"jsonrpc": "2.0",
"id": "1",
"method": "initialize",
"params": {}
}
// List tools
{
"jsonrpc": "2.0",
"id": "2",
"method": "tools/list",
"params": {}
}
// Execute tool
{
"jsonrpc": "2.0",
"id": "3",
"method": "tools/call",
"params": {
"name": "generate_poem",
"arguments": {
"theme": "artificial intelligence",
"style": "haiku",
"mood": "contemplative"
}
}
}
REST API Endpoints
GET /
- Server informationGET /health
- Health checkGET /tools
- List available tools
๐ค Smart CLI Features
The CLI uses AI to automatically select the appropriate tool based on natural language input:
# Examples
python run_cli.py --request "Write a poem about love"
python run_cli.py --request "Create a hero for a fantasy story"
python run_cli.py --request "Design a website for selling products"
python run_cli.py --request "Analyze the market for electric cars"
python run_cli.py --request "Create a workout for beginners"
python run_cli.py --request "Make a recipe with chicken and rice"
python run_cli.py --request "Plan a trip to Japan"
python run_cli.py --request "Solve this puzzle: A farmer has 17 sheep..."
๐งช Testing
Run the comprehensive test suite:
python run_test.py
This will test:
- Server connection and initialization
- Tool listing
- Tool execution (poem generation, puzzle solving, workout creation)
๐ Development
Adding New Tools
- Domain Layer: Add tool definition in
ToolRepositoryImpl._initialize_tools()
- Infrastructure Layer: Add AI method in
AIService
- Repository Layer: Add execution logic in
ToolRepositoryImpl.execute_tool()
Project Structure Benefits
- Maintainability: Clear separation of concerns
- Testability: Easy to unit test each layer independently
- Scalability: Easy to add new tools and features
- Flexibility: Easy to swap implementations (e.g., different AI providers)
๐ License
This project is licensed under the MIT License.
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes following clean architecture principles
- Add tests for new functionality
- Submit a pull request
๐ Support
For issues and questions, please open an issue on the repository.