-
Pre-submission Checklist
Question Category
Your QuestionI'm trying to define a tool that accepts an array of objects example: import { z } from 'zod';
const taskSchema = z.object({
details: z.string().max(10000).optional(),
parent_id: z.number().optional(),
scheduled_time: z.string().optional(),
sort_order: z.number().optional(),
status: z.enum([
'pending',
'in progress',
'on hold',
'blocked',
'review',
'cancelled',
'completed',
]).optional(),
title: z.string(),
});
const schema = z.object({
tasks: z.array(taskSchema).min(1).describe('Array of tasks to create.'),
});
export default async function (server, toolName = 'task-create') {
server.tool(
toolName,
'Creates one or more tasks. Returns an array of the task IDs that were created.',
schema,
async (args, extra) => {
...... and this is what the openai mcp client sees: "type": "mcp_list_tools",
"server_label": "tasklist",
"tools": [
{
"annotations": null,
"description": "Creates one or more tasks. Returns an array of the task IDs that were created.",
"input_schema": {
"type": "object"
},
"name": "task-create"
}, what am i missing? checking the mcp list/tools response {
"result": {
"tools": [
{
"name": "task-create",
"description": "Creates one or more tasks. Returns an array of the task IDs that were created.",
"inputSchema": {
"type": "object"
},
"annotations": {
"type": "object",
"properties": {
"tasks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"details": {
"type": "string",
"maxLength": 10000
},
"parent_id": {
"type": "number"
},
"scheduled_time": {
"type": "string"
},
"sort_order": {
"type": "number"
},
"status": {
"type": "string",
"enum": [
"pending",
"in progress",
"on hold",
"blocked",
"review",
"cancelled",
"completed"
]
},
"title": {
"type": "string"
}
},
"required": [
"title"
],
"additionalProperties": false
},
"minItems": 1
}
},
"required": [
"tasks"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
...
```
|
Beta Was this translation helpful? Give feedback.
Answered by
rpurinton
Jun 10, 2025
Replies: 1 comment
-
resolved. the problem is here: const schema = z.object({
tasks: z.array(taskSchema).min(1).describe('Array of tasks to create.'),
}); change to const schema = {
tasks: z.array(taskSchema).min(1).describe('Array of tasks to create.'),
}; Ie: no outer z.object wrapper |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rpurinton
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
resolved.
the problem is here:
change to
Ie: no outer z.object wrapper