HopHop

Developing an MCP Plugin for Grav: Connecting My Blog to Claude

grav mcp claude ai php plugin development

I'd been thinking about this for a while: what if Claude could talk directly to my blog? Not just read its content, but actually interact with it — create posts, edit them, manage translations. A real editorial assistant.

TL;DR

I developed an MCP (Model Context Protocol) plugin for Grav CMS that allows Claude to interact directly with my blog. The plugin exposes 13 tools to manage posts, translations, and media. All the code is available as open source.

The Initial Idea

As explained in my article about choosing my blog stack, I've been wanting to start a blog for years to document things I'm "proud" of. I never did it due to lack of time, laziness, and probably my distaste for writing.

Since I discovered AI and especially Claude Code with its MCPs, I thought I could use it for writing. The idea is as follows:

  • I'm working on something in Claude Code
  • At some point, I think "this is pretty good, I should share it". I tell Claude to summarize what was done and create a draft blog post. Plus I have a /blog command that describes my style, tone, etc...
  • I review, edit, publish.

Plugin Architecture

The plugin works as an MCP server integrated into Grav. It exposes a JSON-RPC API that Claude can call via the MCP protocol.

Claude Code ↔ MCP Protocol ↔ Grav Plugin ↔ Markdown Files

The 13 Available Tools

The plugin exposes 13 tools across several categories:

Post Management

  • list_posts: list posts with filters (language, tag, status)
  • get_post: retrieve the full content of a post
  • create_post: create a new post
  • update_post: modify an existing post
  • delete_post: delete a post

Translations

  • list_translations: view available translations
  • create_translation: create a translation

Media

  • upload_media: upload an image or file
  • delete_media: delete a media file

System

  • get_site_info: site information
  • list_tags: all tags in use
  • clear_cache: clear Grav cache

Security

When it comes to security, Claude didn't hold back and implemented:

  • API key authentication: every request must include a valid key
  • Input validation: all parameters are validated and sanitized
  • Path restrictions: impossible to access files outside the pages folder
  • Rate limiting: protection against abuse

I admit that without Claude, I wouldn't have done all this right away, but hey, it's cheap ;)

Installation and Configuration

For installation and documentation, check the README.md.

Conclusion

This plugin has truly transformed how I manage my blog. Combined with the Bridgy Fed plugin for Fediverse connection, I now have a complete AI-driven stack. I can ask Claude to create a draft, translate a post, or update content — all without leaving my terminal.

The code is available on GitHub. Feel free to try it out and contribute!


This article was originally written in French. This translation was generated automatically with AI assistance.

Fediverse Interactions

1

Previous Post Next Post