Skip to content

webmasterarbez/gemini_cli_extention_wordpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Gemini CLI WordPress Extension

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.

Description

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.

Core Capabilities

  • 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 list and wp create.

Installation

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • A WordPress site with Application Passwords enabled (WP 5.6+).

Gemini Extension Installation & Setup

  1. Clone and Build the Server:

    cd mcp-server
    npm install
    npm run build
  2. Configuration: This extension uses environment variables for authentication. You must configure gemini-extension.json with your specific WordPress details.

    • Authentication Method: This extension uses Application Passwords for secure access.

    • Setup:

      1. Go to your WordPress Admin Dashboard > Users > Profile.
      2. Scroll down to "Application Passwords".
      3. Create a new password (e.g., named "Gemini CLI").
      4. Edit gemini-extension.json in the root of this project:
      "env": {
        "WORDPRESS_URL": "https://your-wordpress-site.com",
        "WORDPRESS_USERNAME": "your-username",
        "WORDPRESS_PASSWORD": "your-application-password"
      }
  3. 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.
      gemini install .
      (Or follow the specific instructions for your version of the Gemini CLI to add local extensions).

WordPress REST API Integration

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.

Supported Actions

  • 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').

Usage

Once installed, you can interact with your WordPress site using natural language or structured commands.

Command Aliases

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.

Natural Language Examples

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'."

JSON Output

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."

Contributing

  1. Fork the repository.
  2. Create a new feature branch (git checkout -b feature/amazing-feature).
  3. Commit your changes (git commit -m 'Add some amazing feature').
  4. Push to the branch (git push origin feature/amazing-feature).
  5. Open a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published