@@ -19,15 +19,27 @@ import sttp.tapir.docs.apispec.schema.TapirSchemaToJsonSchema
1919 * The server name (for protocol reporting).
2020 * @param version
2121 * The server version (for protocol reporting).
22+ * @param showJsonSchemaMetadata
23+ * Whether to include JSON Schema metadata (such as $schema) in the tool input schemas. Some agents do not recognize it, so it can be
24+ * disabled.
2225 */
23- class McpHandler [F [_]](tools : List [ServerTool [? , F ]], name : String = " Chimp MCP server" , version : String = " 1.0.0" ):
26+ class McpHandler [F [_]](
27+ tools : List [ServerTool [? , F ]],
28+ name : String = " Chimp MCP server" ,
29+ version : String = " 1.0.0" ,
30+ showJsonSchemaMetadata : Boolean = true
31+ ):
2432 private val logger = LoggerFactory .getLogger(classOf [McpHandler [_]])
2533 private val ProtocolVersion = " 2025-03-26"
2634 private val toolsByName = tools.map(t => t.name -> t).toMap
2735
2836 /** Converts a ServerTool to its protocol definition. */
2937 private def toolToDefinition (tool : ServerTool [? , F ]): ToolDefinition =
30- val jsonSchema = TapirSchemaToJsonSchema (tool.inputSchema, markOptionsAsNullable = true )
38+ val jsonSchema =
39+ val base = TapirSchemaToJsonSchema (tool.inputSchema, markOptionsAsNullable = true )
40+ if showJsonSchemaMetadata then base
41+ else base.copy($schema = None )
42+
3143 val json = jsonSchema.asJson
3244 ToolDefinition (
3345 name = tool.name,
0 commit comments