Hey folks, I am trying to implement an `McpToolDes...
# koog-agentic-framework
d
Hey folks, I am trying to implement an
McpToolDescriptorParser
that supports
type
attributes with nullable primitives represented like
["string", "null"]
(as generated by
kotlinx-schema
). So I am trying to transform it to an
ToolParameterType.AnyOf
, though I am confused because
ToolParameterType.AnyOf(...)
takes an array of
ToolParameterDescriptor
for the union types. And
ToolParameterDescriptor
, requires a
title
and
description
which seems incorrect to me as these are supposed to be only types and not parameters. So I believe it should rather take an array of
ToolParameterType
. Am I right? Also there is a TODO in front of the
ToolParameterDescriptor
class definition:
Copy code
// FIXME ToolParameterDescriptor.name in types array is actually always ignored when the schema is constructed.
//  Should we use a dedicated type here instead?
I would love guidance here, please.
a
Hi @Didier Villevalois, thanks for the question! I summon @Pavel Gorgulov for some help 😅 Thanks in advance and sorry for ping
❤️ 1
d
Thanks Anastasiia! 😄
❤️ 1
Hmm, I also tried to completely bypass the
McpToolDescriptorParser
but all the agents and llm client API depends on
ToolDescriptor
. What bugs me is that
ToolDescriptor
s are then used to generate Json again in llm clients... Shouldn't we completely remove those
ToolDescriptor
s and work with MCP SDK's input and output
ToolSchema
directly?
m
Hey! I think the possible way to go is (the example from the integration test). Does this make sense to you or help to solve the problem? Otherwise, could you share the MCP server and the tool name you can or want to parse, I'll try to find a way
Copy code
ToolParameterDescriptor(
                name = "discount",
                description = "Discount for token, can be Double or Null",
                type = ToolParameterType.AnyOf(
                    types = arrayOf(
                        ToolParameterDescriptor(
                            name = "discount",
                            description = "Price for token, can be, Double option",
                            type = ToolParameterType.Float
                        ),
                        ToolParameterDescriptor(
                            name = "discount",
                            description = "Price for token, can be, Null option",
                            type = ToolParameterType.Null
                        )
                    )
                )
            ),
thank you color 1
I think having ToolParameterDescriptor as a type is ok, I guess it's allowed by the JSON schema
d
Then what
ToolParameterDescriptor
should I generate for
"type": ["string", "null"]
? I really believe forcing a
description
and a
name
for the members of a union makes little sense.
I am using
kotlinx-schema
0.5.0 to generate the tool schemas.
I will put garbage in the
name
and
description
for now... But I think
ToolParameterDescriptor
is broken when compared to what MCP allows.
m
Ok, I’ll check how it works in a both of places and be back with the solution, but as for now you can just put the same description and name as for the main parameter. I think the name is extra for sure (description as well I guess, so maybe we will just have a list of types there as you suggested
d
I think that the notion of type declaration and type reference are collapsed here. Why not squeeze out the
ToolDescriptor
for good and use
kotlinx-schema
representations?
m
It's THE plan, just need some time and capacity to do so 🙏
❤️ 1
d
Oh, that's marvelous!