github / github/copilot-cli

MCP tools with $defs/$ref in inputSchema fail — parameters can't be constructed

Abierto
#1,876 1 comentario 3 reacciones 0 asignados Ver en GitHub
area:mcp
Lenguaje dominante
Shell
Estrellas
11.2k
Forks
1.9k
Merge medio
14 h 16 min
PR fusionados (30 d)
6

Descripción

# MCP tools with `$defs`/`$ref` in inputSchema fail — parameters can't be constructed

### Describe the bug

MCP tool calls fail with `Input validation error: 'X' is a required property` when the MCP server's tool `inputSchema` uses `$defs` + `$ref` to define parameter types. The `$ref` references are never resolved, so the client cannot construct or validate the required parameters.

Tools that don't use `$ref` (e.g., simple tools with no required params) work fine on the same MCP connection.

### Affected version

0.0.423

### Root cause analysis

The PagerDuty MCP server (`https://mcp.pagerduty.com/mcp`) returns tool schemas like this (abbreviated):

```json
{
"name": "list_schedules",
"inputSchema": {
"$defs": {
"ScheduleQuery": {
"properties": {
"query": { "type": "string", "default": null },
"team_ids": { "type": "array", "default": null },
"limit": { "type": "integer", "default": 20 }
},
"type": "object"
}
},
"properties": {
"query_model": { "$ref": "#/$defs/ScheduleQuery" }
},
"required": ["query_model"],
"type": "object"
}
}
```

This is valid JSON Schema. The `$defs` block is present in the same schema object and `$ref` points to it. However, the Copilot CLI MCP client:

1. Presents the tool parameter as just `"query_model": {"$ref": "#/$defs/ScheduleQuery"}` — the reference is never inlined
2. The model has no visibility into the actual properties of `query_model`
3. Every call fails validation because `query_model` is required but the model can't construct it

### Steps to reproduce

1. Configure the PagerDuty MCP server:
```json
{
"pagerduty": {
"url": "https://mcp.pagerduty.com/mcp",
"type": "http",
"headers": {
"Authorization": "Token token=${PAGERDUTY_API_TOKEN}"
}
}
}
```
2. Start `copilot`
3. Ask: "Who is on call?"
4. The agent attempts to call `list_schedules` or `list_oncalls`
5. Every call fails with: `MCP server 'pagerduty': Input validation error: 'query_model' is a required property`

### What works vs. what doesn't

| Tool | Has `$ref`? | Result |
|------|------------|--------|
| `get_user_data` | No (no params) | ✅ Works |
| `get_incident` | No (`incident_id` is a plain string) | ✅ Works |
| `list_schedules` | Yes (`query_model: $ref ScheduleQuery`) | ❌ Fails |
| `list_oncalls` | Yes (`query_model: $ref OncallQuery`) | ❌ Fails |
| `list_incidents` | Yes (`query_model: $ref IncidentQuery`) | ❌ Fails |

### Expected behavior

The MCP client should resolve `$ref` references within `inputSchema` (at minimum local `$defs` references) before presenting tool parameters to the model, so it can construct valid inputs.

### Additional context

- The PagerDuty server's schemas are valid JSON Schema and work correctly when called via `curl`
- This likely affects any MCP server that uses `$defs`/`$ref` in `inputSchema` (a common pattern in Python MCP servers using Pydantic models)
- Related: #1825 (another `inputSchema` handling issue)

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.