Skip to main content
Glama
Mistral MCP — Document Extraction

Mistral MCP — Document Extraction

by Swih

mistral-mcp

将 Mistral AI 功能公开给任何 MCP 客户端的 MCP 服务器 - Claude Code、Cursor、Zed、Windsurf、Claude Desktop。

法语版本:README.fr.md

version license node typescript mcp-spec tools resources prompts tests

为什么选择它

Mistral 在法语、代码、OCR、审核、音频和智能体风格的工作流方面拥有强大的模型,但大多数支持 MCP 的 IDE 默认使用 Anthropic 或 OpenAI。mistral-mcp 为这些 Mistral 功能提供了一个简洁的 MCP 接口,因此你可以在不重建智能体循环的情况下,将正确的子任务路由到正确的模型。

本仓库的目标不是“又一个轻量级封装”。它旨在成为一个健壮、可维护的 MCP 服务器,具有明确的模式、可预测的输出、传输灵活性和良好的测试覆盖率。

Related MCP server: MCP Server TypeScript

当前接口 (v0.4.0)

工具 (22)

核心生成:

  • mistral_chat

  • mistral_chat_stream

  • mistral_embed

  • mistral_tool_call

  • codestral_fim

视觉和音频:

  • mistral_vision

  • mistral_ocr

  • voxtral_transcribe

  • voxtral_speak

智能体和分类器:

  • mistral_agent

  • mistral_moderate

  • mistral_classify

文件和批处理:

  • files_upload

  • files_list

  • files_get

  • files_delete

  • files_signed_url

  • batch_create

  • batch_list

  • batch_get

  • batch_cancel

MCP 原生工具:

  • mcp_sample - 通过 MCP 采样将生成委托给客户端模型

资源 (2)

  • mistral://models - 已接受的别名和实时模型目录

  • mistral://voices - Voxtral TTS 的实时语音目录

提示词 (6)

法语精选提示词:

  • french_invoice_reminder

  • french_meeting_minutes

  • french_email_reply

  • french_commit_message

  • french_legal_summary

英语精选提示词:

  • codestral_review

提示词枚举参数使用 completable() 进行包装,因此 MCP 客户端可以通过 completion/complete 调用提示词参数补全。

亮点

  • 高级 McpServer API,每个工具都有 inputSchema、outputSchema 和注释

  • 双重传输支持:默认 stdio,支持远程部署的流式 HTTP

  • 到处都是结构化输出:structuredContent 加上文本回退

  • 通过 mcp_sample 支持 MCP 采样

  • 支持类枚举提示词参数的提示词补全

  • 资源和提示词与工具一起注册,而不是后期添加

  • Mistral SDK 客户端上的重试/退避和请求超时机制

传输

Stdio

默认模式。这是 Claude Code 和大多数本地 MCP 客户端使用的模式。

node dist/index.js

流式 HTTP

使用 --http 或 MCP_TRANSPORT=http 启用。

MCP_TRANSPORT=http node dist/index.js

相关环境变量:

  • MCP_HTTP_HOST - 默认 127.0.0.1

  • MCP_HTTP_PORT - 默认 3333

  • MCP_HTTP_PATH - 默认 /mcp

  • MCP_HTTP_TOKEN - 可选的 bearer 令牌

  • MCP_HTTP_ALLOWED_ORIGINS - 可选的逗号分隔允许列表

  • MCP_HTTP_STATELESS=1 - 无状态会话模式

/healthz 是公开的,不会触及 MCP 服务器。

安装

git clone https://github.com/Swih/mistral-mcp.git
cd mistral-mcp
npm install
npm run build

设置你的 API 密钥:

export MISTRAL_API_KEY=your_key_here

或者在仓库根目录使用 .env 文件。切勿提交它。

在 Claude Code 中使用

claude mcp add mistral -- node /absolute/path/to/mistral-mcp/dist/index.js

示例提示词:

对此 PDF 使用 mistral_ocr,然后对提取的文本运行 french_meeting_minutes。

开发

npm run dev
npm run build
npm run lint
npm test
npm run inspector

测试策略

测试套件目前包含 148 个测试,分为 4 层:

  1. 工具、资源、提示词、传输、音频、智能体、文件、批处理和采样的单元测试

  2. 工具元数据和 MCP 保证的契约测试

  3. 设置 MISTRAL_API_KEY 时针对真实 Mistral API 的实时 API 测试

  4. 针对已构建服务器的 Stdio 端到端测试

