Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
feat(docs): Add tool input/output parameters display
Sushmithamallesh0ee5df48c23f
diff --git a/docs/app/(home)/toolkits/[[...slug]]/page.tsx b/docs/app/(home)/toolkits/[[...slug]]/page.tsxindex 4c7aec9d3..dcbe6c5c0 100644--- a/docs/app/(home)/toolkits/[[...slug]]/page.tsx+++ b/docs/app/(home)/toolkits/[[...slug]]/page.tsx@@ -7,7 +7,80 @@ import { PageActions } from '@/components/page-actions';import { readFile } from 'fs/promises';import { join } from 'path';import type { Metadata } from 'next';-import type { Toolkit } from '@/types/toolkit';+import type { Toolkit, Tool } from '@/types/toolkit';++const API_BASE = process.env.COMPOSIO_API_BASE || 'https://backend.composio.dev/api/v3';+const API_KEY = process.env.COMPOSIO_API_KEY;++// Fetch detailed tool info from Composio API (server-side only)+async function fetchDetailedTools(toolkitSlug: string): Promise<Tool[]> {+ if (!API_KEY) {+ console.warn('[Toolkits] COMPOSIO_API_KEY not set, skipping detailed tool fetch');+ return [];+ }++ try {+ const response = await fetch(+ `${API_BASE}/tools?toolkit_slug=${toolkitSlug.toUpperCase()}&limit=1000`,+ {+ headers: {+ 'Content-Type': 'application/json',+ 'x-api-key': API_KEY,+ },+ next: { revalidate: 3600 }, // Cache for 1 hour+ }+ );++ if (!response.ok) {+ console.warn(`[Toolkits] Failed to fetch tools for ${toolkitSlug}: ${response.status}`);+ return [];+ }++ const data = await response.json();+ const items = data.items || data || [];++ return items.map((tool: any) => {+ // Extract parameters from JSON Schema format+ const inputSchema = tool.input_parameters || tool.parameters;+ const outputSchema = tool.output_parameters || tool.response;++ // Get properties and required array from JSON Schema+ const inputProps = inputSchema?.properties || inputSchema;+ const inputRequired = inputSchema?.required || [];+ const outputProps = outputSchema?.properties || outputSchema;+ const outputRequired = outputSchema?.required || [];++ // Add required flag to each property based on the required array+ const processParams = (props: any, requiredList: string[]) => {+ if (!props || typeof props !== 'object') return undefined;+ const result: Record<string, any> = {};+ for (const [key, value] of Object.entries(props)) {+ if (typeof value === 'object' && value !== null) {+ result[key] = {+ ...(value as object),+ required: requiredList.includes(key),+ };+ }+ }+ return Object.keys(result).length > 0 ? result : undefined;+ };++ return {+ slug: tool.slug || '',+ name: tool.name || tool.display_name || tool.slug || '',+ description: tool.description || '',+ input_parameters: processParams(inputProps, inputRequired),+ output_parameters: processParams(outputProps, outputRequired),+ scopes: tool.scopes || undefined,+ tags: tool.tags || undefined,+ is_deprecated: tool.is_deprecated || false,+ };+ });+ } catch (error) {+ console.error(`[Toolkits] Error fetching detailed tools for ${toolkitSlug}:`, error);+ return [];+ }+}async function getToolkits(): Promise<Toolkit[]> {const filePath = join(process.cwd(), 'public/data/toolkits.json');@@ -115,10 +188,16 @@ export default async function ToolkitsPage({ params }: { params: Promise<{ slug?const toolkit = toolkits.find((t) => t.slug === toolkitSlug);if (toolkit) {+ // Fetch detailed tool info from API (includes input/output params)+ const detailedTools = await fetchDetailedTools(toolkitSlug);++ // Merge detailed info with static tools, or use detailed if available+ const tools = detailedTools.length > 0 ? detailedTools : toolkit.tools;+return (<ToolkitDetailtoolkit={toolkit}- tools={toolkit.tools}+ tools={tools}triggers={toolkit.triggers}path={`/toolkits/${toolkit.slug}`}/>diff --git a/docs/components/toolkits/toolkit-detail.tsx b/docs/components/toolkits/toolkit-detail.tsxindex 0f210548f..e2a385dfe 100644--- a/docs/components/toolkits/toolkit-detail.tsx+++ b/docs/components/toolkits/toolkit-detail.tsx@@ -3,7 +3,8 @@import { useState, useMemo } from 'react';import Link from 'next/link';import { ExternalLink, Search, Copy, Check, ChevronDown, ChevronRight, ArrowLeft } from 'lucide-react';-import type { Toolkit, Tool, Trigger } from '@/types/toolkit';+import { TypeTable } from 'fumadocs-ui/components/type-table';+import type { Toolkit, Tool, Trigger, ParameterSchema } from '@/types/toolkit';import { PageActions } from '@/components/page-actions';import { AuthDetailsSection } from '@/components/toolkits/auth-details-section';@@ -28,6 +29,37 @@ function ToolkitIcon({ toolkit }: { toolkit: Toolkit }) {);}+// Convert parameter schema to TypeTable format+function paramsToTypeTable(params: Record<string, ParameterSchema>): Record<string, {+ type: string;+ description?: string;+ default?: string;+ required?: boolean;+}> {+ const result: Record<string, {+ type: string;+ description?: string;+ default?: string;+ required?: boolean;+ }> = {};++ for (const [name, param] of Object.entries(params)) {+ result[name] = {+ type: param.type || 'string',+ description: param.description || undefined,+ default: param.default !== undefined ? String(param.default) : undefined,+ required: param.required,+ };+ }++ return result;+}++// Check if item is a Tool with parameters+function isTool(item: Tool | Trigger): item is Tool {+ return 'input_parameters' in item || 'output_parameters' in item;+}+function ToolItem({ item }: { item: Tool | Trigger }) {const [expanded, setExpanded] = useState(false);const [copied, setCopied] = useState(false);@@ -39,6 +71,10 @@ function ToolItem({ item }: { item: Tool | Trigger }) {setTimeout(() => setCopied(false), 2000);};+ const tool = isTool(item) ? item : null;+ const hasInputParams = tool?.input_parameters && Object.keys(tool.input_parameters).length > 0;+ const hasOutputParams = tool?.output_parameters && Object.keys(tool.output_parameters).length > 0;+return (<div className="border-b border-fd-border/50 last:border-0"><button@@ -61,8 +97,22 @@ function ToolItem({ item }: { item: Tool | Trigger }) {</span></button>{expanded && (- <div className="bg-fd-muted/20 px-4 py-3 pl-10">+ <div className="space-y-4 bg-fd-muted/20 px-4 py-3 pl-10"><p className="text-sm text-fd-muted-foreground">{item.description}</p>++ {hasInputParams && (+ <div className="space-y-2">+ <h4 className="text-xs font-semibold uppercase tracking-wide text-fd-muted-foreground">Input Parameters</h4>+ <TypeTable type={paramsToTypeTable(tool.input_parameters!)} />+ </div>+ )}++ {hasOutputParams && (+ <div className="space-y-2">+ <h4 className="text-xs font-semibold uppercase tracking-wide text-fd-muted-foreground">Output</h4>+ <TypeTable type={paramsToTypeTable(tool.output_parameters!)} />+ </div>+ )}</div>)}</div>diff --git a/docs/types/toolkit.ts b/docs/types/toolkit.tsindex 860b7f0c7..96f77797d 100644--- a/docs/types/toolkit.ts+++ b/docs/types/toolkit.ts@@ -1,7 +1,23 @@+// Parameter schema for tool inputs/outputs+export interface ParameterSchema {+ type: string;+ description?: string;+ required?: boolean;+ default?: unknown;+ example?: unknown;+ enum?: string[];+}+export interface Tool {slug: string;name: string;description: string;+ // Detailed fields fetched on-demand+ input_parameters?: Record<string, ParameterSchema>;+ output_parameters?: Record<string, ParameterSchema>;+ scopes?: string[];+ tags?: string[];+ is_deprecated?: boolean;}export interface Trigger {