mcpField
M
mcp-server-demo

mcp-server-demo

リモート
github.com/dev-johnny-gh開発ツール085 週間前に更新
リポジトリ

mcp-server-demo について

mcp-server-demoは、LibreChat、Ollama、ローカルのMongoDBを使ったMCPツールの導入と利用手順を示します。サンプルツールでローカルおよび外部のIPv4・IPv6アドレスを取得できます。

主な機能

  1. 01ローカルと外部のIP検索ツール
  2. 02LibreChatの設定例を収録
  3. 03Ollamaモデルを使ったエージェント作成

活用シーン

  1. 01LibreChatでIP検索ツールをテスト
  2. 02エージェントでローカルや外部のIPを確認

MCP 対応

LibreChatにSSE MCPサーバーを設定し、エージェントからローカルおよび外部IPアドレスを取得するツールを呼び出す例です。

設定

リモートサーバーはインストール不要です。クライアントを選んで設定をコピーするか、ワンクリックで導入できます。

エンドポイントhttp://localhost:3000/sse
インストールコマンドをコピー
Claude CodeTerminal
Cursor.cursor/mcp.json
VS Code.vscode/mcp.json
Claude Desktopclaude_desktop_config.json
Windsurf~/.codeium/windsurf/mcp_config.json

コマンドはターミナルで実行し、JSON は各クライアントの MCP 設定に貼り付けて再起動します。認可が必要なサーバーは初回接続時にログインを求めます。

ツール

詳細

インストール

  1. cd IpServer && npm install && npm run build && npm run start

  2. ローカルの MongoDB サーバーをインストールし、mongodb://127.0.0.1:27017 で起動します

  3. cd LibreChat && git clone [email protected]:danny-avila/LibreChat.git && mv .env.example .env && npm install && npm run frontend && npm run backend

  4. 次の設定を librechat.yaml ファイルに追加します。

mcpServers:
  ipServer:
    # type: sse # type can optionally be omitted
    url: http://localhost:3000/sse
    timeout: 60000 # 1 minute timeout for this server, this is the default timeout for MCP servers.

endpoints:
  custom:
    - name: "Ollama"
      apiKey: "ollama"
      # use 'host.docker.internal' instead of localhost if running LibreChat in a docker container
      baseURL: "http://localhost:11434/v1/chat/completions"
      models:
        default:
          [
            "qwen2.5:3b-instruct-q4_K_M",
            "mistral:7b-instruct-q4_K_M",
            "gemma:7b-instruct-q4_K_M",
          ]
        # fetching list of models is supported but the `name` field must start
        # with `ollama` (case-insensitive), as it does in this example.
        fetch: true
      titleConvo: true
      titleModel: "current_model"
      summarize: false
      summaryModel: "current_model"
      forcePrompt: false
      modelDisplayLabel: "Ollama"
  1. ollama をダウンロードして実行し、https://ollama.ai/models/ からモデルをダウンロードして、http://localhost:11434/ で ollama を起動します

使い方

  1. http://localhost:3080/ にアクセスして、LibreChat の UI を表示します。

  2. 名前を「Ollama」にして新しいエージェントを作成し、モデルプロバイダーとして ollama を選択して、モデルを選択します

  3. 下の「Add Tools」ボタンをクリックし、get-external-ip、get-local-ip-v6、get-external-ip-v6、get-local-ip ツールを追加します

  4. エージェントに「自分のローカル IP アドレスは何ですか?/外部 IP アドレスは何ですか?/外部 IPv6 アドレスは何ですか?/内部 IPv6 アドレスは何ですか?」と尋ねます

  5. エージェントがツールを呼び出し、結果を返します。

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。