@devries-cameron20 / composio-1 / commits / 0ee5df48c
Fork 0

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

feat(docs): Add tool input/output parameters display

- Fetch detailed tool info from Composio API server-side on toolkit pages - Parse JSON Schema format for input_parameters and output_parameters - Display params with TypeTable when tool is expanded - Add ParameterSchema type for tool parameters - Cache API responses for 1 hour Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 22, 2026 at 19:18 UTC 0ee5df48c23f533aef5bf14c7d0fa57fbd447868
3 files changed +149 -4
docs/app/(home)/toolkits/[[...slug]]/page.tsx
+81 -2
@@ -7,7 +7,80 @@ import { PageActions } from '@/components/page-actions';
7 import { readFile } from 'fs/promises';
8 import { join } from 'path';
9 import type { Metadata } from 'next';
10 -import type { Toolkit } from '@/types/toolkit';
10 +import type { Toolkit, Tool } from '@/types/toolkit';
11 +
12 +const API_BASE = process.env.COMPOSIO_API_BASE || 'https://backend.composio.dev/api/v3';
13 +const API_KEY = process.env.COMPOSIO_API_KEY;
14 +
15 +// Fetch detailed tool info from Composio API (server-side only)
16 +async function fetchDetailedTools(toolkitSlug: string): Promise<Tool[]> {
17 + if (!API_KEY) {
18 + console.warn('[Toolkits] COMPOSIO_API_KEY not set, skipping detailed tool fetch');
19 + return [];
20 + }
21 +
22 + try {
23 + const response = await fetch(
24 + `${API_BASE}/tools?toolkit_slug=${toolkitSlug.toUpperCase()}&limit=1000`,
25 + {
26 + headers: {
27 + 'Content-Type': 'application/json',
28 + 'x-api-key': API_KEY,
29 + },
30 + next: { revalidate: 3600 }, // Cache for 1 hour
31 + }
32 + );
33 +
34 + if (!response.ok) {
35 + console.warn(`[Toolkits] Failed to fetch tools for ${toolkitSlug}: ${response.status}`);
36 + return [];
37 + }
38 +
39 + const data = await response.json();
40 + const items = data.items || data || [];
41 +
42 + return items.map((tool: any) => {
43 + // Extract parameters from JSON Schema format
44 + const inputSchema = tool.input_parameters || tool.parameters;
45 + const outputSchema = tool.output_parameters || tool.response;
46 +
47 + // Get properties and required array from JSON Schema
48 + const inputProps = inputSchema?.properties || inputSchema;
49 + const inputRequired = inputSchema?.required || [];
50 + const outputProps = outputSchema?.properties || outputSchema;
51 + const outputRequired = outputSchema?.required || [];
52 +
53 + // Add required flag to each property based on the required array
54 + const processParams = (props: any, requiredList: string[]) => {
55 + if (!props || typeof props !== 'object') return undefined;
56 + const result: Record<string, any> = {};
57 + for (const [key, value] of Object.entries(props)) {
58 + if (typeof value === 'object' && value !== null) {
59 + result[key] = {
60 + ...(value as object),
61 + required: requiredList.includes(key),
62 + };
63 + }
64 + }
65 + return Object.keys(result).length > 0 ? result : undefined;
66 + };
67 +
68 + return {
69 + slug: tool.slug || '',
70 + name: tool.name || tool.display_name || tool.slug || '',
71 + description: tool.description || '',
72 + input_parameters: processParams(inputProps, inputRequired),
73 + output_parameters: processParams(outputProps, outputRequired),
74 + scopes: tool.scopes || undefined,
75 + tags: tool.tags || undefined,
76 + is_deprecated: tool.is_deprecated || false,
77 + };
78 + });
79 + } catch (error) {
80 + console.error(`[Toolkits] Error fetching detailed tools for ${toolkitSlug}:`, error);
81 + return [];
82 + }
83 +}
84
85 async function getToolkits(): Promise<Toolkit[]> {
86 const filePath = join(process.cwd(), 'public/data/toolkits.json');
@@ -115,10 +188,16 @@ export default async function ToolkitsPage({ params }: { params: Promise<{ slug?
188 const toolkit = toolkits.find((t) => t.slug === toolkitSlug);
189
190 if (toolkit) {
191 + // Fetch detailed tool info from API (includes input/output params)
192 + const detailedTools = await fetchDetailedTools(toolkitSlug);
193 +
194 + // Merge detailed info with static tools, or use detailed if available
195 + const tools = detailedTools.length > 0 ? detailedTools : toolkit.tools;
196 +
197 return (
198 <ToolkitDetail
199 toolkit={toolkit}
121 - tools={toolkit.tools}
200 + tools={tools}
201 triggers={toolkit.triggers}
202 path={`/toolkits/${toolkit.slug}`}
203 />
docs/components/toolkits/toolkit-detail.tsx
+52 -2
@@ -3,7 +3,8 @@
3 import { useState, useMemo } from 'react';
4 import Link from 'next/link';
5 import { ExternalLink, Search, Copy, Check, ChevronDown, ChevronRight, ArrowLeft } from 'lucide-react';
6 -import type { Toolkit, Tool, Trigger } from '@/types/toolkit';
6 +import { TypeTable } from 'fumadocs-ui/components/type-table';
7 +import type { Toolkit, Tool, Trigger, ParameterSchema } from '@/types/toolkit';
8 import { PageActions } from '@/components/page-actions';
9 import { AuthDetailsSection } from '@/components/toolkits/auth-details-section';
10
@@ -28,6 +29,37 @@ function ToolkitIcon({ toolkit }: { toolkit: Toolkit }) {
29 );
30 }
31
32 +// Convert parameter schema to TypeTable format
33 +function paramsToTypeTable(params: Record<string, ParameterSchema>): Record<string, {
34 + type: string;
35 + description?: string;
36 + default?: string;
37 + required?: boolean;
38 +}> {
39 + const result: Record<string, {
40 + type: string;
41 + description?: string;
42 + default?: string;
43 + required?: boolean;
44 + }> = {};
45 +
46 + for (const [name, param] of Object.entries(params)) {
47 + result[name] = {
48 + type: param.type || 'string',
49 + description: param.description || undefined,
50 + default: param.default !== undefined ? String(param.default) : undefined,
51 + required: param.required,
52 + };
53 + }
54 +
55 + return result;
56 +}
57 +
58 +// Check if item is a Tool with parameters
59 +function isTool(item: Tool | Trigger): item is Tool {
60 + return 'input_parameters' in item || 'output_parameters' in item;
61 +}
62 +
63 function ToolItem({ item }: { item: Tool | Trigger }) {
64 const [expanded, setExpanded] = useState(false);
65 const [copied, setCopied] = useState(false);
@@ -39,6 +71,10 @@ function ToolItem({ item }: { item: Tool | Trigger }) {
71 setTimeout(() => setCopied(false), 2000);
72 };
73
74 + const tool = isTool(item) ? item : null;
75 + const hasInputParams = tool?.input_parameters && Object.keys(tool.input_parameters).length > 0;
76 + const hasOutputParams = tool?.output_parameters && Object.keys(tool.output_parameters).length > 0;
77 +
78 return (
79 <div className="border-b border-fd-border/50 last:border-0">
80 <button
@@ -61,8 +97,22 @@ function ToolItem({ item }: { item: Tool | Trigger }) {
97 </span>
98 </button>
99 {expanded && (
64 - <div className="bg-fd-muted/20 px-4 py-3 pl-10">
100 + <div className="space-y-4 bg-fd-muted/20 px-4 py-3 pl-10">
101 <p className="text-sm text-fd-muted-foreground">{item.description}</p>
102 +
103 + {hasInputParams && (
104 + <div className="space-y-2">
105 + <h4 className="text-xs font-semibold uppercase tracking-wide text-fd-muted-foreground">Input Parameters</h4>
106 + <TypeTable type={paramsToTypeTable(tool.input_parameters!)} />
107 + </div>
108 + )}
109 +
110 + {hasOutputParams && (
111 + <div className="space-y-2">
112 + <h4 className="text-xs font-semibold uppercase tracking-wide text-fd-muted-foreground">Output</h4>
113 + <TypeTable type={paramsToTypeTable(tool.output_parameters!)} />
114 + </div>
115 + )}
116 </div>
117 )}
118 </div>
docs/types/toolkit.ts
+16
@@ -1,7 +1,23 @@
1 +// Parameter schema for tool inputs/outputs
2 +export interface ParameterSchema {
3 + type: string;
4 + description?: string;
5 + required?: boolean;
6 + default?: unknown;
7 + example?: unknown;
8 + enum?: string[];
9 +}
10 +
11 export interface Tool {
12 slug: string;
13 name: string;
14 description: string;
15 + // Detailed fields fetched on-demand
16 + input_parameters?: Record<string, ParameterSchema>;
17 + output_parameters?: Record<string, ParameterSchema>;
18 + scopes?: string[];
19 + tags?: string[];
20 + is_deprecated?: boolean;
21 }
22
23 export interface Trigger {