mistralM

Docs

sideBar

Quickstart: add a connector

Register a public MCP server as a connector, connect it, list its tools, and call one, in about 10 minutes.
flagThis step takes ~10 minutes to complete.

In this quickstart, you register the public DeepWiki MCP server as a connector, connect it, list the tools it exposes, and call one of them directly. It takes about 10 minutes.

A connector is a registered MCP server. After you connect it, you can call its tools directly, or let a model pick them in a conversation or an agent. For more, see Connectors.

Before you begin

  • A Mistral API key, exported as MISTRAL_API_KEY. To create one, see Create your first API key.
  • If you don't use curl, the Python SDK mistralai 3.0 or later (uv add mistralai), or the TypeScript SDK @mistralai/mistralai.
  • An API key with the Private and shared connectors Connector access scope, because this page creates a private connector. The default scope, Shared connectors only, doesn't give access to private connectors.

You don't need administrator rights: this page creates a private connector that only you can see. To share a connector with a workspace or an organization, see visibility scopes. You don't need an account on DeepWiki either: its MCP server is public and requires no OAuth.

1. Create the connector

Register the MCP server URL under a name of up to 64 characters: letters, digits, underscores, and dashes.

import asyncio
import os

from mistralai.client import Mistral

client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])

async def main() -> None:
    connector = await client.beta.connectors.create_async(
        request={
            "protocol": "mcp",
            "name": "my_deepwiki",
            "description": "DeepWiki MCP connector for code repository exploration",
            "server": "https://mcp.deepwiki.com/mcp",
            "visibility": "private",
        },
    )
    print(f"Name:        {connector.name}")
    print(f"ID:          {connector.id}")

asyncio.run(main())

The response contains the name and id of the connector:

Name:        my_deepwiki_be27
ID:          01a1a2e6-f102-7031-84f9-b0a02c623660

The API can add a short suffix to the name, as in my_deepwiki_be27. In the next steps, replace my_deepwiki with the name or id from the response, and keep the id for the clean-up.

2. Connect it

Before you list or call the tools of a connector, connect it, even when the server needs no credentials. Create empty credentials for your user and make them the default. You do this once per connector.

import asyncio
import os

from mistralai.client import Mistral

client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])

async def main() -> None:
    await client.beta.connectors.create_credentials_async(
        connector_id_or_name="my_deepwiki",
        consumer_scope="user",
        name="deepwiki-default",
        credentials={"headers": {}},
        is_default=True,
    )

asyncio.run(main())

If the MCP server requires OAuth, get an authorization URL and complete the flow instead. You can't pass OAuth tokens to the API. For details, see Connect a connector.

3. List its tools

Before you call a tool, check which tools the connector exposes. Tool names must match exactly.

import asyncio
import os

from mistralai.client import Mistral

client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])

async def main() -> None:
    tools = await client.beta.connectors.list_tools_async(
        connector_id_or_name="my_deepwiki",
    )
    for tool in tools:
        print(f"  - {tool.name}: {tool.description}")

asyncio.run(main())

The response lists three tools:

  - ask_wiki_question: Ask any question about a GitHub repository's codebase and get an AI-powered answer
grounded in its DeepWiki.
  - read_wiki_contents: View documentation about a GitHub repository.
  - read_wiki_structure: Get a list of documentation topics for a GitHub repository.

4. Call a tool

Call read_wiki_structure directly, without a conversation or a model. The result lists the documentation pages of the sqlite/sqlite repository.

import asyncio
import os

from mistralai.client import Mistral

client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])

async def main() -> None:
    result = await client.beta.connectors.call_tool_async(
        connector_id_or_name="my_deepwiki",
        tool_name="read_wiki_structure",
        arguments={"repoName": "sqlite/sqlite"},
    )
    for item in result.content:
        if hasattr(item, "text"):
            print(item.text)

asyncio.run(main())

You should see

The tool returns the documentation topics of the sqlite/sqlite repository, as text:

Available pages for sqlite/sqlite:

- 1 Overview
- 2 Core Architecture
  - 2.1 SQL Compilation Pipeline
  - 2.2 Virtual Database Engine (VDBE)

You called a tool of your connector without a model or a conversation. If a call returns 404, check that you used the name or id from step 1. If it returns a permission error, check the Connector access scope of your API key.

Use it from an agent

Name the connector on an Agents SDK agent so the model can pick its tools during a session. The connector must be available to your organization and connected by the user who runs the session.

import mistralai.agents as agents

agent = agents.Agent(
    model="mistral-large-4",
    name="deepwiki-agent",
    instructions="You answer questions about open-source repositories using DeepWiki.",
    harness=agents.Harness(connectors=[agents.connector("my_deepwiki")]),
)

For the requirements that apply when the agent runs on a worker, such as hardened deployments, see Connectors & MCP.

To let a model pick the tools inside a single conversation instead, see Connectors in conversations.

Clean up

To delete the connector, use the id from step 1:

import os

from mistralai.client import Mistral

client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])

result = client.beta.connectors.delete(connector_id="your-connector-id")
print(result.message)
Connector deleted successfully

Going further

Use connectors in workflows
illustrationPlug

Use connectors in workflows

Call external services such as GitHub, Notion, or Slack from a workflow with Connector slots, without managing credentials yourself.

Manage connectors
illustrationGear

Manage connectors

Create, connect, list, update, and delete connectors, and list the tools that each connector exposes.

Use connectors in conversations
illustrationChatText

Use connectors in conversations

Attach a connector to a conversation, filter its tools, combine it with built-in tools, and add it to an agent.

Direct tool calling
illustrationHammer

Direct tool calling

Call an MCP tool of a connector directly, without a model or conversation, and chain several tool calls in a pipeline.

HTTP connectors
illustrationStar

HTTP connectors

Connect agents and workflows to a service through its web API by importing its OpenAPI specification.