Ok so I created two simple tools to add and multiply a couple of numbers, without any widgets, starting from scratch to see if I was doing something wrong. But it seems it only works when the function is read-only; write functions sometimes work randomly, but most times it doesn’t, those are the two functions code:
server.registerTool(
'add',
{
title: 'Addition Tool',
description: 'Use this function to add/sum or subtract two numbers',
inputSchema: { a: z.number(), b: z.number() },
outputSchema: { result: z.number() },
_meta: {
"openai/toolInvocation/invoking": "Displaying result",
"openai/toolInvocation/invoked": "Displayed result"
},
annotations: {
readOnlyHint: false
}
},
async ({ a, b }) => {
const output = { result: a + b };
return {
content: [{ type: 'text', text: JSON.stringify(output) }],
structuredContent: output
};
}
);
server.registerTool(
'multiply',
{
title: 'Multiply Tool',
description: 'Use this function to multiply two numbers',
inputSchema: { a: z.number(), b: z.number() },
outputSchema: { result: z.number() },
_meta: {
"openai/toolInvocation/invoking": "Displaying result",
"openai/toolInvocation/invoked": "Displayed result"
},
annotations: {
readOnlyHint: false
}
},
async ({ a, b }) => {
const output = { result: a * b };
return {
content: [{ type: 'text', text: "Multiplied!" }],
structuredContent: output
};
}
);
When readOnlyHint is true, results display:
When readOnlyHint is false, stuck in “Called tool”:
Am I missing something silly here, or is it really broken?
On a side note, _meta for openai/toolInvocation/invoked and openai/toolInvocation/invoking seems not to be working as well, as you can see in the screenshots