blog_publisher_mcp_server
This document outlines the creation of a Model Context Protocol (MCP) server for automating the process of uploading blog articles from Obsidian to a specified directory and pushing changes to GitHub.
The MCP blog upload service is designed to streamline the process of managing and publishing blog articles stored in Obsidian. When a user inputs 'blog+article_name', the service automatically copies the specified Markdown file from the local Obsidian directory to a designated directory, processes image links, copies images to the target folder, and pushes the changes to GitHub. This automation reduces manual effort and ensures consistency in file management and publication.
Features
- {'name': 'Trigger Condition', 'description': "Activates when the user inputs 'blog+article_name'."}
- {'name': 'File Copying', 'description': 'Copies the specified Markdown file from the Obsidian directory to the target directory.'}
- {'name': 'Image Processing', 'description': 'Detects and updates image links in the Markdown file, copying images to the target folder.'}
- {'name': 'GitHub Integration', 'description': 'Commits and pushes changes to GitHub automatically.'}
Usage with Different Platforms
obsidian_to_github
python
import os
import shutil
import subprocess
# Define paths
obsidian_path = 'I:/B-1 笔记/Android/Android'
blog_path = 'I:/B-MioBlogSites/_Android'
assets_path = 'I:/B-MioBlogSites/assets/images'
# Function to copy markdown and images
def copy_markdown_and_images(article_name):
md_file = f'{obsidian_path}/{article_name}.md'
target_md_file = f'{blog_path}/{article_name}.md'
# Copy markdown file
shutil.copy(md_file, target_md_file)
# Process images
with open(md_file, 'r', encoding='utf-8') as file:
content = file.read()
# Find and copy images
image_links = re.findall(r'!\[.*?\]\((.*?)\)', content)
for image_link in image_links:
image_name = os.path.basename(image_link)
shutil.copy(f'{obsidian_path}/z. attachments/{image_name}', f'{assets_path}/{image_name}')
content = content.replace(image_link, f'../assets/images/{image_name}')
# Write updated content
with open(target_md_file, 'w', encoding='utf-8') as file:
file.write(content)
# Push to GitHub
subprocess.run(['git', 'add', '.'], cwd=blog_path)
subprocess.run(['git', 'commit', '-m', f'Add {article_name}'], cwd=blog_path)
subprocess.run(['git', 'push'], cwd=blog_path)
# Example usage
copy_markdown_and_images('example_article')
Related MCP Servers
View all developer_tools servers →Sequential Thinking
by modelcontextprotocol
An MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.
git-mcp
by idosal
GitMCP is a free, open-source, remote Model Context Protocol (MCP) server that transforms GitHub projects into documentation hubs, enabling AI tools to access up-to-date documentation and code.
Everything MCP Server
by modelcontextprotocol
The Everything MCP Server is a comprehensive test server designed to demonstrate the full capabilities of the Model Context Protocol (MCP). It is not intended for production use but serves as a valuable tool for developers building MCP clients.
context7
by upstash
Context7 MCP provides up-to-date, version-specific documentation and code examples directly into your prompt, enhancing the capabilities of LLMs by ensuring they use the latest information.
exa-mcp-server
by exa-labs
A Model Context Protocol (MCP) server allows AI assistants to use the Exa AI Search API for real-time web searches in a secure manner.
repomix
by yamadashy
Repomix is a tool that packs your codebase into AI-friendly formats, making it easier to use with AI tools like LLMs.
mcpdoc
by langchain-ai
MCP LLMS-TXT Documentation Server provides a structured way to manage and retrieve LLM documentation using the Model Context Protocol.