Text Generation
Transformers
Safetensors
Chinese
English
minicpm
feature-extraction
conversational
custom_code
Instructions to use openbmb/MiniCPM4-MCP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openbmb/MiniCPM4-MCP with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openbmb/MiniCPM4-MCP", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("openbmb/MiniCPM4-MCP", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use openbmb/MiniCPM4-MCP with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openbmb/MiniCPM4-MCP" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM4-MCP", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/openbmb/MiniCPM4-MCP
- SGLang
How to use openbmb/MiniCPM4-MCP with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "openbmb/MiniCPM4-MCP" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM4-MCP", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "openbmb/MiniCPM4-MCP" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openbmb/MiniCPM4-MCP", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use openbmb/MiniCPM4-MCP with Docker Model Runner:
docker model run hf.co/openbmb/MiniCPM4-MCP
Update README.md
Browse files
README.md
CHANGED
|
@@ -48,6 +48,61 @@ As of now, MiniCPM4-MCP supports the following:
|
|
| 48 |
|
| 49 |
- Cross-tool-calling capability: It can perform single- or multi-step tool calls using different tools that complies with the MCP.
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
## Evaluation
|
| 52 |
The detailed evaluation script can be found on the [GitHub](https://github.com/OpenBMB/MiniCPM/tree/main/demo/minicpm4/MCP) page. The evaluation results are presented below.
|
| 53 |
|
|
|
|
| 48 |
|
| 49 |
- Cross-tool-calling capability: It can perform single- or multi-step tool calls using different tools that complies with the MCP.
|
| 50 |
|
| 51 |
+
|
| 52 |
+
## Inference
|
| 53 |
+
|
| 54 |
+
### MCP Servers Deployment
|
| 55 |
+
|
| 56 |
+
The MCP Servers supported by MiniCPM4-MCP include
|
| 57 |
+
[Airbnb](https://github.com/openbnb-org/mcp-server-airbnb),
|
| 58 |
+
[Amap-Maps](https://github.com/zxypro1/amap-maps-mcp-server),
|
| 59 |
+
[Arxiv-MCP-Server](https://github.com/blazickjp/arxiv-mcp-server),
|
| 60 |
+
[Calculator](https://github.com/githejie/mcp-server-calculator),
|
| 61 |
+
[Computer-Control-MCP](https://github.com/AB498/computer-control-mcp),
|
| 62 |
+
[Desktop-commander](https://github.com/wonderwhy-er/DesktopCommanderMCP),
|
| 63 |
+
[Filesystem](https://github.com/mark3labs/mcp-filesystem-server),
|
| 64 |
+
[Github](https://github.com/modelcontextprotocol/servers/tree/main/src/github),
|
| 65 |
+
[Gaode](https://github.com/perMAIN/gaode),
|
| 66 |
+
[MCP-Code-Executor](https://github.com/bazinga012/mcp_code_executor),
|
| 67 |
+
[MCP-DOCx](https://github.com/MeterLong/MCP-Doc),
|
| 68 |
+
[PPT](https://github.com/GongRzhe/Office-PowerPoint-MCP-Server),
|
| 69 |
+
[PPTx](https://github.com/supercurses/powerpoint),
|
| 70 |
+
[Simple-Time-Server](https://github.com/andybrandt/mcp-simple-timeserver),
|
| 71 |
+
[Slack](https://github.com/modelcontextprotocol/servers/tree/main/src/slack), and
|
| 72 |
+
[Whisper](https://github.com/arcaputo3/mcp-server-whisper). Follow the instructions provided in each server's repository for successful deployment. Note that not all tools in these servers will function properly in every environment. Some tools are unstable and may return errors such as timeouts or HTTP errors. During training data construction, tools with consistently high failure rates (e.g., those for which the LLM fails to produce a successful query even after hundreds of attempts) are filtered out.
|
| 73 |
+
|
| 74 |
+
### MCP Client Setup
|
| 75 |
+
|
| 76 |
+
We modified the existing MCP Client from the [mcp-cli](https://github.com/chrishayuk/mcp-cli) repository to enable interaction between MiniCPM and MCP Servers.
|
| 77 |
+
After the MCP Client performs a handshake with a Server, it retrieves a list of available tools. An example of tool information contained in this list is provided in [`available_tool_example.json`](https://github.com/OpenBMB/MiniCPM/blob/main/demo/minicpm4/MCP/available_tool_example.json).
|
| 78 |
+
|
| 79 |
+
Once the available tools and user query are obtained, results can be generated using the following script logic:
|
| 80 |
+
|
| 81 |
+
```bash
|
| 82 |
+
python generate_example.py \
|
| 83 |
+
--tokenizer_path {path to MiniCPM4 tokenizer} \
|
| 84 |
+
--base_url {vllm deployment URL} \
|
| 85 |
+
--model {model name used in vllm deployment} \
|
| 86 |
+
--output_path {path to save results}
|
| 87 |
+
```
|
| 88 |
+
where the `generate_example.py` is located in [link](https://github.com/OpenBMB/MiniCPM/blob/main/demo/minicpm4/MCP/generate_example.py) and MiniCPM4 generates tool calls in the following format:
|
| 89 |
+
|
| 90 |
+
```
|
| 91 |
+
<|tool_call_start|>
|
| 92 |
+
```python
|
| 93 |
+
read_file(path="/path/to/file")
|
| 94 |
+
```
|
| 95 |
+
<|tool_call_end|>
|
| 96 |
+
```
|
| 97 |
+
You can build a custom parser for MiniCPM4 tool calls based on this format. The relevant parsing logic is located in `generate_example.py`.
|
| 98 |
+
|
| 99 |
+
Since the [mcp-cli](https://github.com/chrishayuk/mcp-cli) repository supports the vLLM inference framework, MiniCPM4-MCP can also be integrated into `mcp-cli` by modifying vLLM accordingly.
|
| 100 |
+
Specifically, follow the instructions in [this link](https://github.com/OpenBMB/MiniCPM/tree/main/demo/minicpm3/function_call) to enable interaction between a client running the MiniCPM4-MCP model and the MCP Server.
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
## Evaluation
|
| 107 |
The detailed evaluation script can be found on the [GitHub](https://github.com/OpenBMB/MiniCPM/tree/main/demo/minicpm4/MCP) page. The evaluation results are presented below.
|
| 108 |
|