带LLM和工具服务器的MCPHost🚀
MCPHost是一个CLI主机应用程序,它使大型语言模型(LLM)能够使用 模型上下文协议(MCP)此设置允许LLM访问系统资源、执行命令并与GitHub等第三方服务集成。
______________________________________________________________________
主控程序
MCP是一个开放协议,它规范了应用程序如何向LLM提供上下文。将MCP想象成AI应用程序的USB-C端口。正如USB-C提供了一种将设备连接到各种外围设备和配件的标准化方式一样,MCP提供了一个将AI模型连接到不同数据源和工具的标准化方法。 MCP
概述🌟
使用MCPHost,我们可以利用LLM,例如 OpenAI GPT模型和基于Ollama的模型 执行文本生成之外的实际任务。
我们取得的成就
- 启用MCPHost 与合作 Ollama和OpenAI模型 喜欢
gpt-4o-mini. - 已连接两台MCP服务器:
- 文件系统服务器 📂 – 允许LLM与本地文件系统交互。 - GitHub服务器 🐙 – 使LLM能够在GitHub上创建存储库和管理文件。
- 成功地 创建本地文件 和 GitHub 仓库 使用LLM命令。
______________________________________________________________________
设置和配置🔧
先决条件
- 去 安装在您的系统上。
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version1.️⃣ 安装MCPHost
克隆MCPHost存储库并安装:
go install github.com/mark3labs/mcphost@latest2.️⃣ 配置MCP服务器
在以下位置创建配置文件 ~/.mcp.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": ""
}
},
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/home/username/path/your/filesystem"
]
}
}
}3.️⃣ 使用OpenAI或Ollama启动MCPHost
使用OpenAI GPT-4o-mini:
mcphost -m openai:gpt-4o-mini使用Ollama-Qwen模型:
mcphost -m ollama:qwen2.5:3b______________________________________________________________________
使用与演示🎯
✅ 示例1:创建GitHub存储库和README.md
我们要求LLM创建一个名为 testmcp 并添加a README.md 包含虚拟内容:
> Create a repo in my GitHub; name is `testmcp` and inside that repo you have to create the README.md file and write the dummy text in README.md file.✅ LLM成功创建了仓库并提交了文件。
📌 已创建存储库: testmcp\ 📌 README.md文件: 查看文件
……的内容 README.md:
# Test MCP Repository
This is a dummy README file for the testmcp repository. It contains some placeholder text to illustrate how a README can be structured.
## Installation
Use the following command to install the necessary packages:npm安装
## Usage
Run the application using:npm启动
## Contributing
Feel free to submit pull requests or open issues for discussion.
## License
This project is licensed under the MIT License.______________________________________________________________________
✅ 示例2:在系统上创建本地文件
我们要求LLM创建一个名为的文本文件 mcptester.txt 包含一些虚拟内容:
> Create a file name it mcptester.txt and add the dummy text in it.✅ LLM在中成功创建了文件 下载目录 内容如下:
📌 已创建文件: mcptester.txt\ 📌 内部内容:
This is a dummy text for testing purposes. It serves as a placeholder to demonstrate file creation and content insertion. Feel free to modify this text as needed.______________________________________________________________________
支持的型号🎭
MCPHost可以与多个LLM一起工作,这些LLM具有更好的调用函数的能力。
要指定模型,请执行以下操作:
mcphost -m openai:gpt-4o-mini______________________________________________________________________
MCP交互命令🛠️
在使用MCPHost时,您可以使用以下命令与LLM交互:
/help–显示可用命令/tools–列出已启用的工具服务器/servers–显示已连接的MCP服务器/history–显示最近的消息/quit–退出
______________________________________________________________________
结论🚀
通过整合 MCP主机 随着 OpenAI、Ollama和GitHub,我们演示了LLM如何:\ ✅ 在本地系统上创建和管理文件\ ✅ 与GitHub交互以自动创建存储库\ ✅ 利用多个MCP服务器增强工具功能
这种设置为以下方面开辟了可能性 自动化工作流程, 开发人员协助,以及 人工智能驱动的系统管理.
______________________________________________________________________
