Initial commit
This commit is contained in:
4
skills/mxcp-expert/assets/project-templates/covid_owid/.gitignore
vendored
Normal file
4
skills/mxcp-expert/assets/project-templates/covid_owid/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
target/
|
||||
dbt_packages/
|
||||
logs/
|
||||
149
skills/mxcp-expert/assets/project-templates/covid_owid/README.md
Normal file
149
skills/mxcp-expert/assets/project-templates/covid_owid/README.md
Normal file
@@ -0,0 +1,149 @@
|
||||
# COVID-19 OWID Example
|
||||
|
||||
This example demonstrates how to use MXCP to create a COVID-19 data analysis API. It shows how to:
|
||||
- Fetch and cache COVID-19 data from Our World in Data (OWID)
|
||||
- Transform data using dbt and DuckDB
|
||||
- Create a natural language interface for data exploration using generic SQL tools
|
||||
|
||||
## Features
|
||||
|
||||
- **Comprehensive Data**: Global COVID-19 statistics from OWID
|
||||
- **Data Transformation**: dbt models for efficient querying
|
||||
- **Natural Language**: LLM-friendly query interface (prompt only)
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Make sure you have the required tools installed:
|
||||
```bash
|
||||
# Install MXCP and dependencies
|
||||
pip install mxcp dbt-core dbt-duckdb
|
||||
|
||||
# Option: Install in development mode
|
||||
cd /path/to/mxcp
|
||||
python -m venv .venv && source .venv/bin/activate
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
### Running the Example
|
||||
|
||||
1. Navigate to the COVID example:
|
||||
```bash
|
||||
cd examples/covid_owid
|
||||
```
|
||||
|
||||
2. Initialize the data:
|
||||
```bash
|
||||
dbt deps
|
||||
dbt run
|
||||
```
|
||||
|
||||
3. Start the MCP server:
|
||||
```bash
|
||||
mxcp serve
|
||||
```
|
||||
|
||||
## 🔌 Claude Desktop Integration
|
||||
|
||||
To use this example with Claude Desktop:
|
||||
|
||||
### 1. Locate Claude's Configuration
|
||||
|
||||
Find your Claude Desktop configuration file:
|
||||
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
||||
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
||||
|
||||
### 2. Configure the MCP Server
|
||||
|
||||
Add this configuration to your `claude_desktop_config.json`:
|
||||
|
||||
#### If you installed MXCP globally:
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"covid": {
|
||||
"command": "mxcp",
|
||||
"args": ["serve", "--transport", "stdio"],
|
||||
"cwd": "/absolute/path/to/mxcp/examples/covid_owid"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### If you're using a virtual environment:
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"covid": {
|
||||
"command": "/bin/bash",
|
||||
"args": [
|
||||
"-c",
|
||||
"cd /absolute/path/to/mxcp/examples/covid_owid && source ../../.venv/bin/activate && mxcp serve --transport stdio"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Important**: Replace `/absolute/path/to/mxcp` with the actual path to your MXCP installation.
|
||||
|
||||
### 3. Restart Claude Desktop
|
||||
|
||||
After saving the configuration, restart Claude Desktop to load the new MCP server.
|
||||
|
||||
### 4. Test the Integration
|
||||
|
||||
In Claude Desktop, try asking:
|
||||
- "Show me COVID-19 cases in the United States for 2022"
|
||||
- "Compare vaccination rates between France and Germany"
|
||||
- "What were the peak hospitalization rates in the UK?"
|
||||
|
||||
## 🛠️ Other MCP Clients
|
||||
|
||||
This example works with any MCP-compatible tool:
|
||||
- **mcp-cli**: Interactive command-line interface
|
||||
- **Custom integrations**: Build your own using the MCP specification
|
||||
|
||||
## Example Usage
|
||||
|
||||
The LLM can help you analyze:
|
||||
- Case numbers and death rates
|
||||
- Vaccination progress
|
||||
- Hospital occupancy
|
||||
- Regional comparisons
|
||||
- Policy effectiveness
|
||||
|
||||
All queries are handled through the generic SQL query interface. You can:
|
||||
- Use `list_tables` to see available tables
|
||||
- Use `get_table_schema` to inspect table structure
|
||||
- Use `execute_sql_query` to run custom SQL queries
|
||||
|
||||
## Implementation Details
|
||||
|
||||
The example uses:
|
||||
- dbt for data transformation
|
||||
- DuckDB for efficient storage and querying
|
||||
- SQL analytics for complex calculations
|
||||
- Type-safe parameters for filtering
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
covid_owid/
|
||||
├── endpoints/ # MCP endpoint definitions
|
||||
│ └── prompt.yml # LLM system prompt (generic query interface only)
|
||||
├── models/ # dbt transformations
|
||||
│ ├── covid_data.sql # Main COVID-19 statistics
|
||||
│ ├── hospitalizations.sql # Hospital/ICU data
|
||||
│ └── locations.sql # Geographic data
|
||||
├── mxcp-site.yml # MCP configuration
|
||||
└── dbt_project.yml # dbt configuration
|
||||
```
|
||||
|
||||
## Learn More
|
||||
|
||||
- [OWID COVID-19 Data](https://github.com/owid/covid-19-data) - Data source
|
||||
- [dbt Documentation](https://docs.getdbt.com/) - Data transformation
|
||||
- [DuckDB Documentation](https://duckdb.org/docs/) - Database engine
|
||||
- [MXCP Documentation](../../docs/quickstart.md) - MCP framework
|
||||
@@ -0,0 +1,19 @@
|
||||
analysis-paths:
|
||||
- analyses
|
||||
clean-targets:
|
||||
- target
|
||||
- dbt_packages
|
||||
config-version: 2
|
||||
macro-paths:
|
||||
- macros
|
||||
model-paths:
|
||||
- models
|
||||
name: covid_owid
|
||||
profile: covid_owid_default
|
||||
seed-paths:
|
||||
- seeds
|
||||
snapshot-paths:
|
||||
- snapshots
|
||||
target-path: target
|
||||
test-paths:
|
||||
- tests
|
||||
@@ -0,0 +1,4 @@
|
||||
{{ config(materialized='table') }}
|
||||
|
||||
select *
|
||||
from read_csv_auto('https://github.com/owid/covid-19-data/raw/master/public/data/owid-covid-data.csv')
|
||||
@@ -0,0 +1,5 @@
|
||||
{{ config(materialized='table') }}
|
||||
|
||||
select *
|
||||
|
||||
from read_csv_auto('https://github.com/owid/covid-19-data/raw/master/public/data/hospitalizations/covid-hospitalizations.csv')
|
||||
@@ -0,0 +1,5 @@
|
||||
{{ config(materialized='table') }}
|
||||
|
||||
select *
|
||||
|
||||
from read_csv_auto('https://github.com/owid/covid-19-data/raw/master/public/data/hospitalizations/locations.csv')
|
||||
@@ -0,0 +1,9 @@
|
||||
version: 2
|
||||
|
||||
sources:
|
||||
- name: github_covid_data
|
||||
description: "COVID-19 data loaded directly from Our World in Data GitHub repository"
|
||||
meta:
|
||||
urls:
|
||||
owid_covid_data: "https://github.com/owid/covid-19-data/raw/master/public/data/owid-covid-data.csv"
|
||||
covid_hospitalizations: "https://github.com/owid/covid-19-data/raw/master/public/data/hospitalizations/covid-hospitalizations.csv"
|
||||
@@ -0,0 +1,5 @@
|
||||
mxcp: 1
|
||||
profile: default
|
||||
project: covid_owid
|
||||
sql_tools:
|
||||
enabled: true
|
||||
@@ -0,0 +1,75 @@
|
||||
mxcp: 1
|
||||
|
||||
prompt:
|
||||
name: "covid_data_analyst"
|
||||
description: "An AI assistant that analyzes and explains COVID-19 data from Our World in Data."
|
||||
tags: ["covid", "analysis", "health", "epidemiology"]
|
||||
messages:
|
||||
- role: system
|
||||
type: text
|
||||
prompt: |
|
||||
You are an expert COVID-19 data analyst with access to the Our World in Data (OWID) COVID-19 dataset. You can help users understand and analyze:
|
||||
|
||||
1. Case numbers, deaths, and testing data
|
||||
2. Vaccination rates and their impact
|
||||
3. Hospital and ICU occupancy rates
|
||||
4. Regional and country-specific trends
|
||||
5. Comparative analysis between countries
|
||||
6. Policy responses and their effectiveness
|
||||
|
||||
Data Exploration Tools:
|
||||
You have access to a generic query interface for exploring the COVID-19 data:
|
||||
- list_tables: View all available tables in the database
|
||||
- get_table_schema: Examine the structure and columns of any table
|
||||
- execute_sql_query: Run custom SQL queries for data analysis
|
||||
|
||||
These tools allow you to:
|
||||
1. Explore available data tables and their structure
|
||||
2. Create custom queries for specific analysis needs
|
||||
3. Perform complex aggregations and calculations
|
||||
4. Combine data from different tables
|
||||
5. Filter and sort data in any way needed
|
||||
6. Answer detailed or unusual questions from users
|
||||
|
||||
Available data includes:
|
||||
- Daily and cumulative case counts
|
||||
- Death rates and mortality statistics
|
||||
- Testing rates and positivity rates
|
||||
- Vaccination data (first, second doses, boosters)
|
||||
- Hospital and ICU admissions
|
||||
- Demographics and population metrics
|
||||
- Government response indicators
|
||||
|
||||
When responding:
|
||||
- Use list_tables and get_table_schema to understand available data
|
||||
- Create focused SQL queries that answer the specific question
|
||||
- Provide context for the numbers you present
|
||||
- Explain trends and potential factors affecting the data
|
||||
- Note any data limitations or gaps
|
||||
- Use clear, non-technical language when possible
|
||||
- Cite specific dates and sources
|
||||
- Acknowledge uncertainty where it exists
|
||||
- For SQL queries, explain your logic
|
||||
|
||||
Example Usage:
|
||||
1. Explore available tables:
|
||||
list_tables()
|
||||
|
||||
2. Understand table structure:
|
||||
get_table_schema("covid_data")
|
||||
|
||||
3. Custom analysis:
|
||||
execute_sql_query("
|
||||
SELECT
|
||||
location,
|
||||
date,
|
||||
new_cases,
|
||||
new_deaths,
|
||||
total_vaccinations
|
||||
FROM covid_data
|
||||
WHERE date >= '2021-01-01'
|
||||
AND location IN ('United States', 'United Kingdom')
|
||||
ORDER BY date DESC
|
||||
")
|
||||
|
||||
The data is sourced from Our World in Data's COVID-19 dataset, which is regularly updated and maintained by researchers at the University of Oxford.
|
||||
Reference in New Issue
Block a user