How can I accept a list of strings with `Tool.Arg`...
# http4k
g
How can I accept a list of strings with
Tool.Arg
? I am not able to find something like a
list()
method?
Copy code
val pathsArg =
  Tool.Arg.string().required("collectionPath", "List of Absolute paths")
I want Cursor to call my MCP with argument like this:
Copy code
{
  "paths": [
    "../..",
    "/.."
  ]
}
d
Try Tool.Arg.multi.required()
Although that will probably only work with a csv string. It's a good point and we will need to add it, but you should be able to put the format in the arg description and the LLM will figure it out
g
Thanks @dave. How can I take complex arguments, like a JSON Object? I couldn't find any examples in the repo, they are all taking simple arguments like
int
,
string
etc
d
ah now this is something that we don't support yet. It's on the "next" list right now. We have the tools to create the schema but we concentrated on reflection free design first and the JSON schema in http4k needs reflection
For now you'll have to either: 1. Manually add each of the args in the schema 2. Create your own tool implementation that does build the schema manually. You will have to implement toolcapability interface. It's coming soon - just not there yet. The idea will be to plug it directly into things like the open API generator so we get automatic support for complex schemas
👍🏼 1
g
Sure @dave, also wanna report, maybe
multi
is not working as expected. I constantly get this error with Cursor
d
thanks - although that's no real help without the actual traffic (if you can use a debug filter to see what it is and post it then that would be great)
g
@dave here is the log
Copy code
workbench.desktop.main.js:1001 [ToolV2Service] ToolCallError details: {clientMessage: "Invalid type for parameter 'collectionPaths' in tool execute-collection", modelMessage: "Parameter 'collectionPaths' must be of type array, got string", actualError: 'Type mismatch for execute-collection.collectionPaths: expected array, got string'}
👍 1
Here is a sample MCP server: Ape.kt
d
You might be able to just add a single tool string arg with the correct description for the format (CSV) and the model should be able to figure it out
Might unblock you
g
Copy code
val pmCollectionPathArg =
  Tool.Arg.multi.required(
    "collectionPaths",
    "JSON array of Absolute paths to the Postman Collection files",
  )
I have added single tool string only. What is the expected format for this?
I am expecting this, but it's failing
Copy code
{
  "collectionPaths": [
    "a.postman_collection.json",
    "b.postman_collection.json",
    "c.postman_collection.json"
  ]
}
d
You need to use a single arg and tell the LLM to concatenate values as CSV in a string