PM

php-mcp/client

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

58 stars 12 forks 품질 53 트렌드 13MIT

모형 Context 의정서 (MCP) 클라이언트를 위한 핵심 PHP 실시

개요

그것은 다른 수송 (스트디오, http+sse)를 사용하여 개별 MCP 서버에 연결하는 개발자 친절한 공용영역을 제공하고, 연결 수명주기를, 발견합니다 서버 기능 (도구, 자원, Prompts)를, 공구 또는 독서 자원과 같은 요구를 실행합니다. ReactPHP를 통해 내부적으로 비동기 I/O를 활용하고 서버 상태 이벤트와 같은 기능을 처리하는 동안 라이브러리는 일반적인 사용 사례와 고급 제어 및 암호화를 위한 스트레이트 포워드를 제공합니다. 이 라이브러리는 MCP 사양의 모델과 일치합니다. 1개의 클라이언트 인스턴스가 1개의 서버로 stateful 연결을 관리합니다. Model Context Protocol (MCP)은 AI 조수 및 응용 프로그램이 외부 데이터 소스, API 및 도구와 연결하는 방법을 표준화하도록 설계된 개방형 표준입니다 (Codebases, Databases, 웹 브라우저와 같은).

개요(AI 번역)

PHP MCP Client는 Model Context Protocol (MCP)을 구현하는 서버와 상호 작용하는 PHP 라이브러리입니다.

그것은 다른 운송 (stdio, http+sse]])을 사용하여 개별 MCP 서버에 연결하는 개발자 친화적 인 인터페이스를 제공, 연결 수명주기를 관리, 서버 기능 발견 (도구, 자원, Prompts), 도구 또는 읽기 리소스와 같은 요청을 실행.

Server-sent 이벤트와 같은 견고하고 처리 기능을 위해 ReactPHP를 통해 내부적으로 동기 I/O를 사용하는 동안 라이브러리는 both a straightforward synchronous (blocking) API for common use case and asynchronous (Promise-based) API for advanced control and concurrency.

이 라이브러리는 MCP 사양의 모델과 일치합니다. 1개의 클라이언트 인스턴스가 1개의 서버로 stateful 연결을 관리합니다.

MCP 소개

Model Context Protocol (MCP)은 AI 조수 및 응용 프로그램이 외부 데이터 소스, API 및 도구와 연결하는 방법을 표준화하도록 설계된 개방형 표준입니다 (Codebases, Databases, 웹 브라우저와 같은).

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

원문 README의 일부입니다. 원문 보기.

PHP MCP Client

PHP MCP Client is a PHP library for interacting with servers that implement the Model Context Protocol (MCP).

It provides a developer-friendly interface to connect to individual MCP servers using different transports (stdio, http+sse), manage the connection lifecycle, discover server capabilities (Tools, Resources, Prompts), and execute requests like calling tools or reading resources.

While utilizing asynchronous I/O internally via ReactPHP for robustness and handling features like server-sent events, the library offers both a straightforward synchronous (blocking) API for common use cases and an asynchronous (Promise-based) API for advanced control and concurrency.

This library aligns with the MCP specification’s model where one client instance manages a stateful connection to one server.

Introduction to MCP

The Model Context Protocol (MCP) is an open standard designed to standardize how AI assistants and applications connect to external data sources, APIs, and tools (like codebases, databases, web browsers). It acts as a communication layer, enabling AI models (like Claude, or models integrated via frameworks like OpenAI’s) to securely access and interact with context provided by different servers.

This client library allows your PHP application (acting as the “Host” in MCP terminology) to consume capabilities offered by one or more MCP servers.

Features

  • Client-per-Server Model: Each Client instance manages a stateful connection to a single configured MCP server, aligning with the MCP specification.
  • Fluent Configuration: Easy setup for each client instance using a Client::make()->with...() builder pattern.
  • Dual API:
    • Synchronous Facade: Interact with the server using straightforward, blocking methods (e.g., $client->listTools(), $client->callTool(...)) for simple integration.
    • Asynchronous API: Access underlying Promise-based methods (e.g., $client->listToolsAsync(), $client->callToolAsync(...)) for concurrency and integration with async PHP applications.
  • Multiple Transports: Built-in support for:
    • stdio: Communicating with server processes via Standard Input/Output.
    • http: Communicating with servers via HTTP POST and Server-Sent Events (SSE).
GitHub에서 전체 README 보기

설치

This server does not publish a one-line install command.

Open the repository installation guide MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →

설정

use PhpMcp\Client\ServerConfig; use PhpMcp\Client\Exception\ConfigurationException; $jsonConfig = '{ "mcpServers": { "stdio_files": { "command": "php", "args": ["/app/mcp/file_server.php"], "timeout": 10 }, "http_api": { "url": "https://api.example.com/mcp/sse", "transport": "http", "headers": {"X-API-Key": "secret"} } } }'; $decodedConfig = json_decode($jsonConfig, true)['mcpServers'] ?? []; $serverConfigs = []; foreach ($decodedConfig as $name => $data) { try { $serverConfigs[$name] = ServerConfig::fromArray($name, $data); } catch (ConfigurationException $e) { echo "Error parsing config for '{$name}': {$e->getMessage()}\n"; } } // Now $serverConfigs['stdio_files'] and $serverConfigs['http_api'] // contain ServerConfig objects.