=== Botailor ModelContext Integrator for AI ===
Contributors: hamidxazad
Tags: api, rest, ai, mcp, content
Requires at least: 5.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Author: Hamid Azad
Author URI: https://github.com/hamidhosenazad
Donate link: https://github.com/hamidhosenazad


Expose selected posts & pages as AI-readable endpoints via the Model Context Protocol (MCP) with granular permission control and full CRUD operations.

== Description ==

Botailor ModelContext Integrator for AI is a powerful WordPress plugin that exposes selected posts and pages as AI-readable endpoints via the Model Context Protocol (MCP). This plugin provides a clean, secure way to make your WordPress content available to AI systems, external applications, and other services that need structured access to your content.

The plugin features granular permission control, allowing you to set specific permissions (Read, Write, Update, Delete) for each piece of content, ensuring your data remains secure while providing flexible access for authorized applications.

= Features =

* **Selective Content Exposure**: Choose which posts and pages to expose via the API
* **Granular Permission Control**: Set individual permissions (Read, Write, Update, Delete) for each content item
* **Full CRUD Operations**: Create, Read, Update, and Delete posts and pages via API
* **REST API Endpoints**: Clean, standardized endpoints under `/wp-json/mcia/v1/`
* **Master Endpoint**: List all available endpoints with `/wp-json/mcia/v1/endpoints`
* **Manifest Endpoint**: Auto-generated manifest at `/wp-json/mcia/v1/manifest` and `/.well-known/mcp-manifest.json`
* **Admin Interface**: Easy-to-use settings page with search, pagination, and bulk actions
* **Security**: Built-in authentication, nonces, and capability checks
* **WooCommerce Filtering**: Automatically excludes WooCommerce products and pages
* **Real-time Updates**: Changes take effect immediately

= API Endpoints =

**Read Operations:**
* `GET /wp-json/mcia/v1/manifest` - Get manifest (all exposed content)
* `GET /wp-json/mcia/v1/endpoints` - List all available endpoints
* `GET /wp-json/mcia/v1/{slug}` - Get individual content by slug

**CRUD Operations (Require Authentication):**
* `POST /wp-json/mcia/v1/posts` - Create new post
* `PUT /wp-json/mcia/v1/posts/{id}` - Update existing post
* `DELETE /wp-json/mcia/v1/posts/{id}` - Delete post
* `POST /wp-json/mcia/v1/pages` - Create new page
* `PUT /wp-json/mcia/v1/pages/{id}` - Update existing page
* `DELETE /wp-json/mcia/v1/pages/{id}` - Delete page

**Well-known Endpoint:**
* `GET /.well-known/mcp-manifest.json` - Public manifest (no authentication required)

= Response Format =

Each content endpoint returns:

```json
{
  "title": "Page/Post title",
  "content": "Page/Post content",
  "content_html": "HTML formatted content",
  "description": "Short description",
  "slug": "content-slug",
  "type": "post|page",
  "status": "publish",
  "date": "2024-01-01 00:00:00",
  "modified": "2024-01-01 00:00:00",
  "author": "Author Name",
  "featured_image": "image-url",
  "meta": {},
  "url": "permalink"
}
```

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/botailor-modelcontext-integrator-ai` directory, or install the plugin through the WordPress plugins screen directly.
2. Activate the plugin through the 'Plugins' screen in WordPress
3. Go to Settings > Botailor ModelContext Integrator for AI to configure authentication and exposed content
4. Set up API credentials (username and password) for secure access
5. Configure which posts and pages to expose and set their permissions
6. Test the API endpoints using the provided examples

== Testing the Plugin ==

### Quick Test Setup

1. **Configure Authentication:**
   - Go to Settings > Botailor ModelContext Integrator for AI
   - Set a username and password for API access
   - Save the credentials

2. **Enable Content:**
   - Select which posts/pages to expose
   - Set permissions (Read, Write, Update, Delete) for each item
   - Use bulk actions to enable multiple items at once

3. **Test Read Operations:**
   ```bash
   # Test manifest (no auth required)
   curl "http://yoursite.com/.well-known/mcp-manifest.json"
   
   # Test authenticated manifest
   curl -u "username:password" "http://yoursite.com/wp-json/mcia/v1/manifest"
   
   # Test individual content
   curl -u "username:password" "http://yoursite.com/wp-json/mcia/v1/your-post-slug"
   ```

4. **Test CRUD Operations:**
   ```bash
   # Create a new post
   curl -u "username:password" -X POST "http://yoursite.com/wp-json/mcia/v1/posts" \
     -H "Content-Type: application/json" \
     -d '{"title": "Test Post", "content": "Test content", "status": "publish"}'
   
   # Update a post (replace {id} with actual post ID)
   curl -u "username:password" -X PUT "http://yoursite.com/wp-json/mcia/v1/posts/{id}" \
     -H "Content-Type: application/json" \
     -d '{"title": "Updated Title", "content": "Updated content"}'
   
   # Delete a post (replace {id} with actual post ID)
   curl -u "username:password" -X DELETE "http://yoursite.com/wp-json/mcia/v1/posts/{id}"
   ```

5. **Test Permission System:**
   - Try to update/delete content that only has "Read" permission
   - Verify that operations are blocked with proper error messages
   - Test that content with appropriate permissions works correctly

### Expected Results

- **Manifest**: Should list all exposed content with metadata
- **Individual Content**: Should return full post/page data with permissions
- **CRUD Operations**: Should respect permission settings and authentication
- **Error Handling**: Should return clear error messages for unauthorized operations

== Frequently Asked Questions ==

= How do I enable content for the API? =

Go to Settings > Botailor ModelContext Integrator for AI in your WordPress admin. You'll see lists of all your published posts and pages. Check the boxes next to the content you want to expose via the API.

= What's the difference between the content and content_html fields? =

The `content` field contains plain text (HTML tags stripped), while `content_html` contains the full HTML formatted content.

= Is the API secure? =

Yes! The plugin includes proper nonce verification, capability checks, and only exposes content that you explicitly enable. All data is sanitized and validated.

= Can I customize the API response? =

The plugin follows WordPress coding standards and can be extended with custom filters and actions for advanced customization.

== Screenshots ==

1. Admin settings page showing posts and pages with enable/disable options
2. Bulk actions for enabling/disabling multiple items
3. API response example showing the JSON format

== Changelog ==

= 1.0.0 =
* Initial release
* Basic content exposure functionality
* Admin interface for managing exposed content
* REST API endpoints
* Security features and validation


= 1.0.0 =
Initial release of Botailor ModelContext Integrator for AI plugin.

== Development ==

This plugin follows WordPress coding standards and best practices:

* Proper sanitization and validation
* Nonce verification for security
* Capability checks for admin functions
* Modular code structure with 4-letter prefix naming convention
* Comprehensive error handling
* Responsive admin interface
* Granular permission system
* Full CRUD operations with authentication

== Support ==

**Author:** Hamid Azad  
**GitHub:** [https://github.com/hamidhosenazad](https://github.com/hamidhosenazad)  
**Email:** hamidxazad@gmail.com

For support, feature requests, or bug reports, please visit the plugin's GitHub repository or contact the author directly.
