jsfit-helpdesk-rag_mcp_server_stdio_02

sasaoka-company/jsfit-helpdesk-rag_mcp_server_stdio_02

3.2

If you are the rightful owner of jsfit-helpdesk-rag_mcp_server_stdio_02 and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This project is an MCP server that provides Retrieval-Augmented Generation (RAG) functionality to search for relevant information from PDF/DOCX documents using standard input/output communication.

Tools
1
Resources
0
Prompts
0

RAG 機能を提供する MCP サーバー(標準入出力方式)その2

このプロジェクトは、PDF/DOCX ドキュメントから関連情報を検索し、RAG(Retrieval-Augmented Generation)機能を提供する MCP サーバーです。 標準入出力を通じて MCP クライアントとの通信を行います。

1. 機能

  • 標準入出力方式: MCP クライアントが直接プロセスを起動してアクセス
  • ベクトル DB 検索: 高速な類似性検索による関連文書の取得

2. 前提条件

  • Python 3.12 以上
  • uv (Python パッケージマネージャー)
  • モデル実行環境:Ollama
  • Embedding モデル:nomic-embed-text:latest
  • 仮想環境(.venv)が作成されていること

3. MCP クライアントからの接続

  • コマンド: (プロジェクトルート)\.venv\Scripts\python.exe
  • 実行スクリプト: src\rag_mcp_server_stdio_02.py
  • トランスポート: stdio

(参考)Claude Desktop から利用する場合の設定例:

claude_desktop_config.jsonに以下のように設定:

{
  "mcpServers": {
    "mcp-server-stdio-02": {
      "command": "D:\\github_projects\\jsfit-helpdesk-rag_mcp_server_stdio_02\\.venv\\Scripts\\python.exe",
      "args": [
        "D:\\github_projects\\jsfit-helpdesk-rag_mcp_server_stdio_02\\src\\rag_mcp_server_stdio_02.py"
      ]
    }
  }
}

4. 開発環境セットアップ

4-1. Git 設定

以下コマンドにより、チェックアウト時、コミット時に改行コードを変更しないようにします。(.gitattributes のままになります)

git config --global core.autocrlf false

4-2. 依存関係のインストール

以下コマンドにより、pyproject.tomlで定義されているライブラリをインストールします。

uv sync

5. MCP サーバ起動

明示的な起動は不要です。MCP クライアントから接続されることで起動します。

6. テスト実行

uv run pytest tests/ -v

7. その他

7-1. Embedding モデルを切り替える

以下変更箇所のコメントアウトを切り替える。

  • .env OPENAI_API_BASE OPENAI_API_KEY

※ Ollama を使わない場合はOPENAI_API_BASE定数はコメントアウトして無効にする

  • config.py EMBEDDING_MODEL

  • rag_core.py from langchain_ollama import OllamaEmbeddings # Ollama Embeddings from langchain_openai import OpenAIEmbeddings # OpenAI Embeddings

    embeddings = OllamaEmbeddings(model=EMBEDDING_MODEL) embeddings = OpenAIEmbeddings(model=EMBEDDING_MODEL)