Blogger Cli
БесплатноНе проверенAn all-in-one CLI tool & MCP server for Google Blogger API v3. Automates article posting, updating, and GCS image uploading/replacing.
Описание
An all-in-one CLI tool & MCP server for Google Blogger API v3. Automates article posting, updating, and GCS image uploading/replacing.
README
A Python utility to create and publish posts on Blogger using the Google Blogger API v3 from the command line.
Features
- Title and Content Specification: Create or update posts by passing raw HTML content strings (
--content) or specifying a path to an HTML file (--file). - Draft or Live Status: Save as a draft or publish immediately to your blog.
- Labels Management: Attach comma-separated labels (tags) to your posts.
- OAuth 2.0 Authentication: Automatically handles authorization via web browser and securely caches tokens locally.
- Update and History Tracking: Update existing posts using
blogger_update.py. Post history is automatically saved topost_history.json. - Fetch Post Information: Retrieve current live status, content, and other metadata of existing posts directly from Blogger using
blogger_get.py. Output can be dynamically filtered by specific fields. - Module Support: Import modules into other Python scripts to programmatically create or update posts.
- Multi-Blog Support: Dynamically route posts to different blogs based on genre or alias using the
--target_blogparameter. - MCP Server Support: Includes
Blogger_mcp_server.py(FastMCP) allowing AI assistants to post or update articles directly.
Setup Instructions
1. Install Dependencies
Create a Python 3.x virtual environment and install the required packages:
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install required packages
pip install -r requirements.txt
2. Configure Environment Variables and Credentials
To run this tool, you need to set up two configuration files in the script directory:
.envFile Create a.envfile in the same directory as the script with the following content:BLOG_ID=YOUR_DEFAULT_BLOG_ID BLOG_ID_SITE1=YOUR_SITE1_BLOG_ID (Optional: links with --target_blog site1) BLOG_ID_SITE2=YOUR_SITE2_BLOG_ID (Optional: links with --target_blog site2) GCS_BUCKET_NAME=YOUR_GCS_BUCKET_NAME GCP_PROJECT_ID=YOUR_GCP_PROJECT_IDclient_secret.jsonFile Download your Desktop Application OAuth 2.0 client credentials JSON file from the Google Cloud Console, rename it toclient_secret.json, and place it in the script directory.GCS Authentication for Image Uploads (ADC) To use the image upload feature (
image_post.py), run the following command locally and complete the browser authentication for Application Default Credentials (ADC):gcloud auth application-default login
[!WARNING] For security,
.env,client_secret.json, and the auto-generatedtoken.jsonare excluded from Git commits via.gitignore. Be careful not to expose your credentials.
Usage
Make sure your virtual environment is activated before running the script.
Create a Post (Save as Draft)
Provide a title and HTML string content to save a draft post:
python blogger_post.py \
--title "My First API Post" \
--content "<h1>Hello World</h1><p>This is a test post from Blogger API.</p>"
Read from HTML File and Publish (Live Status)
Specify an HTML file path using --file and set --status live to publish the post immediately:
python blogger_post.py \
--title "Article Loaded from HTML File" \
--file "path/to/article.html" \
--status live
Add Labels to Your Post
Pass labels as a comma-separated string using the --labels option:
python blogger_post.py \
--title "Post with Labels" \
--content "<p>Testing Blogger API v3 labels.</p>" \
--labels "Python, Blogger API, Test"
Route Post to a Specific Blog (Multi-Blog Support)
If you have configured multiple blog IDs in your .env (e.g., BLOG_ID_SITE1), use the --target_blog argument to dynamically switch the destination:
python blogger_post.py \
--title "Site 1 News" \
--content "<p>This goes to the site1 blog.</p>" \
--target_blog "site1"
Update an Existing Post
Use blogger_update.py to update an existing post by its post_id:
python blogger_update.py \
--post_id 1234567890123456789 \
--title "Updated Title" \
--content "<p>Updated content.</p>" \
--status live
Note: You can also specify an HTML file using --file "path/to/article.html" instead of --content. Successful posts and updates are automatically recorded in post_history.json.
Fetch Post Information
Use blogger_get.py to retrieve the current status, content, or other metadata of a specific post_id. You can extract only specific fields using the --fields argument.
Available Fields (--fields):
id: The ID of the posttitle: The title of the poststatus: The publication status (e.g.,LIVE,DRAFT,SCHEDULED)url: The public URL of the postlabels: A list of labels (tags) attached to the postcontent: The HTML content of the postpublished: The time the post was publishedupdated: The time the post was last updatedreplies: Comment informationauthor: Information about the author
python blogger_get.py \
--post_id 1234567890123456789 \
--fields "title,status,url"
Use as a Module
You can also import the script into other Python projects:
from blogger_post import post_article
try:
url = post_article(
title="My API Post",
content="<p>This is posted via Python module.</p>",
labels=["Python", "Module"],
status="draft"
)
print(f"Posted successfully: {url}")
except Exception as e:
print(f"Failed to post: {e}")
Use as an MCP Server
The included Blogger_mcp_server.py script runs a FastMCP server. By configuring your AI assistant (e.g., Claude) to use this script as an MCP server, it exposes the following tools:
post_to_blogger: Publish or draft new articles and automatically save the history locally. Accepts HTML strings (content) or local HTML file paths (file_path), as well astarget_blogto route posts dynamically.update_blogger_post: Update existing articles by theirpost_idand sync the local history. Accepts HTML strings (content) or local HTML file paths (file_path), andtarget_blog.upload_image_to_gcs: Uploads a single local image to GCS (automatically converts to WebP and resizes) and returns the public URL.replace_html_images_with_gcs: Reads local image links within an HTML document, uploads all of them to GCS, and returns a new HTML string with replaced image URLs.get_blogger_post: Retrieves the current information of a specific post directly from the Blogger API. You can specify which fields (e.g., status, url) to extract.
Note: Ensure the mcp, google-cloud-storage, Pillow, and beautifulsoup4 packages are installed (pip install -r requirements.txt) before running the MCP server.
Error Handling
If any issue occurs, the script catches the exception and outputs localized troubleshooting advice:
- File Errors: Warns you if the HTML file is missing, lacks read permissions, or is not UTF-8 encoded.
- Network Connection Errors: Catches failures when there is no internet connection, Google servers are unreachable, or the request times out (maximum 30-second socket timeout to prevent hanging).
- HTTP Errors (403, 404, 500, etc.): Suggests causes and fixes depending on the status code (e.g. check Blogger API enablement for 403, verify BLOG_ID for 404, or wait for Google servers for 500).
- Authentication Errors: Guides you if credentials are invalid or expired. This includes a 120-second timeout for the local browser OAuth flow; if it times out (common when your Google Cloud project is in "Testing" mode and the current account is not registered as a "Test User"), the script will abort and print steps to configure test users in Google Cloud Console.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
- This script is provided "AS IS", without warranty of any kind.
- The authors are not responsible for any damage, data loss, or API quota consumption caused by using this software.
- Please comply with Google's API terms of service when using this tool.
Установка Blogger Cli
У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.
▸ github.com/tai1mo/blogger-cli-mcpFAQ
Blogger Cli MCP бесплатный?
Да, Blogger Cli MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Blogger Cli?
Нет, Blogger Cli работает без API-ключей и переменных окружения.
Blogger Cli — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Blogger Cli в Claude Desktop, Claude Code или Cursor?
Открой Blogger Cli на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
ARA
Generate images, video and audio from any AI agent — one connector.
автор: ARAOmni Video
An MCP server that transforms LLM-enabled IDEs into professional video editors by pre-processing footage into text proxies, generating motion graphics via HTML/
автор: buildwithtazaYouTube
Transcripts, channel stats, search
автор: YouTubeEverArt
AI image generation using various models.
автор: modelcontextprotocolCompare Blogger Cli with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории media
