Skip to content

No way to set a tool's outputSchema: ToolDefinition has the field, the server builder has no setter #206

Description

@azhur

Summary

ToolDefinition carries outputSchema, but nothing on the server side can populate it — so it is always None on the wire.

Detail (chimp 0.4.0)

The protocol type has the field:

// chimp.protocol
final case class ToolDefinition(
    name: String,
    description: Option[String],
    inputSchema: Json,
    outputSchema: Option[Json],  // <- never set
    // ...
)

The server-side tool has no output counterpart, only an input schema and decoder:

// chimp.server
final case class ServerTool[I, F[_], C <: ServerContext[F]](
    name: String,
    description: Option[String],
    inputSchema: ToolSchema,
    inputDecoder: Decoder[I],
    annotations: Option[ToolAnnotations],
    logic: (I, C, Seq[Header]) => F[?]
)

and the builder offers no way to supply one:

// chimp.server
final case class PartialTool(...):
  def input[I: Schema: Decoder]: Tool[I]
  def inputJson(schema: Json): Tool[Json]
  // no .output / .outputJson

So a tool can describe what it accepts, but not what it returns:

tool("get_violations")
  .description("Top violated criteria, ranked by count")
  .input[ViolationsInput]      // schema advertised
  .serverLogic[F] { (in, _) =>
    ZIO.succeed(ToolResult.text(summary).withStructured(rows.asJson))
  }                            // structuredContent, but no schema describing it

Why it matters

ToolResult.withStructured already returns structuredContent, so clients get structured data — with no declared schema to validate it against. For tools returning tabular results that is the difference between data and a contract.

Spec context: outputSchema/structuredContent arrived in 2025-06-18, and 2026-07-28 loosened both inputSchema and outputSchema to allow any JSON Schema 2020-12 keywords — so it seems to be getting more load-bearing, not less.

Suggested shape

An .output mirroring .input, deriving the schema the same way:

tool("get_violations")
  .description("Top violated criteria, ranked by count")
  .input[ViolationsInput]
  .output[ViolationsOutput]    // populates ToolDefinition.outputSchema
  .serverLogic[F] { ... }

Happy to send a PR if that shape looks right.

Context

Possibly in scope for #144, but that issue is a general conformance target and does not name this, so filing separately. Found while building a server whose tools all return tabular data — everything else in chimp has been a pleasure to work with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions