Skip to main content
Glama

MCP Base - 汎用モデルコンテキストプロトコルフレームワーク

このフォルダには、AIを活用したアプリケーションを構築するためのモデルコンテキストプロトコル(MCP)の汎用的な基本実装が含まれています。これにより、LLMをアプリケーションに統合するために使用できるMCPサーバーとクライアントを標準化された方法で作成できます。

📋 機能

  • 標準化されたMCPサーバー:HTTPおよびstdioトランスポートをサポートする基本サーバー実装

  • 汎用MCPクライアント:任意のMCPサーバーに接続するためのクライアント

  • Ollama 統合: Ollama で埋め込みとテキストを生成するためのすぐに使えるサービス

  • Supabase 統合: Supabase ベクター データベースの組み込みサポート

  • モジュラー設計: リソース、ツール、プロンプトを明確に整理した構造

  • サンプルテンプレート: すぐに開始できるようにするための実装例

Related MCP server: PAELLADOC

🛠️ ディレクトリ構造

_mcp-base/ ├── server.ts # Main MCP server implementation ├── client.ts # Generic MCP client ├── utils/ # Utility services │ ├── ollama_embedding.ts # Embedding generation with Ollama │ └── ollama_text_generation.ts # Text generation with Ollama ├── tools/ # Tool implementations │ └── sample-tool.ts # Example tool template ├── resources/ # Resource implementations │ └── sample-resource.ts # Example resource template ├── prompts/ # Prompt implementations │ └── sample-prompt.ts # Example prompt template └── README.md # This documentation

🚀 はじめに

前提条件

  • Node.js と npm/pnpm

  • ローカル埋め込みとテキスト生成のための Ollama

  • ベクターストレージ用のSupabaseアカウント

環境設定

次の変数を含む.envファイルを作成します。

PORT=3000 SUPABASE_URL=https://your-project.supabase.co SUPABASE_SERVICE_KEY=your-service-key OLLAMA_URL=http://localhost:11434 OLLAMA_EMBED_MODEL=nomic-embed-text OLLAMA_LLM_MODEL=llama3 SERVER_MODE=http # 'http' or 'stdio'

サーバーの初期化

  1. 必要なモジュールをインポートする

  2. リソース、ツール、プロンプトを登録する

  3. サーバーを起動する

// Import base server and utilities import server from "./server"; import { registerSampleResources } from "./resources/sample-resource"; import { registerSampleTool } from "./tools/sample-tool"; import { registerSamplePrompts } from "./prompts/sample-prompt"; // Initialize database if needed async function initializeDatabase() { // Your database initialization logic } // Register your components registerSampleResources(server, supabase); registerSampleTool(server, textGenerator, embeddings, supabase); registerSamplePrompts(server, supabase); // Start the server startServer();

クライアントの使用状況

import MCPClient from "./client"; // Create a client instance const client = new MCPClient({ serverUrl: "http://localhost:3000", }); // Example: Call a tool async function callSampleTool() { const result = await client.callTool("sample-tool", { query: "example query", maxResults: 5, }); console.log(result); } // Example: Read a resource async function readResource() { const items = await client.readResource("items://all"); console.log(items); } // Example: Get a prompt async function getPrompt() { const prompt = await client.getPrompt("simple-prompt", { task: "Explain quantum computing", }); console.log(prompt); } // Don't forget to disconnect when done await client.disconnect();

📚 フレームワークの拡張

新しいツールの作成

  1. tools/ディレクトリに新しいファイルを作成する

  2. Zodを使用してツールの機能とスキーマを定義する

  3. ツールロジックを実装する

  4. ツールをサーバーに登録する

新しいリソースの作成

  1. resources/ディレクトリに新しいファイルを作成する

  2. リソースのエンドポイントとスキーマを定義する

  3. リソースロジックを実装する

  4. サーバーにリソースを登録する

新しいプロンプトの作成

  1. prompts/ディレクトリに新しいファイルを作成する

  2. プロンプトのスキーマとパラメータを定義する

  3. プロンプトテンプレートを実装する

  4. サーバーにプロンプトを登録する

📄 ライセンス

マサチューセッツ工科大学

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jsmiff/mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server