-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
Summary
I believe that the crate_model_from_json_schema is producing invalid Pydantic models, which eventually produce a KeyError when BaseModel.model_json_schema() is called.
Background
I was troubleshooting an issue which I believe originates from within mcpadapt.
A minimal example which produces the issue is:
#!/usr/bin/env python
from mcp import StdioServerParameters
from mcpadapt.core import MCPAdapt
from mcpadapt.crewai_adapter import CrewAIAdapter
with MCPAdapt(
StdioServerParameters(
command="npx",
args=["@smartbear/mcp@latest"],
env={
"PACT_BROKER_BASE_URL": "https://pact.example.com",
"PACT_BROKER_TOKEN": "foobar",
},
),
CrewAIAdapter(),
):
...which you can run with
$ uv venv --python 3.12
$ uv pip install mcp mcpadapt crewai websockets
$ uv run mwe.py
Traceback (most recent call last):
File "~/mwe/mwe.py", line 6, in <module>
with MCPAdapt(
^^^^^^^^^
[...]
KeyError: '#/properties/requestResponse/properties/request'I first thought that the MCP server was producing some malformed output, but inspecting it and it all looks fine (the below is abridged):
{
"tools": [
{
"name": "contract-testing_generate_pact_tests",
"title": "Contract Testing: Generate Pact Tests",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"language": { "type": "string" },
"requestResponse": {
"type": "object",
"properties": {
"request": {
"type": "object",
"properties": {
"filename": { "type": "string" },
"body": { "type": "string" }
},
"required": ["body"],
"additionalProperties": false
},
"response": {
"$ref": "#/properties/requestResponse/properties/request"
}
},
"required": ["request", "response"],
"additionalProperties": false
}
},
"additionalProperties": false
},
"annotations": {
"title": "Contract Testing: Generate Pact Tests",
"readOnlyHint": true,
"destructiveHint": false,
"idempotentHint": true,
"openWorldHint": false
}
}
]
}I suspect that the $ref is not being appropriately transformed, though I haven't looked into it much at this stage.
Related
The following error is related:
Metadata
Metadata
Assignees
Labels
No labels