Skip to content
The 38 guidesFREN中文
Guides
Part 4 · guide 2 of 11 Level: Intermediate Reading time: 18 min

MCP: connect your tools to the agent

Give Claude Code, Codex and OpenCode access to your tools. Connect local and remote servers, manage context, write your own server in thirty lines and keep it secure.

In this guide
  1. 01How it works, in thirty seconds
  2. 02Connect a server in each agent
  3. 03Share the configuration with your team
  4. 04The hidden cost: context
  5. 05Long-running tasks move to the background
  6. 06Write your own server
  7. 07Security pitfalls
  8. 08The steps to follow
  9. 09Frequently asked questions

In short

MCP (Model Context Protocol) is the standard for connecting a coding agent to tools such as GitHub, a database, a browser, Notion or a service you built. An MCP server runs on the mini-PC, where the agent starts it, or on a vendor's infrastructure, where you connect to a URL, often with OAuth. Use claude mcp add in Claude Code, codex mcp add in Codex, and opencode mcp add in OpenCode. Each connected tool takes up context, so enable only what you use. You can write your own server in about thirty lines of Python. An MCP server acts with the permissions of the key you give it. Start with read-only keys and dedicated accounts, and treat anything the server returns as untrusted.

Do this first: Setting up your agents

Out of the box, a coding agent can see your files and use your terminal. That’s a good start, but your work also lives in GitHub, a Postgres database, Notion, a dashboard or the browser. MCP (Model Context Protocol) is the standard connector that links your agent to all of those. Anthropic launched it in late 2024, OpenAI, Google and Microsoft adopted it, and in 2026 it’s everywhere, including Google Home (in French) and Safari (in French).

Setting up your agents introduces the idea. Here are the exact commands, what they cost in context, how to write your own server and what to watch out for. For a general introduction, read Numerama’s MCP explainer (in French) or Clubic’s full guide (in French).

How it works, in thirty seconds

There are two roles. The agent (Claude Code, Codex, OpenCode, Hermes or OpenClaw) is the client. The MCP server is a program that advertises what it can do. It can offer three things:

  • Tools, actions the model can trigger, such as “read issue 42” or “run this SQL query”.
  • Resources, content you can reference in a conversation, such as a file or database schema.
  • Prompts, ready-made instructions that show up as commands.

The model reads each tool’s description and decides when to use it. That’s what makes tools powerful, and what makes them risky.

Local and remote servers

Local server (stdio)Remote server (HTTP)
Where it runsOn the mini-PC, started by the agentOn the service vendor’s infrastructure
How you register itA command (npx, uvx, a binary or a script)A URL such as https://…/mcp
AuthenticationA key in an environment variableOften OAuth, where you sign in once
What it can seeYour files and local networkOnly your account with the vendor
ExamplesFilesystem, local Postgres, Playwright, a script you wroteGitHub, Notion, Sentry, Figma, Linear

Vendors recommend HTTP transport for remote servers. The older SSE transport is deprecated. If the docs point you to it, look for the HTTP URL.

Connect a server in each agent

All three agents now have an mcp add command, so you can skip hand-editing the configuration file. These examples add a local server (Context7, which gives the agent up-to-date library docs) and a remote server.

# Local server: everything after -- is the server command
claude mcp add context7 -- npx -y @upstash/context7-mcp

# Remote HTTP server, then OAuth sign-in
claude mcp add --transport http notion https://mcp.notion.com/mcp
claude mcp login notion          # shows the URL to open on your computer

# Pass a key in an environment variable
claude mcp add --env AIRTABLE_API_KEY=votre_cle --transport stdio airtable -- npx -y airtable-mcp-server

claude mcp list                  # configured servers and their connection status
claude mcp remove notion

In a session, /mcp shows your servers and their status and lets you start OAuth. Use --scope to choose where to save the configuration: local (the default, for you and this project), project (in a .mcp.json file at the root, shared through Git), or user (for all your projects). Before removing a remote server, run claude mcp logout to revoke its token if the vendor supports revocation. remove only removes the configuration.

Commands checked on November 17, 2026 against the Claude Code, OpenCode and Codex docs. These tools change every month. If a command differs, follow the current docs.

Share the configuration with your team

Put Claude Code’s .mcp.json at the repository root. It travels with the code so everyone on the team gets the same tools. Follow two rules:

  • Keep plaintext secrets out. Reference the secret as ${GITHUB_TOKEN}. Claude Code expands the variable at startup, and each person keeps their key in their environment. For security, Anthropic credential variables expand to empty values in remote server URLs and headers, so a project can’t send your key to a server it chose.
  • Each developer approves the servers. Claude Code asks for approval before activating servers in .mcp.json. That keeps a cloned repository from running a program without your consent. Run claude mcp reset-project-choices to reset those choices.

The hidden cost: context

Every connected tool presents its name, description and parameters to the model. That text goes with each request. A full GitHub server exposes dozens of tools. Stack five or six servers together and they’ll take up a noticeable chunk of the context window before you ask your first question. Similar tools also make it harder for the model to pick the right one.

You have three options:

  • Connect servers per project, with project or local scope.
  • Filter tools using enabled_tools and disabled_tools in Codex.
  • Use Code Mode. The model writes a small script that chains tool calls and puts only the result back into context. OpenCode enables it by default, and Claude Code has offered it as an opt-in preview since version 2.1.323.

Long-running tasks move to the background