如果没有 MISTRAL_API_KEY,本地默认运行 139 个通过测试,外加 9 个受限的实时/stdio 测试。

项目布局

mistral-mcp/
|-- src/
|   |-- index.ts
|   |-- transport.ts
|   |-- tools.ts
|   |-- tools-fn.ts
|   |-- tools-vision.ts
|   |-- tools-audio.ts
|   |-- tools-agents.ts
|   |-- tools-files.ts
|   |-- tools-batch.ts
|   |-- tools-sampling.ts
|   |-- resources.ts
|   `-- prompts.ts
|-- test/
|-- examples/
|-- .github/workflows/ci.yml
|-- package.json
`-- tsconfig.test.json

状态

v0.4.0 — 已发布。查看 CHANGELOG.md 获取相对于 v0.3.0 的完整差异:

  • 共享辅助函数、实时模型 + 语音目录、契约测试

  • 视觉 + OCR

  • 音频转录 + 语音

  • 智能体 + 审核 + 分类

  • 文件 + 批处理 API

  • 流式 HTTP 传输 + MCP 采样

  • 5 个法语精选提示词 + 1 个英语提示词 + 提示词参数补全

示例

可运行脚本位于 examples/ 中。请参阅 examples/README.md。

许可证

MIT Copyright Dayan Decamp

Available Tools

6 tools
codestral_fimCodestral fill-in-the-middle completionA
Read-only

Fill-in-the-middle code completion with Codestral.

Given prompt (code preceding the cursor) and suffix (code after the cursor), Codestral writes the middle. Use for editor autocomplete scenarios, code-patching agents, or structured refactors where you know the target boundaries.

Default stop tokens: [] — let the model decide. Override with stop if needed.

Inputs: prompt (required), suffix (required), seed, stop, +4 more. Returns: text, model, usage, finish_reason

mistral_chatMistral chat completionA
Read-only

Generate a chat completion using a Mistral model.

When to use:

  • Drafting French (or any European-language) content where Mistral shines.

  • Codestral for code-specific generation/review.

  • Ministral for cheap / low-latency classification.

Returns structured content with the assistant text and token usage. Does NOT stream — use mistral_chat_stream for long outputs with progress updates.

Inputs: messages (required), seed, model, top_p, +4 more. Returns: text, model, usage, finish_reason, +1 more

mistral_ocrMistral OCR (document to markdown)A
Read-onlyIdempotent

Run Mistral OCR on a PDF or image, returning structured markdown per page.

Input document is one of:

  • { type: "document_url", documentUrl: "https://...pdf" }

  • { type: "image_url", imageUrl: "https://..." | "data:image/..." }

  • { type: "file", fileId: "" }

Options:

  • pages: array of 0-indexed page numbers or string like "0-5,7".

  • tableFormat: 'markdown' (default) or 'html'.

  • extractHeader / extractFooter: include page header/footer when present.

  • includeImageBase64: embed extracted image bytes as base64 in the response.

  • document_annotation_format: JSON schema for whole-document structured extraction.

  • bbox_annotation_format: JSON schema for extracted image / bbox annotations.

  • confidence_scores_granularity: 'page', 'word', or 'block'. 'block' adds per-block content/type confidence under pages[].blocks[].confidence_scores and requires OCR 4.1 or newer.

  • includeBlocks: return paragraph-level blocks (bounding box + type) in reading order — titles, lists, tables, images, equations, captions, code, references, aside text, header, footer, signature. Requires OCR 4 (mistral-ocr-4-0) or newer; older models accept the flag but return an empty blocks array.

Returns pages[].markdown plus optional pages[].hyperlinks, header, footer, images bounding boxes, blocks, annotations, confidence scores, and dimensions.

Inputs: document (required), model, pages, imageLimit, +10 more. Returns: model, pages, usage, annotations, +2 more

mistral_visionMistral multimodal chat (vision)A
Read-only

Chat completion with multimodal input: text + image_url parts.

Requires a vision-capable model. Accepted:

  • pixtral-large-latest

  • pixtral-12b-latest

  • mistral-large-latest

  • mistral-medium-latest

  • mistral-small-latest

Each message's content is either a plain string (pure text) or an array of parts { type: 'text', text } / { type: 'image_url', imageUrl }. The image URL can be an https URL or a data: URI base64 payload.

Returns the assistant text + token usage. For non-visual requests, prefer mistral_chat.

