WaaSuP与您的网站
](https://php.net)    
WaaSuP (使用PHP的网站即服务器)-一种面向生产的、面向SaaS的PHP模型上下文协议(MCP)服务器实现。内置企业级功能,包括OAuth 2.1身份验证、实时服务器发送事件(SSE)和全面的工具管理。
🚀 现场试用
想看看WaaSuP的实际应用吗? 连接到我们的现场演示MCP服务器 使用您最喜欢的法学硕士或代理工具!
💬 与此存储库聊天
获得以下方面的即时帮助:
- ✅ 安装指南 -为您的环境逐步设置
- ⚙️ 配置协助 -数据库设置、OAuth、框架集成
- 🛠️ 定制工具开发 -构建特定于您的用例的工具
- 🐛 故障排除 -调试访问完整代码库的问题
- 📚 代码探索 -了解引擎盖下的功能是如何工作的
MCP服务器可以访问我们的整个存储库、文档和示例。随便问!
📡 实时MCP服务器
https://seolinkmap.com/mcp-repo
此公共MCP端点通过完整的网站即服务器实现(authless)展示了服务器的功能。
🔗 需要帮助连接?
MCP服务器新手? 了解如何连接: 如何连接到MCP服务器
连接后,您可以通过聊天浏览我们的整个存储库,并获得WaaSuP安装和配置的实时帮助。
建造于 SEOLink地图 -这是我们生产的“聊天和代理网络服务器”,为AI访问我们的整个SEO智能平台提供动力。
✨ 特性
- 🔐 OAuth 2.1身份验证 -完整的OAuth流程,支持MCP 2025-06-18的RFC 8707资源指示器
- ⚡ 多运输支持 -服务器发送事件(SSE)和流式HTTP用于实时消息传递
- 🛠️ 柔性刀具系统 -通过基于类和可调用的方法轻松注册工具
- 🏢 多租户架构 -SaaS应用程序的代理/用户上下文隔离
- 📊 生产就绪 -全面的日志记录、错误处理和会话管理
- 🔌 框架不可知 -PSR兼容Slim框架和Laravel集成
- 💾 数据库和内存存储 -针对不同部署场景的多个存储后端
- 🌐 CORS支持 -完全跨源资源共享配置
- 🎵 音频内容支持 -处理工具和提示中的音频内容(MCP 2025-03-26+)
- 📝 结构化用户输入 -收集结构化数据的激励支持(MCP 2025-06-18)
- 🔄 进度通知 -通过版本感知消息传递实时进度更新
- 🏷️ 工具注释 -丰富的工具元数据,便于更好地理解LLM(MCP 2025-03-26+)
- 📦 JSON-RPC批处理 -高效的批处理请求(MCP 2025-03-26)
需求
- PHP 8.1或更高版本
- 作曲家
- 数据库(MySQL/PostgreSQL推荐用于生产环境)
MCP协议合规性
WaaSuP通过自动特征门控在多个协议版本中实现了完整的MCP规范:
特征矩阵摘要
| 特征 | 2024-11-05 | 2025-03-26 | 2025-06-18 |
|---|---|---|---|
| 工具 | ✅ | ✅ | ✅ |
| 提示 | ✅ | ✅ | ✅ |
| 资源 | ✅ | ✅ | ✅ |
| 采样 | ✅ | ✅ | ✅ |
| 根 | ✅ | ✅ | ✅ |
| Ping | ✅ | ✅ | ✅ |
| 进度通知 | ✅ | ✅ | ✅ |
| 工具注释 | ❌ | ✅ | ✅ |
| 音频内容 | ❌ | ✅ | ✅ |
| 完工 | ❌ | ✅ | ✅ |
| JSON-RPC批处理 | ❌ | ✅ | ❌ |
| OAuth 2.1 | ❌ | ❌ | ✅ |
| 激励 | ❌ | ❌ | ✅ |
| 结构化输出 | ❌ | ❌ | ✅ |
| 资源链接 | ❌ | ❌ | ✅ |
| 资源指示器(RFC 8707) | ❌ | ❌ | ✅ (必填) |
安装
composer require seolinkmap/waasup
# For PSR-3 logging support
composer require monolog/monolog
# For Slim Framework integration
composer require slim/slim slim/psr7数据库设置
- 导入数据库架构:
1. Open `examples/database/database-schema.sql`
2. Use either MySQL section OR PostgreSQL section (not both)
3. Customize table names/prefixes as needed
4. Create only the tables you need (if using your own table mapping)- 创建您的第一个代理机构:
INSERT INTO mcp_agencies (uuid, name, active)
VALUES ('550e8400-e29b-41d4-a716-446655440000', 'My Company', 1);- 创建OAuth令牌:
INSERT INTO mcp_oauth_tokens (
access_token, scope, expires_at, agency_id
) VALUES (
'your-secret-token-here',
'mcp:read mcp:write',
DATE_ADD(NOW(), INTERVAL 1 YEAR),
1
);快速开始
基本服务器设置
PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
// Initialize components
$storage = new DatabaseStorage($pdo, ['table_prefix' => 'mcp_']);
$toolRegistry = new ToolRegistry();
$promptRegistry = new PromptRegistry();
$resourceRegistry = new ResourceRegistry();
$responseFactory = new ResponseFactory();
$streamFactory = new StreamFactory();
// Configuration
$config = [
'server_info' => [
'name' => 'My MCP Server',
'version' => '0.0.7'
],
'auth' => [
'context_types' => ['agency'],
'base_url' => 'https://your-domain.com'
]
];
// Create MCP provider
$mcpProvider = new SlimMCPProvider(
$storage, $toolRegistry, $promptRegistry, $resourceRegistry,
$responseFactory, $streamFactory, $config
);
// Setup Slim app
$app = AppFactory::create();
$app->addErrorMiddleware(true, true, true);
// OAuth discovery endpoints
$app->get('/.well-known/oauth-authorization-server',
[$mcpProvider, 'handleAuthDiscovery']);
// Main MCP endpoint
$app->map(['GET', 'POST', 'OPTIONS'], '/mcp/{agencyUuid}[/{sessID}]',
[$mcpProvider, 'handleMCP'])
->add($mcpProvider->getAuthMiddleware());
$app->run();添加工具
简单可调用工具
$toolRegistry->register('get_weather', function($params, $context) {
$location = $params['location'] ?? 'Unknown';
return [
'location' => $location,
'temperature' => '22°C',
'condition' => 'Sunny'
];
}, [
'description' => 'Get weather information for a location',
'inputSchema' => [
'type' => 'object',
'properties' => [
'location' => ['type' => 'string', 'description' => 'Location name']
],
'required' => ['location']
]
]);内置工具
use Seolinkmap\Waasup\Tools\Built\{PingTool, ServerInfoTool};
$toolRegistry->registerTool(new PingTool());
$toolRegistry->registerTool(new ServerInfoTool($config));添加提示和资源
// Register a prompt
$promptRegistry->register('greeting', function($arguments, $context) {
$name = $arguments['name'] ?? 'there';
return [
'description' => 'A friendly greeting prompt',
'messages' => [[
'role' => 'user',
'content' => [['type' => 'text', 'text' => "Please greet {$name}."]]
]]
];
});
// Register a resource
$resourceRegistry->register('server://status', function($uri, $context) {
return [
'contents' => [[
'uri' => $uri,
'mimeType' => 'application/json',
'text' => json_encode(['status' => 'healthy', 'timestamp' => date('c')])
]]
];
});框架集成
Laravel集成
将服务提供者添加到Laravel应用程序中:
// config/app.php
'providers' => [
Seolinkmap\Waasup\Integration\Laravel\LaravelServiceProvider::class,
],注册路由并使用提供的控制器模式。查看完整的Laravel集成示例 /examples 目录。
独立式(PSR-7)
use Seolinkmap\Waasup\MCPSaaSServer;
$server = new MCPSaaSServer($storage, $toolRegistry, $promptRegistry, $resourceRegistry, $config, $logger);
$response = $server->handle($request, $response);配置
服务器配置
$config = [
'supported_versions' => ['2025-06-18', '2025-03-26', '2024-11-05'],
'server_info' => [
'name' => 'Your MCP Server',
'version' => '0.0.7'
],
'auth' => [
'context_types' => ['agency', 'user'],
'validate_scope' => true,
'required_scopes' => ['mcp:read'],
'base_url' => 'https://your-domain.com'
],
'sse' => [
'keepalive_interval' => 1,
'max_connection_time' => 1800,
'switch_interval_after' => 60
]
];存储选项
数据库存储(生产)
$storage = new DatabaseStorage($pdo, [
'table_prefix' => 'mcp_',
'cleanup_interval' => 3600
]);内存存储(开发/测试)
$storage = new MemoryStorage();
// Add test data
$storage->addContext('550e8400-e29b-41d4-a716-446655440000', 'agency', [
'id' => 1, 'name' => 'Test Agency', 'active' => true
]);OAuth 2.1和身份验证
WaaSuP为MCP 2025-06-18实现了完整的OAuth 2.1和RFC 8707资源指示符:
- 授权码流 带PKCE(必需)
- 资源指标 用于将令牌绑定到特定MCP端点
- 社交认证 通过谷歌、领英和GitHub
- 令牌验证 包括受众声明和范围检查
- 发现端点 用于客户端配置
可以为每个提供者配置社交身份验证:
$config['google'] = [
'client_id' => 'your-google-client-id',
'client_secret' => 'your-google-client-secret',
'redirect_uri' => 'https://your-domain.com/oauth/google/callback'
];高级功能
音频内容处理(MCP 2025-03-26+)
use Seolinkmap\Waasup\Content\AudioContentHandler;
// In your tool
return [
'content' => [
['type' => 'text', 'text' => 'Here is the audio file:'],
AudioContentHandler::createFromFile('/path/to/audio.mp3', 'example.mp3')
]
];结构化用户输入(MCP 2025-06-18)
// Request structured input from user
$requestId = $server->requestElicitation(
$sessionId,
'Please provide your contact information',
[
'type' => 'object',
'properties' => [
'name' => ['type' => 'string'],
'email' => ['type' => 'string', 'format' => 'email']
]
]
);进度通知
// Send progress updates during long-running operations
$server->sendProgressNotification($sessionId, 50, 'Processing data...');api参考
MCP方法
| 方法 | 描述 | 支持的版本 |
|---|---|---|
initialize | 初始化MCP会话 | 全部 |
ping | 健康检查 | 全部 |
tools/list | 列出可用工具 | 全部 |
tools/call | 执行工具 | 全部 |
prompts/list | 列出可用提示 | 全部 |
prompts/get | 获取提示 | 全部 |
resources/list | 列出可用资源 | 全部 |
resources/read | 阅读资源 | 全部 |
completion/complete | 获取参数的补全 | 全部 |
sampling/createMessage | 请求LLM采样 | 全部 |
roots/list | 列出可用的根目录 | 全部 |
elicitation/create | 请求用户输入 | 2025-06-18 |
错误代码
| 代码 | 描述 |
|---|---|
-32000 | 需要身份验证 |
-32001 | 需要会话 |
-32600 | 无效请求 |
-32601 | 未找到方法 |
-32602 | 无效参数 |
-32603 | 内部错误 |
-32700 | 解析错误 |
测试
# Run tests
composer test
# Static analysis
composer analyse
# Code formatting
composer format安全
- 令牌验证:所有请求都需要具有适当受众验证的有效OAuth令牌
- 范围检查:用于细粒度访问控制的可配置范围验证
- SQL注入保护:所有数据库查询都使用预先准备好的语句
- 会话安全:加密安全会话ID生成
- CORS配置:跨源请求的可配置CORS策略
- DNS重新绑定保护:本地主机端点的Origin标头验证
部署
码头工人
FROM php:8.1-fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql
COPY . /var/www/html
WORKDIR /var/www/html
RUN composer install --no-dev --optimize-autoloader
EXPOSE 9000
CMD ["php-fpm"]Nginx配置
server {
listen 80;
server_name your-mcp-server.com;
root /var/www/html/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# SSE connection timeout
location /mcp/ {
proxy_read_timeout 1800s;
proxy_send_timeout 1800s;
}
}贡献
我们欢迎捐款!此服务器在生产中被积极使用 SEOLink地图 它为我们的SEO智能平台提供动力。
- 分叉存储库
- 创建要素分支(
git checkout -b feature/amazing-feature) - 进行更改
- 添加新功能的测试
- 确保所有测试通过(
composer test) - 提交您的更改(
git commit -m 'Add amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
发展
git clone https://github.com/seolinkmap/waasup.git
cd waasup
composer install
cp .env.example .env
# Configure your .env file
php -S localhost:8000 -t examples/slim-framework/许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
致谢
- Anthropic 用于模型上下文协议规范
- 模型上下文协议.io 用于官方MCP文档和模式
- PHP-FIG PSR标准
- 超薄框架 优秀的HTTP基础
支持与社区
- 🌐 现场演示: https://seolinkmap.com/mcp-repo(使用WaaSuP服务器与WaaSuP存储库聊天…帮助、安装、工具构建)
- 📖 文档:
- 🐛 问题:
- 💬 讨论:
内置于❤️ 靠近 SEOLink地图 对于MCP社区来说。
