77 ReadResourceResultSchema ,
88 CallToolResultSchema ,
99 ListPromptsResultSchema ,
10+ Tool ,
11+ ClientRequest ,
1012} from "mcp-typescript/types.js" ;
1113import { useState } from "react" ;
1214import {
@@ -28,8 +30,9 @@ import RequestsTab from "./components/RequestsTabs";
2830import ResourcesTab , { Resource } from "./components/ResourcesTab" ;
2931import NotificationsTab from "./components/NotificationsTab" ;
3032import PromptsTab , { Prompt } from "./components/PromptsTab" ;
31- import ToolsTab , { Tool as ToolType } from "./components/ToolsTab" ;
33+ import ToolsTab from "./components/ToolsTab" ;
3234import History from "./components/History" ;
35+ import { AnyZodObject } from "node_modules/zod/lib" ;
3336
3437const App = ( ) => {
3538 const [ connectionStatus , setConnectionStatus ] = useState <
@@ -39,7 +42,7 @@ const App = () => {
3942 const [ resourceContent , setResourceContent ] = useState < string > ( "" ) ;
4043 const [ prompts , setPrompts ] = useState < Prompt [ ] > ( [ ] ) ;
4144 const [ promptContent , setPromptContent ] = useState < string > ( "" ) ;
42- const [ tools , setTools ] = useState < ToolType [ ] > ( [ ] ) ;
45+ const [ tools , setTools ] = useState < Tool [ ] > ( [ ] ) ;
4346 const [ toolResult , setToolResult ] = useState < string > ( "" ) ;
4447 const [ error , setError ] = useState < string | null > ( null ) ;
4548 const [ command , setCommand ] = useState < string > (
@@ -57,7 +60,7 @@ const App = () => {
5760 null ,
5861 ) ;
5962 const [ selectedPrompt , setSelectedPrompt ] = useState < Prompt | null > ( null ) ;
60- const [ selectedTool , setSelectedTool ] = useState < ToolType | null > ( null ) ;
63+ const [ selectedTool , setSelectedTool ] = useState < Tool | null > ( null ) ;
6164
6265 const pushHistory = ( request : object , response : object ) => {
6366 setRequestHistory ( ( prev ) => [
@@ -66,10 +69,10 @@ const App = () => {
6669 ] ) ;
6770 } ;
6871
69- const makeRequest = async (
70- request : Parameters < Client [ "request" ] > [ 0 ] ,
71- schema : Parameters < Client [ "request" ] > [ 1 ] ,
72- ) : Promise < ReturnType < Client [ "request" ] > > => {
72+ const makeRequest = async < T extends AnyZodObject > (
73+ request : ClientRequest ,
74+ schema : T ,
75+ ) => {
7376 if ( ! mcpClient ) {
7477 throw new Error ( "MCP client not connected" ) ;
7578 }
@@ -114,9 +117,7 @@ const App = () => {
114117 } ,
115118 ListPromptsResultSchema ,
116119 ) ;
117- if ( response . prompts ) {
118- setPrompts ( response . prompts ) ;
119- }
120+ setPrompts ( response . prompts ) ;
120121 } ;
121122
122123 const getPrompt = async ( name : string , args : Record < string , string > = { } ) => {
@@ -137,9 +138,7 @@ const App = () => {
137138 } ,
138139 ListToolsResultSchema ,
139140 ) ;
140- if ( response . tools ) {
141- setTools ( response . tools ) ;
142- }
141+ setTools ( response . tools ) ;
143142 } ;
144143
145144 const callTool = async ( name : string , params : Record < string , unknown > ) => {
0 commit comments