Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/spec.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,11 +1166,7 @@ export interface Tool extends BaseMetadata, Icons {
* An optional JSON Schema object defining the structure of the tool's output returned in
* the structuredContent field of a CallToolResult.
*/
outputSchema?: {
type: "object";
properties?: { [key: string]: object };
required?: string[];
};
outputSchema?: { [key: string]: unknown };

/**
* Optional additional tool information.
Expand Down
7 changes: 4 additions & 3 deletions src/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,17 @@ describe('Types', () => {
expect(result.success).toBe(false);
});

test('should still require type: object at root for outputSchema', () => {
test('should accept outputSchema with type: array', () => {
const tool = {
name: 'test',
inputSchema: { type: 'object' },
outputSchema: {
type: 'array'
type: 'array',
items: { type: 'string' }
}
};
const result = ToolSchema.safeParse(tool);
expect(result.success).toBe(false);
expect(result.success).toBe(true);
});

test('should accept simple minimal schema (backward compatibility)', () => {
Expand Down
10 changes: 1 addition & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1012,16 +1012,8 @@ export const ToolSchema = z.object({
/**
* An optional JSON Schema 2020-12 object defining the structure of the tool's output
* returned in the structuredContent field of a CallToolResult.
* Must have type: 'object' at the root level per MCP spec.
*/
outputSchema: z
.object({
type: z.literal('object'),
properties: z.record(z.string(), AssertObjectSchema).optional(),
required: z.array(z.string()).optional()
})
.catchall(z.unknown())
.optional(),
outputSchema: z.record(z.string(), z.unknown()).optional(),
/**
* Optional additional tool information.
*/
Expand Down
Loading