create_blog_post
Generate and publish blog posts by specifying a website ID, title, and HTML content. Integrates with DevHub CMS MCP for efficient content management.
Instructions
Create a new blog post
Args:
site_id: Website ID where the post will be published. Prompt the user for this ID.
title: Blog post title
content: HTML content of blog post. Should not include a <h1> tag, only h2+
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | ||
| site_id | Yes | ||
| title | Yes |
Implementation Reference
- src/devhub_cms_mcp/server.py:230-257 (handler)The handler function for the 'create_blog_post' MCP tool. Decorated with @mcp.tool() for automatic registration and schema inference from type hints and docstring. Posts new blog post data to DevHub CMS API and returns post details.@mcp.tool() def create_blog_post(site_id: int, title: str, content: str) -> str: """Create a new blog post Args: site_id: Website ID where the post will be published. Prompt the user for this ID. title: Blog post title content: HTML content of blog post. Should not include a <h1> tag, only h2+ """ client, base_url = get_client() payload = { 'content': content, 'site_id': site_id, 'title': title, } r = client.post( '{}posts/'.format(base_url), json=payload, ) post = r.json() return f""" Post ID: {post['id']} Title: {post['title']} Date: {post['date']} Content (HTML): {post['content']} """
- src/devhub_cms_mcp/server.py:230-230 (registration)The @mcp.tool() decorator registers the create_blog_post function as an MCP tool.@mcp.tool()
- src/devhub_cms_mcp/server.py:15-21 (helper)Helper function to obtain authenticated DevHub API client, used by create_blog_post and other tools.def get_client(): """Get DevHub API client and base_url.""" client = OAuth1Session( os.environ['DEVHUB_API_KEY'], client_secret=os.environ['DEVHUB_API_SECRET']) base_url = '{}/api/v2/'.format(os.environ['DEVHUB_BASE_URL']) return client, base_url