Skip to main content

Crate mtp_sdk

Crate mtp_sdk 

Source
Expand description

§mtp-sdk

Make any Clap-based CLI tool LLM-discoverable with --mtp-describe.

This crate reads type information, help strings, defaults, and possible values directly from Clap’s Command and Arg metadata, so you get --mtp-describe with zero extra annotation in most cases.

§Quick start

use clap::Parser;
use mtp_sdk::Describable;

#[derive(Parser)]
#[command(name = "mytool", version = "1.0.0", about = "Does things")]
struct Cli {
    /// Input file
    input: String,
}

fn main() {
    let cli = Cli::describable();
}

Structs§

ArgDescriptor
Describes a single argument (positional or flag).
AuthConfig
Tool-level auth configuration.
AuthProvider
A supported authentication provider.
CommandAnnotation
Annotations for a single command (examples, IO, auth).
CommandAuth
Per-command auth overrides.
CommandDescriptor
A single (leaf) command in the tool.
DescribableBuilder
Builder for attaching examples, IO descriptors, and auth config to commands before checking --mtp-describe.
DescribeOptions
Options passed to describe() for attaching metadata.
Example
An example invocation.
IODescriptor
Describes stdin or stdout for a command.
ToolSchema
Top-level tool schema returned by --mtp-describe.

Constants§

MTP_SPEC_VERSION
The MTP specification version this SDK implements.

Traits§

Describable
Trait for Clap-derived CLI structs to add --mtp-describe support.

Functions§

describe
Extract the full ToolSchema from a Clap Command.
extract_arg
Extract an ArgDescriptor from a Clap Arg. Returns None for hidden args.
extract_schema
Extract the full ToolSchema from an already-built Command.
infer_arg_type
Infer the MTP arg type from a Clap Arg.
walk_commands
Recursively walk a Command tree, returning leaf commands with space-separated names (e.g. “auth login”). Commands with no visible subcommands are leaves.