Explorer

definy.mcp-create-project

description
The definy_create_project MCP tool
type
Fn(arguments: @definy.json, request: @http.request) -> @definy.service-io
expression
fn(arguments$0, request$1) =>
  let project$2 = match @definy.json-get-string(value: $0, key: "project") {
      #some(text$3) =>
        $3,
      #none(_) =>
        ""
    };
  let message$4 = match @definy.json-get-string(value: $0, key: "message") {
      #some(text$5) =>
        $5,
      #none(_) =>
        @core.string-concat(left: "Create project ", right: $2)
    };
  match @core.equal(left: $2, right: "") {
    true =>
      @definy.mcp-text-error(text: "project is required"),
    false =>
      @definy.mcp-with-account(
        then: fn(account$6) =>
          @definy.read-branch-snapshot(
            project: $2,
            branch: "main",
            then: fn(commit$7, commits$8) =>
              match $7 {
                #some(_) =>
                  @definy.mcp-text-error(text: @std.string-join(items: ["Project ", $2, " already exists"], separator: "")),
                #none(_) =>
                  @definy.mcp-submit-content(
                    account: $6,
                    after_time_ms: 0,
                    content: #project_commit<@core.event-content>({
                      project_name: $2,
                      branch: "main",
                      project_description: match @definy.json-get-string(value: $0, key: "description") {
                        #some(text$9) =>
                          [{language: "en", text: $9}],
                        #none(_) =>
                          []
                      },
                      message: $4,
                      parent_commit_hash: #none,
                      merged_commit_hash: #none,
                      modules: []
                    }),
                    then: fn(accepted$10, text$11) =>
                      match $10 {
                        true =>
                          @definy.mcp-text(
                            text: @std.string-join(
                              items: [
                                "Created project ",
                                $2,
                                " with an empty main branch (owned by account ",
                                $6.account_id,
                                "). Add modules and parts with definy_create_snapshot (branch: main)\n",
                                $11
                              ],
                              separator: ""
                            )
                          ),
                        false =>
                          @definy.mcp-text-error(text: $11)
                      }
                  )
              }
          )
      )
  }
visibility
public
definy.mcp-create-project (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: YOoKZSnV89yaB0HT2rXA8T2cN6c2kYTopXPzXcu0wDU
content hash: 1c-cCRfbRiAwyPPw91X3rgl73P7hE-70EmkeImPYBd0