File tree Expand file tree Collapse file tree
examples/transcript-server/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 type McpUiHostContext ,
1010 applyDocumentTheme ,
1111} from "@modelcontextprotocol/ext-apps" ;
12- import { z } from "zod" ;
1312import "./global.css" ;
1413import "./mcp-app.css" ;
1514
@@ -331,25 +330,19 @@ function updateSendButton() {
331330}
332331
333332function updateModelContext ( ) {
333+ const caps = app . getHostCapabilities ( ) ;
334+ if ( ! caps ?. updateModelContext ) return ;
335+
334336 const text = getUnsentText ( ) ;
335337 log . info ( "Updating model context:" , text || "(empty)" ) ;
336338
337- // EXPERIMENTAL: Updates model context with current transcript
338- // See https://github.com/modelcontextprotocol/ext-apps/pull/125
339339 app
340- . request (
341- {
342- method : "ui/update-model-context" ,
343- params : {
344- role : "user" ,
345- content : text
346- ? [ { type : "text" , text : `[Live transcript]: ${ text } ` } ]
347- : [ ] ,
348- } ,
349- } as unknown as Parameters < typeof app . request > [ 0 ] ,
350- z . object ( { } ) as any ,
351- )
352- . catch ( ( e ) => {
340+ . updateModelContext ( {
341+ content : text
342+ ? [ { type : "text" , text : `[Live transcript]: ${ text } ` } ]
343+ : [ ] ,
344+ } )
345+ . catch ( ( e : unknown ) => {
353346 log . warn ( "Failed to update model context:" , e ) ;
354347 } ) ;
355348}
You can’t perform that action at this time.
0 commit comments