Skip to content

sr-networks/gesagent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

German Legal Agent v0.1

βš–οΈ An intelligent German legal QA agent with MCP (Model Context Protocol) integration for accessing comprehensive German federal law database and providing legal analysis.

License: MIT React TypeScript MCP

πŸš€ Overview

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.

Key Capabilities

  • 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

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   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 β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

⚑ Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn
  • (Optional) Ollama for local models
  • (Optional) OpenRouter API key for cloud models

Installation

  1. Clone the repository
git clone <repository-url>
cd german-legal-agent
  1. Install dependencies
# Frontend
cd app && npm install

# MCP Server
cd ../server && npm install

# MCP Tools
cd ../mcp-servers/legal-files && npm install
  1. Configure your data source
# Set your German law data directory (use absolute path on your system)
export LEGAL_FILES_ROOT="$(pwd)/data/gesetze"

πŸš€ Running the Application

Start All Services (Recommended)

# From project root
./scripts/start-all.sh

Manual Service Management

  1. Start MCP Proxy Server
cd server
LEGAL_FILES_ROOT="$(pwd)/../data/gesetze" npm start
  1. Start Frontend
cd app
npm run dev
  1. Access the application

🎯 Features

Core Functionality

  • βœ… 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

Advanced Features

  • βœ… 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

πŸ› οΈ Configuration

LLM Providers

Option 1: Ollama (Local)

# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Pull a model
ollama pull qwen3:8b

# Model will be available at localhost:11434

Option 2: OpenRouter (Cloud)

  1. Get API key from OpenRouter
  2. In the application, select "OpenRouter" provider
  3. Enter your API key
  4. Choose a model (e.g., anthropic/claude-3.5-sonnet)

Data Sources

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-Z

πŸ“Š Usage Examples

Legal QA Scenarios

Employment 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."

πŸ”§ Development

Project Structure

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

Development Commands

# Run tests
npm test

# Type checking
npm run type-check

# Linting
npm run lint

# Build for production
npm run build

Adding New Data Sources

  1. Create MCP tool for your data source
  2. Register tool in MCP server
  3. Update system prompt with tool descriptions
  4. Test with sample queries

πŸš€ Deployment

Production Build

# Build frontend
cd app && npm run build

# Build server
cd ../server && npm run build

# Deploy to your hosting platform

Environment Variables

LEGAL_FILES_ROOT="./data/gesetze"  # Relative to project root
OPENROUTER_API_KEY="your-api-key"
MCP_SERVER_PORT=8787
FRONTEND_PORT=5173

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

πŸ™ Acknowledgments


Version: 1.0.0 | Last Updated: December 2024

About

A legal QA agent

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors