Skip to content

Commit c9d20f1

Browse files
committed
Enhance tool descriptions with italic formatting and improve parameter handling in MCP tools
1 parent 9df6df1 commit c9d20f1

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

mini-a-mcptest.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function listMCPTools(mcpClient, showElapsed) {
109109
tools.forEach((tool, idx) => {
110110
print(ansiColor("FG(41)", `[${idx + 1}] ${tool.name}`))
111111
if (isDef(tool.description)) {
112-
print(" " + ansiColor("FAINT", tool.description))
112+
print(" " + ansiColor("FAINT,ITALIC", tool.description))
113113
}
114114
if (isDef(tool.inputSchema) && isDef(tool.inputSchema.properties)) {
115115
var props = Object.keys(tool.inputSchema.properties)
@@ -130,7 +130,7 @@ function listMCPTools(mcpClient, showElapsed) {
130130
// Show tool details
131131
function showToolDetails(tool) {
132132
print("\n" + ansiColor("BOLD,FG(41)", "Tool: " + tool.name))
133-
print(ansiColor("FAINT", "─────────────────────"))
133+
print(ansiColor("FAINT", repeat(tool.name.length, "─")))
134134

135135
if (isDef(tool.description)) {
136136
print(ansiColor("FG(248)", "Description: ") + tool.description)
@@ -151,13 +151,13 @@ function showToolDetails(tool) {
151151
print(" " + ansiColor("FAINT", "Type: ") + prop.type)
152152
}
153153
if (isDef(prop.description)) {
154-
print(" " + ansiColor("FAINT", prop.description))
154+
print(" " + ansiColor("FAINT,ITALIC", prop.description))
155155
}
156156
if (isDef(prop.enum)) {
157157
print(" " + ansiColor("FAINT", "Allowed: ") + prop.enum.join(", "))
158158
}
159159
if (isDef(prop.example)) {
160-
print(" " + ansiColor("FAINT", "Example: ") + prop.example)
160+
print(" " + ansiColor("FAINT", "Example: ") + (isObject(prop.example) ? af.toCSLON(prop.example) : prop.example))
161161
}
162162
})
163163
}
@@ -196,7 +196,7 @@ function buildToolParams(tool) {
196196
promptMsg += ansiColor("FAINT", " (" + prop.type + ")")
197197
}
198198
if (isDef(prop.description)) {
199-
print(" " + ansiColor("FAINT", prop.description))
199+
print(" " + ansiColor("FAINT,ITALIC", prop.description))
200200
}
201201

202202
var value = ask(promptMsg + ": ")
@@ -620,7 +620,7 @@ function mainMCPTest(args) {
620620
var toolIdx = askChoose("Choose a tool to call: ", toolNames, sessionOptions.toolchoosesize)
621621

622622
if (toolIdx < tools.length) {
623-
var tool = tools[toolIdx]
623+
var tool = tools.filter(t => t.name == toolNames[toolIdx])[0]
624624
showToolDetails(tool)
625625

626626
var params = buildToolParams(tool)
@@ -647,7 +647,7 @@ function mainMCPTest(args) {
647647
var toolIdx = askChoose("Choose a tool to inspect: ", toolNames, sessionOptions.toolchoosesize)
648648

649649
if (toolIdx < tools.length) {
650-
showToolDetails(tools[toolIdx])
650+
showToolDetails(tools.filter(t => t.name == toolNames[toolIdx])[0])
651651
}
652652
}
653653
}
@@ -683,7 +683,7 @@ function mainMCPTest(args) {
683683
var optionIdx = askChoose("Choose an option to toggle: ", optionChoices)
684684

685685
if (optionIdx < optionKeys.length) {
686-
toggleOption(optionKeys[optionIdx])
686+
toggleOption(optionKeys.filter((k) => optionChoices[optionIdx].startsWith(k))[0])
687687
print()
688688
}
689689
}
@@ -705,7 +705,7 @@ function mainMCPTest(args) {
705705
var setOptionIdx = askChoose("Choose an option to set: ", allOptionChoices)
706706

707707
if (setOptionIdx < allOptionKeys.length) {
708-
var selectedKey = allOptionKeys[setOptionIdx]
708+
var selectedKey = allOptionKeys.filter((k) => allOptionChoices[setOptionIdx].startsWith(k))[0]
709709
var def = optionDefinitions[selectedKey]
710710
var newValue = ask("Enter new value for " + selectedKey + " (" + def.type + "): ")
711711

0 commit comments

Comments
 (0)