Foreign Trade Statistics MCP Server
Query Latvian import and export data by partner country, HS/CN commodity code, and time period. Annual and monthly granularity, values in euros.
Overview
This MCP server provides SQL-based access to Latvia's foreign trade statistics database. The AI assistant writes SQL queries against a PostgreSQL database containing comprehensive trade data maintained by the Central Statistical Bureau of Latvia.
Trade Data
Import and export values in euros, weight in kilograms, and supplementary units for all HS/CN commodity codes.
Partner Countries
Bilateral trade data with all partner countries, identified by ISO 3166-1 alpha-2 codes, names in English and Latvian.
Product Classification
Hierarchical HS/CN product classification with 2-digit chapters through 8-digit detailed codes. Descriptions in English and Latvian.
Connection
{
"mcpServers": {
"latvia-foreign-trade": {
"url": "https://mcp-ft.stat.gov.lv/mcp"
}
}
}Endpoint: https://mcp-ft.stat.gov.lv/mcp · Transport: Streamable HTTP · No API key required
Available Tools
| Tool | Purpose | Parameters |
|---|---|---|
getContext |
Get database schema, table descriptions, join patterns, query examples | — |
execute_sql |
Execute read-only SQL queries against the trade database | query: SQL string |
explain_query |
Get execution plan for a SQL query | query: SQL string |
list_objects |
List available tables and views | schema (optional) |
get_object_details |
Get column definitions for a table | object_name: table name |
Database Tables
| Table | Description | Key Columns |
|---|---|---|
ft.impexp_data |
Annual import/export data: country, HS code, flow, value (EUR), weight (kg) | countrycode, code (HS), flow (Imp/Exp), time (year), value (EUR), weight (kg) |
ft.impexp_data_m |
Monthly import/export data with same structure | Same as annual, time in YYYY-MM format |
ft.countries |
Country reference: ISO codes, names in English and Latvian | code (ISO alpha-2), name_en, name_lv |
ft.hs_classification |
Hierarchical HS/CN product classification (2–8 digit codes) | code, parent, level, shorttext_en, longtext_en |
ft.business_glossary |
Trade terminology dictionary | term, definition, context |
Example Questions
- What are Latvia’s top 10 export destinations?
- Show monthly imports of machinery from Germany in 2024
- Calculate the trade balance with EU countries
- Which HS chapters had the highest export growth?
- Compare food imports from Lithuania vs Estonia
- What are the main commodities Latvia exports to the US?
- Show seasonal patterns in agricultural exports
- Which product categories have the largest trade deficit?
Example SQL Query
Top 10 Export Partners by Value
SELECT c.name_en AS country,
SUM(d.value) AS total_value_eur
FROM ft.impexp_data d
JOIN ft.countries c ON d.countrycode = c.code
WHERE d.flow = 'Exp' AND d.time = 2024
AND d.countrycode != 'TOTAL'
GROUP BY c.name_en
ORDER BY total_value_eur DESC
LIMIT 10;Data Source
Trade data is sourced from the foreign trade statistics database of the Central Statistical Bureau of Latvia. It covers bilateral trade between Latvia and all partner countries, classified by the Harmonized System (HS) and Combined Nomenclature (CN).
Free to use under CC BY 4.0 license. No authentication required.