MCP Servers

A collection of Model Context Protocol servers, templates, tools and more.

提供 STDIO/HTTP 工具列举与调用、兼容 OpenAI Function 的轻量 PHP MCP Client.

Created 1/9/2026
Updated 1 day ago
Repository documentation and setup instructions

MCP PHP Runtime

一个解耦与我自己别的项目的的 MCP 客户端运行时(PHP 8.1+),支持 STDIO 与 HTTP/Streamable HTTP 传输。

特性

  • 支持 MCP initializenotifications/initialized → 业务请求的完整握手。
  • 双传输:STDIO(子进程 JSON-RPC)与 HTTP/Streamable HTTP
  • Tools 列表缓存、工具调用、OpenAI Function Calling 前缀化映射。
  • 用户/项目/自定义连接器配置合并,凭证校验,工具禁用列表。

快速使用

require __DIR__ . '/src/mcp_runtime.php';

// 加载 manifest
$manifest = mola_mcp_manifest(__DIR__ . '/src/mcp_manifest.example.json');

// MCP 配置
$userMcp = [
    'connectors' => [
        'github' => [
            'enabled' => true,
            'transport' => 'http',
            'credentials' => ['pat' => getenv('GITHUB_PAT')],
        ],
    ],
];

// 列出工具
$list = mola_mcp_get_all_enabled_tools('demo-user', $userMcp);

// 调用某个工具
$resp = mola_mcp_tools_call('github', 'list_repos', ['owner' => 'octocat'], 'demo-user', $userMcp);

环境变量与可配置项(可选)

  • MCP_TOOLS_CACHE_PATH:工具缓存目录,默认 src/mcp_tools_cache
  • MCP_TOOLS_CACHE_TTL:缓存秒数,默认 3600。
  • MCP_LOG_FILE:日志文件路径,默认 src/mcp_runtime.log
  • MCP_LOG_MAX_SIZE:日志轮转大小(字节),默认 10MB
  • MCP_LOG_ENABLED:启用文件日志(1/0)。
  • MCP_RUNTIME_PATH_BASE:STDIO 子进程 PATH 前缀,默认继承当前 PATH。
  • MCP_AMAP_PRESET_KEY:示例 Amap 连接器的预置 key(可留空)。

自定义连接器

userMcp['custom_connectors'][customId] 结构:

{
  "enabled": true,
  "title": "My HTTP MCP",
  "transport": "http", // or "sse"
  "config": { "url": "https://example.com/mcp" },
  "credentials": { "key": "xxx" },
  "auth": { "required": true, "type": "bearer", "fields": { "key": {"label":"API Key","required":true} } }
}

集成提示

  • 工具名前缀格式:mcp_{connectorId}__{toolName},避免冲突;旧格式保持兼容。(注意,这里是双下划线。)

许可证

MIT

Quick Setup
Installation guide for this server

Installation Command (package not published)

git clone https://github.com/MOLAaaaaaaa/mcp-php-runtime
Manual Installation: Please check the README for detailed setup instructions and any additional dependencies required.

Cursor configuration (mcp.json)

{ "mcpServers": { "molaaaaaaaa-mcp-php-runtime": { "command": "git", "args": [ "clone", "https://github.com/MOLAaaaaaaa/mcp-php-runtime" ] } } }