# Open Trivia Database MCP

> Open Trivia Database gives your AI agent direct access to a massive, structured collection of 13,000+ quiz questions. Need random science facts? Want to check how many 'Film & TV' questions exist? Use this server to pull filtered trivia data by category, difficulty, or type. It handles session management so you don't get duplicate questions.

## Overview
- **Category:** knowledge-management
- **Price:** Free
- **Tags:** quiz, trivia, educational-content, data-retrieval, content-generation

## Description

Listen up: This server gives your AI client direct access to the Open Trivia Database. You don't have to scrape or worry about rate limits; your agent pulls structured knowledge straight into the conversation.

**Checking Content Volumes (Auditing)**

The `get_global_question_count` tool tells you exactly how many total trivia questions are sitting in the database—the whole shebang. Need to know if a specific topic is worth building on? Use `get_category_question_count`. This function counts all the questions available under one particular category or topic, giving you instant volume metrics.

**Discovering Topics (Listing)**

The `list_categories` tool pulls every single trivia category name and its corresponding ID. You gotta run this first to see what's available for filtering before your agent can pull anything useful.

**Managing Uniqueness (Session Tokens)**

When you need random questions, they gotta be unique. That's where the session tokens come in. Start by calling `request_session_token`. This generates a fresh token that guarantees the next batch of trivia won't repeat content for you. Remember, these tokens expire after six hours, so plan your usage accordingly. If your process stalls or you need to restart the entire flow, use `reset_session_token` to issue a brand-new token and get all available question sets again.

**Retrieving Questions (The Main Event)**

The core function is `get_trivia_questions`. You'll gotta pass it a session token first; that keeps the questions unique. This tool retrieves a batch of random trivia questions, and you can filter this pull down tight. You specify the category, you set the difficulty (easy or hard), and you even select the type of question. It’s instant data retrieval built around your criteria.

***

**How it Works in Practice**

When building an educational tool, for instance, you run `list_categories` to map out all topics. Then, before showing a quiz, you hit `request_session_token`. Next, if you want to see how deep the 'Science' category goes, you check that count with `get_category_question_count`. Once you’re ready to play, your agent uses `get_trivia_questions`, passing in the token and specifying both the difficulty and the desired topic. If you need a completely fresh round of unique questions later, you ditch the old token and run `reset_session_token` before making another call to pull random sets.

## Tools

### get_category_question_count
Counts how many questions are currently stored under a specific topic or category.

### get_global_question_count
Returns the total number of trivia questions in the entire database.

### get_trivia_questions
Retrieves a batch of random trivia questions, supporting category, difficulty, and type filters. Requires a session token.

### list_categories
Lists all available categories for the database, providing their names and IDs.

### request_session_token
Generates a fresh session token to guarantee unique questions in future calls. The token expires after 6 hours.

### reset_session_token
Issues a new session token, allowing you to restart the process and receive all available question sets again.

## Prompt Examples

**Prompt:** 
```
Get 5 random trivia questions from the 'Science' category using Trivia API.
```

**Response:** 
```
I've retrieved 5 science trivia questions for you! They cover topics from biology to physics and are identified as having varied difficulties. Would you like the correct answers or another set of questions?
```

**Prompt:** 
```
Show me easy trivia questions about 'Geography'.
```

**Response:** 
```
I've identified several easy geography questions! Notable entries include queries about major world capitals and landmarks. I can provide the full list of choices for each question if you'd like.
```

**Prompt:** 
```
List all available trivia categories.
```

**Response:** 
```
I've scanned the category catalog. There are 10 main groups available, including 'Arts & Literature', 'Film & TV', 'Food & Drink', 'General Knowledge', and 'Geography'. I can help you retrieve questions for any of these specific themes.
```

## Capabilities

### Count content volumes
Check the total number of questions available across the entire database or within a specific topic.

### List all topics
Retrieve a full list of every trivia category available for filtering and use.

### Request unique session tokens
Get a temporary token that guarantees the next batch of questions won't repeat content. Tokens expire after 6 hours.

