You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"}]
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 in src/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 APIletprocessedOptions={ ...options};if(processedOptions.labels&&Array.isArray(processedOptions.labels)){processedOptions={
...processedOptions,labels: processedOptions.labels.map(label=>typeoflabel==='string' ? label : label.name)asstring[]};}
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.
The text was updated successfully, but these errors were encountered:
sirkitree
added a commit
to sirkitree/mcp-servers
that referenced
this issue
Mar 2, 2025
…error logging
Resolvesmodelcontextprotocol#715
- Update CreateIssueOptionsSchema to support label objects with name and description
- Add robust error logging in createIssue function
- Improve label processing to handle both string and object label formats
- Add detailed error reporting for GitHub API and request handler errors
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:Problem Analysis
The issue occurs because:
The GitHub API can accept labels in two formats:
["bug", "enhancement"]
[{"name": "bug", "description": "A bug"}]
The current implementation in
schemas.ts
only accepts string arrays: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:Modified the
createIssue
function insrc/github/index.ts
to process the labels before sending them to the GitHub API:Testing
The fix has been tested and confirmed to work with:
This change makes the GitHub MCP server more robust when handling different label formats while maintaining backward compatibility with existing code.
The text was updated successfully, but these errors were encountered: