Description
Issue Description
The GitHub MCP server's create_issue
function encounters an error when provided with labels that are objects with name/description properties instead of simple strings. This causes the following error when creating issues with labels:
MCP error -32603: Invalid arguments: labels.0.description: Expected string, received null
Problem Analysis
The issue occurs because:
-
The GitHub API can accept labels in two formats:
- Simple string arrays:
["bug", "enhancement"]
- Objects with name and description:
[{"name": "bug", "description": "A bug"}]
- Simple string arrays:
-
The current implementation in
schemas.ts
only accepts string arrays:labels: z.array(z.string()).optional()
-
When clients (like Cursor) send labels as objects with name/description properties, the validation fails.
Proposed Changes
I've implemented the following changes to fix this issue:
-
Updated the schema in
src/github/schemas.ts
to accept either format:labels: z.array( z.union([ z.string(), z.object({ name: z.string(), description: z.string().optional() }) ]) ).optional().describe("Array of label names or label objects")
-
Modified the
createIssue
function insrc/github/index.ts
to process the labels before sending them to the GitHub API:// Process labels to ensure they're in the right format for GitHub API let processedOptions = { ...options }; if (processedOptions.labels && Array.isArray(processedOptions.labels)) { processedOptions = { ...processedOptions, labels: processedOptions.labels.map(label => typeof label === 'string' ? label : label.name ) as string[] }; }
Testing
The fix has been tested and confirmed to work with:
- Labels as simple string arrays
- Multiple labels
- Single labels
This change makes the GitHub MCP server more robust when handling different label formats while maintaining backward compatibility with existing code.