Inputs: messages (required), seed, model, top_p, +2 more. Returns: text, model, usage, finish_reason

process_documentProcess a business document end-to-endA
Read-onlyIdempotent

Single-call pipeline: provided text/Markdown or Mistral OCR → classify (if kind=auto) → typed extraction → validation. source.type=text skips OCR and Files uploads. Text with kind=generic makes no API calls; classification and typed extraction use Mistral chat. Results expose extraction_source. Provided text has null ocr_confidence and page_count; ocr_text contains the supplied text unchanged. Replaces the manual chain of mistral_ocr + mistral_chat + JSON parsing.

Kinds: contract | invoice | id_document | generic. Use kind=auto to let the server classify. Returns a discriminated union — switch on kind to access typed fields. Validation checks schema and, for OCR sources, OCR confidence; not factual or accounting accuracy. Typed extraction rejects text longer than 60000 characters rather than truncating it.

Cache keys include source, kind, page limit, endpoint, models and pipeline version. Override location with MISTRAL_MCP_CACHE_DIR. Override mode with options.cache. Default cache mode is 'read_write' EXCEPT for kind=id_document (auto-bypass to avoid persisting PII). Set options.cache='read_write' explicitly to opt in for id documents.

options.maxPages and options.minOcrConfidence apply only to OCR sources. The confidence floor defaults to 0.3. Below the floor the tool returns isError. Missing or partial confidence scores also return isError; use mistral_ocr directly if you need raw OCR without a confidence guarantee. 0.3 is a conservative starting point, not a measured one: calibrate it for your corpus with npm run eval:docs.

Inputs: source (required), kind, options. Returns: dob, kind, name, total, +22 more

voxtral_transcribeVoxtral speech-to-textA
Read-onlyIdempotent

Transcribe an audio file to text using Mistral Voxtral.

Accepted models:

  • voxtral-mini-latest

  • voxtral-small-latest

Audio source is one of:

  • { type: "file_url", fileUrl: "https://..." } (public URL)

  • { type: "file", fileId: "" }

Options:

  • language: ISO-639-1 hint (e.g. 'fr', 'en'). Boosts accuracy when known.

  • temperature: sampling temperature.

  • diarize: return per-speaker segments (default false).

  • timestampGranularities: ['segment'] to return per-segment timestamps.

  • contextBias: list of phrases/terms that should bias the decoder.

Returns plain text, detected language, optional segments[], and token usage.

Inputs: audio (required), model, diarize, language, +3 more. Returns: text, model, usage, language, +1 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 6 tools

    Disambiguation4/5

    Each tool targets a distinct modality/action: code FIM, text chat, OCR, vision chat, document pipeline, and audio transcription. There is minor overlap between mistral_chat and mistral_vision (both chat) and between process_document and mistral_ocr, but the descriptions explicitly steer selection, so confusion is limited.

    Naming Consistency3/5

    Names mix provider-prefixed conventions (codestral_fim, mistral_chat, mistral_ocr, mistral_vision, voxtral_transcribe) with a plain action name (process_document). The pattern is somewhat readable but not a predictable verb_noun scheme and the provider prefixes fragment consistency.

    Tool Count4/5

    Six tools is well-scoped for a multimodal Mistral wrapper, with each tool covering a distinct capability rather than redundancy. Slightly broad for a server named 'Document Extraction' since it also includes code completion and chat, but not excessive.

    Completeness3/5

    Covers OCR, vision, chat, transcription, and a combined pipeline, but several tools reference a Files API (fileId) that is not exposed as a tool, creating a dead-end for uploading files. No model-listing or file-management operations leave workflows partially blocked.

    Maintenance

    ActivitySlowing
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      D
      maintenance
      A TypeScript implementation of a Model Context Protocol server and client that enables interaction with language models (specifically Mistral running on Ollama).
      -
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      A production-ready TypeScript MCP server providing basic tools (add, echo, timestamp), resources (server info, greetings, data access), and prompt templates (analyze, code-review, summarize). Serves as a foundation for building custom MCP servers with extensible architecture.
      547 npm
      -
    • A
      license
      B
      quality
      D
      maintenance
      A TypeScript-based MCP server that provides tools to interact with local Codex and Gemini CLIs via stdio transport. It enables users to execute prompts through the ask_codex and ask_gemini tools, supporting custom models and timeout configurations.
      1
      11 npm
      6
      MIT