mcp_client
Note that extensive parts of this module was generating via AI coding agents under human supervision.
INTRODUCTION
The MCP Client module enables Drupal to connect to Model Context Protocol (MCP) servers and expose their tools to AI modules. MCP is a standardized protocol for communication between AI applications and external tools/data sources.
This module integrates with the Drupal AI module to provide seamless access to MCP server capabilities, allowing AI agents to use external tools like file systems, databases, APIs, and more.
-
For a full description of the module, visit the project page: https://www.drupal.org/project/mcp_client
-
To submit bug reports and feature suggestions, or track changes: https://www.drupal.org/project/issues/mcp_client
REQUIREMENTS
This module requires the following:
- PHP 8.2 or higher (required by Swis MCP Client library)
- Drupal core 10.3+ or 11+
- AI module (https://www.drupal.org/project/ai) 1.2.x or higher
- AI Agents module (https://www.drupal.org/project/ai) 1.2.x or higher
- Key module (https://www.drupal.org/project/key) 1.18 or higher
- SWIS MCP Client library (swisnl/mcp-client automatically installed via Composer)
INSTALLATION
Install as you would normally install a contributed Drupal module. For further information, see: https://www.drupal.org/docs/extending-drupal/installing-drupal-modules
composer require drupal/mcp_client
drush en mcp_client -y
CONFIGURATION
HTTP Transport (Remote MCP Server)
Use this transport type for MCP servers accessible via HTTP/HTTPS.
- Navigate to Administration > Configuration > AI > MCP Servers (
/admin/structure/mcp-server) - Click "Add MCP Server"
- Fill in the following fields:
- Label: A descriptive name (e.g., "GitHub MCP Server")
- Transport Type: Select "HTTP (Streamable HTTP)"
- Endpoint URL: Your MCP server URL (e.g.,
https://example.com/mcp) - Timeout: Connection timeout in seconds (default: 30)
- Click "Save"
- Edit the server configuration to enable specific tools
- Enabled tools are now available in the AI API Explorer
STDIO Transport (Local Process)
Use this transport type for running MCP servers as local processes (Node.js, Python, etc.).
- Navigate to Administration > Configuration > AI > MCP Servers
- Click "Add MCP Server"
- Fill in the following fields:
- Label: A descriptive name
- Transport Type: Select "STDIO (Process)"
- Command: Full command to execute (e.g.,
node /path/to/server.js) - Working Directory: Optional working directory for the process
- Environment Variables: Add environment variables as name-value pairs
- For sensitive values (API keys, tokens), use Key module references
- For non-sensitive values, use plain text
- Click "Save"
- Edit the server configuration to enable specific tools
Environment Variables with Key Module
For secure handling of API keys and other sensitive data:
- Install and enable the Key module (automatically required by this module)
- Create keys at Administration > Configuration > System > Keys
- When configuring environment variables in MCP Server settings:
- Name: The environment variable name (e.g., API_KEY)
- Type: Select "Key"
- Key: Choose the key you created
- For non-sensitive variables, select "Plain text" and enter the value directly
FEATURES
- Multiple Transport Types: Supports both HTTP and STDIO (local process) connections
- No Middleware Required: Direct connection to MCP servers for HTTP transport
- AI Module Integration: Seamlessly integrates with Drupal AI module's function calling system
- Tool Management: Easy-to-use UI for enabling/disabling specific tools per server
- Multiple Servers: Connect to multiple MCP servers simultaneously
- Secure Credential Management: Integration with Key module for secure storage of API keys and sensitive environment variables
- Dynamic Plugin System: Tools from MCP servers are automatically discovered and exposed as AI function call plugins
DOCUMENTATION
For more details, look at the 📚 Complete Documentation.