An AI-powered data exploration tool for Swiss business registry data, built with MXCP (Model Context Protocol) and dbt. This server enables AI assistants to query and analyze Swiss company information through natural language interfaces.
This MXCP server provides intelligent access to Swiss business registry data containing 1,000+ companies across all Swiss cantons. It demonstrates how to build production-ready AI data tools with comprehensive testing, audit logging, and cloud deployment capabilities.
- Natural Language Queries: Search and analyze companies using conversational language
- Advanced Analytics: Aggregate data by up to two dimensions simultaneously, create time series analyses
- Consistent Filtering: All tools support the same comprehensive set of filters for unified querying
- Comprehensive Data Model: Includes company details, legal forms, industries, and financial information
- Production-Ready: Complete with testing, audit logging, and AWS deployment
- AI-Powered: Integrates seamlessly with AI assistants like Claude, GPT-4, and others
- Python 3.8+
- Virtual environment tool (venv)
- OpenAI API key (for AI-powered features)
- Clone the repository:
git clone https://github.com/raw-labs/swiss-mxcp-server.git
cd swiss-mxcp-server
git submodule update --init --recursive # Initialize deployment scripts
- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Install dbt dependencies:
dbt deps
- Build the data model:
dbt run
- Start the MXCP server:
mxcp serve
- Test the installation:
mxcp list
You should see 4 available tools:
search_companies
- Search for companies with filtersaggregate_companies
- Aggregate data by dimensionstimeseries_companies
- Time-based analysiscategorical_company_values
- Get distinct categorical values
Run the comprehensive test suite:
./scripts/run_tests.sh
This runs:
- MXCP configuration validation
- dbt data quality tests
- Tool functionality tests
- Data integrity checks
All tools support comprehensive filtering with the following parameters:
- company_name / company_name_like: Exact or partial company name match
- uid: Unique Identification Number
- legal_form: Legal form (AG, GmbH, etc.)
- canton: Swiss canton
- industry_code: Industry classification code
- min_capital / max_capital: Share capital range in CHF
- min_employees / max_employees: Employee count range
- registration_date_from / registration_date_to: Registration date range
Search for Swiss companies with pagination support.
Example queries:
- "Find all AG companies in Zürich with capital over 1M CHF"
- "Show companies with 50-200 employees registered in 2024"
- "List companies with 'Tech' in their name"
Aggregate company data by one or two dimensions:
- Group by (comma-separated, max 2): Canton, LegalForm, IndustryCode, IndustryDescription, RegistrationYear
- Metrics (comma-separated): count, total_capital, avg_share_capital, min_capital, max_capital, total_employees, avg_employees
Example queries:
- "What's the average share capital by legal form?"
- "Show company count by canton and legal form" (two-level grouping)
- "Compare total capital by industry for Zürich companies"
- "Group by canton,legalform and show count and average capital"
Analyze trends over time:
- date_field: Currently supports RegistrationDate
- interval: day, week, month, quarter, year
- Supports all standard filters
Example queries:
- "Show monthly company registrations for AG companies"
- "Track quarterly registrations with capital > 500K"
- "Analyze yearly growth patterns by canton"
Get distinct values for categorical fields:
- field: canton, legal_form, industry_code, industry_description
Example queries:
- "List all Swiss cantons in the data"
- "What legal forms are available?"
- "Show all industry categories"
The swiss_companies
table contains:
- CompanyName: Company name
- LegalForm: Legal structure (AG, GmbH, etc.)
- UID: Unique Identification Number
- RegistrationDate: Official registration date
- Canton: Swiss canton
- ShareCapitalCHF: Share capital in Swiss Francs
- IndustryCode: Industry classification code
- IndustryDescription: Industry description
- Employees: Number of employees
All tool calls are automatically logged with:
- Timestamp and tool name
- Input parameters
- Execution time
- Success/error status
View audit logs:
./exec/aws-apprunner/shared-scripts/scripts/latest-logs.sh --audit
Comprehensive dbt tests ensure:
- Valid Swiss cantons
- Proper legal forms
- Capital requirements (e.g., AG minimum 100,000 CHF)
- No duplicate companies
- Required fields are populated
Deploy to AWS App Runner:
cd exec/aws-apprunner
./shared-scripts/scripts/deploy-service.sh
Monitor deployment:
./shared-scripts/scripts/monitor-deployment.sh
swiss-mxcp-server/
├── data/ # Sample data and DuckDB database
├── models/ # dbt models and schema
├── sql/ # SQL queries for tools
├── tools/ # MXCP tool definitions
├── tests/ # dbt and Python tests
├── scripts/ # Utility scripts
├── exec/aws-apprunner/ # Deployment configuration
└── evals/ # MXCP evaluation scenarios
- Create SQL query in
sql/
- Define tool in
tools/
with YAML configuration - Add tests in
tests/python/
- Update documentation
Always run tests before deployment:
# Validate MXCP configuration
mxcp validate
# Run dbt tests
dbt test
# Run tool tests
python tests/python/test_swiss_companies_fixed.py
# Run all tests
./scripts/run_tests.sh
The project includes complete AWS App Runner deployment:
- Configure AWS credentials
- Update
exec/aws-apprunner/project-config.sh
- Build and push Docker image:
./shared-scripts/scripts/build-and-push.sh
- Deploy service:
./shared-scripts/scripts/deploy-service.sh
Required for deployment:
OPENAI_API_KEY
- For AI features (optional for basic testing)- AWS credentials for deployment
- Two-Level Grouping: aggregate_companies now supports grouping by two dimensions (e.g., Canton,LegalForm)
- Consistent Filtering: All tools now support the same comprehensive set of filters
- Enhanced Time Series: Added support for day, week, quarter intervals in addition to month and year
- Improved SQL Structure: Queries follow clean, maintainable patterns similar to UAE MXCP server
- Better Testing: Added specific tests for two-level grouping and comprehensive filter validation
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
MIT License - see LICENSE file for details.
- Built with MXCP by RAW Labs
- Data transformation powered by dbt
- Sample data is fictional and for demonstration purposes only
For issues, questions, or contributions:
- Open an issue on GitHub
- Check the MXCP documentation
- Join the MXCP community discussions