A hybrid Gemini Extension and MCP (Model Context Protocol) server that allows the Gemini CLI to interact with your WordPress site via the REST API.
This project enables you to manage your WordPress site directly from the Gemini CLI. It consists of:
- MCP Server: A Node.js/TypeScript server that implements the logic to communicate with the WordPress REST API.
- Gemini Extension: Configuration and custom command aliases that integrate the MCP server into your Gemini CLI workflow.
- List Posts: Retrieve recent blog posts with summaries.
- Get Post: Fetch full content and details of specific posts by ID.
- Create Post: Draft or publish new posts using natural language.
- Custom Aliases: User-friendly CLI commands like
wp listandwp create.
- Node.js (v18 or higher)
- npm or yarn
- A WordPress site with Application Passwords enabled (WP 5.6+).
-
Clone and Build the Server:
cd mcp-server npm install npm run build -
Configuration: This extension uses environment variables for authentication. You must configure
gemini-extension.jsonwith your specific WordPress details.-
Authentication Method: This extension uses Application Passwords for secure access.
-
Setup:
- Go to your WordPress Admin Dashboard > Users > Profile.
- Scroll down to "Application Passwords".
- Create a new password (e.g., named "Gemini CLI").
- Edit
gemini-extension.jsonin the root of this project:
"env": { "WORDPRESS_URL": "https://your-wordpress-site.com", "WORDPRESS_USERNAME": "your-username", "WORDPRESS_PASSWORD": "your-application-password" }
-
-
Register the Extension: To use this extension with the Gemini CLI, you need to register it.
- Local Install: Use the Gemini CLI command to point to the directory containing
gemini-extension.json.(Or follow the specific instructions for your version of the Gemini CLI to add local extensions).gemini install .
- Local Install: Use the Gemini CLI command to point to the directory containing
This extension acts as a bridge to the WordPress REST API. It currently supports the following endpoints and features:
- Authentication: Basic Auth using Application Passwords.
- Endpoints:
/wp-json/wp/v2/posts(GET, POST)- Used for listing, searching, and creating posts.
- Listing Posts: Fetches recent posts with support for pagination (
per_page) and status filtering (publish,draft, etc.). - Getting a Post: Retrieves full content for a specific post by its numeric ID.
- Creating Posts: Allows creating new posts with a Title, Content, and Status (defaults to 'draft').
Once installed, you can interact with your WordPress site using natural language or structured commands.
The extension comes with pre-defined aliases in commands/wp.toml for quick access:
-
List Posts:
gemini wp list
Fetches the 5 most recent posts.
-
Create Draft:
gemini wp create "My New Post Title" "This is the content of my new post."
Creates a new post in 'draft' status.
You can also ask Gemini to perform complex tasks involving the API:
- Fetch and Summarize:
"Fetch the latest 3 draft posts from WordPress and summarize them."
- Content Generation:
"Write a blog post about the top 5 coding tips for 2025 and save it as a draft on my WordPress site."
- Specific Retrieval:
"Get the content of post ID 123 and tell me if it mentions 'React'."
If you need raw data for scripting, you can often request it via the prompt:
"Get the last post and show me the raw JSON response."
- Fork the repository.
- Create a new feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'Add some amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.