Skip to content

Commit d60251b

Browse files
ochafikclaude
andcommitted
feat: add @description JSDoc tags for .describe() generation
When extracting derived capability types during pre-processing, copy the parent property's JSDoc description and add it as @description tag. ts-to-zod then converts @description to .describe() calls in schemas: - ClientTasksCapabilitySchema.describe('Present if the client supports...') - ServerTasksCapabilitySchema.describe('Present if the server supports...') 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 239910a commit d60251b

File tree

3 files changed

+81
-73
lines changed

3 files changed

+81
-73
lines changed

scripts/generate-schemas.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,16 @@ function injectDerivedCapabilityTypes(sourceFile: SourceFile): void {
318318
// Remove trailing '?' or '| undefined' to get the non-optional type
319319
typeText = typeText.replace(/\s*\|\s*undefined\s*$/, '').trim();
320320

321-
// Create the derived type alias
321+
// Get the JSDoc comment from the parent property for @description
322+
const jsDocs = prop.getJsDocs();
323+
const description = jsDocs.length > 0 ? jsDocs[0].getDescription().trim() : '';
324+
325+
// Create the derived type alias with @description for .describe() generation
322326
sourceFile.addTypeAlias({
323327
name: typeName,
324328
isExported: true,
325329
type: typeText,
326-
docs: [`Extracted from ${parent}["${property}"] for standalone use.`]
330+
docs: [description ? `@description ${description}` : `Extracted from ${parent}["${property}"].`]
327331
});
328332
console.log(` ✓ Added derived type: ${typeName} from ${parent}.${property}`);
329333
}

src/generated/sdk.schemas.ts

Lines changed: 73 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,76 +1960,80 @@ export const ListToolsResultSchema = PaginatedResultSchema.extend({
19601960
tools: z.array(ToolSchema)
19611961
});
19621962

1963-
/** Extracted from ClientCapabilities["tasks"] for standalone use. */
1964-
export const ClientTasksCapabilitySchema = z.object({
1965-
/**
1966-
* Whether this client supports tasks/list.
1967-
*/
1968-
list: z.record(z.string(), z.any()).optional(),
1969-
/**
1970-
* Whether this client supports tasks/cancel.
1971-
*/
1972-
cancel: z.record(z.string(), z.any()).optional(),
1973-
/**
1974-
* Specifies which request types can be augmented with tasks.
1975-
*/
1976-
requests: z
1977-
.object({
1978-
/**
1979-
* Task support for sampling-related requests.
1980-
*/
1981-
sampling: z
1982-
.object({
1983-
/**
1984-
* Whether the client supports task-augmented sampling/createMessage requests.
1985-
*/
1986-
createMessage: z.record(z.string(), z.any()).optional()
1987-
})
1988-
.optional(),
1989-
/**
1990-
* Task support for elicitation-related requests.
1991-
*/
1992-
elicitation: z
1993-
.object({
1994-
/**
1995-
* Whether the client supports task-augmented elicitation/create requests.
1996-
*/
1997-
create: z.record(z.string(), z.any()).optional()
1998-
})
1999-
.optional()
2000-
})
2001-
.optional()
2002-
});
1963+
/** @description Present if the client supports task-augmented requests. */
1964+
export const ClientTasksCapabilitySchema = z
1965+
.object({
1966+
/**
1967+
* Whether this client supports tasks/list.
1968+
*/
1969+
list: z.record(z.string(), z.any()).optional(),
1970+
/**
1971+
* Whether this client supports tasks/cancel.
1972+
*/
1973+
cancel: z.record(z.string(), z.any()).optional(),
1974+
/**
1975+
* Specifies which request types can be augmented with tasks.
1976+
*/
1977+
requests: z
1978+
.object({
1979+
/**
1980+
* Task support for sampling-related requests.
1981+
*/
1982+
sampling: z
1983+
.object({
1984+
/**
1985+
* Whether the client supports task-augmented sampling/createMessage requests.
1986+
*/
1987+
createMessage: z.record(z.string(), z.any()).optional()
1988+
})
1989+
.optional(),
1990+
/**
1991+
* Task support for elicitation-related requests.
1992+
*/
1993+
elicitation: z
1994+
.object({
1995+
/**
1996+
* Whether the client supports task-augmented elicitation/create requests.
1997+
*/
1998+
create: z.record(z.string(), z.any()).optional()
1999+
})
2000+
.optional()
2001+
})
2002+
.optional()
2003+
})
2004+
.describe('Present if the client supports task-augmented requests.');
20032005

2004-
/** Extracted from ServerCapabilities["tasks"] for standalone use. */
2005-
export const ServerTasksCapabilitySchema = z.object({
2006-
/**
2007-
* Whether this server supports tasks/list.
2008-
*/
2009-
list: z.record(z.string(), z.any()).optional(),
2010-
/**
2011-
* Whether this server supports tasks/cancel.
2012-
*/
2013-
cancel: z.record(z.string(), z.any()).optional(),
2014-
/**
2015-
* Specifies which request types can be augmented with tasks.
2016-
*/
2017-
requests: z
2018-
.object({
2019-
/**
2020-
* Task support for tool-related requests.
2021-
*/
2022-
tools: z
2023-
.object({
2024-
/**
2025-
* Whether the server supports task-augmented tools/call requests.
2026-
*/
2027-
call: z.record(z.string(), z.any()).optional()
2028-
})
2029-
.optional()
2030-
})
2031-
.optional()
2032-
});
2006+
/** @description Present if the server supports task-augmented requests. */
2007+
export const ServerTasksCapabilitySchema = z
2008+
.object({
2009+
/**
2010+
* Whether this server supports tasks/list.
2011+
*/
2012+
list: z.record(z.string(), z.any()).optional(),
2013+
/**
2014+
* Whether this server supports tasks/cancel.
2015+
*/
2016+
cancel: z.record(z.string(), z.any()).optional(),
2017+
/**
2018+
* Specifies which request types can be augmented with tasks.
2019+
*/
2020+
requests: z
2021+
.object({
2022+
/**
2023+
* Task support for tool-related requests.
2024+
*/
2025+
tools: z
2026+
.object({
2027+
/**
2028+
* Whether the server supports task-augmented tools/call requests.
2029+
*/
2030+
call: z.record(z.string(), z.any()).optional()
2031+
})
2032+
.optional()
2033+
})
2034+
.optional()
2035+
})
2036+
.describe('Present if the server supports task-augmented requests.');
20332037

20342038
/**
20352039
* A request that expects a response.

src/generated/sdk.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,7 +2557,7 @@ export type ServerResult =
25572557
| GetTaskPayloadResult
25582558
| ListTasksResult
25592559
| CancelTaskResult;
2560-
/** Extracted from ClientCapabilities["tasks"] for standalone use. */
2560+
/** @description Present if the client supports task-augmented requests. */
25612561
export type ClientTasksCapability = {
25622562
/**
25632563
* Whether this client supports tasks/list.
@@ -2591,7 +2591,7 @@ export type ClientTasksCapability = {
25912591
};
25922592
};
25932593
};
2594-
/** Extracted from ServerCapabilities["tasks"] for standalone use. */
2594+
/** @description Present if the server supports task-augmented requests. */
25952595
export type ServerTasksCapability = {
25962596
/**
25972597
* Whether this server supports tasks/list.

0 commit comments

Comments
 (0)