@@ -35,35 +35,28 @@ export const DEFAULT_SSE_MCP_CLIENT_LOGGER_NAME =
3535export interface MCPServer {
3636 cacheToolsList : boolean ;
3737 toolFilter ?: MCPToolFilterCallable | MCPToolFilterStatic ;
38-
39- /**
40- * Whether to include structuredContent in tool outputs when available.
41- */
42- useStructuredContent ?: boolean ;
4338 connect ( ) : Promise < void > ;
4439 readonly name : string ;
4540 close ( ) : Promise < void > ;
4641 listTools ( ) : Promise < MCPTool [ ] > ;
4742 callTool (
4843 toolName : string ,
4944 args : Record < string , unknown > | null ,
50- ) : Promise < CallToolResult > ;
45+ ) : Promise < CallToolResultContent > ;
5146 invalidateToolsCache ( ) : Promise < void > ;
5247}
5348
5449export abstract class BaseMCPServerStdio implements MCPServer {
5550 public cacheToolsList : boolean ;
5651 protected _cachedTools : any [ ] | undefined = undefined ;
5752 public toolFilter ?: MCPToolFilterCallable | MCPToolFilterStatic ;
58- public useStructuredContent ?: boolean ;
5953
6054 protected logger : Logger ;
6155 constructor ( options : MCPServerStdioOptions ) {
6256 this . logger =
6357 options . logger ?? getLogger ( DEFAULT_STDIO_MCP_CLIENT_LOGGER_NAME ) ;
6458 this . cacheToolsList = options . cacheToolsList ?? false ;
6559 this . toolFilter = options . toolFilter ;
66- this . useStructuredContent = options . useStructuredContent ?? false ;
6760 }
6861
6962 abstract get name ( ) : string ;
@@ -73,7 +66,7 @@ export abstract class BaseMCPServerStdio implements MCPServer {
7366 abstract callTool (
7467 _toolName : string ,
7568 _args : Record < string , unknown > | null ,
76- ) : Promise < CallToolResult > ;
69+ ) : Promise < CallToolResultContent > ;
7770 abstract invalidateToolsCache ( ) : Promise < void > ;
7871
7972 /**
@@ -92,7 +85,6 @@ export abstract class BaseMCPServerStreamableHttp implements MCPServer {
9285 public cacheToolsList : boolean ;
9386 protected _cachedTools : any [ ] | undefined = undefined ;
9487 public toolFilter ?: MCPToolFilterCallable | MCPToolFilterStatic ;
95- public useStructuredContent ?: boolean ;
9688
9789 protected logger : Logger ;
9890 constructor ( options : MCPServerStreamableHttpOptions ) {
@@ -101,7 +93,6 @@ export abstract class BaseMCPServerStreamableHttp implements MCPServer {
10193 getLogger ( DEFAULT_STREAMABLE_HTTP_MCP_CLIENT_LOGGER_NAME ) ;
10294 this . cacheToolsList = options . cacheToolsList ?? false ;
10395 this . toolFilter = options . toolFilter ;
104- this . useStructuredContent = options . useStructuredContent ?? false ;
10596 }
10697
10798 abstract get name ( ) : string ;
@@ -111,7 +102,7 @@ export abstract class BaseMCPServerStreamableHttp implements MCPServer {
111102 abstract callTool (
112103 _toolName : string ,
113104 _args : Record < string , unknown > | null ,
114- ) : Promise < CallToolResult > ;
105+ ) : Promise < CallToolResultContent > ;
115106 abstract invalidateToolsCache ( ) : Promise < void > ;
116107
117108 /**
@@ -130,15 +121,13 @@ export abstract class BaseMCPServerSSE implements MCPServer {
130121 public cacheToolsList : boolean ;
131122 protected _cachedTools : any [ ] | undefined = undefined ;
132123 public toolFilter ?: MCPToolFilterCallable | MCPToolFilterStatic ;
133- public useStructuredContent ?: boolean ;
134124
135125 protected logger : Logger ;
136126 constructor ( options : MCPServerSSEOptions ) {
137127 this . logger =
138128 options . logger ?? getLogger ( DEFAULT_SSE_MCP_CLIENT_LOGGER_NAME ) ;
139129 this . cacheToolsList = options . cacheToolsList ?? false ;
140130 this . toolFilter = options . toolFilter ;
141- this . useStructuredContent = options . useStructuredContent ?? false ;
142131 }
143132
144133 abstract get name ( ) : string ;
@@ -148,7 +137,7 @@ export abstract class BaseMCPServerSSE implements MCPServer {
148137 abstract callTool (
149138 _toolName : string ,
150139 _args : Record < string , unknown > | null ,
151- ) : Promise < CallToolResult > ;
140+ ) : Promise < CallToolResultContent > ;
152141 abstract invalidateToolsCache ( ) : Promise < void > ;
153142
154143 /**
@@ -212,7 +201,7 @@ export class MCPServerStdio extends BaseMCPServerStdio {
212201 callTool (
213202 toolName : string ,
214203 args : Record < string , unknown > | null ,
215- ) : Promise < CallToolResult > {
204+ ) : Promise < CallToolResultContent > {
216205 return this . underlying . callTool ( toolName , args ) ;
217206 }
218207 invalidateToolsCache ( ) : Promise < void > {
@@ -248,7 +237,7 @@ export class MCPServerStreamableHttp extends BaseMCPServerStreamableHttp {
248237 callTool (
249238 toolName : string ,
250239 args : Record < string , unknown > | null ,
251- ) : Promise < CallToolResult > {
240+ ) : Promise < CallToolResultContent > {
252241 return this . underlying . callTool ( toolName , args ) ;
253242 }
254243 invalidateToolsCache ( ) : Promise < void > {
@@ -284,7 +273,7 @@ export class MCPServerSSE extends BaseMCPServerSSE {
284273 callTool (
285274 toolName : string ,
286275 args : Record < string , unknown > | null ,
287- ) : Promise < CallToolResult > {
276+ ) : Promise < CallToolResultContent > {
288277 return this . underlying . callTool ( toolName , args ) ;
289278 }
290279 invalidateToolsCache ( ) : Promise < void > {
@@ -457,7 +446,6 @@ export async function getAllMcpTools<TContext = UnknownContext>(
457446
458447/**
459448 * Converts an MCP tool definition to a function tool for the Agents SDK.
460- * When useStructuredContent is enabled, returns JSON strings for consistency with Python SDK.
461449 */
462450export function mcpToFunctionTool (
463451 mcpTool : MCPTool ,
@@ -475,36 +463,8 @@ export function mcpToFunctionTool(
475463 if ( currentSpan ) {
476464 currentSpan . spanData [ 'mcp_data' ] = { server : server . name } ;
477465 }
478- const result = await server . callTool ( mcpTool . name , args ) ;
479-
480- if ( result . content && result . content . length === 1 ) {
481- if (
482- server . useStructuredContent &&
483- 'structuredContent' in result &&
484- result . structuredContent !== undefined
485- ) {
486- return JSON . stringify ( [ result . content [ 0 ] , result . structuredContent ] ) ;
487- }
488- return result . content [ 0 ] ;
489- } else if ( result . content && result . content . length > 1 ) {
490- if (
491- server . useStructuredContent &&
492- 'structuredContent' in result &&
493- result . structuredContent !== undefined
494- ) {
495- const outputs = [ ...result . content , result . structuredContent ] ;
496- return JSON . stringify ( outputs ) ;
497- }
498- return result . content ;
499- } else if (
500- server . useStructuredContent &&
501- 'structuredContent' in result &&
502- result . structuredContent !== undefined
503- ) {
504- return JSON . stringify ( result . structuredContent ) ;
505- }
506- // Preserve backward compatibility: return empty array when no content
507- return result . content || [ ] ;
466+ const content = await server . callTool ( mcpTool . name , args ) ;
467+ return content . length === 1 ? content [ 0 ] : content ;
508468 }
509469
510470 const schema : JsonObjectSchema < any > = {
@@ -573,11 +533,6 @@ export interface BaseMCPServerStdioOptions {
573533 encodingErrorHandler ?: 'strict' | 'ignore' | 'replace' ;
574534 logger ?: Logger ;
575535 toolFilter ?: MCPToolFilterCallable | MCPToolFilterStatic ;
576-
577- /**
578- * Whether to include structuredContent in tool outputs when available.
579- */
580- useStructuredContent ?: boolean ;
581536 timeout ?: number ;
582537}
583538export interface DefaultMCPServerStdioOptions
@@ -600,11 +555,6 @@ export interface MCPServerStreamableHttpOptions {
600555 name ?: string ;
601556 logger ?: Logger ;
602557 toolFilter ?: MCPToolFilterCallable | MCPToolFilterStatic ;
603-
604- /**
605- * Whether to include structuredContent in tool outputs when available.
606- */
607- useStructuredContent ?: boolean ;
608558 timeout ?: number ;
609559
610560 // ----------------------------------------------------
@@ -629,11 +579,6 @@ export interface MCPServerSSEOptions {
629579 name ?: string ;
630580 logger ?: Logger ;
631581 toolFilter ?: MCPToolFilterCallable | MCPToolFilterStatic ;
632-
633- /**
634- * Whether to include structuredContent in tool outputs when available.
635- */
636- useStructuredContent ?: boolean ;
637582 timeout ?: number ;
638583
639584 // ----------------------------------------------------
@@ -676,22 +621,9 @@ export interface JsonRpcResponse {
676621 error ?: any ;
677622}
678623
679- /**
680- * Structured content that can be returned by MCP tools.
681- * Supports various data types including objects, arrays, primitives, and null.
682- */
683- export type StructuredContent =
684- | Record < string , unknown >
685- | unknown [ ]
686- | string
687- | number
688- | boolean
689- | null ;
690-
691624export interface CallToolResponse extends JsonRpcResponse {
692625 result : {
693626 content : { type : string ; text : string } [ ] ;
694- structuredContent ?: StructuredContent ;
695627 } ;
696628}
697629export type CallToolResult = CallToolResponse [ 'result' ] ;
0 commit comments