OpenBanking MCP Server
An MCP (Model Context Protocol) server that integrates with local Ollama LLMs for OpenBanking applications.
Features
- Multiple LLM Agents: Support for 4 different specialized agents
- Ollama Integration: Local LLM model support
- Tool System: Comprehensive toolset for various operations
- OpenBanking Focus: Specialized tools for banking and financial data
Architecture
This MCP server follows the architecture shown in the diagram:
- MCP Host communicates with MCP Server
- 4 Specialized Agents (Agent 1-4) with LLM/Model capabilities
- Tool system for specific operations
- Banking Services/API integration
Agents
- Agent 1 - Market Analyst: Market data analysis and volatile situations
- Agent 2 - Portfolio Manager: Portfolio management and strategy finding
- Agent 3 - Risk Analyst: Risk analysis for users
- Agent 4 - Explainability Agent: LLM for explainability and SWOT analysis
Project Structure
mcpOpenbankingMCPServer/
├── src/
│ ├── __init__.py
│ ├── main.py # Main server entry point
│ ├── agents/
│ │ ├── __init__.py
│ │ └── agent_manager.py # Agent management system
│ ├── tools/
│ │ ├── __init__.py
│ │ ├── tool_registry.py # Tool registration and management
│ │ ├── portfolio_tools.py # Portfolio analysis tools
│ │ ├── market_tools.py # Market data tools
│ │ ├── risk_tools.py # Risk assessment tools
│ │ ├── strategy_tools.py # Strategy recommendation tools
│ │ └── analysis_tools.py # SWOT and explanation tools
│ ├── config/
│ │ ├── __init__.py
│ │ └── config.py # Configuration management
│ └── utils/
│ ├── __init__.py
│ └── utils.py # Utility functions
├── config/
│ └── config.yaml # Server configuration
├── requirements.txt # Python dependencies
├── startup.py # Python startup script
├── start_server.ps1 # PowerShell startup script
├── start_server.bat # Batch file for Windows
├── demo.py # Demo examples
├── test_server.py # Test script
└── README.md # This file
Prerequisites
- Python 3.8+ with conda environment
- Ollama installed and running locally
- Conda environment named
openbanking-backend
Setup
1. Create Conda Environment (if not exists)
conda create -n openbanking-backend python=3.11
conda activate openbanking-backend
2. Install Dependencies
pip install -r requirements.txt
3. Install and Start Ollama
Download and install Ollama from https://ollama.ai
# Pull a model (example with Llama 3.2)
ollama pull llama3.2:latest
# Start Ollama server
ollama serve
4. Configure the Server
Edit config/config.yaml to customize:
- Ollama connection settings
- Agent configurations
- Model assignments
- Tool settings
Running the Server
Option 1: Using PowerShell Script (Recommended for Windows)
.\start_server.ps1
Option 2: Using Python Startup Script
python startup.py
Option 3: Direct Execution
conda activate openbanking-backend
python src/main.py
Option 4: Development Mode
python src/main.py --dev
Tools Available
Portfolio Analysis
analyze_portfolio: Comprehensive portfolio analysisportfolio_optimization: Portfolio allocation optimization
Market Analysis
market_analysis: Current market conditions analysisvolatility_analysis: Market volatility assessment
Risk Assessment
assess_risk: User-specific risk assessmentrisk_simulation: Scenario-based risk simulation
Strategy Recommendations
recommend_strategy: Investment strategy recommendations
Analysis & Explainability
swot_analysis: SWOT analysis for any subjectexplain_concept: Explain financial concepts simplyreverse_simulation: Reverse engineering analysis
Usage Examples
Run Demo
python demo.py
Test the Server
python test_server.py
Configuration
The server uses config/config.yaml for configuration. Key sections:
# Ollama connection
ollama:
host: "localhost"
port: 11434
timeout: 30
# Agents configuration
agents:
- name: "market_analyst"
model: "gemma3:4b"
role: "Market Data Analyst"
# ... more config
# Tools configuration
tools:
- name: "portfolio_analysis"
enabled: true
Troubleshooting
Common Issues
-
Ollama Connection Failed
- Ensure Ollama is installed and running (
ollama serve) - Check if the default port 11434 is available
- Verify models are pulled (
ollama list)
- Ensure Ollama is installed and running (
-
Conda Environment Issues
- Make sure
openbanking-backendenvironment exists - Activate the environment before running
- Install dependencies in the correct environment
- Make sure
-
Import Errors
- Ensure all dependencies are installed
- Check Python path and working directory
Logs
Check the console output for detailed error messages and debugging information.
Development
Adding New Tools
- Create tool class in
src/tools/ - Add tool registration in
tool_registry.py - Update configuration if needed
Adding New Agents
- Add agent configuration in
config/config.yaml - Implement custom agent logic if needed
- Test with demo scripts
License
MIT License
