Fluent MCP について
Fluent MCPは、埋め込みLLMの推論機能とツール管理を備えたMCPサーバー構築用Pythonフレームワークです。内部推論ツールと、利用側のLLMに公開するツールを分けたい開発者向けです。
主な機能
- 01MCPサーバープロジェクトの生成
- 02内部ツールと外部ツールの分離
- 03埋め込みLLM推論の実行
- 04ツールの登録と実行
- 05ツール定義付きプロンプトの読み込み
活用シーン
- 01新しいMCPサーバー構成の作成
- 02内部ツールとクライアント向けツールの分離
- 03複数段階の推論を埋め込みLLMに委譲
MCP 対応
MCPサーバーの構築と、利用側LLMに公開するツールの管理を支援し、埋め込み推論用の内部ツールにも対応します。
設定
ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。
このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。
ツール
ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。
詳細
Fluent MCP
インテリジェントな推論機能を備えた Model Context Protocol(MCP)サーバーを構築するための最新のフレームワークです。
概要
Fluent MCP は、AI 統合に重点を置いた、MCP サーバーのひな形作成と管理のためのツールキットです。言語モデルによる組み込み推論、ツールの登録と実行、プロンプトや設定の管理が可能なサーバーを構築するための、構造化された手法を提供します。
このフレームワークは拡張性を備えており、LLM が独自のツールを構築して登録できるため、自己改善型の AI システムの開発を支援します。
コアアーキテクチャパターン
Fluent MCP は、AI システムの対話方法を根本的に変える強力なアーキテクチャパターンを実装しています。
2 層 LLM アーキテクチャ
- 組み込み LLM:複雑な推論や複数ステップのタスクを実行する内部 LLM
- 利用側 LLM:MCP サーバーと対話する外部 LLM(Claude など)
ツールの分離
- 組み込みツール:組み込み LLM のみが利用でき、外部には公開されない内部ツール
- 外部ツール:MCP プロトコルを介して利用側 LLM に公開されるツール
推論のオフロード
- 複雑な複数ステップの推論を利用側 LLM から組み込み LLM にオフロードします
- 外部ツールは、シンプルなインターフェースを提供しながら、内部で組み込み推論を活用できます
- これにより、複雑なロジックを中間層で処理する「推論サンドイッチ」が実現します
メリット
- トークン効率:推論を組み込み LLM にオフロードすることで、利用側 LLM が使用するトークンを削減できます
- コスト削減:小型の特化型モデルで、特定の推論タスクを低コストで処理できます
- 複雑さの隠蔽:複雑な複数ステップのプロセスを、シンプルなインターフェースの背後に隠せます
- 関心の分離:公開されるものと内部に留まるものの境界を明確にできます

機能
- 推論のオフロード:複雑な推論を利用側 LLM から組み込み LLM にオフロードし、トークン効率とコスト効率を高めます
- ツールの分離:組み込みツール(内部)と外部ツール(公開)の明確な区別
- サーバーのひな形作成:適切な構造を備えた新しい MCP サーバープロジェクトを生成します
- LLM 統合:さまざまなプロバイダーの言語モデルにシームレスに接続します
- ツールレジストリ:組み込みツール(内部で使用)と外部ツール(利用側 LLM に公開)の両方を登録します
- 組み込み推論:LLM による推論を実行し、ツール呼び出しを実行します
- プロンプト管理:ファイルからプロンプトを読み込み、フロントマターでのツール定義にも対応します
- エラー処理:LLM 統合とツール実行のための堅牢なエラー処理
インストール
pip install fluent_mcp
開発用:
# Clone the repository
git clone https://github.com/yourusername/fluent_mcp.git
cd fluent_mcp
# Install in development mode with extra dependencies
pip install -e ".[dev]"
クイックスタート
新しいサーバーの作成
CLI を使用して新しいサーバーのひな形を作成します。
fluent-mcp new my_server
または、プログラムからサーバーを作成します。
from fluent_mcp import scaffold_server
scaffold_server(
output_dir=".",
server_name="my_server",
description="My MCP server with AI capabilities"
)
コアアーキテクチャパターンの実装
from fluent_mcp.core.tool_registry import register_embedded_tool, register_external_tool
from fluent_mcp.core.llm_client import run_embedded_reasoning
import asyncio
# 1. Define embedded tools (ONLY available to the embedded LLM)
@register_embedded_tool()
def search_database(query: str) -> list:
"""Search the database for information (only used internally)."""
# Implementation...
return ["result1", "result2"]
@register_embedded_tool()
def analyze_data(data: list) -> dict:
"""Analyze data and extract insights (only used internally)."""
# Implementation...
return {"key_insight": "finding", "confidence": 0.95}
# 2. Define an external tool that leverages embedded reasoning
@register_external_tool()
async def research_question(question: str) -> dict:
"""
Research a question and provide a comprehensive answer.
This external tool is exposed to consuming LLMs but internally
uses embedded reasoning with access to embedded tools.
"""
# Define system prompt for embedded reasoning
system_prompt = """
You are a research assistant with access to internal tools:
- search_database: Search for information
- analyze_data: Analyze and extract insights
Use these tools to thoroughly research the question.
"""
# Run embedded reasoning (this is where the magic happens)
result = await run_embedded_reasoning(
system_prompt=system_prompt,
user_prompt=f"Research this question: {question}"
)
# Return a clean, structured response to the consuming LLM
return {
"answer": result["content"],
"confidence": 0.9,
"sources": ["source1", "source2"]
}
アーキテクチャパターンを使ったサーバーの実行
from fluent_mcp import create_mcp_server
from my_tools import search_database, analyze_data, research_question
# Create and run MCP server
server = create_mcp_server(
server_name="my_server",
# Embedded tools (ONLY available to the embedded LLM)
embedded_tools=[search_database, analyze_data],
# External tools (exposed to consuming LLMs)
external_tools=[research_question],
config={
"provider": "ollama",
"model": "llama2",
"base_url": "http://localhost:11434",
"api_key": "ollama"
}
)
server.run()
ツール定義を含むプロンプトの使用
Fluent MCP では、プロンプトのフロントマターに、そのプロンプトで利用可能なツールを直接定義できます。
---
name: math_tools
description: A prompt that uses math-related tools
model: gpt-4
temperature: 0.3
tools:
- add_numbers
- multiply_numbers
---
You are a math assistant that can perform calculations.
Use the available tools to help solve math problems.
このプロンプトを組み込み推論で使用すると、指定されたツールのみが利用可能になります。
from fluent_mcp.core.llm_client import run_embedded_reasoning
# Get a prompt with tool definitions
math_prompt = server.get_prompt("math_tools")
# Run embedded reasoning with only the tools defined in the prompt
result = await run_embedded_reasoning(
system_prompt=math_prompt["template"],
user_prompt="What is 5 + 3?",
prompt=math_prompt # Pass the prompt to use its tool definitions
)
この方法により、プロンプトごとに利用可能なツールをより正確に制御できるため、セキュリティが向上し、意図しないツール使用の可能性を減らせます。
ドキュメント
詳細については、docs ディレクトリを参照してください。
サンプル
動作する完全なサンプルについては、サンプルディレクトリをご覧ください。
開発
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
flake8
black .
isort .
ライセンス
MIT
コメント
AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。