ednark/mcp-drupal-ts
If you are the rightful owner of mcp-drupal-ts and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server that provides tools and resources for searching and accessing Drupal and PHP documentation.
MCP Drupal Documentation Server
A Model Context Protocol (MCP) server that provides tools and resources for searching and accessing Drupal and PHP documentation.
Overview
This project implements an MCP server that allows AI assistants to search and retrieve information from Drupal and PHP documentation. It follows a strict Test-Driven Development (TDD) approach to ensure high code quality and comprehensive test coverage.
Features
- MCP server implementation following the Model Context Protocol specification
- Tools for searching Drupal and PHP documentation
- Resources for accessing documentation content
- Custom file-based vector database integration for semantic search
- Comprehensive test suite with high coverage
Project Structure
mcp-drupal-ts/
āāā src/ # Source code
ā āāā mcp/ # MCP server implementation
ā ā āāā tools/ # MCP tools
ā ā āāā resources/ # MCP resources
ā āāā types/ # TypeScript type definitions
ā āāā index.ts # Entry point
āāā tests/ # Test files
ā āāā unit/ # Unit tests
ā āāā integration/ # Integration tests
āāā docs/ # Documentation
ā āāā README.md # Documentation index
āāā README.md # This file
Test-Driven Development
This project follows a strict Test-Driven Development (TDD) approach. All features and bug fixes must be implemented following the TDD process:
- Write tests first
- Run tests to verify they fail
- Implement minimal code to make tests pass
- Refactor while maintaining passing tests
For detailed information about the TDD process in this project, see the .
Getting Started
Prerequisites
- Node.js 18 or higher
- npm 8 or higher
Installation
-
Clone the repository:
git clone https://github.com/yourusername/mcp-drupal-ts.git cd mcp-drupal-ts
-
Install dependencies:
npm install
-
Build the project:
npm run build
Running Tests
Run all tests:
npm test
Run unit tests only:
npm run test:unit
Run integration tests only:
npm run test:integration
Generate coverage report:
npm run test:coverage
Running the Server
Start the MCP server:
npm start
For development with automatic rebuilding:
npm run dev
Usage
The MCP server can be used by AI assistants that support the Model Context Protocol. It provides tools and resources for searching and accessing Drupal and PHP documentation.
MCP Server for RooCode
This project can be used as an MCP server for RooCode, providing semantic search capabilities for PHP and Drupal documentation. For detailed instructions, see the .
Documentation Pipeline
The project includes a documentation pipeline that collects, processes, and imports Drupal and PHP documentation:
-
Collect documentation from sources
npm run collect-php-docs npm run collect-drupal-docs
-
Convert documentation to markdown format
npm run markdown-php-docs npm run markdown-drupal-docs
-
Import documentation into the database
npm run import-docs
-
Run the entire pipeline
npm run docs-pipeline
Vector Search
The project uses a custom file-based vector database for semantic search capabilities:
- Search documentation with semantic search
npm run search-docs -- "your search query"
The vector database is a simple JSON-based storage system that doesn't require a separate server process.
For more details about the vector database integration, see the .
Vector Database Release Management
This project implements a release-based distribution approach for vector database files. Instead of storing large vector database files in the Git repository, they are managed through GitHub releases and downloaded automatically when needed.
Architecture Overview
The vector database release system consists of several components:
- Version Management: A
vector-db-version.json
file tracks metadata about vector files, including versions, checksums, and compatibility information - Development Setup: Tools to set up a development environment with the necessary vector files
- Release Building: Scripts to build and publish new vector database releases
- Deployment: Scripts to ensure vector files are present during deployment
- CI/CD Integration: GitHub Actions workflows to automate the release process
This approach provides several benefits:
- Keeps the Git repository small and manageable
- Ensures all developers use the same vector database files
- Provides versioning and compatibility checks
- Enables easy updates with integrity verification
Vector Database Version System
The system uses semantic versioning for vector database releases, independent from the main application version. Vector file metadata is stored in vector-db-version.json
:
{
"version": "0.1.0", // Semantic version of the vector database
"releaseDate": "2025-05-12", // Last update date
"compatibility": { // App version compatibility range
"minAppVersion": "0.1.0",
"maxAppVersion": null
},
"files": { // Vector files included in this version
"drupal-vectors.json": {
"size": 0,
"checksum": "",
"lastUpdated": "2025-05-12",
"description": "Drupal documentation vector embeddings"
},
"php-vectors.json": {
"size": 0,
"checksum": "",
"lastUpdated": "2025-05-12",
"description": "PHP documentation vector embeddings"
}
},
"repositoryInfo": { // Repository information for downloads
"owner": "your-github-username",
"repo": "mcp-drupal-ts",
"releasesUrl": "https://github.com/your-github-username/mcp-drupal-ts/releases"
}
}
When the application runs, it checks for these vector files and downloads them if they're missing or corrupted.
Development Workflow
Setting Up the Development Environment
When you first clone the repository or need to refresh your vector files:
# Install dependencies and auto-setup vector files (runs after npm install)
npm install
# Or manually set up the development environment
npm run setup:dev
# Force redownload of all vector files
npm run setup:dev:force
The setup script:
- Checks if vector database files are present
- Downloads missing files from GitHub releases
- Verifies file integrity using checksums
- Reports the status of all files
Creating a New Vector Database Release
When you need to create a new vector release (e.g., after updating embeddings):
# Build a release with patch version increment (0.1.0 ā 0.1.1)
npm run vector:build-release:patch
# Build a release with minor version increment (0.1.0 ā 0.2.0)
npm run vector:build-release:minor
# Build a release with major version increment (0.1.0 ā 1.0.0)
npm run vector:build-release:major
# Or specify the increment type as an argument
npm run vector:build-release -- minor
The release builder:
- Increments the version based on the specified type
- Updates file metadata (size, checksum, date)
- Creates a release bundle in the
dist/vector-release
directory - Provides instructions for publishing the release on GitHub
After building:
- Commit the updated
vector-db-version.json
file - Tag the commit with
vector-db-v{version}
(e.g.,vector-db-v0.2.0
) - Create a GitHub release with the files from
dist/vector-release
Deploying with Vector Files
When deploying the application:
# Deploy with automatic vector file management
npm run deploy
# Or directly
bash scripts/deploy-with-vectors.sh
The deployment script:
- Reads the vector database version information
- Checks for each required vector file
- Downloads missing files from GitHub releases
- Continues with the deployment process
This ensures that all necessary vector files are available before the application starts.
CI/CD with GitHub Actions
The project includes a GitHub Actions workflow for automated vector database releases:
Manual Trigger
You can manually trigger a release from the GitHub Actions tab:
- Select the "Vector Database Release" workflow
- Click "Run workflow"
- Choose a version increment type (major, minor, patch)
- Optionally enable automatic GitHub release creation
Automatic Trigger
Pushing a tag with the format vector-db-v*
(e.g., vector-db-v0.2.0
) will also trigger the workflow:
git tag vector-db-v0.2.0
git push origin vector-db-v0.2.0
The workflow:
- Builds the application
- Generates vector database files (if manually triggered)
- Updates version information
- Creates a GitHub release with the vector files
- Optionally commits changes to the version file
NPM Script Reference
Vector Database Management:
setup:dev
: Set up development environment with vector filessetup:dev:force
: Force redownload all vector filesvector:build-release
: Build vector release (default: patch)vector:build-release:patch
: Build vector release with patch incrementvector:build-release:minor
: Build vector release with minor incrementvector:build-release:major
: Build vector release with major incrementdeploy
: Deploy with automatic vector file management
Related Documentation Scripts:
docs-pipeline
: Run the complete documentation processing pipelineimport-docs
: Import documentation into vector databasesearch-docs
: Search documentation using semantic search
Troubleshooting Common Issues
Missing Vector Files
- Issue: Application reports missing vector files
- Solution: Run
npm run setup:dev
to download vector files
Checksum Validation Failure
- Issue: Vector file fails checksum validation
- Solution: Run
npm run setup:dev:force
to force redownload all files
GitHub Release Not Found
- Issue: Cannot download vector files from GitHub release
- Solution: Check that the repository information in
vector-db-version.json
is correct and that the GitHub release exists
Permission Denied for deploy-with-vectors.sh
- Issue: Cannot execute the deployment script
- Solution: Make the script executable with
chmod +x scripts/deploy-with-vectors.sh
jq Not Found Error in Deployment Script
- Issue: Deployment script reports jq not found
- Solution: This is just a warning; the script will fall back to Node.js for JSON parsing
Semantic Search via MCP
The vector database powers a semantic search tool that is exposed through the MCP server. This allows AI assistants like RooCode to perform semantic searches on the documentation:
{
"id": "789",
"jsonrpc": "2.0",
"method": "call_tool",
"params": {
"name": "semantic-docs-search",
"arguments": {
"query": "How to apply a function to each element of an array?"
}
}
}
The MCP server can be used by AI assistants that support the Model Context Protocol. It provides tools and resources for searching and accessing Drupal and PHP documentation.
Example Tool Usage
{
"id": "123",
"jsonrpc": "2.0",
"method": "call_tool",
"params": {
"name": "drupal-docs-search",
"arguments": {
"query": "hook_form_alter"
}
}
}
Example Resource Access
{
"id": "456",
"jsonrpc": "2.0",
"method": "read_resource",
"params": {
"uri": "drupal-docs://api/hook_form_alter"
}
}
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Follow the TDD process (write tests first!)
- Submit a pull request
For more details, see the .
Development Guidelines
- Follow the TDD process for all changes
- Maintain high test coverage (minimum 80%)
- Follow TypeScript best practices
- Use ESLint for code quality
License
This project is licensed under the MIT License - see the file for details.
Acknowledgments
- The Model Context Protocol team for the MCP specification
- The Drupal community for their excellent documentation