Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Chore: Update TS Docs (#1847)

Musthaq Ahamadf65d9c4b9258
diff --git a/CLAUDE.md b/CLAUDE.md
index ad1758df5..015e079a2 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -201,11 +201,23 @@ const wrappedTools = provider.wrapTools(tools);
### Custom Tool Creation
```typescript
+import { z } from 'zod';
+
const customTool = await composio.tools.createCustomTool({
name: 'My Tool',
description: 'Tool description',
- inputParameters: { /* JSON schema */ },
- handler: async (params) => { /* implementation */ }
+ slug: 'MY_TOOL',
+ inputParams: z.object({
+ param: z.string().describe('Parameter description')
+ }),
+ execute: async (input) => {
+ // Implementation
+ return {
+ data: { result: input.param },
+ error: null,
+ successful: true
+ };
+ }
});
```
diff --git a/ts/README.md b/ts/README.md
index 36844e477..7b019a674 100644
--- a/ts/README.md
+++ b/ts/README.md
@@ -138,45 +138,20 @@ if (completion.choices[0].message.tool_calls) {
## Creating Custom Tools
```typescript
+import { z } from 'zod';
+
// Create a custom tool
const customTool = await composio.tools.createCustomTool({
name: 'Weather Forecast',
description: 'Get the weather forecast for a location',
slug: 'WEATHER_FORECAST',
- inputParameters: {
- type: 'object',
- properties: {
- location: {
- type: 'string',
- description: 'The location to get the forecast for',
- },
- days: {
- type: 'integer',
- description: 'Number of days for the forecast',
- default: 3,
- },
- },
- required: ['location'],
- },
- outputParameters: {
- type: 'object',
- properties: {
- forecast: {
- type: 'array',
- items: {
- type: 'object',
- properties: {
- date: { type: 'string' },
- temperature: { type: 'number' },
- conditions: { type: 'string' },
- },
- },
- },
- },
- },
- handler: async (params, context) => {
+ inputParams: z.object({
+ location: z.string().describe('The location to get the forecast for'),
+ days: z.number().optional().default(3).describe('Number of days for the forecast')
+ }),
+ execute: async (input) => {
try {
- const { location, days = 3 } = params.arguments;
+ const { location, days = 3 } = input;
// Your implementation here
const forecast = [
diff --git a/ts/docs/advanced/error-handling.md b/ts/docs/advanced/error-handling.md
index 033056804..3a926d925 100644
--- a/ts/docs/advanced/error-handling.md
+++ b/ts/docs/advanced/error-handling.md
@@ -177,27 +177,19 @@ try {
When creating custom tools, implement proper error handling in your handler function:
```typescript
+import { z } from 'zod';
+
const customTool = await composio.tools.createCustomTool({
name: 'My Custom Tool',
description: 'A custom tool with error handling',
slug: 'MY_CUSTOM_TOOL',
- inputParameters: {
- type: 'object',
- properties: {
- param1: { type: 'string' },
- },
- required: ['param1'],
- },
- outputParameters: {
- type: 'object',
- properties: {
- result: { type: 'string' },
- },
- },
- handler: async (params, context) => {
+ inputParams: z.object({
+ param1: z.string().describe('Required parameter')
+ }),
+ execute: async (input) => {
try {
- // Validate input
- const { param1 } = params.arguments;
+ // Input is already validated by zod
+ const { param1 } = input;
if (!param1 || param1.trim() === '') {
return {
data: {},
diff --git a/ts/docs/api/auth-configs.md b/ts/docs/api/auth-configs.md
index 67098b691..34fdb8ab1 100644
--- a/ts/docs/api/auth-configs.md
+++ b/ts/docs/api/auth-configs.md
@@ -73,24 +73,40 @@ const authConfig = await composio.authConfigs.create('github', {
Updates an existing auth config.
```typescript
-// Update an auth config
+// Update a custom auth config with new credentials
const updatedAuthConfig = await composio.authConfigs.update('auth_config_123', {
- name: 'Updated GitHub Auth Config',
- fields: {
+ type: 'custom',
+ credentials: {
client_id: 'new_client_id',
client_secret: 'new_client_secret',
},
+ toolAccessConfig: {
+ toolsAvailableForExecution: ['GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER']
+ }
+});
+
+// Update a default auth config with new scopes
+const updatedDefaultAuth = await composio.authConfigs.update('auth_config_456', {
+ type: 'default',
+ scopes: 'read:user,repo',
+ toolAccessConfig: {
+ toolsAvailableForExecution: ['GITHUB_GET_A_REPOSITORY', 'GITHUB_LIST_REPOSITORIES_FOR_A_USER']
+ }
});
```
**Parameters:**
- `id` (string): The unique identifier of the auth config to update
-- `data` (AuthConfigUpdateParams): The parameters for updating the auth config
+- `data` (AuthConfigUpdateParams): The parameters for updating the auth config. Must be a discriminated union with either:
+ - `{ type: 'custom', credentials: Record<string, unknown>, toolAccessConfig?: {...} }`
+ - `{ type: 'default', scopes: string, toolAccessConfig?: {...} }`
**Returns:** Promise<AuthConfigUpdateResponse> - The updated auth config
-**Throws:** ComposioAuthConfigNotFoundError if the auth config cannot be found
+**Throws:**
+- ValidationError if the update parameters are invalid
+- ComposioAuthConfigNotFoundError if the auth config cannot be found
### delete(id)
@@ -167,10 +183,28 @@ interface AuthConfigCreateParams {
### AuthConfigUpdateParams
```typescript
-interface AuthConfigUpdateParams {
- name?: string; // Name of the auth config
- fields?: Record<string, unknown>; // Configuration fields
-}
+// Discriminated union type for updating auth configs
+type AuthConfigUpdateParams =
+ | {
+ type: 'custom';
+ credentials: Record<string, string | number | boolean | unknown>;
+ toolAccessConfig?: {
+ toolsAvailableForExecution?: string[];
+ toolsForConnectedAccountCreation?: string[];
+ };
+ /** @deprecated Use toolAccessConfig instead */
+ restrictToFollowingTools?: string[];
+ }
+ | {
+ type: 'default';
+ scopes: string;
+ toolAccessConfig?: {
+ toolsAvailableForExecution?: string[];
+ toolsForConnectedAccountCreation?: string[];
+ };
+ /** @deprecated Use toolAccessConfig instead */
+ restrictToFollowingTools?: string[];
+ };
```
### AuthConfigType
diff --git a/ts/docs/api/tools.md b/ts/docs/api/tools.md
index 8f23bad5b..54d259f1f 100644
--- a/ts/docs/api/tools.md
+++ b/ts/docs/api/tools.md
@@ -90,26 +90,24 @@ const result = await composio.tools.execute(
Creates a custom tool that can be used within the Composio SDK.
```typescript
+import { z } from 'zod';
+
const customTool = await composio.tools.createCustomTool({
name: 'My Custom Tool',
description: 'A custom tool that does something specific',
slug: 'MY_CUSTOM_TOOL',
- inputParameters: {
- param1: {
- type: 'string',
- description: 'First parameter',
- required: true,
- },
- },
- outputParameters: {
- result: {
- type: 'string',
- description: 'The result of the operation',
- },
- },
- handler: async (params, context) => {
+ inputParams: z.object({
+ param1: z.string().describe('Description of param1'),
+ param2: z.number().optional().describe('Optional numeric parameter')
+ }),
+ execute: async (input) => {
// Custom logic here
- return { data: { result: 'Success!' } };
+ console.log('Input:', input.param1, input.param2);
+ return {
+ data: { result: 'Success!' },
+ error: null,
+ successful: true
+ };
},
});
```
diff --git a/ts/docs/core-concepts.md b/ts/docs/core-concepts.md
index 1277bcc00..f7ac3b9eb 100644
--- a/ts/docs/core-concepts.md
+++ b/ts/docs/core-concepts.md
@@ -399,27 +399,25 @@ Use direct execution when:
Custom Tools allow you to extend Composio's functionality by creating your own tools. You define the input and output parameters and provide a handler function that implements the tool's behavior.
```typescript
+import { z } from 'zod';
+
// Example: Create a custom tool
const customTool = await composio.tools.createCustomTool({
name: 'My Custom Tool',
description: 'A custom tool that does something specific',
slug: 'MY_CUSTOM_TOOL',
- inputParameters: {
- param1: {
- type: 'string',
- description: 'First parameter',
- required: true,
- },
- },
- outputParameters: {
- result: {
- type: 'string',
- description: 'The result of the operation',
- },
- },
- handler: async (params, context) => {
+ inputParams: z.object({
+ param1: z.string().describe('First parameter'),
+ param2: z.number().optional().describe('Optional parameter')
+ }),
+ execute: async (input) => {
// Custom logic here
- return { data: { result: 'Success!' } };
+ console.log('Received input:', input.param1, input.param2);
+ return {
+ data: { result: 'Success!' },
+ error: null,
+ successful: true
+ };
},
});
```
diff --git a/ts/docs/getting-started.md b/ts/docs/getting-started.md
index 2cf49511d..03367749f 100644
--- a/ts/docs/getting-started.md
+++ b/ts/docs/getting-started.md
@@ -193,53 +193,28 @@ For a more complete integration, check out the [OpenAI Provider example](../exam
You can extend Composio by creating your own custom tools:
```typescript
+import { z } from 'zod';
+
// Create a custom tool
const customTool = await composio.tools.createCustomTool({
name: 'Weather Forecast',
description: 'Get the weather forecast for a location',
slug: 'WEATHER_FORECAST',
- inputParameters: {
- type: 'object',
- properties: {
- location: {
- type: 'string',
- description: 'The location to get the forecast for',
- },
- days: {
- type: 'integer',
- description: 'Number of days for the forecast',
- default: 3,
- },
- },
- required: ['location'],
- },
- outputParameters: {
- type: 'object',
- properties: {
- forecast: {
- type: 'array',
- items: {
- type: 'object',
- properties: {
- date: { type: 'string' },
- temperature: { type: 'number' },
- conditions: { type: 'string' },
- },
- },
- },
- },
- },
- handler: async (params, context) => {
+ inputParams: z.object({
+ location: z.string().describe('The location to get the forecast for'),
+ days: z.number().optional().default(3).describe('Number of days for the forecast')
+ }),
+ execute: async (input) => {
try {
- const { location, days = 3 } = params.arguments;
+ const { location, days = 3 } = input;
// Here you would call your weather API
const forecast = await getWeatherForecast(location, days);
return {
data: { forecast },
- successful: true,
error: null,
+ successful: true,
};
} catch (error) {
return {