Wenyan MCP Server

repository·main·Indexed 23 days ago

https://github.com/caol64/wenyan-mcp

A Model Context Protocol (MCP) server for Wenyan, a Markdown formatting tool that enables AI assistants to apply themes and publish articles directly to WeChat Official Accounts (微信公众号). It provides tools to publish articles, manage built-in and custom themes, and support image-only messages (Xiao Lü Shu). Supports local mode via stdio, Docker deployment, and remote client-server mode.

Tokens
2.7K
Snippets
8
Records
21
Agent score
72%

What's inside wenyan-mcp

  1. Format Markdown articles with Frontmatter

    main

    To ensure successful uploading, every Markdown article must include a frontmatter block at the top. This block provides metadata required for the WeChat publication process.

    FieldRequiredDescription
    titleArticle title
    coverCover image (local path or URL). If omitted, the first image in the body is used.
    authorAuthor name
    source_urlOriginal article link
    typeSet to image for image-only messages (Xiao Lü Shu)
    image_listList of image paths (for type: image, max 20)
    need_open_commentWhether to enable comments
    only_fans_can_commentWhether only fans can comment

    Example Article Structure:

    ---
    title: My Article Title
    cover: /Users/xxx/image.jpg
    author: John Doe
    source_url: http://example.com
    ---
    
    # Content starts here...
    ---
    title: 在本地跑一个大语言模型(2) - 给模型提供外部知识库
    cover: /Users/xxx/image.jpg
    author: xxx
    source_url: http://
    ---
  2. Manage WeChat Official Account Themes via AI

    main

    You can manage publication themes through conversational commands with your AI client:

    • List Themes: Ask "What official account themes can you currently use?" to see available styles and color palettes.
    • Register a New Theme: Provide a CSS URL and a name.
    • Delete a Theme: Ask to remove a specific theme by name.
      • Example: "Delete the theme named 'xiuluochang'"
    • Apply a Theme during Publication: Specify the theme when asking to publish.
      • Example: "Use the phycat theme to publish this article to WeChat: ./path/to/article.md"
  3. Publish Image-only Messages (Xiao Lü Shu)

    main

    To publish an image-only message (Xiao Lü Shu) instead of a standard article, use one of the following two methods in your Markdown frontmatter:

    Set type: image in the frontmatter. The system will automatically extract all images found in the Markdown body.

    ---
    title: My Image Post
    type: image
    ---
    
    ![](./1.jpeg)
    ![](./2.jpeg)

    Method 2: Manually specifying image_list

    Explicitly list the image paths in the frontmatter. The first image in the list will be used as the cover. The list can contain a maximum of 20 images.

    ---
    title: My Image Post
    image_list:
      - ./1.jpeg
      - ./2.jpeg
    ---
    ---
    title: 人勤春来早,读书正当时
    type: image
    ---
    
    ![](./1.jpeg)
    ![](./2.jpeg)
  4. Configure Claude Desktop for Wenyan MCP

    main

    To use Wenyan MCP with Claude Desktop, add the following configuration to your claude_desktop_config.json file. You must provide your WeChat WECHAT_APP_ID and WECHAT_APP_SECRET as environment variables.

    {
      "mcpServers": {
        "wenyan-mcp": {
          "command": "wenyan-mcp",
          "env": {
            "WECHAT_APP_ID": "your_app_id",
            "WECHAT_APP_SECRET": "your_app_secret"
          }
        }
      }
    }
  5. Configure Claude Desktop using Docker

    main

    If you prefer not to install Node.js locally, you can run Wenyan MCP via Docker.

    Important Requirements:

    1. Volume Mount (-v): You must mount your host machine's file/image directory to /mnt/host-downloads inside the container.
    2. HOST_FILE_PATH: This environment variable must match the absolute path of the directory you mounted on your host machine.
    {
      "mcpServers": {
        "wenyan-mcp": {
          "command": "docker",
          "args": [
            "run",
            "--rm",
            "-i",
            "-v", "/your/host/file/path:/mnt/host-downloads",
            "-e", "WECHAT_APP_ID=your_app_id",
            "-e", "WECHAT_APP_SECRET=your_app_secret",
            "-e", "HOST_FILE_PATH=/your/host/file/path",
            "caol64/wenyan-mcp"
          ]
        }
      }
    }
  6. Configure Wenyan MCP in Client-Server Mode

    main

    Use Client-Server mode if you want to connect to a remote Wenyan Server (e.g., for team collaboration, CI/CD, or to bypass local IP whitelist restrictions). In this mode, the MCP client sends requests to the remote server which handles the WeChat API calls.

    {
      "mcpServers": {
        "wenyan-mcp": {
          "command": "wenyan-mcp",
          "args": ["--server", "https://api.example.com", "--api-key", "your-api-key"]
        }
      }
    }
  7. Debug Wenyan MCP using Inspector

    main

    To debug the MCP server, use the official MCP Inspector. Run the following command, replacing <command> with your actual startup command (e.g., wenyan-mcp with necessary environment variables):

    npx @modelcontextprotocol/inspector <command>

    Once started, access the provided URL in your browser to:

    1. Connect to the server.
    2. List available tools via Tools -> List Tools.
    3. Run specific tools with parameters and inspect the output.
  8. Troubleshoot AppID errors in publish_article

    main

    If you attempt to use the app_id parameter while the server is running in local mode, the operation will fail with an error.

    Error: AppID is only supported in remote client mode. Please remove 'app_id' or run the server in remote client mode with --server <server_url>.

    Solution: To use a specific app_id, you must run the Wenyan MCP server in remote client mode by providing the --server flag with your server URL.