Build and Deploy Your Own MCP Server
On this page
Update November 2, 2026 — Le Chat is now Vibe. As of May 28, 2026, Le Chat has been rebranded as Vibe (still at chat.mistral.ai): a single agent for work and code, carrying over your conversations, settings, and subscriptions. The legacy Le Chat experience remains accessible in Chat mode; in Work mode, agents have become skills (invoked with
@), memories serve as the knowledge base, and deep search is now the Deep Research skill. Plans are now called Mistral Free, Pro, Team, and Enterprise. This lesson uses the name Vibe; note that some menus described here may have changed names or locations.
From Idea to Production Server
You know how to use existing connectors and add custom ones. Now it’s time to take the final step: write your own MCP server and deploy it for use in Vibe. We’ll walk the full path here, from the first Python file on your machine to production hosting, covering the design choices that separate a usable server from one the model never calls correctly.
Creating an MCP Server Locally
The FastMCP library (pip install fastmcp, version 4 as of November 2026), a framework independent of the official mcp SDK, reduces server creation to a few decorators:
from fastmcp import FastMCP
mcp = FastMCP("My Server")
@mcp.tool()
def greet(name: str) -> str:
"""Greets a person by name.
Args:
name: The first name of the person to greet.
Returns:
A personalized greeting message.
"""
return f"Hello {name}! Welcome to our platform."
Everything hinges on these few lines. The @mcp.tool() decorator registers the function as an MCP tool. The docstring becomes the description the model sees when deciding whether to call the tool—so it’s not a comment for your colleagues, but a functional element. Parameter typing (name: str) and return typing (-> str) inform the model about expected types, and the function name must be clear and descriptive. The official alternative is Anthropic’s MCP SDK, available in Python and TypeScript: it offers more control at the cost of slightly heavier configuration.
Since the model sees only the text description of your tool, write it like a complete user manual:
@mcp.tool()
def search_products(
query: str,
category: str = "all",
max_results: int = 10
) -> str:
"""Searches the product catalog.
Use this tool when the user looks for a product
by name, SKU, or category.
Args:
query: Search terms (product name, SKU, keywords).
category: Filter category. Possible values: 'all',
'electronics', 'clothing', 'food'. Default: 'all'.
max_results: Maximum number of results to return (1-50).
Returns:
List of products with name, price, availability, and SKU.
"""
Notice what this docstring adds that the previous one lacked: the usage condition, possible values for category, and bounds for max_results. Two more rules complete the exercise. Names must be explicit—prefer search_products over search, create_invoice over create, get_user_orders over get_data. And returns must be readable: send back understandable text rather than raw IDs, or the model won’t be able to use them to formulate a natural response.
Testing Locally
First, start the server, which runs on a local port, defaulting to localhost:8000:
python server.py
Then expose it so Vibe can reach it:
ngrok http 8000
ngrok provides a public URL, for example https://abc123.ngrok.io, which you’ll use as the connector URL in Vibe—remember to append /mcp to get the full endpoint. Before heading into Vibe, validate the server with the MCP Inspector:
npx @modelcontextprotocol/inspector
Connect to your local server, list the tools, test them individually, and check the returns. This tells you whether any issues stem from your code or from how the model interprets your descriptions.
Deployment Options
Once your server is ready, hosting depends mostly on your constraints. Hugging Face Spaces is the free option recommended by the Mistral AI team: these are virtual machines that host web applications, completely free as long as you don’t need a GPU. You can set up your MCP server there with FastAPI and deploy multiple servers on the same Space, each with its own endpoint—/api1/mcp, /api2/mcp—which Vibe will add as separate connectors. An added bonus: nothing stops you from adding a frontend to the Space to visualize your server activity.
Prefect Horizon (formerly FastMCP Cloud), the platform from the FastMCP team, imports a GitHub repository containing a FastMCP server directly: you select the repo on horizon.prefect.io, the platform builds it and publishes an authenticated URL; a free tier exists for personal projects. For lightweight servers without heavy dependencies, Cloudflare Workers offers fast, low-cost edge deployment. Finally, traditional providers remain perfectly viable for teams already equipped: AWS (Lambda, ECS), Google Cloud (Cloud Run, Cloud Functions), or Azure (Functions, Container Apps).
Multi-Tool vs. Single-Tool Servers
A common reflex is to split tools very finely. Experience points the other way: an MCP hackathon organized by Mistral showed that the highest-performing teams designed high-level tools corresponding to complete workflows. They exposed book_restaurant instead of list_restaurants + check_availability + make_reservation, or deploy_application instead of build + test + push + deploy. The model has fewer chances to mess up the sequence, and cumulative latency drops accordingly.
Granularity still makes sense in three situations: when you’re creating a generic MCP server used by different teams, when workflow steps can serve independently of each other, and when you need flexibility in the order of operations.
Managing Environment Variables
Your servers will often need API keys, database credentials, or other secrets. Store them systematically in environment variables, never in code. Keep in mind especially that a public MCP server without authentication lets anyone consume your API keys: protect it with a token or OAuth as soon as it calls a paid service. On Hugging Face Spaces, the Space Secrets are designed exactly for this.
Key Takeaways
- FastMCP is the simplest way to create an MCP server in Python
- Polish your tool descriptions, names, and typing
- Test locally first with ngrok and the MCP Inspector before deploying
- Hugging Face Spaces offers ideal free hosting for MCP servers
- Prefer workflow-style tools over overly granular ones
- Protect your secrets and consider authentication for your servers