mcp
MCP(Model Context Protocol)は、LLM(大規模言語モデル)に文脈とツールを提供するための新しい標準化された方法です。`pronskiy/mcp`は、PHPを使用してMCPサーバーを簡単に構築できるライブラリです。ツールの作成、リソースの公開、プロンプトの定義、コンポーネントの接続をクリーンなPHPコードで行うことができます。初心者でも扱いやすく、迅速な開発が可能です。
GitHubスター
117
ユーザー評価
未評価
お気に入り
0
閲覧数
8
フォーク
4
イシュー
2
インストール方法
難易度
初級推定所要時間
5-10 分
必要な環境
PHP: 7.4以上
Composer: 最新版
インストール方法
インストール方法
前提条件
PHP: 7.4以上
Composer: 最新版
インストール手順
1. Composerを使用してインストール
bash
composer require pronskiy/mcp
トラブルシューティング
よくある問題
問題: Composerがインストールされていない 解決策: Composerをインストールしてください。公式サイトから手順を確認できます。設定方法
設定方法
基本設定
MCPサーバーの基本的な設定は、PHPコード内で行います。以下は、ツールを定義する例です。php
require 'vendor/autoload.php';
$server = new \Pronskiy\Mcp\Server('simple-mcp-server');
$server
->tool(
'add-numbers',
'Adds two numbers together',
fn(float $num1, float $num2) => "The sum of {
$num1} and {
$num2} is " . ($num1 + $num2)
)
->tool(
'multiply-numbers',
'Multiplies two numbers',
fn(float $num1, float $num2) => "The product of {
$num1} and {
$num2} is " . ($num1 * $num2)
);
$server->run();
使用例
使用例
基本的な使用方法
以下は、MCPサーバーの基本的な使用方法の例です。php
require 'vendor/autoload.php';
$server = new \Pronskiy\Mcp\Server('simple-mcp-server');
$server
->tool(
'add-numbers',
'Adds two numbers together',
fn(float $num1, float $num2) => "The sum of {
$num1} and {
$num2} is " . ($num1 + $num2)
)
->tool(
'multiply-numbers',
'Multiplies two numbers',
fn(float $num1, float $num2) => "The product of {
$num1} and {
$num2} is " . ($num1 * $num2)
);
$server->run();
使用ケース
数値を加算するツールを作成し、MCPサーバーで実行する
数値を乗算するツールを作成し、他のアプリケーションと統合する
MCPサーバーを使用して、複数の計算ツールを提供するAPIを構築する
PHPを使用して、カスタムプロンプトを定義し、LLMに指示を与える
追加リソース
作者情報
353
フォロワー
88
リポジトリ
16
Gist
0
貢献数