@modeltoolsprotocol/sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modeltoolsprotocol/sdk",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Add MTP --describe support to any Commander.js CLI",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -16,6 +16,9 @@
16
16
  "scripts": {
17
17
  "test": "bun test"
18
18
  },
19
+ "dependencies": {
20
+ "zod": "^3.23.0"
21
+ },
19
22
  "peerDependencies": {
20
23
  "commander": ">=12.0.0"
21
24
  },
package/src/index.ts CHANGED
@@ -29,6 +29,20 @@ export type {
29
29
  IODescriptor,
30
30
  Example,
31
31
  AuthConfig,
32
+ AuthProvider,
33
+ CommandAuth,
32
34
  DescribeOptions,
33
35
  CommandAnnotation,
34
36
  } from "./types.js";
37
+
38
+ export {
39
+ ExampleSchema,
40
+ IODescriptorSchema,
41
+ ArgDescriptorSchema,
42
+ CommandAuthSchema,
43
+ CommandDescriptorSchema,
44
+ AuthProviderSchema,
45
+ AuthConfigSchema,
46
+ ToolSchemaSchema,
47
+ MTP_SPEC_VERSION,
48
+ } from "./schemas.js";
package/src/introspect.ts CHANGED
@@ -6,8 +6,7 @@ import type {
6
6
  DescribeOptions,
7
7
  ToolSchema,
8
8
  } from "./types.js";
9
-
10
- const MTP_SPEC_VERSION = "2026-02-07";
9
+ import { MTP_SPEC_VERSION } from "./schemas.js";
11
10
 
12
11
  // Commander stores these as private fields. We access them for filtering.
13
12
  interface CommandInternals {
@@ -193,6 +192,7 @@ function buildCommand(
193
192
  if (annotation?.stdout) descriptor.stdout = annotation.stdout;
194
193
  if (annotation?.examples && annotation.examples.length > 0)
195
194
  descriptor.examples = annotation.examples;
195
+ if (annotation?.auth) descriptor.auth = annotation.auth;
196
196
 
197
197
  return descriptor;
198
198
  }
package/src/schemas.ts ADDED
@@ -0,0 +1,66 @@
1
+ import { z } from "zod";
2
+
3
+ export const MTP_SPEC_VERSION = "2026-02-07";
4
+
5
+ export const ExampleSchema = z.object({
6
+ description: z.string().optional(),
7
+ command: z.string(),
8
+ output: z.string().optional(),
9
+ });
10
+
11
+ export const IODescriptorSchema = z.object({
12
+ contentType: z.string().optional(),
13
+ description: z.string().optional(),
14
+ schema: z.any().optional(),
15
+ });
16
+
17
+ export const ArgDescriptorSchema = z.object({
18
+ name: z.string(),
19
+ type: z.string(),
20
+ description: z.string().optional(),
21
+ required: z.boolean().default(false),
22
+ default: z.any().optional(),
23
+ values: z.array(z.string()).optional(),
24
+ });
25
+
26
+ export const CommandAuthSchema = z.object({
27
+ required: z.boolean().default(false),
28
+ scopes: z.array(z.string()).optional(),
29
+ });
30
+
31
+ export const CommandDescriptorSchema = z.object({
32
+ name: z.string(),
33
+ description: z.string(),
34
+ args: z.array(ArgDescriptorSchema).default([]),
35
+ stdin: IODescriptorSchema.optional(),
36
+ stdout: IODescriptorSchema.optional(),
37
+ examples: z.array(ExampleSchema).default([]),
38
+ auth: CommandAuthSchema.optional(),
39
+ });
40
+
41
+ export const AuthProviderSchema = z.object({
42
+ id: z.string(),
43
+ type: z.string(),
44
+ displayName: z.string().optional(),
45
+ authorizationUrl: z.string().optional(),
46
+ tokenUrl: z.string().optional(),
47
+ scopes: z.array(z.string()).optional(),
48
+ clientId: z.string().optional(),
49
+ registrationUrl: z.string().optional(),
50
+ instructions: z.string().optional(),
51
+ });
52
+
53
+ export const AuthConfigSchema = z.object({
54
+ required: z.boolean().default(false),
55
+ envVar: z.string(),
56
+ providers: z.array(AuthProviderSchema),
57
+ });
58
+
59
+ export const ToolSchemaSchema = z.object({
60
+ specVersion: z.string(),
61
+ name: z.string(),
62
+ version: z.string(),
63
+ description: z.string(),
64
+ auth: AuthConfigSchema.optional(),
65
+ commands: z.array(CommandDescriptorSchema),
66
+ });
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export interface Example {
2
- description: string;
2
+ description?: string;
3
3
  command: string;
4
4
  output?: string;
5
5
  }
@@ -19,6 +19,11 @@ export interface ArgDescriptor {
19
19
  values?: string[];
20
20
  }
21
21
 
22
+ export interface CommandAuth {
23
+ required?: boolean;
24
+ scopes?: string[];
25
+ }
26
+
22
27
  export interface CommandDescriptor {
23
28
  name: string;
24
29
  description: string;
@@ -26,12 +31,25 @@ export interface CommandDescriptor {
26
31
  stdin?: IODescriptor;
27
32
  stdout?: IODescriptor;
28
33
  examples?: Example[];
34
+ auth?: CommandAuth;
29
35
  }
30
36
 
31
- export interface AuthConfig {
37
+ export interface AuthProvider {
38
+ id: string;
32
39
  type: string;
33
- description?: string;
34
- [key: string]: unknown;
40
+ displayName?: string;
41
+ authorizationUrl?: string;
42
+ tokenUrl?: string;
43
+ scopes?: string[];
44
+ clientId?: string;
45
+ registrationUrl?: string;
46
+ instructions?: string;
47
+ }
48
+
49
+ export interface AuthConfig {
50
+ required?: boolean;
51
+ envVar: string;
52
+ providers: AuthProvider[];
35
53
  }
36
54
 
37
55
  export interface ToolSchema {
@@ -48,6 +66,7 @@ export interface CommandAnnotation {
48
66
  stdout?: IODescriptor;
49
67
  examples?: Example[];
50
68
  argTypes?: Record<string, string>;
69
+ auth?: CommandAuth;
51
70
  }
52
71
 
53
72
  export interface DescribeOptions {