Some tools take a while to complete an export, analysis or remote build. Starting with version 2.1.304, Claude Code supports MCP tasks in beta. A call that takes more than two minutes moves to the background, appears in /tasks and lets the agent keep working. Set the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS, or set it to 0 to turn this off.

Write your own server

Here’s where MCP gets interesting on a mini-PC. You can give the agent access to your scripts, your data and your services. Start with a server that reports the machine’s status.

# A dedicated directory and Python environment
mkdir -p ~/mcp && cd ~/mcp
python3 -m venv .venv
.venv/bin/pip install mcp        # the official Python SDK
# ~/mcp/machine.py: three tools for checking the mini-PC's status
import shutil, subprocess
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("machine")

@mcp.tool()
def espace_disque(chemin: str = "/") -> str:
    """Espace libre et total du disque qui contient ce chemin, en Go."""
    total, utilise, libre = shutil.disk_usage(chemin)
    return f"{libre / 1e9:.1f} Go libres sur {total / 1e9:.1f} Go"

@mcp.tool()
def services_en_echec() -> str:
    """Liste des services systemd en échec sur la machine."""
    r = subprocess.run(["systemctl", "--failed", "--no-legend"], capture_output=True, text=True)
    return r.stdout or "Aucun service en échec."

@mcp.tool()
def modeles_ollama() -> str:
    """Modèles installés dans Ollama, avec leur taille."""
    r = subprocess.run(["ollama", "list"], capture_output=True, text=True)
    return r.stdout

if __name__ == "__main__":
    mcp.run()        # stdio transport by default
# Register it like any other local server
claude mcp add machine -- ~/mcp/.venv/bin/python ~/mcp/machine.py

Ask “Is there still space on the disk, and have any services failed?” and the agent will choose the right tools. Each function’s docstring tells the model how to use it, so take the time to write it carefully. You can even describe the tools you want to your agent and have it write the file. Then read through it yourself.

Security pitfalls

An MCP server brings three concrete risks:

  1. It acts with your permissions. A write-enabled GitHub key can push code, and an advertising API key can spend money. Start with read-only tokens on a dedicated, narrowly scoped service account.
  2. It runs code. npx -y paquet downloads and runs a program on the mini-PC. Get servers from the official vendor and watch for lookalike package names.
  3. It brings text back to the agent, and that text can contain instructions. A web page, ticket or email can contain hidden directions, such as a request to send your .env file elsewhere. That’s prompt injection. Model defenses can miss it. The most reliable precaution is to keep access to outside content and tools that can send data out in separate agent sessions.

Review, audit and secure your work goes deeper into these risks.

The steps to follow

0 of 5 steps done Your ticks stay in this browser.

  1. Start with a specific need

    “I want the agent to read my GitHub issues” is a good place to start. One need, one server.

  2. Find the official server

    Look for an MCP page on the vendor’s website. Most now publish their own remote server. If you can’t find one, the protocol’s official registry lists hundreds.

  3. Connect it read-only for this project

    Use claude mcp add, codex mcp add or opencode mcp add with a read-only token and project scope.

  4. Test it on a small task

    Ask a question that requires the agent to use the tool, then check the answer yourself. /mcp shows whether the server is connected.

  5. Expand access when it's worth it

    Add write access, more tools or team sharing through .mcp.json one step at a time. Keep manual approval for actions that cost money or are visible to others.

For more on the protocol and its history, read our article on Frandroid (in French). QUELLE IA’s tool profiles explain how each agent supports MCP: Claude Code, Codex and OpenCode.

Frequently asked questions

What's the difference between a local and a remote MCP server?

A local server is a small program the agent starts on the mini-PC and talks to over standard input and output (stdio). It can see your files and your network. A remote server is hosted by a vendor such as Notion, Sentry or Figma. The agent connects to an HTTP URL and you sign in, often with OAuth. Vendors now recommend HTTP transport for remote servers since the old SSE transport is deprecated.

How do I sign in to an MCP server with OAuth on a headless mini-PC?

In Claude Code, run /mcp in the session or claude mcp login nom-du-serveur in the terminal. The agent shows a URL to open in your computer's browser. Codex has codex mcp login nom-du-serveur and OpenCode has opencode mcp auth nom-du-serveur. If the localhost callback fails over SSH, forward the callback port with ssh -L. Claude Code lets you set that port with --callback-port.

How many MCP servers should I connect at once?

As few as possible. The descriptions of all connected tools go into the model's context on each request. Ten servers with twenty tools each take up a noticeable chunk of the context window before your first question. Connect what each project needs and filter out unused tools (with enabled_tools in Codex).

Can an MCP server be dangerous?

Yes, in two ways. Starting a local server with npx -y runs downloaded code on your machine, so get it from the official vendor. Also, anything the server returns, like a web page, ticket or email, can contain hidden instructions the model might follow. Use read-only tokens and dedicated accounts, and require manual approval for anything that writes, spends or publishes.

Do I need to know how to program to create an MCP server?

Very little, and the agent can write it for you. With the official Python SDK, a server takes about thirty lines. Each function decorated with @mcp.tool() becomes a tool, and its docstring tells the model how to use it. Register it like any other local server.

Terms in this guide: AgentMCPClaude CodeCodexOpenCodeHermesOpenClawRepository (repo)ParametersContext windowAPI keyTokenPrompt

Spotted a mistake?

A command stopped working, a price changed?

Tools change every month. Tell me what is wrong in this chapter and I will fix it and update its date.

Only the page, your message and the optional contact are kept. Nothing else.

Guide 21 of 38 · part 4 no guides read yet Open the list of guides