Create LearnDash Lesson


Adds a new lesson to the end of a LearnDash course, through LearnDash's course steps, so it shows in the course builder. The lesson is created as a draft that students cannot see unless publish is true. Reversible: the lesson can be edited, moved or trashed in LearnDash afterwards. Get the course ID from mosmcp/learndash-list-courses. Add topics to the lesson with mosmcp/learndash-create-topic.

Also known as: add a lesson, add course content, add a module, add a chapter.

Property Value
Ability slug mosmcp/learndash-create-lesson
Wire tool name mosmcp__learndash-create-lesson
Category LearnDash (mosmcp-learndash)
Plan Pro

 

Required access

Requirement Value
Capability edit_posts, plus the LearnDash lesson post type's create_posts capability and edit_post on the course (checked in the code)
Minimum default role Contributor
Annotations readOnly: false · destructive: false · idempotent: false · openWorld: false

 

Input schema

Field Type Required Default Description
course_id integer (min 1) Yes — The LearnDash course ID, as returned by mosmcp/learndash-list-courses.
title string (min length 1) Yes — The lesson title.
content string — Optional lesson content. HTML is saved the way the WordPress editor saves it: a user with the unfiltered_html capability can save any markup, including forms, scripts and styles, and markup a user is not allowed to save is refused with the reason rather than silently removed. Backslashes are kept.
publish boolean false Publish the lesson straight away. Leave false to create a draft.

 

Output schema

Field Type Required Description
step_id integer Yes
type string Yes lesson, topic or quiz.
title string Yes
status string Yes
course_id integer Yes
course_title string
parent_id integer Yes The course, lesson or topic the new step sits under.
parent_type string course, lesson or topic.
position integer Its position among the parent's steps of the same kind, from 1.
edit_url string
view_url string
warnings object[] Notes about the save, such as markup that could not be kept.
warnings[].code string
warnings[].message string
warnings[].context string
notes string[]

 

Example

Sample prompt
Add a lesson called 'Reading CSV Files' to the end of LearnDash course 512.

Example request (json)

{
  "jsonrpc": "2.0",
  "id": 671,
  "method": "tools/call",
  "params": {
    "name": "mosmcp__learndash-create-lesson",
    "arguments": {
      "input": {
        "course_id": 512,
        "title": "Reading CSV Files"
      }
    }
  }
}

Example response (json)

{
  "jsonrpc": "2.0",
  "id": 671,
  "result": {
    "isError": false,
    "structuredContent": {
      "step_id": 530,
      "type": "lesson",
      "title": "Reading CSV Files",
      "status": "draft",
      "course_id": 512,
      "course_title": "Python for Analysts",
      "parent_id": 512,
      "parent_type": "course",
      "position": 7,
      "edit_url": "https://example.com/wp-admin/post.php?post=530&action=edit",
      "view_url": "https://example.com/?post_type=sfwd-lessons&p=530",
      "warnings": [],
      "notes": [
        "It is a draft, so students will not see it until it is published."
      ]
    }
  }
}

 

Edge cases / errors

  • Always a draft unless publish is true; without the right to publish lessons it is submitted for review (status "pending") instead.
  • No right to edit that course → mosmcp_learndash_cannot_edit_course; ID that is not a LearnDash course → mosmcp_learndash_course_not_found.
  • LearnDash does not list the new lesson in the course's steps → mosmcp_learndash_step_not_attached, and the new post is deleted again; steps that cannot be read back → mosmcp_learndash_step_unconfirmed, with the draft's step_id to check in the course builder.
  • Needs LearnDash 4.8 or later for its course-steps API; older versions → mosmcp_learndash_api_unavailable.

 


<< Previous Next >>
Create LearnDash Course Create LearnDash Quiz

For more information about the Secure MCP Server for WordPress plugin, explore the following resources:

Product Overview | Pricing | Try for Free | Documentation

If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.