
3choff/mcp-chatbot
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
3choff/mcp-chatbotは、https://github.com/3choff/mcp-chatbot.からインポートされたMCPサーバー候補です。
概要
3choff/mcp-chatbotは、https://github.com/3choff/mcp-chatbot.からインポートされたMCPサーバー候補です。
概要(AI 翻訳)
このチャットボットの例は、モデルコンテキストプロトコル(MCP)をシンプルなCLIチャットボットに統合する方法を示しています。この実装は、MCPサーバーを通じて複数のツールをサポートし、OpenAI API標準に準拠した任意のLLMプロバイダーと互換性があるMCPの柔軟性を示しています。
このプロジェクトが役に立ったら、リポジトリに星印をつけるか、コーヒーをお☕ごるのを忘れ⭐ないでください。
主な特徴
- LLM プロバイダーの柔軟性:OpenAI API標準に準拠した任意のLLMで動作します(GroqのLlama 3.2 90bおよびGitHub MarketplaceのGPT-4o miniでテスト済み)。
- 動的ツール統合:ツールはシステムプロンプトで宣言され、異なるLLM間で最大限の互換性を確保します。
- サーバー設定:ClaudeデスクトップアプリのようなシンプルなJSON設定ファイルを通じて複数のMCPサーバーをサポートします。
要件
- Python 3.10
python-dotenvrequestsmcpuvicorn
設置
-
リポジトリのクローン:
-
依存関係をインストールする:
-
環境変数の設定:
ルートディレクトリに.envファイルを作成し、APIキーを追加します:
- サーバーの設定:
『servers_config』だ。
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
README
以下は原文 README の抜粋です。原文を見る。
MCP Chatbot
This chatbot example demonstrates how to integrate the Model Context Protocol (MCP) into a simple CLI chatbot. The implementation showcases MCP’s flexibility by supporting multiple tools through MCP servers and is compatible with any LLM provider that follows OpenAI API standards.
If you find this project helpful, don’t forget to ⭐ star the repository or buy me a ☕ coffee.
Key Features
- LLM Provider Flexibility: Works with any LLM that follows OpenAI API standards (tested with Llama 3.2 90b on Groq and GPT-4o mini on GitHub Marketplace).
- Dynamic Tool Integration: Tools are declared in the system prompt, ensuring maximum compatibility across different LLMs.
- Server Configuration: Supports multiple MCP servers through a simple JSON configuration file like the Claude Desktop App.
Requirements
- Python 3.10
python-dotenvrequestsmcpuvicorn
Installation
-
Clone the repository:
git clone https://github.com/3choff/mcp-chatbot.git cd mcp-chatbot -
Install the dependencies:
pip install -r requirements.txt -
Set up environment variables:
Create a
.envfile in the root directory and add your API key:LLM_API_KEY=your_api_key_here -
Configure servers:
The
servers_config.jsonfollows the same structure as Claude Desktop, allowing for easy integration of multiple servers. Here’s an example:{ "mcpServers": { "sqlite": { "command": "uvx", "args": ["mcp-server-sqlite", "--db-path", "./test.db"] }, "puppeteer": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-puppeteer"] } } }Environment variables are supported as well. Pass them as you would with the Claude Desktop App.
Example:
{ "mcpServers": { "server_name": { "command": "uvx", "args": ["mcp-server-name", "--additional-args"], "env": { "API_KEY": "your_api_key_here" } } } }
Usage
-
Run the client:
python main.py -
Interact with the assistant:
The assistant will automatically detect available tools and can respond to queries based on the tools provided by the configured servers.
-
Exit the session:
Type
quitorexitto end the session.
Architecture
- Tool Discovery: Tools are automatically discovered from configured servers.
- System Prompt: Tools are dynamically included in the system prompt, allowing the LLM to understand available capabilities.
- Server Integration: Supports any MCP-compatible server, tested with various server implementations including Uvicorn and Node.js.
Class Structure
- Configuration: Manages environment variables and server configurations
インストール
uvx mcp-server-sqlite --db-path ./test.db設定
{
"mcpServers": {
"sqlite": {
"command": "uvx",
"args": ["mcp-server-sqlite", "--db-path", "./test.db"]
},
"puppeteer": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-puppeteer"]
}
}
}