mustafaskyer
10/31/2025, 4:45 PMts
const { data } = await composio.tools.execute('GMAIL_FETCH_EMAILS', {})
const dataResponse = data // typeof data => Record<string, unknown> ??mustafaskyer
10/31/2025, 8:57 PMUday
11/01/2025, 5:15 AMmustafaskyer
11/01/2025, 8:24 AMAkram Boussanni
11/01/2025, 8:25 AMdata object for a specific tool, you need to inspect the tool's output schema. Composio provides several ways to do this:
### 1. Get the Raw Tool Schema
You can fetch the raw tool definition to see the exact output parameters:
typescript
// Get the raw tool schema
const tool = await composio.tools.getRawComposioToolBySlug('GMAIL_FETCH_EMAILS');
// Inspect the output parameters
console.log(tool.output_parameters);
This will show you the complete structure of what the tool returns, including all fields and their types [[getRawComposioToolBySlug]](https://docs.composio.dev/sdk-reference/type-script/models/tools#getrawcomposiotoolbyslug).
### 2. Check the Tool Documentation
You can also view the tool's schema in the Composio documentation. For example, the [Tool Type Generator documentation](https://docs.composio.dev/examples/tool-generator#getting-the-raw-tool-definition) shows how tool schemas include detailed output_parameters with properties like:
json
{
"output_parameters": {
"properties": {
"data": {
"description": "Data from the action execution",
"properties": {
"response_data": {
"description": "Full response with details",
"type": "object"
}
}
}
}
}
}
### 3. Practical Approach
Once you know the schema, you can create a targeted afterExecute modifier:Akram Boussanni
11/01/2025, 8:25 AMtypescript
// First, inspect the schema
const tool = await composio.tools.getRawComposioToolBySlug('GMAIL_FETCH_EMAILS');
console.log(JSON.stringify(tool.output_parameters, null, 2));
// Then create your modifier based on what you see
const result = await composio.tools.execute(
'GMAIL_FETCH_EMAILS',
{
userId,
arguments: { /* your arguments */ },
},
{
afterExecute: ({ toolSlug, toolkitSlug, result }) => {
if (result.successful && result.data) {
// Based on the schema, keep only essential fields
// For example, if emails is an array with many fields:
const trimmedData = {
emails: (result.data.emails as any[] || []).map(email => ({
id: email.id,
subject: email.subject,
from: email.from,
// Add only the fields you need
}))
};
return {
...result,
data: trimmedData,
};
}
return result;
},
}
);
This way, you can inspect the schema first to understand what fields are available, then create a modifier that keeps only what you need [[Fetching raw tools]](https://github.com/composioHQ/composio/blob/next/fern/pages/src/tool-calling/fetching-tools.mdx).mustafaskyer
11/01/2025, 9:01 AMjson to zod
If so just confirm, and I think this shouldn't be the way to just get a return type of an execution !!joelcodes
11/01/2025, 1:27 PMmustafaskyer
11/02/2025, 4:18 AM