Skip to content

Conversation

@ezynda3
Copy link
Contributor

@ezynda3 ezynda3 commented Jun 26, 2025

Summary

Fixes #89: Tools created without input properties were causing OpenAI function calling validation errors.

Problem

When MCP tools were created without input parameters using mcp.NewTool("foo", mcp.WithDescription("tool without input")), the resulting OpenAPI schema had Type="object" but Properties=nil. This violated OpenAI's function calling schema requirements, causing the error:

OpenAIException - Invalid schema for function 'bar__foo' In context=(), object schema missing properties

Solution

  • Added schema validation fix in loadServerTools to ensure object schemas have an empty properties map when Properties is nil
  • The fix is minimal and targeted: if inputSchema.Type == "object" && inputSchema.Properties == nil { inputSchema.Properties = make(openapi3.Schemas) }

Testing

  • Added comprehensive regression test TestIssue89_ObjectSchemaMissingProperties
  • Added additional test coverage for tools without properties
  • All existing tests continue to pass
  • Project builds successfully with no linting issues

Impact

  • ✅ Resolves OpenAI function calling validation errors for tools without input parameters
  • ✅ Maintains backward compatibility
  • ✅ Users no longer need the workaround of adding dummy __unused__ parameters
  • ✅ No breaking changes to existing functionality

🤖 Generated with opencode

…rameters

Fixes #89: Tools created without input properties were causing OpenAI function
calling validation errors with "object schema missing properties" message.

The issue occurred when MCP tools had no input parameters, resulting in OpenAPI
schemas with Type="object" but Properties=nil, which violates OpenAI's function
calling schema requirements.

Changes:
- Add schema validation fix in loadServerTools to ensure object schemas have
  empty properties map when Properties is nil
- Add comprehensive regression test TestIssue89_ObjectSchemaMissingProperties
- Add additional test coverage for tools without properties

The fix ensures backward compatibility while resolving the validation error.
Users no longer need the workaround of adding dummy parameters to their tools.

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>
@ezynda3 ezynda3 merged commit daf5c41 into main Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error if a tool has no property (since 0.9.0)

2 participants