wechat_oa_mcp

kakaxi3019/wechat_oa_mcp

3.3

If you are the rightful owner of wechat_oa_mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This is a WeChat Official Account MCP server based on the FastMCP framework, offering a range of practical WeChat Official Account API interfaces.

The WeChat Official Account MCP Server is a Python-based application built using the FastMCP framework. It provides a set of APIs for managing WeChat Official Account content, including creating, publishing, and deleting drafts. The server adheres to the Model Control Protocol (MCP) standard, making it easy to integrate into various AI systems and automated workflows. Users can manage their WeChat Official Account content efficiently by leveraging this server's capabilities. To use this tool, users must first register on the WeChat Official Platform and obtain their developer ID (AppID) and secret (AppSecret). The server is designed to handle authentication, parameter validation, and communication with the WeChat API, allowing users to focus on their business logic without worrying about the underlying implementation. The server supports modular design, with each function encapsulated as an independent MCP tool that can be called separately.

Features

  • Provides APIs for managing WeChat Official Account content.
  • Built using the FastMCP framework for easy integration.
  • Handles authentication and parameter validation.
  • Modular design with independent MCP tools.
  • Supports creating, publishing, and deleting drafts.

Usages

usage with pip

bash
pip install wechat_oa_mcp

usage with python code

python
from wechat_oa_mcp import (
    WeChat_get_access_token, 
    WeChat_create_draft,
    WeChat_publish_draft,
    WeChat_del_draft,
    WeChat_del_material
)

# 获取access_token
token_result = WeChat_get_access_token({
    "AppID": "您的微信AppID", 
    "AppSecret": "您的微信AppSecret"
})

if token_result["success"]:
    access_token = token_result["access_token"]
    
    # 创建草稿
    draft_result = WeChat_create_draft({
        "access_token": access_token,
        "image_url": "https://example.com/image.jpg",
        "title": "测试文章标题",
        "content": "<p>这是文章内容</p>",
        "author": "作者名称"
    })
    
    if draft_result["success"]:
        draft_id = draft_result["draft_media_id"]
        image_id = draft_result["image_media_id"]
        
        # 发布草稿
        publish_result = WeChat_publish_draft({
            "access_token": access_token,
            "draft_media_id": draft_id
        })
        
        if publish_result["success"]:
            print(f"发布成功!发布ID: {publish_result['publish_id']}")
            
        # 删除草稿示例
        # 注意:通常在发布后才会删除草稿,这里仅为演示API用法
        del_draft_result = WeChat_del_draft({
            "access_token": access_token,
            "media_id": draft_id
        })
        
        if del_draft_result["success"]:
            print(f"删除草稿成功:{del_draft_result['errmsg']}")
        
        # 删除素材示例
        # 注意:通常在不需要图片素材时才会删除,这里仅为演示API用法
        del_material_result = WeChat_del_material({
            "access_token": access_token,
            "media_id": image_id
        })
        
        if del_material_result["success"]:
            print(f"删除素材成功:{del_material_result['errmsg']}")

usage with mcp inspector

bash
npx @modelcontextprotocol/inspector python -m wechat_oa_mcp


之后访问 http://localhost:6274 可进行交互测试

usage with json mcp server

{
    "mcpServers": {
        "wechat_oa_mcp": {
            "type": "sse",
            "url": "http://localhost:8000/sse"
        }
    }
}