VVCMS MCP 栏目与内容工具:参数、返回值与更新语义

最后更新时间:2026-09-22 18:42:35

1. 栏目工具

1.1 list_columns

列出所有栏目,无参数。

{
  "name": "list_columns",
  "arguments": {}
}

1.2 get_column

{
  "name": "get_column",
  "arguments": {
    "id": 1
  }
}

1.3 create_column

创建栏目。当前 MCP 输入 Schema 会要求栏目字段完整传入,建议使用以下完整结构:

{
  "name": "create_column",
  "arguments": {
    "pid": 0,
    "name": "MCP 栏目",
    "title": "MCP 栏目标题",
    "description": "",
    "keywords": "",
    "slug": "mcp-column",
    "kind": 1,
    "status": 1,
    "link_url": "",
    "link_target": "_self",
    "img": "",
    "template": "",
    "c_template": "",
    "limit_num": 10,
    "sort": 0,
    "inherit": 0,
    "ext": "",
    "content": ""
  }
}

成功返回新建栏目的 ID:

{
  "id": 42
}

1.4 update_column

{
  "name": "update_column",
  "arguments": {
    "id": 1,
    "pid": 0,
    "name": "更新后的栏目",
    "title": "更新后的标题",
    "description": "更新后的描述",
    "keywords": "",
    "slug": "mcp-column",
    "kind": 1,
    "status": 1,
    "link_url": "",
    "link_target": "_self",
    "img": "",
    "template": "",
    "c_template": "",
    "limit_num": 10,
    "sort": 0,
    "inherit": 0,
    "ext": "",
    "content": ""
  }
}

1.5 delete_column

只能删除空栏目:

{
  "name": "delete_column",
  "arguments": {
    "id": 1
  }
}

小结:create_column 必填 nameslugupdate_columndelete_column 必填 id;三者成功时均返回 {"ok": true}

2. 内容工具

2.1 list_articles

列出文章,工具内部会省略长正文内容

所有筛选字段都是可选的,只传需要的即可;current 默认 1,size 默认 20、上限 100。返回结构为 {"total": 总数, "current": 页码, "size": 每页条数, "items": [...]},其中分页值已按服务端默认值归一化。

只做分页时:

{
  "name": "list_articles",
  "arguments": {
    "current": 1,
    "size": 10
  }
}

按栏目和标题筛选时:

{
  "name": "list_articles",
  "arguments": {
    "column_id": 1,
    "title": "产品",
    "status": 1,
    "current": 1,
    "size": 20
  }
}

可选字段:idid_gtid_ltslugtitletagscolumn_idcolumn_idsstatusuidcurrentsizeorderbefore_sortbefore_idstatus 为 0 表示不过滤状态。

2.2 get_article

返回完整文章对象,包括 contentext

{
  "name": "get_article",
  "arguments": {
    "id": 1
  }
}

为安全起见,password 字段在 MCP 返回中被置空

2.3 create_article

必填字段只有 titlecolumn_id,其余字段可选,未传的字段使用服务端默认值:

{
  "name": "create_article",
  "arguments": {
    "title": "MCP 文章标题",
    "column_id": 1,
    "content": "

MCP 文章正文

", "status": 1, "slug": "mcp-article", "description": "文章摘要", "keywords": "mcp" } }

成功返回新建内容的 ID:

{
  "id": 12
}

column_id 必须是已存在的栏目 ID(外部 HTTP API 用的是 column_name,两者不同)。

2.4 update_article

id 必填,只传需要修改的字段即可,未提供的字段保持原值:

{
  "name": "update_article",
  "arguments": {
    "id": 1,
    "title": "更新后的标题",
    "content": "

更新后的正文

" } }

成功返回:

{
  "ok": true
}

2.5 字段更新语义(重要)

字段语义分两类:

  • contentdescriptionkeywordsoriginalbumsauthorpasswordimgtags不传表示保持原值;显式传空字符串才是清空。
  • 其余字段(nametitleslugcolumn_idstatussourcepriceenable_replysortcreate_timeexttag_ids):不传或传零值表示不修改。

因此下面的调用只会改标题,不会动正文

{
  "name": "update_article",
  "arguments": {
    "id": 1,
    "title": "只改标题"
  }
}

2.6 delete_article

{
  "name": "delete_article",
  "arguments": {
    "id": 1
  }
}

成功返回:

{
  "ok": true
}

3. curl 调用示例

调用 get_column

curl -X POST "http://127.0.0.1:8000/api/mcp" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d '{
    "jsonrpc": "2.0",
    "id": 10,
    "method": "tools/call",
    "params": {
      "name": "get_column",
      "arguments": {
        "id": 1
      }
    }
  }'

调用 get_article

curl -X POST "http://127.0.0.1:8000/api/mcp" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d '{
    "jsonrpc": "2.0",
    "id": 11,
    "method": "tools/call",
    "params": {
      "name": "get_article",
      "arguments": {
        "id": 1
      }
    }
  }'