[Bug] /mcp slash command sends empty string for required prompt parameters, causing Zod validation error
Resolved 💬 1 comment Opened May 11, 2026 by mayukoooo Closed May 19, 2026
Bug Description
When executing an MCP prompt via the /mcp slash command, required parameters (defined with argsSchema) are sent as empty strings, causing Zod validation errors before the prompt handler is reached.
Steps to Reproduce
- Configure an MCP server that registers a prompt with required parameters using
argsSchema:
``typescript``
mcpServer.registerPrompt('my_prompt', {
description: 'Example prompt',
argsSchema: {
repository: z.string().regex(/^[\w.\-/]+$/).max(100).describe('Repository name (e.g., "RepoName")'),
},
}, async (params) => { /* handler */ });
- In Claude Code CLI, type
/mcp - Select the prompt from the dialog
- The prompt is invoked immediately without prompting the user to input the required
repositoryparameter
Expected Behavior
- Claude Code should prompt the user to input required parameters before invoking the MCP prompt, OR
- Display a user-friendly error message when required parameters are missing
Actual Behavior
The prompt is invoked with an empty string for the required parameter, resulting in a raw Zod validation error:
McpError: MCP error -32602: MCP error -32602: Invalid arguments for prompt my_prompt: [
{
"origin": "string",
"code": "invalid_format",
"format": "regex",
"pattern": "/^[\\w.\\-/]+$/",
"path": ["repository"],
"message": "Invalid string: must match pattern /^[\\w.\\-/]+$/"
}
]
Environment
- Claude Code v2.1.74
- macOS (Darwin 24.6.0)
Notes
- This affects any MCP prompt with required parameters that have format validation (regex, min length, etc.)
- MCP tools with required
inputSchemaparameters work correctly — this issue is specific to prompts withargsSchema - As a server-side workaround, removing regex validation from the Zod schema and validating manually inside the handler can provide a friendlier error, but this shouldn't be necessary
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