ロール固有のコンテキストMCPサーバー
システム内のエージェント ロールに基づいてコンテキスト境界を定義および管理するモデル コンテキスト プロトコル (MCP) サーバー。
概要
この MCP サーバーは、AI エージェントのロールベースのコンテキスト管理を可能にし、次のことを可能にします。
各 AI エージェント (マーケティング エキスパート、ソングライター、エグゼクティブ アシスタントなど) に明確な指示、目的、ドメイン知識を確立します。
ロールに関連するメモリを分割してスコープを設定し、異なるエージェント ロール間の相互汚染を防ぎます。
トーンプロファイルをプロンプトに組み込み、役割ごとにトーンとスタイル(真面目、機知に富んだ、皮肉)を動的に調整します。
Related MCP server: MCP Toolkit
特徴
役割管理
カスタムロールの作成、更新、削除
特定の専門分野を持つ事前定義された役割
役割別のシステムプロンプトと指示
カスタマイズ可能なトーンプロファイル
メモリ管理
役割固有のメモリストレージ
現在のクエリとの関連性に基づくメモリ検索
メモリの有効期間(TTL)
ロールごとのメモリ制限
MCP統合
ロールをMCPリソースとして公開する
ロール管理とクエリ処理のためのツールを提供します
役割ベースのインタラクションのためのプロンプトを提供する
はじめる
前提条件
Node.js 18歳以上
OpenAI APIキー
インストール
# Clone the repository
git clone https://github.com/yourusername/role-context-mcp.git
cd role-context-mcp
# Install dependencies
npm install
# Set up environment variables
echo "OPENAI_API_KEY=your_api_key_here" > .env
# Build the project
npm run buildサーバーの実行
# Run the MCP server
npm start
# Run the HTTP server for testing
npm run start:http構成
サーバーはsrc/config.ts変更することで設定できます。主な設定オプションは次のとおりです。
デフォルトロールとそのプロパティ
利用可能なトーンプロファイル
メモリ管理設定
OpenAIモデル選択
MCP統合
リソース
サーバーは次のリソースを公開します。
role://{roleId}- 特定のロールに関する情報role://tones- 利用可能なトーンプロファイル
ツール
サーバーは次のツールを提供します。
process-with-role- 特定のロールを使用してクエリを処理するcreate-role- 新しいロールを作成するupdate-role- 既存のロールを更新するdelete-role- カスタムロールを削除するchange-role-tone- 役割のトーンを変更するstore-memory- 特定のロールのメモリを保存するclear-role-memories- ロールのすべてのメモリをクリアする
プロンプト
サーバーは次のプロンプトを提供します。
role-{roleId}- リクエストを処理するために特定のロールを使用するcreate-custom-role- 新しいカスタムロールを作成する
使用例
ロールによるクエリの処理 (MCP)
// Example of using the process-with-role tool
const result = await client.executeToolRequest({
name: 'process-with-role',
parameters: {
roleId: 'marketing-expert',
query: 'How can I improve my social media engagement?',
customInstructions: 'Focus on B2B strategies'
}
});ロールを使用したクエリの処理 (HTTP API)
// Example of using the HTTP API
const response = await axios.post('http://localhost:3000/process', {
roleId: 'marketing-expert',
query: 'How can I improve my social media engagement?',
customInstructions: 'Focus on B2B strategies'
});
console.log(response.data.response);カスタムロールの作成
// Example of using the create-role tool
const result = await client.executeToolRequest({
name: 'create-role',
parameters: {
id: 'tech-writer',
name: 'Technical Writer',
description: 'Specializes in clear, concise technical documentation',
instructions: 'Create documentation that is accessible to both technical and non-technical audiences',
domains: ['technical-writing', 'documentation', 'tutorials'],
tone: 'technical',
systemPrompt: 'You are an experienced technical writer with expertise in creating clear, concise documentation for complex systems.'
}
});ライセンス
マサチューセッツ工科大学