Repository navigation
Replies: 3 comments
|
I just found the ILlmController interface documentation: https://github.com/samchon/typia/blob/master/packages/interface/src/schema/ILlmController.ts It shows this example: class Calculator {
add(input: { a: number; b: number }): number { // returns number (primitive)
return input.a + input.b;
}
}But when I actually tried this, I got an error:
The documentation suggests that returning a primitive like number or string is allowed. In practice, typia requires the return type to be an object. |
|
import type { ILlmController } from "@typia/interface";
export class TicketController implements ILlmController {
public async searchTickets(
props: { query: string },
): Promise<{ content: { type: "text"; text: string }[] }> {
const markdown = "# Ticket 123\nStatus: Open\n\nDescription: Payment failed";
return {
content: [
{
type: "text",
text: markdown, // raw markdown, no extra JSON.stringify applied
},
],
};
}
} |
|
Solved in RC, wait for TS v7 release |
Uh oh!
There was an error while loading. Please reload this page.
I'm using registerMcpControllers from @typia/mcp to register my MCP tools.
My controller method must return an object (typia requirement). But @typia/mcp then passes that object through JSON.stringify() before sending the response.
What the client actually receives:
{ "result": { "content": [ { "type": "text", "text": "{\n \"content\": \"# Ticket 123\\nStatus: Open\\n\\nDescription: Payment failed\"\n}" } ] } }What I need the client to receive:
{ "result": { "content": [ { "type": "text", "text": "# Ticket 123\nStatus: Open\n\nDescription: Payment failed" } ] } }Is there any way to return plain text (Markdown) from a controller registered with registerMcpControllers without getting double serialization?
Thanks for any advice.
All reactions