# Mistral AI MCP

> Mistral AI connects your agent directly to Mistral's European models via a single API gateway. You use it to hold conversations, generate vector embeddings for search, check content safety, and manage large-scale batch jobs—all without juggling multiple vendor APIs.

## Overview
- **Category:** ai-frontier
- **Price:** Free
- **Tags:** llm, natural-language-processing, embeddings, model-inference, ai-agents, batch-processing

## Description

Mistral AI gives your agent direct access to Mistral's European models through one API gateway. You don't have to juggle multiple vendor APIs just to run an LLM or process data.

To start chatting, you use the `chat` tool; it sends a structured conversation message—whether you're talking to a large model like Mistral Large or using CodeMistral—and pulls the model's text reply back. Before starting any chat session, check out `list_models`; this tells you exactly which Mistral models are available on the server and what their context window sizes are.

For semantic search, you call the `embeddings` tool. You feed it a string or an array of strings, and it spits out numerical vector embeddings. These vectors are crucial because they let your system find similar documents in a vector database without relying only on keyword matching.

When you need to check content safety, use `moderate`. This checks any input text against predefined safety categories like hate speech or violence; the tool doesn't just say 'safe'—it gives you specific risk scores for multiple categories so you know exactly where the potential issues lie. 

For handling massive amounts of data, you manage batch jobs. To start a large-scale processing job, you use `create_batch`, passing it an input file ID; this kicks off an asynchronous job and immediately returns a unique batch ID for tracking. You can check on that work using the `list_batches` tool to see an overview of every job's status—running, failed, pending—or call `get_batch` with your specific ID to pull detailed results and current status updates. If you mess up and submit way too much data, don't sweat it; you can stop the process instantly by using `cancel_batch`. 

For file housekeeping, use `list_files` to see every document or dataset you've uploaded to Mistral for either batch processing or document AI. When you're done with a file and want to keep your workspace clean, you call `delete_file`; remember, that action is irreversible.

This architecture lets your agent manage everything from simple conversational turns to complex, multi-step data pipelines without ever leaving the Mistral environment.

## Tools

### cancel_batch
Stops a running batch job immediately, useful if you submitted too much data by accident.

### chat
Sends a structured conversation message to Mistral models and gets the model's text response.

### create_batch
Starts an asynchronous processing job using an input file ID, returning a batch ID for tracking.

### delete_file
Removes an uploaded file from Mistral's system; this action cannot be undone.

### embeddings
Generates numerical vector embeddings for any text input, which are used in semantic search systems.

### get_batch
Fetches detailed status and results for a specific batch job using its ID.

### list_batches
Shows an overview of all your batch processing jobs, including their current status (running, failed, etc.).

### list_files
Lists every file you've uploaded to Mistral for document AI or batch processing.

### list_models
Retrieves a list of all available Mistral models, showing their IDs and context window sizes.

### moderate
Checks text content for safety issues across multiple categories and provides associated risk scores.

## Prompt Examples

**Prompt:** 
```
Send a message to Mistral Large asking 'What is the capital of France?'
```

**Response:** 
```
Mistral responded: 'The capital of France is Paris. It is the most populous city in France and serves as the country's political, economic, and cultural center.'
```

**Prompt:** 
```
List all available Mistral models.
```

**Response:** 
```
Available models: mistral-large-latest (most capable, 128K context), mistral-small-latest (efficient, 32K context), codestral-latest (code specialist, 32K context), mistral-embed (embeddings, 8K context).
```

**Prompt:** 
```
Moderate this text: 'I want to learn about AI safety and content filtering.'
```

**Response:** 
```
The text passed moderation with all safety scores below thresholds. Categories checked: sexual (0.01), hate (0.00), violence (0.00), self-harm (0.00), criminal (0.00). Content is safe to process.
```

## Capabilities

### Chat with models
Sends a conversational message to Mistral (e.g., large, small, code) and receives the model's reply.

### Generate vector embeddings
Takes text—a string or an array of strings—and returns numerical vectors usable for semantic search.

### Moderate text content
Checks input text against predefined safety categories (violence, hate speech, etc.) and reports specific scores.

### Manage batch jobs
Creates, tracks, retrieves details for, or cancels large-scale, asynchronous processing requests.

### Discover available models
Lists every Mistral model ID currently supported by the server, along with their context window and capabilities.

