Download the PHP package huangdijia/mcp-sdk-php without Composer
On this page you can find all versions of the php package huangdijia/mcp-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download huangdijia/mcp-sdk-php
More information about huangdijia/mcp-sdk-php
Files in huangdijia/mcp-sdk-php
Package mcp-sdk-php
Short Description Model Context Protocol SDK for PHP
License MIT
Homepage https://github.com/huangdijia/mcp-sdk-php
Informations about the package mcp-sdk-php
MCP PHP SDK
Table of Contents
- Overview
- Installation
- Quickstart
- What is MCP?
- Core Concepts
- Server
- Resources
- Tools
- Prompts
- Running Your Server
- stdio
- HTTP with SSE
- Testing and Debugging
- Examples
- Echo Server
- SQLite Explorer
- Advanced Usage
- Low-Level Server
- Writing MCP Clients
- Server Capabilities
Overview
The Model Context Protocol allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. This PHP SDK implements the full MCP specification, making it easy to:
- Build MCP clients that can connect to any MCP server
- Create MCP servers that expose resources, prompts and tools
- Use standard transports like stdio and SSE
- Handle all MCP protocol messages and lifecycle events
Installation
Quick Start
Let's create a simple MCP server that exposes a calculator tool and some data:
What is MCP?
The Model Context Protocol (MCP) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but specifically designed for LLM interactions. MCP servers can:
- Expose data through Resources (think of these sort of like GET endpoints; they are used to load information into the LLM's context)
- Provide functionality through Tools (sort of like POST endpoints; they are used to execute code or otherwise produce a side effect)
- Define interaction patterns through Prompts (reusable templates for LLM interactions)
- And more!
Available Tools
MCP PHP SDK提供了多种内置工具,可以在您的MCP服务器中使用:
-
基础计算工具
add
- 将两个数字相加multiply
- 将两个数字相乘
- 文本处理工具
textProcess
- 可执行各种文本操作,包括:- 转为大写 (uppercase)
- 转为小写 (lowercase)
- 首字母大写 (capitalize)
- 文本反转 (reverse)
Available Resources
SDK支持多种资源类型,可以通过URI方案访问:
-
greeting - 个性化问候
- URI模板:
greeting://{name}
- 示例:
greeting://world
→ "Hello, world!"
- URI模板:
-
time - 时间信息
- URI模式:
time://
- 提供当前时间信息,支持时区和格式自定义
- URI模式:
- random - 随机数生成
- URI模式:
random://{min}/{max}
- 示例:
random://1/100
→ 生成1到100之间的随机数
- URI模式:
MCP Server Setting
Output:
All versions of mcp-sdk-php with dependencies
ext-json Version *
guzzlehttp/guzzle Version ^7.0 || ^8.0
psr/http-client Version ^1.0
psr/http-message Version ^1.0 || ^2.0
psr/log Version ^1.0 || ^2.0 || ^3.0