@@ -16,7 +16,10 @@ import { BaseMCPServer, type Context, type ToolResponse } from "./mcp-server-bas
1616
1717
1818const ToolInputSchema = ToolSchema . shape . inputSchema ;
19- export type ToolInput = z . infer < typeof ToolInputSchema > ;
19+ type ToolInput = z . infer < typeof ToolInputSchema > ;
20+
21+ export const ToolOutputSchema = ToolSchema . shape . outputSchema ;
22+ type ToolOutput = z . infer < typeof ToolOutputSchema > ;
2023
2124export const PingSchema = z . object ( { } ) ;
2225
@@ -29,6 +32,13 @@ export const GetRelevantQuestionsSchema = z.object({
2932 . describe ( "The datasources to get questions for, this is the ids of the datasources to get data from. Each id is a GUID string." )
3033} ) ;
3134
35+ export const GetRelevantQuestionsOutputSchema = z . object ( {
36+ questions : z . array ( z . object ( {
37+ question : z . string ( ) ,
38+ datasourceId : z . string ( ) ,
39+ } ) ) ,
40+ } ) ;
41+
3242export const GetAnswerSchema = z . object ( {
3343 question : z . string ( ) . describe ( "The question to get the answer for, these are generally the questions generated by the getRelevantQuestions tool." ) ,
3444 datasourceId : z . string ( )
@@ -94,6 +104,7 @@ export const toolDefinitionsMCPServer = [
94104 name : ToolName . GetRelevantQuestions ,
95105 description : "Get relevant data questions from ThoughtSpot database" ,
96106 inputSchema : zodToJsonSchema ( GetRelevantQuestionsSchema ) as ToolInput ,
107+ outputSchema : zodToJsonSchema ( GetRelevantQuestionsOutputSchema ) as ToolOutput ,
97108 annotations : {
98109 title : "Get Relevant Questions for a Query" ,
99110 readOnlyHint : true ,
@@ -237,11 +248,7 @@ export class MCPServer extends BaseMCPServer {
237248 return this . createSuccessResponse ( "No relevant questions found" ) ;
238249 }
239250
240- const questionTexts = relevantQuestions . questions . map ( q =>
241- `Question: ${ q . question } \nDatasourceId: ${ q . datasourceId } `
242- ) ;
243-
244- return this . createArraySuccessResponse ( questionTexts , "Relevant questions found" ) ;
251+ return this . createStructuredContentSuccessResponse ( { questions : relevantQuestions . questions } , "Relevant questions found" ) ;
245252 }
246253
247254 @WithSpan ( 'call-get-answer' )
@@ -268,7 +275,7 @@ export class MCPServer extends BaseMCPServer {
268275 async callCreateLiveboard ( request : z . infer < typeof CallToolRequestSchema > ) {
269276 const { name, answers, noteTile } = CreateLiveboardSchema . parse ( request . params . arguments ) ;
270277 const liveboard = await this . getThoughtSpotService ( ) . fetchTMLAndCreateLiveboard ( name , answers , noteTile ) ;
271-
278+
272279 if ( liveboard . error ) {
273280 return this . createErrorResponse ( liveboard . error . message , `Error creating liveboard ${ liveboard . error . message } ` ) ;
274281 }
0 commit comments