βοΈ An intelligent German legal QA agent with MCP (Model Context Protocol) integration for accessing comprehensive German federal law database and providing legal analysis.
This German legal agent provides expert legal analysis by intelligently accessing the comprehensive German federal law database through the Model Context Protocol (MCP). It can answer legal questions, explain regulations, analyze legal scenarios, and provide precise legal references by querying the complete German federal law collection in real-time.
- Legal Data Access: Comprehensive access to all German federal laws and regulations (Bundesgesetze und -verordnungen)
- Multi-LLM Support: Works with both local (Ollama) and cloud-based (OpenRouter) language models
- Tool-Calling Architecture: Automatic legal document retrieval without manual intervention
- Real-Time Monitoring: Complete visibility into legal database queries and system operations
- Clean Interface: Filtered chat experience with technical details in separate monitoring panel
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β React UI β β LLM Provider β β German Law DB β
β β β β β β
β β’ Chat InterfaceβββββΊβ β’ Ollama βββββΊβ β’ Federal Laws β
β β’ Provider Setupβ β β’ OpenRouter β β β’ Regulations β
β β’ MCP Monitoringβ β β’ Tool Calling β β β’ Legal Codes β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β² β² β²
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ
β MCP Proxy β
β β
β β’ Protocol Hub β
β β’ Data Bridge β
β β’ Tool Registry β
βββββββββββββββββββ
- Node.js 18+
- npm or yarn
- (Optional) Ollama for local models
- (Optional) OpenRouter API key for cloud models
- Clone the repository
git clone <repository-url>
cd german-legal-agent- Install dependencies
# Frontend
cd app && npm install
# MCP Server
cd ../server && npm install
# MCP Tools
cd ../mcp-servers/legal-files && npm install- Configure your data source
# Set your German law data directory (use absolute path on your system)
export LEGAL_FILES_ROOT="$(pwd)/data/gesetze"# From project root
./scripts/start-all.sh- Start MCP Proxy Server
cd server
LEGAL_FILES_ROOT="$(pwd)/../data/gesetze" npm start- Start Frontend
cd app
npm run dev- Access the application
- Frontend: http://localhost:5173
- MCP Proxy: http://localhost:8787
- β Intelligent Legal Analysis: Multi-iteration reasoning for complex legal questions
- β Real-Time Legal Data Access: Live querying of German federal law database
- β Multi-Provider Support: Choice between local and cloud-based language models
- β Enhanced Monitoring: Detailed logging of all data operations
- β Clean Chat Interface: Customer-focused view with technical details hidden
- β Tool Call Visualization: See exactly what data is being accessed
- β Parameter Tracking: Monitor search queries and file access patterns
- β Error Handling: Graceful degradation with helpful error messages
- β Iteration Control: Automatic continuation until customer question is fully answered
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Pull a model
ollama pull qwen3:8b
# Model will be available at localhost:11434- Get API key from OpenRouter
- In the application, select "OpenRouter" provider
- Enter your API key
- Choose a model (e.g.,
anthropic/claude-3.5-sonnet)
The bot can be configured to access various business data sources:
// German Law Database Structure
data/gesetze/
βββ a/ // Laws starting with 'A'
β βββ agg/ // Allgemeines Gleichbehandlungsgesetz
β β βββ index.md // Full law text in Markdown
β βββ arbzg/ // Arbeitszeitgesetz
βββ b/ // Laws starting with 'B'
βββ ... // All German federal laws A-ZEmployment Law Question
User: "What are the maximum working hours allowed in Germany?"
Agent: [Accesses Arbeitszeitgesetz] β "According to Β§ 3 ArbZG, the daily working time must not exceed 8 hours. It can be extended to 10 hours if compensated within 6 months or 24 weeks."
Anti-Discrimination Law
User: "What constitutes discrimination based on age under German law?"
Agent: [Searches AGG] β "Under Β§ 1 AGG (Allgemeines Gleichbehandlungsgesetz), age-based discrimination is prohibited. Β§ 10 AGG allows different treatment only if objectively justified by legitimate aims."
Legal Reference Lookup
User: "What does Β§ 823 BGB say about tort liability?"
Agent: [Queries BGB] β "Β§ 823 BGB establishes the fundamental principle of tort liability: whoever unlawfully and culpably injures another's life, body, health, freedom, property, or similar rights must compensate for damages."
german-legal-agent/
βββ app/ # React frontend
β βββ src/
β β βββ components/ # UI components
β β βββ lib/ # Core logic
β β βββ styles/ # CSS styles
βββ server/ # MCP proxy server
βββ mcp-servers/ # MCP tool implementations
βββ data/gesetze/ # German federal law database
βββ docs/ # Documentation
# Run tests
npm test
# Type checking
npm run type-check
# Linting
npm run lint
# Build for production
npm run build- Create MCP tool for your data source
- Register tool in MCP server
- Update system prompt with tool descriptions
- Test with sample queries
# Build frontend
cd app && npm run build
# Build server
cd ../server && npm run build
# Deploy to your hosting platformLEGAL_FILES_ROOT="./data/gesetze" # Relative to project root
OPENROUTER_API_KEY="your-api-key"
MCP_SERVER_PORT=8787
FRONTEND_PORT=5173- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- π Documentation: Wiki
- π Bug Reports: Issues
- π¬ Discussions: Discussions
- π§ Email: support@example.com
- Model Context Protocol for the integration framework
- Anthropic for MCP development
- React and TypeScript for the frontend
- Ollama for local LLM support
Version: 1.0.0 | Last Updated: December 2024