Skip to content

Commit 5315511

Browse files
its-mashclaude
andauthored
feat: add default property to input schema definition (#12)
Add `default` field to the input definition in the JSON schema, aligning the schema with the Rust types that already support it. Includes a schema validation test for inputs with defaults. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 417d53d commit 5315511

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

schemas/server-definition.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@
218218
"type": "string",
219219
"description": "Help text for this input"
220220
},
221+
"default": {
222+
"type": "string",
223+
"description": "Default value for this input (used when user provides no value)"
224+
},
221225
"placeholder": {
222226
"type": "string",
223227
"description": "Placeholder text"

tests/schema-validation.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ describe("Server Definition Schema", () => {
5050
it.each([
5151
{ id: "com.example-test", name: "Test", transport: { type: "stdio", command: "echo" } },
5252
{ id: "com.example-remote", name: "Remote", transport: { type: "http", url: "https://example.com/mcp" } },
53+
{
54+
id: "com.example-defaults", name: "Defaults Test",
55+
transport: {
56+
type: "stdio", command: "node", args: ["server.js"],
57+
env: { "LOG_LEVEL": "${input:LOG_LEVEL}" },
58+
metadata: {
59+
inputs: [
60+
{ id: "LOG_LEVEL", label: "Log Level", type: "text", required: false, default: "info" },
61+
{ id: "API_KEY", label: "API Key", type: "password", required: true, secret: true },
62+
],
63+
},
64+
},
65+
},
5366
])("validates valid server definition: $id", (data) => {
5467
expect(validate(data)).toBe(true);
5568
});

0 commit comments

Comments
 (0)