@leanmcp/elicitation 0.1.1 → 0.1.3

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.
Files changed (3) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +351 -351
  3. package/package.json +64 -64
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 LeanMCP Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 LeanMCP Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,351 +1,351 @@
1
- <p align="center">
2
- <img
3
- src="https://raw.githubusercontent.com/LeanMCP/leanmcp-sdk/refs/heads/main/assets/logo.png"
4
- alt="LeanMCP Logo"
5
- width="400"
6
- />
7
- </p>
8
-
9
- <p align="center">
10
- <strong>@leanmcp/elicitation</strong><br/>
11
- Structured user input collection for MCP tools using the elicitation protocol.
12
- </p>
13
-
14
- <p align="center">
15
- <a href="https://www.npmjs.com/package/@leanmcp/elicitation">
16
- <img src="https://img.shields.io/npm/v/@leanmcp/elicitation" alt="npm version" />
17
- </a>
18
- <a href="https://www.npmjs.com/package/@leanmcp/elicitation">
19
- <img src="https://img.shields.io/npm/dm/@leanmcp/elicitation" alt="npm downloads" />
20
- </a>
21
- <a href="https://docs.leanmcp.com/sdk/elicitation">
22
- <img src="https://img.shields.io/badge/Docs-leanmcp-0A66C2?" />
23
- </a>
24
- <a href="https://discord.com/invite/DsRcA3GwPy">
25
- <img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" />
26
- </a>
27
- <a href="https://x.com/LeanMcp">
28
- <img src="https://img.shields.io/badge/@LeanMCP-f5f5f5?logo=x&logoColor=000000" />
29
- </a>
30
- </p>
31
-
32
- ## Features
33
-
34
- - **@Elicitation Decorator** — Automatically collect missing user inputs before tool execution
35
- - **Fluent Builder API** — Programmatic form creation with `ElicitationFormBuilder`
36
- - **Multiple Strategies** — Form and multi-step elicitation
37
- - **Built-in Validation** — min/max, pattern matching, custom validators
38
- - **Conditional Elicitation** — Only ask for inputs when needed
39
-
40
- ## Installation
41
-
42
- ```bash
43
- npm install @leanmcp/elicitation @leanmcp/core
44
- ```
45
-
46
- ## Quick Start
47
-
48
- ### Simple Form Elicitation
49
-
50
- ```typescript
51
- import { Tool } from "@leanmcp/core";
52
- import { Elicitation } from "@leanmcp/elicitation";
53
-
54
- class SlackService {
55
- @Tool({ description: "Create a new Slack channel" })
56
- @Elicitation({
57
- title: "Create Channel",
58
- description: "Please provide channel details",
59
- fields: [
60
- {
61
- name: "channelName",
62
- label: "Channel Name",
63
- type: "text",
64
- required: true,
65
- validation: {
66
- pattern: "^[a-z0-9-]+$",
67
- errorMessage: "Must be lowercase alphanumeric with hyphens"
68
- }
69
- },
70
- {
71
- name: "isPrivate",
72
- label: "Private Channel",
73
- type: "boolean",
74
- defaultValue: false
75
- }
76
- ]
77
- })
78
- async createChannel(args: { channelName: string; isPrivate: boolean }) {
79
- return { success: true, channelName: args.channelName };
80
- }
81
- }
82
- ```
83
-
84
- ### How It Works
85
-
86
- 1. **Client calls tool** with missing required fields
87
- 2. **Decorator intercepts** and checks for missing fields
88
- 3. **Elicitation request returned** with form definition
89
- 4. **Client displays form** to collect user input
90
- 5. **Client calls tool again** with complete arguments
91
- 6. **Method executes** normally
92
-
93
- ---
94
-
95
- ## Fluent Builder API
96
-
97
- For more complex forms, use `ElicitationFormBuilder`:
98
-
99
- ```typescript
100
- import { Tool } from "@leanmcp/core";
101
- import { Elicitation, ElicitationFormBuilder, validation } from "@leanmcp/elicitation";
102
-
103
- class UserService {
104
- @Tool({ description: "Create user account" })
105
- @Elicitation({
106
- builder: () => new ElicitationFormBuilder()
107
- .title("User Registration")
108
- .description("Create a new user account")
109
- .addEmailField("email", "Email Address", { required: true })
110
- .addTextField("username", "Username", {
111
- required: true,
112
- validation: validation()
113
- .minLength(3)
114
- .maxLength(20)
115
- .pattern("^[a-zA-Z0-9_]+$")
116
- .build()
117
- })
118
- .addSelectField("role", "Role", [
119
- { label: "Admin", value: "admin" },
120
- { label: "User", value: "user" }
121
- ])
122
- .build()
123
- })
124
- async createUser(args: any) {
125
- return { success: true, email: args.email };
126
- }
127
- }
128
- ```
129
-
130
- ### Builder Methods
131
-
132
- | Method | Description |
133
- |--------|-------------|
134
- | `title(string)` | Set form title |
135
- | `description(string)` | Set form description |
136
- | `condition(fn)` | Set condition for elicitation |
137
- | `addTextField(name, label, opts?)` | Add text input |
138
- | `addTextAreaField(name, label, opts?)` | Add textarea |
139
- | `addNumberField(name, label, opts?)` | Add number input |
140
- | `addBooleanField(name, label, opts?)` | Add checkbox |
141
- | `addSelectField(name, label, options, opts?)` | Add dropdown |
142
- | `addMultiSelectField(name, label, options, opts?)` | Add multi-select |
143
- | `addEmailField(name, label, opts?)` | Add email input |
144
- | `addUrlField(name, label, opts?)` | Add URL input |
145
- | `addDateField(name, label, opts?)` | Add date picker |
146
- | `addCustomField(field)` | Add custom field |
147
- | `build()` | Build final config |
148
-
149
- ---
150
-
151
- ## Conditional Elicitation
152
-
153
- Only ask for inputs when needed:
154
-
155
- ```typescript
156
- @Tool({ description: "Send message to Slack" })
157
- @Elicitation({
158
- condition: (args) => !args.channelId,
159
- title: "Select Channel",
160
- fields: [
161
- {
162
- name: "channelId",
163
- label: "Channel",
164
- type: "select",
165
- required: true,
166
- options: [
167
- { label: "#general", value: "C12345" },
168
- { label: "#random", value: "C67890" }
169
- ]
170
- }
171
- ]
172
- })
173
- async sendMessage(args: { channelId?: string; message: string }) {
174
- // Only elicits if channelId is missing
175
- }
176
- ```
177
-
178
- ---
179
-
180
- ## Multi-Step Elicitation
181
-
182
- Break input collection into sequential steps:
183
-
184
- ```typescript
185
- @Tool({ description: "Deploy application" })
186
- @Elicitation({
187
- strategy: "multi-step",
188
- builder: () => [
189
- {
190
- title: "Step 1: Environment",
191
- fields: [
192
- {
193
- name: "environment",
194
- label: "Environment",
195
- type: "select",
196
- required: true,
197
- options: [
198
- { label: "Production", value: "prod" },
199
- { label: "Staging", value: "staging" }
200
- ]
201
- }
202
- ]
203
- },
204
- {
205
- title: "Step 2: Configuration",
206
- fields: [
207
- {
208
- name: "replicas",
209
- label: "Replicas",
210
- type: "number",
211
- defaultValue: 3
212
- }
213
- ],
214
- condition: (prev) => prev.environment === "prod"
215
- }
216
- ]
217
- })
218
- async deployApp(args: any) {
219
- // Implementation
220
- }
221
- ```
222
-
223
- ---
224
-
225
- ## Field Types
226
-
227
- | Type | Description |
228
- |------|-------------|
229
- | `text` | Single-line text input |
230
- | `textarea` | Multi-line text area |
231
- | `number` | Numeric input |
232
- | `boolean` | Checkbox |
233
- | `select` | Dropdown (single choice) |
234
- | `multiselect` | Multi-select |
235
- | `email` | Email input |
236
- | `url` | URL input |
237
- | `date` | Date picker |
238
-
239
- ---
240
-
241
- ## Validation
242
-
243
- ### Built-in Validation
244
-
245
- ```typescript
246
- {
247
- name: "username",
248
- label: "Username",
249
- type: "text",
250
- validation: {
251
- minLength: 3,
252
- maxLength: 20,
253
- pattern: "^[a-zA-Z0-9_]+$",
254
- errorMessage: "Username must be 3-20 alphanumeric characters"
255
- }
256
- }
257
- ```
258
-
259
- ### Using ValidationBuilder
260
-
261
- ```typescript
262
- import { validation } from "@leanmcp/elicitation";
263
-
264
- validation()
265
- .minLength(8)
266
- .maxLength(100)
267
- .pattern("^[a-zA-Z0-9]+$")
268
- .customValidator((value) => value !== "admin")
269
- .errorMessage("Invalid input")
270
- .build()
271
- ```
272
-
273
- ---
274
-
275
- ## API Reference
276
-
277
- ### ElicitationConfig
278
-
279
- ```typescript
280
- interface ElicitationConfig {
281
- strategy?: 'form' | 'multi-step';
282
- title?: string;
283
- description?: string;
284
- fields?: ElicitationField[];
285
- condition?: (args: any) => boolean;
286
- builder?: (context: ElicitationContext) => ElicitationRequest | ElicitationStep[];
287
- }
288
- ```
289
-
290
- ### ElicitationField
291
-
292
- ```typescript
293
- interface ElicitationField {
294
- name: string;
295
- label: string;
296
- type: 'text' | 'number' | 'boolean' | 'select' | 'multiselect' | 'date' | 'email' | 'url' | 'textarea';
297
- description?: string;
298
- required?: boolean;
299
- defaultValue?: any;
300
- options?: Array<{ label: string; value: any }>;
301
- validation?: FieldValidation;
302
- placeholder?: string;
303
- helpText?: string;
304
- }
305
- ```
306
-
307
- ### FieldValidation
308
-
309
- ```typescript
310
- interface FieldValidation {
311
- min?: number;
312
- max?: number;
313
- minLength?: number;
314
- maxLength?: number;
315
- pattern?: string;
316
- customValidator?: (value: any) => boolean | string;
317
- errorMessage?: string;
318
- }
319
- ```
320
-
321
- ---
322
-
323
- ## Best Practices
324
-
325
- 1. **Use conditional elicitation** — Only ask when truly needed
326
- 2. **Provide sensible defaults** — Reduce user input burden
327
- 3. **Clear field labels** — Make fields self-explanatory
328
- 4. **Validate early** — Catch errors before submission
329
- 5. **Use builder for complex forms** — Fluent API is more maintainable
330
-
331
- ---
332
-
333
- ## Documentation
334
-
335
- - [Full Documentation](https://docs.leanmcp.com/sdk/elicitation)
336
-
337
- ## Related Packages
338
-
339
- - [@leanmcp/core](https://www.npmjs.com/package/@leanmcp/core) — Core MCP server functionality
340
- - [@leanmcp/auth](https://www.npmjs.com/package/@leanmcp/auth) — Authentication decorators
341
- - [@leanmcp/cli](https://www.npmjs.com/package/@leanmcp/cli) — CLI for project scaffolding
342
-
343
- ## Links
344
-
345
- - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
346
- - [NPM Package](https://www.npmjs.com/package/@leanmcp/elicitation)
347
- - [MCP Specification](https://spec.modelcontextprotocol.io/)
348
-
349
- ## License
350
-
351
- MIT
1
+ <p align="center">
2
+ <img
3
+ src="https://raw.githubusercontent.com/LeanMCP/leanmcp-sdk/refs/heads/main/assets/logo.png"
4
+ alt="LeanMCP Logo"
5
+ width="400"
6
+ />
7
+ </p>
8
+
9
+ <p align="center">
10
+ <strong>@leanmcp/elicitation</strong><br/>
11
+ Structured user input collection for MCP tools using the elicitation protocol.
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="https://www.npmjs.com/package/@leanmcp/elicitation">
16
+ <img src="https://img.shields.io/npm/v/@leanmcp/elicitation" alt="npm version" />
17
+ </a>
18
+ <a href="https://www.npmjs.com/package/@leanmcp/elicitation">
19
+ <img src="https://img.shields.io/npm/dm/@leanmcp/elicitation" alt="npm downloads" />
20
+ </a>
21
+ <a href="https://docs.leanmcp.com/sdk/elicitation">
22
+ <img src="https://img.shields.io/badge/Docs-leanmcp-0A66C2?" />
23
+ </a>
24
+ <a href="https://discord.com/invite/DsRcA3GwPy">
25
+ <img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" />
26
+ </a>
27
+ <a href="https://x.com/LeanMcp">
28
+ <img src="https://img.shields.io/badge/@LeanMCP-f5f5f5?logo=x&logoColor=000000" />
29
+ </a>
30
+ </p>
31
+
32
+ ## Features
33
+
34
+ - **@Elicitation Decorator** — Automatically collect missing user inputs before tool execution
35
+ - **Fluent Builder API** — Programmatic form creation with `ElicitationFormBuilder`
36
+ - **Multiple Strategies** — Form and multi-step elicitation
37
+ - **Built-in Validation** — min/max, pattern matching, custom validators
38
+ - **Conditional Elicitation** — Only ask for inputs when needed
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install @leanmcp/elicitation @leanmcp/core
44
+ ```
45
+
46
+ ## Quick Start
47
+
48
+ ### Simple Form Elicitation
49
+
50
+ ```typescript
51
+ import { Tool } from "@leanmcp/core";
52
+ import { Elicitation } from "@leanmcp/elicitation";
53
+
54
+ class SlackService {
55
+ @Tool({ description: "Create a new Slack channel" })
56
+ @Elicitation({
57
+ title: "Create Channel",
58
+ description: "Please provide channel details",
59
+ fields: [
60
+ {
61
+ name: "channelName",
62
+ label: "Channel Name",
63
+ type: "text",
64
+ required: true,
65
+ validation: {
66
+ pattern: "^[a-z0-9-]+$",
67
+ errorMessage: "Must be lowercase alphanumeric with hyphens"
68
+ }
69
+ },
70
+ {
71
+ name: "isPrivate",
72
+ label: "Private Channel",
73
+ type: "boolean",
74
+ defaultValue: false
75
+ }
76
+ ]
77
+ })
78
+ async createChannel(args: { channelName: string; isPrivate: boolean }) {
79
+ return { success: true, channelName: args.channelName };
80
+ }
81
+ }
82
+ ```
83
+
84
+ ### How It Works
85
+
86
+ 1. **Client calls tool** with missing required fields
87
+ 2. **Decorator intercepts** and checks for missing fields
88
+ 3. **Elicitation request returned** with form definition
89
+ 4. **Client displays form** to collect user input
90
+ 5. **Client calls tool again** with complete arguments
91
+ 6. **Method executes** normally
92
+
93
+ ---
94
+
95
+ ## Fluent Builder API
96
+
97
+ For more complex forms, use `ElicitationFormBuilder`:
98
+
99
+ ```typescript
100
+ import { Tool } from "@leanmcp/core";
101
+ import { Elicitation, ElicitationFormBuilder, validation } from "@leanmcp/elicitation";
102
+
103
+ class UserService {
104
+ @Tool({ description: "Create user account" })
105
+ @Elicitation({
106
+ builder: () => new ElicitationFormBuilder()
107
+ .title("User Registration")
108
+ .description("Create a new user account")
109
+ .addEmailField("email", "Email Address", { required: true })
110
+ .addTextField("username", "Username", {
111
+ required: true,
112
+ validation: validation()
113
+ .minLength(3)
114
+ .maxLength(20)
115
+ .pattern("^[a-zA-Z0-9_]+$")
116
+ .build()
117
+ })
118
+ .addSelectField("role", "Role", [
119
+ { label: "Admin", value: "admin" },
120
+ { label: "User", value: "user" }
121
+ ])
122
+ .build()
123
+ })
124
+ async createUser(args: any) {
125
+ return { success: true, email: args.email };
126
+ }
127
+ }
128
+ ```
129
+
130
+ ### Builder Methods
131
+
132
+ | Method | Description |
133
+ |--------|-------------|
134
+ | `title(string)` | Set form title |
135
+ | `description(string)` | Set form description |
136
+ | `condition(fn)` | Set condition for elicitation |
137
+ | `addTextField(name, label, opts?)` | Add text input |
138
+ | `addTextAreaField(name, label, opts?)` | Add textarea |
139
+ | `addNumberField(name, label, opts?)` | Add number input |
140
+ | `addBooleanField(name, label, opts?)` | Add checkbox |
141
+ | `addSelectField(name, label, options, opts?)` | Add dropdown |
142
+ | `addMultiSelectField(name, label, options, opts?)` | Add multi-select |
143
+ | `addEmailField(name, label, opts?)` | Add email input |
144
+ | `addUrlField(name, label, opts?)` | Add URL input |
145
+ | `addDateField(name, label, opts?)` | Add date picker |
146
+ | `addCustomField(field)` | Add custom field |
147
+ | `build()` | Build final config |
148
+
149
+ ---
150
+
151
+ ## Conditional Elicitation
152
+
153
+ Only ask for inputs when needed:
154
+
155
+ ```typescript
156
+ @Tool({ description: "Send message to Slack" })
157
+ @Elicitation({
158
+ condition: (args) => !args.channelId,
159
+ title: "Select Channel",
160
+ fields: [
161
+ {
162
+ name: "channelId",
163
+ label: "Channel",
164
+ type: "select",
165
+ required: true,
166
+ options: [
167
+ { label: "#general", value: "C12345" },
168
+ { label: "#random", value: "C67890" }
169
+ ]
170
+ }
171
+ ]
172
+ })
173
+ async sendMessage(args: { channelId?: string; message: string }) {
174
+ // Only elicits if channelId is missing
175
+ }
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Multi-Step Elicitation
181
+
182
+ Break input collection into sequential steps:
183
+
184
+ ```typescript
185
+ @Tool({ description: "Deploy application" })
186
+ @Elicitation({
187
+ strategy: "multi-step",
188
+ builder: () => [
189
+ {
190
+ title: "Step 1: Environment",
191
+ fields: [
192
+ {
193
+ name: "environment",
194
+ label: "Environment",
195
+ type: "select",
196
+ required: true,
197
+ options: [
198
+ { label: "Production", value: "prod" },
199
+ { label: "Staging", value: "staging" }
200
+ ]
201
+ }
202
+ ]
203
+ },
204
+ {
205
+ title: "Step 2: Configuration",
206
+ fields: [
207
+ {
208
+ name: "replicas",
209
+ label: "Replicas",
210
+ type: "number",
211
+ defaultValue: 3
212
+ }
213
+ ],
214
+ condition: (prev) => prev.environment === "prod"
215
+ }
216
+ ]
217
+ })
218
+ async deployApp(args: any) {
219
+ // Implementation
220
+ }
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Field Types
226
+
227
+ | Type | Description |
228
+ |------|-------------|
229
+ | `text` | Single-line text input |
230
+ | `textarea` | Multi-line text area |
231
+ | `number` | Numeric input |
232
+ | `boolean` | Checkbox |
233
+ | `select` | Dropdown (single choice) |
234
+ | `multiselect` | Multi-select |
235
+ | `email` | Email input |
236
+ | `url` | URL input |
237
+ | `date` | Date picker |
238
+
239
+ ---
240
+
241
+ ## Validation
242
+
243
+ ### Built-in Validation
244
+
245
+ ```typescript
246
+ {
247
+ name: "username",
248
+ label: "Username",
249
+ type: "text",
250
+ validation: {
251
+ minLength: 3,
252
+ maxLength: 20,
253
+ pattern: "^[a-zA-Z0-9_]+$",
254
+ errorMessage: "Username must be 3-20 alphanumeric characters"
255
+ }
256
+ }
257
+ ```
258
+
259
+ ### Using ValidationBuilder
260
+
261
+ ```typescript
262
+ import { validation } from "@leanmcp/elicitation";
263
+
264
+ validation()
265
+ .minLength(8)
266
+ .maxLength(100)
267
+ .pattern("^[a-zA-Z0-9]+$")
268
+ .customValidator((value) => value !== "admin")
269
+ .errorMessage("Invalid input")
270
+ .build()
271
+ ```
272
+
273
+ ---
274
+
275
+ ## API Reference
276
+
277
+ ### ElicitationConfig
278
+
279
+ ```typescript
280
+ interface ElicitationConfig {
281
+ strategy?: 'form' | 'multi-step';
282
+ title?: string;
283
+ description?: string;
284
+ fields?: ElicitationField[];
285
+ condition?: (args: any) => boolean;
286
+ builder?: (context: ElicitationContext) => ElicitationRequest | ElicitationStep[];
287
+ }
288
+ ```
289
+
290
+ ### ElicitationField
291
+
292
+ ```typescript
293
+ interface ElicitationField {
294
+ name: string;
295
+ label: string;
296
+ type: 'text' | 'number' | 'boolean' | 'select' | 'multiselect' | 'date' | 'email' | 'url' | 'textarea';
297
+ description?: string;
298
+ required?: boolean;
299
+ defaultValue?: any;
300
+ options?: Array<{ label: string; value: any }>;
301
+ validation?: FieldValidation;
302
+ placeholder?: string;
303
+ helpText?: string;
304
+ }
305
+ ```
306
+
307
+ ### FieldValidation
308
+
309
+ ```typescript
310
+ interface FieldValidation {
311
+ min?: number;
312
+ max?: number;
313
+ minLength?: number;
314
+ maxLength?: number;
315
+ pattern?: string;
316
+ customValidator?: (value: any) => boolean | string;
317
+ errorMessage?: string;
318
+ }
319
+ ```
320
+
321
+ ---
322
+
323
+ ## Best Practices
324
+
325
+ 1. **Use conditional elicitation** — Only ask when truly needed
326
+ 2. **Provide sensible defaults** — Reduce user input burden
327
+ 3. **Clear field labels** — Make fields self-explanatory
328
+ 4. **Validate early** — Catch errors before submission
329
+ 5. **Use builder for complex forms** — Fluent API is more maintainable
330
+
331
+ ---
332
+
333
+ ## Documentation
334
+
335
+ - [Full Documentation](https://docs.leanmcp.com/sdk/elicitation)
336
+
337
+ ## Related Packages
338
+
339
+ - [@leanmcp/core](https://www.npmjs.com/package/@leanmcp/core) — Core MCP server functionality
340
+ - [@leanmcp/auth](https://www.npmjs.com/package/@leanmcp/auth) — Authentication decorators
341
+ - [@leanmcp/cli](https://www.npmjs.com/package/@leanmcp/cli) — CLI for project scaffolding
342
+
343
+ ## Links
344
+
345
+ - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
346
+ - [NPM Package](https://www.npmjs.com/package/@leanmcp/elicitation)
347
+ - [MCP Specification](https://spec.modelcontextprotocol.io/)
348
+
349
+ ## License
350
+
351
+ MIT
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
- {
2
- "name": "@leanmcp/elicitation",
3
- "version": "0.1.1",
4
- "description": "Elicitation support for LeanMCP - structured user input collection",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "require": "./dist/index.js",
12
- "import": "./dist/index.mjs"
13
- }
14
- },
15
- "files": [
16
- "dist",
17
- "README.md",
18
- "LICENSE"
19
- ],
20
- "scripts": {
21
- "build": "tsup src/index.ts --format cjs,esm --dts",
22
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
23
- "clean": "rm -rf dist",
24
- "test": "jest --passWithNoTests",
25
- "lint": "eslint src"
26
- },
27
- "dependencies": {
28
- "reflect-metadata": "^0.2.0"
29
- },
30
- "devDependencies": {
31
- "@types/jest": "^29.5.0",
32
- "@types/node": "^20.0.0",
33
- "jest": "^29.7.0",
34
- "ts-jest": "^29.1.0"
35
- },
36
- "peerDependencies": {
37
- "@leanmcp/core": "*"
38
- },
39
- "keywords": [
40
- "mcp",
41
- "model-context-protocol",
42
- "typescript",
43
- "decorators",
44
- "elicitation",
45
- "forms",
46
- "validation",
47
- "user-input",
48
- "leanmcp"
49
- ],
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://github.com/LeanMCP/leanmcp-sdk.git",
53
- "directory": "packages/elicitation"
54
- },
55
- "homepage": "https://github.com/LeanMCP/leanmcp-sdk#readme",
56
- "bugs": {
57
- "url": "https://github.com/LeanMCP/leanmcp-sdk/issues"
58
- },
59
- "author": "LeanMCP <admin@leanmcp.com>",
60
- "license": "MIT",
61
- "publishConfig": {
62
- "access": "public"
63
- }
64
- }
1
+ {
2
+ "name": "@leanmcp/elicitation",
3
+ "version": "0.1.3",
4
+ "description": "Elicitation support for LeanMCP - structured user input collection",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsup src/index.ts --format cjs,esm --dts",
22
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
23
+ "clean": "rm -rf dist",
24
+ "test": "jest --passWithNoTests",
25
+ "lint": "eslint src"
26
+ },
27
+ "dependencies": {
28
+ "reflect-metadata": "^0.2.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/jest": "^29.5.0",
32
+ "@types/node": "^20.0.0",
33
+ "jest": "^29.7.0",
34
+ "ts-jest": "^29.1.0"
35
+ },
36
+ "peerDependencies": {
37
+ "@leanmcp/core": "*"
38
+ },
39
+ "keywords": [
40
+ "mcp",
41
+ "model-context-protocol",
42
+ "typescript",
43
+ "decorators",
44
+ "elicitation",
45
+ "forms",
46
+ "validation",
47
+ "user-input",
48
+ "leanmcp"
49
+ ],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/LeanMCP/leanmcp-sdk.git",
53
+ "directory": "packages/elicitation"
54
+ },
55
+ "homepage": "https://github.com/LeanMCP/leanmcp-sdk#readme",
56
+ "bugs": {
57
+ "url": "https://github.com/LeanMCP/leanmcp-sdk/issues"
58
+ },
59
+ "author": "LeanMCP <admin@leanmcp.com>",
60
+ "license": "MIT",
61
+ "publishConfig": {
62
+ "access": "public"
63
+ }
64
+ }