Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

McpSchema.Tool should expose outputSchema via public accessor instead of requiring reflection #783

Copy link
Copy link
@sivakothuri

Description

@sivakothuri
Issue body actions

When building CallToolResult for tools that declare an outputSchema, the SDK 0.17.2 requires structuredContent to be included in the response. However, there is no clean public API to check whether a McpSchema.Tool has an outputSchema set.

Currently, we are forced to use Java reflection to access the outputSchema field:
Object outputSchema = null; try { java.lang.reflect.Field field = tool.getClass().getDeclaredField("outputSchema"); field.setAccessible(true); outputSchema = field.get(tool); } catch (Exception e) { // No outputSchema field or access failed }

This approach is:

Fragile — breaks if the field is renamed or the class structure changes
Incompatible with module system — setAccessible(true) may fail under strict Java module rules (Java 17+)
Not idiomatic — McpSchema.Tool is a record, so it should already have an outputSchema() accessor

Expected Behavior:

McpSchema.Tool should expose a public outputSchema() method (or it already does as a record accessor, but it returns Map<String, Object> which may be null). The SDK should clearly document:

How to check if a tool has an outputSchema
Whether structuredContent is mandatory when outputSchema is present
Provide a utility or builder pattern that auto-handles the structured vs text content decision

Suggested Fix:

If Tool is a record, simply use tool.outputSchema() — document this clearly. If it's not exposed, add a public getter.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.