Contributing to PHP MCP SDK โ
Thank you for your interest in contributing to the PHP MCP SDK! This guide will help you get started with contributing to the project.
๐ค How to Contribute โ
There are many ways to contribute to the PHP MCP SDK:
- Report bugs and request features
- Improve documentation and examples
- Submit code improvements and new features
- Help other users in discussions and issues
- Share your projects built with the SDK
๐ Before You Start โ
Code of Conduct โ
This project follows a Code of Conduct to ensure a welcoming environment for all contributors. Please read and follow our community guidelines.
Getting Familiar โ
Before contributing, please:
- Read the documentation
- Try the examples
- Understand the MCP protocol
- Review existing issues
๐ Reporting Issues โ
Bug Reports โ
When reporting bugs, please include:
- Clear description of the issue
- Steps to reproduce the problem
- Expected vs actual behavior
- Environment details (PHP version, OS, etc.)
- Code samples that demonstrate the issue
Feature Requests โ
For new features, please describe:
- Use case and problem it solves
- Proposed solution or implementation approach
- Alternative approaches considered
- Impact on existing functionality
๐ ๏ธ Development Setup โ
Prerequisites โ
- PHP 8.1 or higher
- Composer
- Git
Setting Up Your Environment โ
Fork the repository on GitHub
Clone your fork locally:
bashgit clone https://github.com/your-username/php-mcp-sdk.git cd php-mcp-sdk
Install dependencies:
bashcomposer install
Run tests to ensure everything works:
bashcomposer test
Development Workflow โ
Create a feature branch:
bashgit checkout -b feature/your-feature-name
Make your changes following our coding standards
Add tests for your changes
Run the test suite:
bashcomposer test composer test:coverage
Check code quality:
bashcomposer lint composer analyze
Commit your changes:
bashgit add . git commit -m "Add: your descriptive commit message"
Push to your fork:
bashgit push origin feature/your-feature-name
Create a Pull Request on GitHub
๐ Coding Standards โ
PHP Standards โ
We follow these coding standards:
- PSR-12 for code style
- PSR-4 for autoloading
- PHPDoc for documentation
- Type declarations for all parameters and return types
Code Style โ
<?php
declare(strict_types=1);
namespace MCP\Example;
use MCP\Server\McpServer;
use MCP\Types\Implementation;
/**
* Example class demonstrating coding standards.
*/
class ExampleClass
{
private string $property;
public function __construct(string $property)
{
$this->property = $property;
}
/**
* Example method with proper documentation.
*/
public function exampleMethod(array $parameters): array
{
return [
'property' => $this->property,
'parameters' => $parameters,
];
}
}
Naming Conventions โ
- Classes: PascalCase (
McpServer
,TransportInterface
) - Methods: camelCase (
executeTask
,validateInput
) - Properties: camelCase (
$serverName
,$connectionPool
) - Constants: SCREAMING_SNAKE_CASE (
MAX_CONNECTIONS
,DEFAULT_TIMEOUT
)
๐งช Testing Guidelines โ
Test Structure โ
<?php
declare(strict_types=1);
namespace MCP\Tests\Server;
use MCP\Server\McpServer;
use MCP\Types\Implementation;
use PHPUnit\Framework\TestCase;
class McpServerTest extends TestCase
{
private McpServer $server;
protected function setUp(): void
{
$this->server = new McpServer(
new Implementation('test-server', '1.0.0')
);
}
public function testServerCreation(): void
{
$this->assertInstanceOf(McpServer::class, $this->server);
}
public function testToolRegistration(): void
{
$this->server->tool(
'test-tool',
'Test tool description',
['type' => 'object'],
fn($args) => ['result' => 'success']
);
$tools = $this->server->getTools();
$this->assertCount(1, $tools);
$this->assertEquals('test-tool', $tools[0]['name']);
}
}
Test Categories โ
- Unit Tests: Test individual classes and methods
- Integration Tests: Test component interactions
- Feature Tests: Test complete features end-to-end
- Performance Tests: Test performance characteristics
Running Tests โ
# Run all tests
composer test
# Run specific test suite
composer test -- --testsuite=Unit
# Run with coverage
composer test:coverage
# Run performance tests
composer test:performance
๐ Documentation โ
Documentation Standards โ
- Clear and concise explanations
- Code examples for all features
- Real-world use cases when possible
- API documentation for all public methods
Documentation Structure โ
# Feature Name
Brief description of the feature.
## Overview
Detailed explanation of what the feature does and why it's useful.
## Basic Usage
```php
// Simple example
$example = new ExampleClass();
$result = $example->doSomething();
```
Advanced Usage โ
// More complex example with configuration
$example = new ExampleClass([
'option1' => 'value1',
'option2' => 'value2',
]);
API Reference โ
Methods โ
doSomething(array $parameters): array
โ
Description of what the method does.
Parameters:
$parameters
(array): Description of parameters
Returns:
array
: Description of return value
Example:
$result = $example->doSomething(['key' => 'value']);
## ๐ Pull Request Process
### Before Submitting
- [ ] Tests pass locally
- [ ] Code follows style guidelines
- [ ] Documentation is updated
- [ ] CHANGELOG.md is updated
- [ ] No merge conflicts with main branch
### Pull Request Template
When creating a pull request, please include:
```markdown
## Description
Brief description of changes and motivation.
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that causes existing functionality to change)
- [ ] Documentation update
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Manual testing completed
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] CHANGELOG.md updated
Review Process โ
- Automated checks must pass (tests, linting, etc.)
- Code review by maintainers
- Discussion and feedback incorporation
- Final approval and merge
๐๏ธ Architecture Guidelines โ
Design Principles โ
- Single Responsibility: Each class should have one reason to change
- Open/Closed: Open for extension, closed for modification
- Dependency Injection: Use constructor injection for dependencies
- Interface Segregation: Prefer small, focused interfaces
- Type Safety: Use strict types throughout
Project Structure โ
src/
โโโ Client/ # MCP client implementations
โโโ Server/ # MCP server implementations
โโโ Shared/ # Shared components
โโโ Types/ # Type definitions and schemas
โโโ Transport/ # Transport layer implementations
โโโ Validation/ # Input validation and schemas
โโโ Utils/ # Utility classes
tests/
โโโ Unit/ # Unit tests
โโโ Integration/ # Integration tests
โโโ Feature/ # Feature tests
โโโ Performance/ # Performance tests
examples/
โโโ server/ # Server examples
โโโ client/ # Client examples
โโโ real-world/ # Real-world applications
๐ฏ Contribution Areas โ
High Priority โ
- Performance optimizations
- Additional transport implementations
- Enhanced error handling
- More comprehensive examples
- Documentation improvements
Medium Priority โ
- Framework integrations (Symfony, CakePHP, etc.)
- Additional validation schemas
- Monitoring and observability tools
- Development utilities
Ideas Welcome โ
- Creative examples and use cases
- Performance benchmarks
- Security enhancements
- Developer experience improvements
๐ Recognition โ
Contributors are recognized in:
- README.md contributors section
- CHANGELOG.md for significant contributions
- GitHub releases for major features
- Documentation for examples and guides
๐ Getting Help โ
Community Support โ
- GitHub Discussions: General questions and ideas
- GitHub Issues: Bug reports and feature requests
- Discord/Slack: Real-time community chat (if available)
Direct Contact โ
For sensitive issues or private discussions:
- Email: maintainers@example.com
๐ Legal โ
Licensing โ
By contributing to this project, you agree that your contributions will be licensed under the same license as the project (MIT License).
Copyright โ
Please ensure you have the right to contribute any code or content you submit.
๐ Release Process โ
Versioning โ
We follow Semantic Versioning:
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
Release Cycle โ
- Regular releases every 2-4 weeks
- Hotfix releases for critical bugs
- Major releases for significant changes
Thank you for contributing to PHP MCP SDK! Your contributions help make AI development more accessible and powerful for the PHP community. ๐