### Pull filtered trivia sets
Fetch random trivia questions instantly, filtering by category, difficulty, or type.

## Use Cases

### Building a daily knowledge quiz
The developer needs 10 unique, medium-difficulty questions about World History. They first run `list_categories` to confirm 'History' exists. Then they use `request_session_token`, followed by `get_trivia_questions` specifying the category and difficulty. The agent returns a structured list of ready-to-use facts.

### Auditing a new content vertical
A client wants to know if they have enough 'Food & Drink' content for their app. They use `get_category_question_count` on that specific category. If the count is low, they might check `get_global_question_count` to see if other areas are stronger.

### Testing a major update cycle
The team needs to verify question availability across all difficulty levels before launch. They run `list_categories`, then loop through the top 5 categories, calling `get_category_question_count` for 'easy', 'medium', and 'hard' on each.

### Refreshing content in a live app
The trivia game is running, but the questions are getting stale. Instead of waiting 6 hours, the ops lead simply calls `reset_session_token`, which tells the agent to pull an entirely new batch via `get_trivia_questions`.

## Benefits

- Stop worrying about content depth. Use `get_category_question_count` to check how many questions are in 'Science' vs. 'Arts & Literature' before building a quiz.
- Never run out of ideas. Running `list_categories` immediately shows you every available topic, letting your agent pull facts from anywhere without guesswork.
- Get unique data streams on demand. Use `request_session_token` and `get_trivia_questions` together to ensure the questions pulled are fresh, even if the database is huge.
- Know your limits upfront. Run `get_global_question_count` to get a solid metric of the total size of the knowledge base you're working with.
- Handle content shifts easily. If your quiz feels repetitive, running `reset_session_token` gives the agent permission to pull an entirely new set of questions.

## How It Works

The bottom line is: it automates content auditing and retrieval by handling topic discovery and session state in one workflow.

1. First, ask your agent to run `list_categories` to see what topics are available.
2. Next, use `request_session_token` to grab a unique session ID. This prevents getting duplicate questions later.
3. Finally, pass the token and desired filters (like 'Science' and 'hard') into `get_trivia_questions`. The agent delivers your question set.

## Frequently Asked Questions

**How do I find out what topics are available using list_categories?**
Run the `list_categories` tool. It returns a structured list of all available trivia categories and their corresponding IDs, letting you pick exactly what you need.

**Do I need an API key for get_trivia_questions?**
No, this server doesn't require an API key. You just need to manage your session tokens using `request_session_token` before calling the function.

**What is the purpose of request_session_token?**
It generates a unique access token for your current task. Using this token in subsequent calls to `get_trivia_questions` prevents you from receiving duplicate questions.

**Can I check total question volume with get_global_question_count?**
Yes, running `get_global_question_count` gives you a single number representing the entire database size. It's useful for scope planning.

**If I need to know how many questions exist in a specific topic, should I use get_category_question_count?**
Yes. This tool returns an immediate count based on the category ID you provide. It lets you audit content depth before making requests for actual questions, saving API calls.

**What is the process if my session token expires or starts returning duplicate questions?**
You must call reset_session_token. This action invalidates the old token and issues a brand new one, allowing you to continue drawing from the full pool of unique trivia results.

**When using get_trivia_questions, how do I ensure I only receive questions of a specific difficulty?**
You pass the desired filter—like 'easy' or 'hard'—directly into the function call. This mechanism immediately narrows the results set to match your required cognitive level.

**What is the time limit for my session token, and what should I do if I wait too long?**
The token expires after six hours of inactivity. If you wait that long, you must call request_session_token again to get fresh access and prevent duplicate questions.

**Is an API Key required for The Trivia API?**
No. The Trivia API provides a free and open service. This server works out of the box without any static credentials required.

**Can I filter questions by difficulty?**
Yes. Use the `get_trivia_questions` tool and provide the `difficulties` parameter (e.g., 'easy' or 'hard'). Your agent will return matching questions instantly.

**What format are the answers in?**
The API provides a correct answer and a list of incorrect answers. Your agent automatically combines and sorts these into a list of choices for each question.