@@ -4,6 +4,8 @@ import { UnknownToolCard } from "./unknown";
44import { GreetingCard } from "./greeting" ;
55import { ErrorToolCard } from "./error" ;
66import { AlwaysExceptionCard } from "./always-exception" ;
7+ import { JsonRpc } from "./jsonrpc" ;
8+ import { parseJsonRpcResult , UNKNOWN_JSONRPC_RESULT } from "./utils/common" ;
79
810type ToolsProps = {
911 messageId : string ;
@@ -14,11 +16,26 @@ type ToolsProps = {
1416 animated : boolean ;
1517} ;
1618
19+ // define a const string list.
20+ const XTRA_MCP_TOOL_NAMES = [
21+ "enhance_academic_writing" ,
22+ "search_relevant_papers" ,
23+ "search_user" ,
24+ "identify_improvements" ,
25+ "get_user_papers" ,
26+ "deep_research" ,
27+ "get_conference_papers" ,
28+ "search_papers_on_openreview" ,
29+ "search_papers" ,
30+ ] ;
31+
1732export default function Tools ( { messageId, functionName, message, error, preparing, animated } : ToolsProps ) {
1833 if ( error && error !== "" ) {
1934 return < ErrorToolCard functionName = { functionName } errorMessage = { error } animated = { animated } /> ;
2035 }
2136
37+ const jsonRpcResult = parseJsonRpcResult ( message ) ;
38+
2239 if ( functionName === "paper_score" ) {
2340 return < PaperScoreCard message = { message } preparing = { preparing } animated = { animated } /> ;
2441 } else if ( functionName === "paper_score_comment" ) {
@@ -27,7 +44,14 @@ export default function Tools({ messageId, functionName, message, error, prepari
2744 return < GreetingCard message = { message } preparing = { preparing } animated = { animated } /> ;
2845 } else if ( functionName === "always_exception" ) {
2946 return < AlwaysExceptionCard message = { message } preparing = { preparing } animated = { animated } /> ;
47+ } else if ( XTRA_MCP_TOOL_NAMES . includes ( functionName ) ) {
48+ return < JsonRpc functionName = { functionName } jsonRpcResult = { jsonRpcResult || UNKNOWN_JSONRPC_RESULT } preparing = { preparing } animated = { animated } /> ;
3049 }
3150
32- return < UnknownToolCard functionName = { functionName } message = { message } animated = { animated } /> ;
51+ // fallback to unknown tool card if the json rpc result is not defined
52+ if ( jsonRpcResult ) {
53+ return < JsonRpc functionName = { functionName } jsonRpcResult = { jsonRpcResult } preparing = { preparing } animated = { animated } /> ;
54+ } else {
55+ return < UnknownToolCard functionName = { functionName } message = { message } animated = { animated } /> ;
56+ }
3357}
0 commit comments