examples/MCP_QUICK_START.md
š Connect your models to external tools and services using the Model Context Protocol (MCP).
What is MCP? The Model Context Protocol allows your AI models to access external tools like web search, file systems, databases, and APIs automatically during conversations.
Key Benefits:
š Full Documentation | āļø Configuration Reference
Create mcp-config.json with a working example using the filesystem server:
{
"servers": [
{
"name": "Filesystem Tools",
"source": {
"type": "Process",
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "."]
}
}
],
"auto_register_tools": true
}
Note: To install the filesystem server, run:
npx @modelcontextprotocol/server-filesystem . -y
Alternative Transport Examples (commented out by default):
<details> <summary>HTTP Example - Hugging Face MCP Server</summary>{
"servers": [
{
"name": "Hugging Face MCP",
"source": {
"type": "Http",
"url": "https://hf.co/mcp",
"timeout_secs": 30
},
"bearer_token": "hf_xxx",
"tool_prefix": "hf",
"enabled": false
},
{
"name": "Filesystem Tools",
"source": {
"type": "Process",
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "."]
}
}
],
"auto_register_tools": true
}
{
"servers": [
{
"name": "WebSocket Example",
"source": {
"type": "WebSocket",
"url": "wss://api.example.com/mcp",
"timeout_secs": 30
},
"enabled": false
},
{
"name": "Filesystem Tools",
"source": {
"type": "Process",
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "."]
}
}
],
"auto_register_tools": true
}
# Start with MCP configuration
mistralrs serve --mcp-config mcp-config.json -p 1234 -m Qwen/Qwen3-4B
# Alternative: Use environment variable
export MCP_CONFIG_PATH=mcp-config.json
mistralrs serve -p 1234 -m Qwen/Qwen3-4B
ā Server starts with tools automatically loaded!
That's it! Tools work automatically in conversations:
# File operations example
curl -X POST http://localhost:1234/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-4B",
"messages": [
{"role": "user", "content": "List the files in the current directory and create a hello.txt file"}
]
}'
š The model automatically uses tools when needed - no extra steps required!
curl http://localhost:1234/v1/models
Look for MCP status in the response:
{
"object": "list",
"data": [{
"id": "Qwen/Qwen3-4B",
"object": "model",
"tools_available": true,
"mcp_tools_count": 3,
"mcp_servers_connected": 1
}]
}
ā
tools_available: true means MCP tools are working!
Test filesystem server is working:
# This should return "3" or more (filesystem tools available)
curl http://localhost:1234/v1/models | jq '.data[0].mcp_tools_count'
# Check if filesystem server process is running
ps aux | grep server-filesystem
| Server | Description | Installation | Use Case |
|---|---|---|---|
| Filesystem | File operations | npm i -g @modelcontextprotocol/server-filesystem | Read/write files |
| Hugging Face | HF API access | Web service at https://hf.co/mcp | Models, datasets, spaces |
| Postgres | Database | npm i -g @modelcontextprotocol/server-postgres | SQL queries |
Links to more servers:
- Brave Search - Web search capabilities
- GitHub - Repository access
| Transport | When to Use | Examples |
|---|---|---|
| Process | Local tools, npm packages | Most MCP servers |
| HTTP | REST APIs, cloud services | Custom web services |
| WebSocket | Real-time streaming | Live data feeds |
{
"servers": [{
"name": "File Operations",
"source": {
"type": "Process",
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "."]
}
}],
"auto_register_tools": true
}
{
"servers": [
{
"name": "Hugging Face MCP",
"source": {
"type": "Http",
"url": "https://hf.co/mcp",
"timeout_secs": 30
},
"bearer_token": "hf_xxx",
"tool_prefix": "hf",
"enabled": false
},
{
"name": "File Operations",
"source": {
"type": "Process",
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "."]
}
}
],
"auto_register_tools": true
}
{
"servers": [
{
"name": "WebSocket Example",
"source": {
"type": "WebSocket",
"url": "wss://api.example.com/mcp",
"timeout_secs": 30
},
"enabled": false
},
{
"name": "File Operations",
"source": {
"type": "Process",
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "."]
}
}
],
"auto_register_tools": true
}
The system gracefully handles failures:
Ready for more?
Need help?