## Use Cases

### Building a Customer Support Triage System
A user submits a large document. Instead of writing a multi-step process, you ask your agent to first run `moderate` on the text for policy violations. If clear, you then call `embeddings` to vectorize it. Finally, you use `chat` to summarize the content and send the result. The entire flow is managed by the MCP server.

### Processing a Quarterly Report of 10k Records
You have a massive spreadsheet needing sentiment analysis. You can't run it all in memory. You use `create_batch` with your data file ID and the chat endpoint. The server handles the queue, letting you monitor the progress until `list_batches` shows 'succeeded'. Much cleaner than 10,000 individual API calls.

### Creating a Semantic Knowledge Base
You collect hundreds of articles. Instead of writing custom code for every document, you use `list_files` to ensure everything is uploaded correctly. Then, your agent runs `embeddings` on all files. These vectors are ready to be loaded into a vector store for advanced retrieval.

### Debugging an API Flow
Your batch job fails and you don't know why. You check `list_batches` to get the ID, then run `get_batch` with that ID. This instantly shows you the failure details or if it just needs more time running.

## Benefits

- **Run Conversational AI:** Use the `chat` tool to talk directly to models like Mistral Large. You don't need separate endpoints for chat; it handles complex message history and parameters.
- **Vectorize Data on Demand:** The `embeddings` tool lets you turn any text into vectors instantly. This is your single point for preparing data for vector databases or similarity checks.
- **Manage High-Volume Jobs Safely:** Instead of timeout errors, use `create_batch`. You get a trackable job ID and can monitor progress with `list_batches`—essential for large datasets.
- **Filter Content Before Use:** The `moderate` tool adds a safety layer. Run it first to check user input or generated content against hate speech or violence before passing it anywhere else.
- **Stay Informed on Models:** Don't guess which model works best. Run `list_models` to see the exact IDs and context windows available, letting you choose between small/efficient or large/capable.
- **Clean Up Your Workspace:** Use `list_files` and `delete_file`. When a batch job is done, delete the input files so your server stays clean.

## How It Works

The bottom line is that you get all Mistral’s core services through one standardized endpoint, making complex workflows simple to build into your agent.

1. First, subscribe to the server and provide your unique Mistral AI API Key. This connects your agent to the platform.
2. Next, call a specific tool—say, `embeddings`—and pass the required inputs (e.g., the model ID and text array).
3. The server executes the request and returns structured data—whether it's a vector list, an error code, or a generated response.

## Frequently Asked Questions

**How do I get a Mistral AI API Key?**
Log in to the [**Mistral Console**](https://console.mistral.ai), go to **API Keys** in your workspace settings, click **Create new key** and copy it immediately. You'll need to set up billing in the admin portal first.

**What models are available?**
Use the `list_models` tool to see all available Mistral models. Key models include mistral-large-latest (most capable), mistral-small-latest (efficient), codestral-latest (code specialist), and mistral-embed for embeddings. Each has different context windows, capabilities and pricing.

**Can I send multi-turn conversations?**
Yes! Pass a messages array with alternating 'user', 'assistant' and 'system' roles. Each message has a 'role' and 'content' field. Mistral will continue the conversation based on the full message history.

**Can I moderate content for safety?**
Yes! Use the `moderate` tool with text input. It returns safety scores for categories including sexual, hate, violence, self-harm, criminal and other harmful content. This is useful for filtering user-generated content before processing.

**If I use `create_batch`, how do I track or cancel a job that fails or runs too long?**
You monitor jobs using `list_batches` to see the status. If needed, you can pull specific details with `get_batch`. If something goes wrong, run `cancel_batch` immediately, providing the batch ID.

**What is the proper input format for generating embeddings using the `embeddings` tool?**
You pass the text as a string or an array of strings. The resulting vector embeddings are optimized for semantic search and comparison in your external database layer.

**When I use the `chat` tool, how do I control the length and creativity of the response?**
You adjust parameters like `max_tokens`, `temperature`, and `top_p`. To make the output highly predictable, set a low temperature; increase tokens if you need the agent to elaborate.

**How do I manage files uploaded for batch processing or document AI using `list_files`?**
First, use `list_files` to get the file ID. Remember that running `delete_file` is irreversible; always confirm you don't need the data before deleting it.