← All procedures

procedure.define

Define a new procedure from an aggregation

MCPCLIbrowser
Package
@procedures/client · README
Path
["procedure","define"]
CLI
mark procedure define --path <string[]> --aggregation <object>
MCP tool
procedure.define on the dev-tools server
As data
{"$proc":["procedure","define"],"input":{}}
Tags
core, meta, runs-refs

Try it in the Composer →

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY, allCoreProcedures } from "@procedures/client";

for (const procedure of allCoreProcedures) {
  if (!PROCEDURE_REGISTRY.has(procedure.path)) PROCEDURE_REGISTRY.register(procedure);
}

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["procedure","define"], { path: [], aggregation: {} });
console.log(JSON.stringify(result));

From the command line

$ mark procedure define --path <string[]> --aggregation <object>

As data, in a program

{
  "$proc": ["procedure", "define"],
  "input": { "path": [], "aggregation": {} }
}

Input

FieldTypeRequiredDefaultDescription
pathstring[]yesThe path of the new procedure, for example ["tools", "double"]
aggregationobjectyesThe body of the procedure: a call ({ $proc, input }) that runs, as client.exec runs it, each time the procedure is called
metadataobjectnoThe metadata of the procedure, for example { description, tags }. The fields of the framework have their types. A custom field keeps any value.
replacebooleannoReplace a procedure that procedure.define made at the same path (never a procedure of code)

Output

FieldTypeRequiredDefaultDescription
pathstring[]yesThe path of the defined procedure
replacedbooleanyesTrue when the call replaced a runtime-defined procedure
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "path": {
        "minItems": 1,
        "type": "array",
        "items": {
          "type": "string",
          "minLength": 1
        },
        "description": "The path of the new procedure, for example [\"tools\", \"double\"]"
      },
      "aggregation": {
        "type": "object",
        "properties": {
          "$proc": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "The path of the procedure that the body calls"
          },
          "input": {
            "description": "The input of that call. It reads the input of the new procedure as { $ref: \"input.<field>\" }."
          },
          "$name": {
            "description": "A name that a $ref can read",
            "type": "string"
          }
        },
        "required": [
          "$proc"
        ],
        "additionalProperties": {},
        "description": "The body of the procedure: a call ({ $proc, input }) that runs, as client.exec runs it, each time the procedure is called"
      },
      "metadata": {
        "description": "The metadata of the procedure, for example { description, tags }. The fields of the framework have their types. A custom field keeps any value.",
        "type": "object",
        "properties": {
          "description": {
            "description": "A text that tells people and tools what the procedure does",
            "type": "string"
          },
          "tags": {
            "description": "The tags of the procedure",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "title": {
            "description": "The short name of the procedure, for example the title of an MCP tool",
            "type": "string"
          },
          "deprecated": {
            "description": "True when the procedure is deprecated",
            "type": "boolean"
          },
          "deprecationMessage": {
            "description": "The steps that replace a deprecated procedure",
            "type": "string"
          },
          "effects": {
            "description": "The side effects of the procedure",
            "type": "object",
            "properties": {
              "reads": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "writes": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "idempotent": {
                "type": "boolean"
              },
              "destructive": {
                "type": "boolean"
              }
            },
            "additionalProperties": {}
          },
          "stream": {
            "description": "The stream of the procedure",
            "type": "object",
            "properties": {
              "unbounded": {
                "type": "boolean"
              }
            },
            "additionalProperties": {}
          },
          "untrusted": {
            "description": "The output fields that hold text from outside the host",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "fsRoot": {
            "description": "The rules of the procedure under a root of the files",
            "type": "object",
            "properties": {
              "cwd": {
                "type": "string"
              },
              "paths": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "names": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "required": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "values": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "refuse": {
                "type": "string"
              },
              "program": {
                "type": "boolean"
              }
            },
            "additionalProperties": {}
          }
        },
        "additionalProperties": {}
      },
      "replace": {
        "description": "Replace a procedure that procedure.define made at the same path (never a procedure of code)",
        "type": "boolean"
      }
    },
    "required": [
      "path",
      "aggregation"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "path": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "The path of the defined procedure"
      },
      "replaced": {
        "type": "boolean",
        "description": "True when the call replaced a runtime-defined procedure"
      }
    },
    "required": [
      "path",
      "replaced"
    ],
    "additionalProperties": {}
  }
}