今天我们发布 Studio 中的连接器(Connectors),旨在帮助开发者构建基于企业数据的高度定制化 AI 应用。所有内置连接器以及自定义 MCP 现在均可通过 API/SDK 使用,适用于所有模型和智能体调用。
我们还引入了直接工具调用功能,让开发者能够精确控制工具的调用方式和时机,且无需担心身份验证障碍影响测试与迭代。此外,您现在可以实现人工审核(human-in-the-loop)审批流程,在工具执行前进行安全审查和确认,从而兼顾灵活性与治理要求。
通过编程方式,您可以创建、修改、列出和删除连接器,同时还能列出其工具并直接运行它们。
所有连接器均集中注册,可在 Mistral 应用(LeChat 和 AI Studio,Vibe 即将支持)中跨平台使用。
通过 Conversation API、Completions API 和 Agent SDK 的使用,现在可以支持复杂的工作流以及与 CRM、知识库和生产力工具等企业系统的集成。
集成存在于平台中,而非您的代码中。
构建企业级 AI 智能体正变得越来越容易。但更困难的部分在于它们周围的一切:查找正确的 API 文档、编写和维护工具函数、构建集成、设置 OAuth、处理 token 刷新,以及调试分页异常等边界情况。
正因如此,团队不断重复构建相同的集成层。即便在同一家公司内,类似的集成也常常在任意代码中被多次实现,从而导致安全风险、缺乏流量可观测性以及工作重复。
连接器通过使用 MCP 协议将集成封装为单一、可复用的实体来解决这一问题。
my_connector = client.beta.connectors.create( name="salesforce-crm", description="Salesforce CRM — 账户、联系人、商机", server="https://your-mcp-server.internal/salesforce", visibility="shared_workspace", oauth_config={ "client_id": os.environ["SALESFORCE_CLIENT_ID"], "scopes": ["read_accounts", "read_contacts"], "redirect_uri": "https://your-app.internal/oauth/callback", }, )
注册完成后,自定义 MCP 连接器即可在 Studio 中被发现、治理和监控,并成为任何对话、智能体或工作流的原生工具,无需重写集成逻辑、无需重新实现身份验证、也无需在团队间重复配置。一次设置,即可随时随地持续运行。将连接器附加到任何对话只需一行代码:
response = client.beta.conversations.start_async( model="mistral-medium-latest", inputs="哪些企业账户在上个季度续约了?", tools=[{"type": "connector", "connector_id": "salesforce-crm"}],)
一条可执行的黄金路径
让我们构建一个智能体,用于执行基于多源推理的多步骤工作流——该智能体可安全连接 GitHub、公共仓库内容与文档,以及来自网络的实时数据。该智能体能够理解意图、分析代码并提出修改建议,同时还能处理生成测试、重构、识别低效代码、缺陷或漏洞等其他常见用例。
前置条件
pip install mistralaiexport MISTRAL_API_KEY="your-api-key"client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
1 - 为公共远程 MCP 创建连接器
为了查询和探索代码库,我们将利用 DeepWiki 远程服务器,该服务器提供了面向 API/工具端点的 MCP 接口。这样一来,智能体无需手动抓取文档或加载整个仓库,即可探索代码内容与文档。
my_custom_mcp = client.beta.connectors.create_async( name="my_deepwiki", description="用于代码仓库探索的 DeepWiki MCP", server="https://mcp.deepwiki.com/mcp", visibility="shared_workspace",)
只需注册一次 MCP 服务器,用户即可在多个对话、智能体或直接工具调用中重复使用它。这是任何自定义 MCP 流程的入口点。关于如何管理内置和自定义连接器的完整示例,请参阅指南:连接器管理。
2 - 创建智能体
该智能体还应能够连接 GitHub 和网络;用户无需创建这些连接器,因为它们已内置于 Mistral 中。
请注意,一个连接器可以暴露数十个工具。如果用户希望排除可能具有破坏性的操作,`tool_configuration` 可以在不修改连接器本身的情况下控制工具的可用性。更多详情请参见《操作指南:在对话中使用连接器》。
my_agent = client.beta.agents.create_async( name="deepwiki_agent", description="用于代码仓库探索的智能体", model="mistral-small-latest", instructions="""\ 你是一名开源软件审计员。\
当被要求审查某个库或仓库时,你**必须**执行以下**所有**任务:
## Final verdictBased on all three analyses, give a clear recommendation:- **SAFE TO ADOPT** — no major concerns- **ADOPT WITH CAUTION** — some concerns to be aware of- **AVOID** — significant risks identified
Always be thorough and cite your sources.\""", tools=[ {"type": "web_search"}, { "type": "connector", "connector_id": "github", "tool_configuration": {"exclude": ["delete_file"]}, }, {"type": "connector", "connector_id": "my_custom_mcp.name"}, ],)
response = await client.beta.conversations.start_async( agent_id=my_agent.id, inputs=[ { "role": "user", "content": "Please perform full audit on repo pallets/flask", } ],)
直接工具调用
并非每个工作流都需要模型来决定何时以及如何调用工具。为了获得更确定性的体验,用户现在可以直接调用连接器。
result = await client.beta.connectors.call_tool_async( connector_id="my_deepwiki", tool_name="read_wiki_structure", arguments={"repoName": "sqlite/sqlite"}, ) print(f"工具输出:\n{result.content}")
这对于调试和限制不确定性的流水线式自动化尤其有用。完整模式请参见《操作指南:连接器工具调用》。
当需要人工介入时
某些操作未经明确批准不应执行。`requires_confirmation` 会在工具运行前暂停执行,并将控制权交还给你的应用程序:
{ "type": "connector", "connector_id": "gmail", "tool_configuration": { "include": ["gmail_search"], "requires_confirmation": ["gmail_search"] }}
模型提出建议,用户应用程序决定是否继续。AI 判断与人类判断之间的界限是明确的,并以代码形式呈现。有关完整的审批流程(包括待处理的工具调用和恢复步骤),请参见《操作指南:人工确认》。
开始构建
你现在可以在 Studio(公开预览版)中使用连接器。立即访问 Studio 控制台开始构建:https://console.mistral.ai/build/connectors
发布文档
关于各种常见使用模式的操作指南
Today we are releasing Connectors in Studio to unblock developers building highly customised AI applications grounded in enterprise data. All built-in connectors, as well as custom MCPs, are now available via API/SDK to be used with all model and agent calls.
We are also introducing direct tool calling, giving developers precise control over how and when tools are invoked, without authentication barriers getting in the way of testing and iterating. In addition, you can now implement human-in-the-loop approval flows, allowing secure review and confirmation before tool execution, ensuring both flexibility and governance.
Programmatic access for creating, modifying, listing and deleting your connectors but also listing their tools and directly running them.
All connectors are centrally registered making them available across Mistral apps: LeChat and AI Studio (with Vibe coming soon).
Usage via Conversation API, Completions API, and Agent SDK can now facilitate complex workflows and integration with enterprise systems like CRMs, knowledgebases & productivity tools.
Integrations that live in the platform, not in your code
Building enterprise AI agents is getting easier. The harder part is everything around them: tracking down the right API docs, writing and maintaining tool functions, building integrations, setting up OAuth, handling token refresh, and debugging edge cases like broken pagination.
Because of this, teams keep rebuilding the same integration layer. Even within the same company, similar integrations are often implemented multiple times in arbitrary code, leading to security risks, lack of traffic observability, and duplication of work.
A connector solves this by packaging an integration into a single, reusable entity using the MCP protocol.
my_connector = client.beta.connectors.create( name="salesforce-crm", description="Salesforce CRM — accounts, contacts, opportunities", server="https://your-mcp-server.internal/salesforce", visibility="shared_workspace", oauth_config={ "client_id": os.environ["SALESFORCE_CLIENT_ID"], "scopes": ["read_accounts", "read_contacts"], "redirect_uri": "https://your-app.internal/oauth/callback", },)
Once registered, the custom MCP connector is discoverable, governed & monitored in Studio and becomes a native tool for any conversation, agent, or workflow without rewriting integration logic, without re-implementing auth, without duplicating it across teams. Set up once, run it all the time, everywhere. Attaching a connector to any conversation takes one line:
response = client.beta.conversations.start_async( model="mistral-medium-latest", inputs="Which enterprise accounts renewed last quarter?", tools=[{"type": "connector", "connector_id": "salesforce-crm"}],)
A runnable golden path
Let’s build an agent for a multi-step workflow based on reasoning across sources given agent’s secure connectivity to GitHub, public repo content & docs, and live data from the web. The agent can understand intent, analyse code, and propose changes alongside other common use cases like generating tests, refactoring, identifying inefficiencies, bugs or vulnerabilities.
Prerequisites
pip install mistralaiexport MISTRAL_API_KEY="your-api-key"client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
1 - Create a connector for a public remote MCP
To query and explore code bases, we will leverage the DeepWiki remote server which provides an MCP interface to API/tool endpoint. This way the agent can explore the content and documentation without scraping docs manually or loading whole repos.
my_custom_mcp = client.beta.connectors.create_async( name="my_deepwiki", description="DeepWiki MCP for code repository exploration", server="https://mcp.deepwiki.com/mcp", visibility="shared_workspace",)
Registering the MCP server once allows users to reuse it across conversations, agents, or direct tool calls. This is the entry point for any custom MCP flow. For a comprehensive example of how to manage built-in and custom connectors see cookbook: Connectors Management.
2 - Create agent
The agent should also be able to connect to GitHub and the web; users don’t need to create those connectors as they are already built into Mistral.
Note that a connector can expose dozens of tools. If users want to exclude potentially damaging actions,tool_configuration controls the tool availability without modifying the connector itself. More details can be found in Cookbook: Using Connectors in Conversations.
my_agent = client.beta.agents.create_async( name="deepwiki_agent", description="Agent for code repository exploration", model="mistral-small-latest", instructions="""\ You are an Open-Source Software Auditor. \
When asked to vet a library or repository, you MUST perform ALL of the following tasks:
## Final verdictBased on all three analyses, give a clear recommendation:- **SAFE TO ADOPT** — no major concerns- **ADOPT WITH CAUTION** — some concerns to be aware of- **AVOID** — significant risks identified
Always be thorough and cite your sources.\""", tools=[ {"type": "web_search"}, { "type": "connector", "connector_id": "github", "tool_configuration": {"exclude": ["delete_file"]}, }, {"type": "connector", "connector_id": "my_custom_mcp.name"}, ],)
response = await client.beta.conversations.start_async( agent_id=my_agent.id, inputs=[ { "role": "user", "content": "Please perform full audit on repo pallets/flask", } ],)
Direct tool calling
Not every workflow needs the model to decide when and how tools are invoked. For a more deterministic experience, users can now call connectors directly.
result = await client.beta.connectors.call_tool_async( connector_id="my_deepwiki", tool_name="read_wiki_structure", arguments={"repoName": "sqlite/sqlite"}, ) print(f"Tool output:\n{result.content}")
This is especially useful for debugging and pipeline-style automation which limits ambiguity. For the full pattern, see cookbook: Connector tool calling.
When a human needs to be in the loop
Some actions should not execute without explicit approval. requires_confirmation pauses execution and hands control back to your application before the tool runs:
{ "type": "connector", "connector_id": "gmail", "tool_configuration": { "include": ["gmail_search"], "requires_confirmation": ["gmail_search"] }}
The model proposes, the user application decides whether to proceed. The boundary between AI judgment and human judgment is explicit and written in code. For the full approval flow, including the pending tool call and resume step, see cookbook: Human-in-the-loop Confirmation.
Start building
You can now use Connectors in Studio, in Public Preview. Start building today by visiting the Studio console: https://console.mistral.ai/build/connectors
Documentation on the release
Cookbooks on various common usage patterns