Overview
Theprepare_gdelt_query tool is the essential first step in any GDELT query workflow. It fetches the complete table schemas and code references you need to construct accurate SQL queries.
When to use
Useprepare_gdelt_query when:
- Starting any new query workflow
- A user asks to analyze GDELT data
- Building SQL for alerts or saved queries
- You need to understand available tables and columns
Parameters
Tables to query. Select based on question type.Available tables:
gdelt_events- WHO-WHAT-WHERE-WHEN structured eventsgdelt_mentions- Coverage tracking and event-to-article bridgingmv_event_mention_stats- Trending/viral events (pre-aggregated, fastest)gdelt_gkg_themes_extracted- Topic/theme filtering (ENV_, ECON_, PROTEST, etc.)gdelt_gkg_persons_extracted- Person mentions in articlesgdelt_gkg_organizations_extracted- Organization mentions in articlesgdelt_gkg_locations_extracted- Geographic location mentions with coordinatesgdelt_persons_master- Historical person tracking (all-time, no 30-day limit)gdelt_organizations_master- Historical org tracking (all-time, no 30-day limit)
Include ISO-3 country codes (USA, CHN, GBR) for filtering WHO is involved.Use with
actor1_country_code, actor2_country_code in gdelt_events.Include FIPS 2-char country codes (US, CH, UK) for filtering WHERE events happened.Use with
*_geo_country_code in gdelt_events, or country_code in gdelt_gkg_locations_extracted.Include CAMEO actor type codes (GOV, MIL, COP, EDU, etc.) for filtering actor classifications.Use with
actor*_type1_code, actor*_type2_code, actor*_type3_code in gdelt_events.Include known group codes (NATO, UN, IGO, etc.) for filtering international organizations.Use with
actor*_known_group_code in gdelt_events. High precision, low recall.Include ethnic group codes for filtering by ethnic identity.Use with
actor*_ethnic_code in gdelt_events. Sparse field, use as secondary filter.Include religion codes for filtering by religious affiliation.Use with
actor*_religion1_code, actor*_religion2_code in gdelt_events. Sparse field.Include CAMEO event codes (01-20 root codes) for filtering WHAT happened.Use with
event_code, event_base_code, event_root_code in gdelt_events.Root codes: 14=protest, 18=assault, 19=fight, 20=mass violence, etc.Include Goldstein scale reference (-10 to +10) for filtering event intensity.Includes natural language mapping: ‘violent conflict’ (-10 to -7), ‘cooperation’ (+3 to +6), etc.Use with
goldstein_scale and quad_class in gdelt_events.Include GDELT theme taxonomy (ENV_, ECON_, CONFLICT_, GOV_, HEALTH_, WB_, UNGP_*) for filtering article topics.Use with
theme column in gdelt_gkg_themes_extracted.Include CrisisLex terms for filtering crisis/disaster content.Covers: casualties, evacuations, damage, relief efforts, etc.Use with
theme column (CRISISLEX_* patterns) in gdelt_gkg_themes_extracted.Response
Returns a comprehensive text response containing:- Complete table schemas - All columns with types, descriptions, and sample values
- Code references - Valid codes for filtering based on your flags
- JOIN guidance - How to connect multiple tables correctly
- Query requirements - Critical rules for valid GDELT queries
The response includes everything you need to build a valid SQL query without additional lookups.
Usage examples
Query workflow
1
Prepare your query
Call
prepare_gdelt_query with your selected tables and code flags.You now have complete schemas and codes to build your SQL query.
2
Build your SQL
Use the returned schemas to construct your SELECT query with proper:
- Column names
- Date filters (required)
- LIMIT clause (required, max 1000)
- Source URL column (required)
3
Execute or present
Choose your next step:
- Research/analysis: Use
execute_queryto run the query and get results - Alerts/saved queries: Use
present_sqlto validate and present the query
Table selection guide
WHO-WHAT-WHERE-WHEN questions: gdelt_events
WHO-WHAT-WHERE-WHEN questions: gdelt_events
Use
gdelt_events for structured event data with actors, actions, locations, and timestamps.Examples:- “What did China do in Taiwan last month?”
- “Show me military actions by Russia”
- “Find protests in France involving labor unions”
Topic/theme filtering: gdelt_gkg_themes_extracted
Topic/theme filtering: gdelt_gkg_themes_extracted
Use
gdelt_gkg_themes_extracted to filter articles by subject matter.Examples:- “Find articles about climate change (ENV_CLIMATECHANGE)”
- “Show me economic news (ECON_*)”
- “Track health policy discussions (HEALTH_*, GOV_HEALTH)”
Trending/viral events: mv_event_mention_stats
Trending/viral events: mv_event_mention_stats
Person/org mentions: gdelt_gkg_*_extracted tables
Person/org mentions: gdelt_gkg_*_extracted tables
Use entity extraction tables for mentions in article text.Examples:
- “Find articles mentioning Elon Musk”
- “Track coverage of Microsoft”
- “Show locations discussed in climate articles”
Historical tracking: gdelt_*_master tables
Historical tracking: gdelt_*_master tables
Use master tables for all-time entity tracking (no 30-day limit).Examples:
- “How has Biden been covered over the past year?”
- “Track Tesla mentions across all time”
- “Historical presence of NATO in news”
Best practices
Multiple tables: You can select multiple tables in one call. The response will include JOIN guidance showing you how to connect them correctly.
Common patterns
Simple event analysis
Theme-based article search
Multi-table with entities
Error handling
Empty tables array
Empty tables array
Error: “At least one table must be specified”Solution: Always provide at least one table in the tables array.
Invalid table name
Invalid table name
Error: “Table ‘xyz’ not found in GDELT schema”Solution: Use only the 9 valid table names listed in the parameters section.
Authentication error
Authentication error
Error: “Authentication required”Solution: Ensure your bearer token is properly configured in your MCP client. See authentication guide.

