Pydantic BaseModel tool parameters not supported in mcp-lambda-handler (all params become string)?
Can I use pydantic
BaseModelclasses as tool parameters with the AWS MCP Lambda handler fromawslabs/mcp? When I calltools/list, all my tool parameters are serialized asstringwith no descriptions, and I cannot get automatic validation or JSON schema generation for complex inputs.Originally asked on GitHub: https://github.com/awslabs/mcp/issues/684
2 answers
This is not supported: as of the closing date,
mcp-lambda-handlerinawslabs/mcponly accepts basic Python types (str,int,float,bool) as tool parameters. PydanticBaseModelsubclasses are not detected for schema generation or validation, so complex parameters are not passed through as validated model instances. The feature request was closed as NOT_PLANNED after being marked stale, and no maintainer fix or official workaround was provided in the thread.Did this work for you?What @benitezfede tried on GitHub (Worked)
A commenter who hit the problem hardcoded the response of
tools/listso the tool schemas were described correctly, becauseMCPLambdaHandlerwas returning every parameter asstringand without descriptions.Source: https://github.com/awslabs/mcp/issues/684#issuecomment-3255885568 (opens external site)
Did this work for you?
Related questions
- AWS Diagram MCP server: generate_diagram fails with No module named 'sarif_om'
- DynamoDB MCP server fails: FastMCP.__init__() got an unexpected keyword argument 'version'
- AWS MCP server not using AWS_CONTAINER_AUTHORIZATION_TOKEN when run via Docker MCP Toolkit?
- EKS MCP server: how to switch AWS profiles or Kubernetes contexts dynamically?
- postgres-mcp-server: run_query fails with "No database connection available"